From patchwork Fri Dec 10 13:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2019BC433EF for ; Fri, 10 Dec 2021 13:01:53 +0000 (UTC) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.groups.io with SMTP id smtpd.web12.6756.1639141312532765710 for ; Fri, 10 Dec 2021 05:01:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aluOEer1; spf=pass (domain: gmail.com, ip: 209.85.221.41, mailfrom: uvv.mail@gmail.com) Received: by mail-wr1-f41.google.com with SMTP id t9so14798644wrx.7 for ; Fri, 10 Dec 2021 05:01:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TwbPp4Fb7Ob9Led3y7jnHXxVROuvh5PHVzvG0vCjjYk=; b=aluOEer1Ui1cVNyNAnL/QIt1jEeK5oQtK0o2faWS3kXaF34y6J7Yj8jqQ5Ub6UvjR6 anJ2Mm8Ox2MQA8zCFcnU10MNjRL5ZETY8wB9w1WNUrZuZ1FuLdku+wUvN1wvVMWv6Gk2 ym2AMJD+c43cZoBzPJmGu/5mIiSVSxqBQ3DnZCdausI4u+y81cQkThr/ChNnAVl01jLd wb8/8/rv4v/uPUDlN0N+uuPqiAj/z7A/GuaQENEcbGBtFe+BKbDoHgbXvjHBBKUhntuf LBL7u62DPuRGXkfxhijt0ygkD9QJNnFyfhMU+6PpMqEJl/x2OLv7FJr2ypHRGRoGgJRi wAug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TwbPp4Fb7Ob9Led3y7jnHXxVROuvh5PHVzvG0vCjjYk=; b=3dPQad5hufaLf3YVSivx1Mzbnh3XI17x6Uqb3YwsocuRtm9MFfvLiu4vFW6o9U6/8D TXXWExoye5rvqLJqo3ujjVX5/u7i8AXX5oZ6pk4LspAaFDNNUXEgFYl7ysIIWew5XyjM yr2y610Nj1m9Z8d5yj2TpQa7s0hfmUqhYLk8gCKmS8aVmfEFACYBLJsD1kGUyJE3zU5I 8liKCzLY3XEmjtEbTO8wKRNjPgORWVNoI4RchEWCmJqnh5Vyxi0/4fcfEt5LKezt7Eoo vbdfKibo4f4cQXiblxGmXtK57RFRtdHBZCryGVNA2NzR+pwn8yHjb5u0cro53LxUlW26 SHpw== X-Gm-Message-State: AOAM5311D5h0UsU3eHEMNPsMdgZF2Hr8C+i1VXOvVNUmn1SC85Pvub+T GRIBy/oAMI3OiYJjbSUEBev67JFpczPUgQ== X-Google-Smtp-Source: ABdhPJwfxKiA2cmTvPS1WmT7Z3jA+jOX3sksMxJDy7zloD8bOOKAATH7wA2S+iBURN2qIEvqbYTBsA== X-Received: by 2002:a5d:6da9:: with SMTP id u9mr13859730wrs.237.1639141310423; Fri, 10 Dec 2021 05:01:50 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:49 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/8] files: add overlayfs-etc-preinit.sh.in Date: Fri, 10 Dec 2021 14:01:38 +0100 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159510 A template init script for overlayfs-etc class Signed-off-by: Vyacheslav Yurkov --- meta/files/overlayfs-etc-preinit.sh.in | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 meta/files/overlayfs-etc-preinit.sh.in diff --git a/meta/files/overlayfs-etc-preinit.sh.in b/meta/files/overlayfs-etc-preinit.sh.in new file mode 100644 index 0000000000..2ebb6c9224 --- /dev/null +++ b/meta/files/overlayfs-etc-preinit.sh.in @@ -0,0 +1,29 @@ +#!/bin/sh + +echo "PREINIT: Start" + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +mount -o remount,rw / + +mkdir -p /proc +mkdir -p /sys +mkdir -p /run +mkdir -p /var/run + +mount -t proc proc /proc +mount -t sysfs sysfs /sys + +[ -z "$CONSOLE" ] && CONSOLE="/dev/console" + +mkdir -p {OVERLAYFS_ETC_MOUNT_POINT} +if mount -n -t {OVERLAYFS_ETC_FSTYPE} -o {OVERLAYFS_ETC_MOUNT_OPTIONS} {OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT} +then + mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper + mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/work + mount -n -t overlay -o upperdir={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper,lowerdir=/etc,workdir={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/work {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper /etc || echo "PREINIT: Mounting etc-overlay failed!" +else + echo "PREINIT: Mounting failed!" +fi + +echo "PREINIT: done; starting " +exec {SBIN_INIT_NAME} From patchwork Fri Dec 10 13:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 245DEC433FE for ; Fri, 10 Dec 2021 13:01:54 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web12.6757.1639141313286816870 for ; Fri, 10 Dec 2021 05:01:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QER6C+z7; spf=pass (domain: gmail.com, ip: 209.85.221.42, mailfrom: uvv.mail@gmail.com) Received: by mail-wr1-f42.google.com with SMTP id q3so14800780wru.5 for ; Fri, 10 Dec 2021 05:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WG3DlwDMlA1fmMZVZjvVBg3QED1VwlgiA2G8nXlPUdE=; b=QER6C+z79dn3V9i0L2RzzpDbRcjFZFTwRUgRTxgyOTUh8X9zjTsNE0fNt9IYvEHd6x M20qC4ANaA/VGzF+wi7aAtx+miuLiRNIbmfGMu1F1ZuZtjx/e2rHa7nC4k5+Njksabml rkOBvX0wom7QGy9ERHN3BOr5KfjT81XeD7+545mjU8GSEF/wbKHfAspWCkfuhLYjBHiM KD5cUa68Q7Ywfz02y77Qgp3hMkcaqebnBCLKXzrJhMGEBfYXj4RprZmWUrc9wxA3X+/Z UG+1Cbhlj7ouYn04VKRnO4sFPfAUBDMgVjVXwes1klaWNtPeXdDjqQmAHddf3BlpPXzw nIcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WG3DlwDMlA1fmMZVZjvVBg3QED1VwlgiA2G8nXlPUdE=; b=I2O9ilhR9PeOd4W20iZH2wD3xv1GHU5uDK2Ff7YGkfDe2GETZK3YLN2hBDkcWMUqr8 OnbnKqVZtbBGa4bTr66eCuETD9v0LehagGJHuyHmpp9FwhJjhVu7eKuYszZ3sQRd8QOJ tkSlZ4jxKFGQTuTqSxC39zWSGy6b1AKRTphbOm1X/q55frRptDHas3XnpcXQmMuPv8+f FpPPgFpMKXEMfJOI6KK/5KCEEsXwO5tMiahaQBYVGiNHupEfO4IFYPla/bEjxVf8iXn6 ILXrGl1iq+tjbEB5GxiA/naS1tfw29GnbYW6vBxE8XnaQOvG5X9vX+If7DOwrlfWVAas 3D9w== X-Gm-Message-State: AOAM533mUMBQ23aiIl10thM9q3fg+3+hrZ8Aos5BNVo00FPCUVXnoqsX nkI8nV603sKrTT1afIuGXggRQ6wlX6ALZw== X-Google-Smtp-Source: ABdhPJwb++IY91unfiDezE8kdO91aKE3MLIsAm7YrjvEZnfEPtrpU7r2Nu8kVK/R61pwJzAzXPPZzA== X-Received: by 2002:adf:b34f:: with SMTP id k15mr14256961wrd.125.1639141311446; Fri, 10 Dec 2021 05:01:51 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:50 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/8] overlayfs-etc: mount etc as overlayfs Date: Fri, 10 Dec 2021 14:01:39 +0100 Message-Id: <762ff05ca23aeff364a8498b48b03c5806cf3a46.1639141237.git.uvv.mail@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:54 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159511 This class provides an image feature that mounts /etc as an overlayfs file system. This is an extension for existing overlayfs class, which doesn't support /etc Signed-off-by: Alfred Schapansky Signed-off-by: Vyacheslav Yurkov --- meta/classes/overlayfs-etc.bbclass | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 meta/classes/overlayfs-etc.bbclass diff --git a/meta/classes/overlayfs-etc.bbclass b/meta/classes/overlayfs-etc.bbclass new file mode 100644 index 0000000000..4ced07ba11 --- /dev/null +++ b/meta/classes/overlayfs-etc.bbclass @@ -0,0 +1,76 @@ +# Class for setting up /etc in overlayfs +# +# In order to have /etc directory in overlayfs a special handling at early boot stage is required +# The idea is to supply a custom init script that mounts /etc before launching actual init program, +# because the latter already requires /etc to be mounted +# +# The configuration must be machine specific. You should at least set these three variables: +# OVERLAYFS_ETC_MOUNT_POINT ?= "/data" +# OVERLAYFS_ETC_FSTYPE ?= "ext4" +# OVERLAYFS_ETC_DEVICE ?= "/dev/mmcblk0p2" +# +# To control more mount options you should consider setting mount options: +# OVERLAYFS_ETC_MOUNT_OPTIONS ?= "defaults" +# +# The class provides two options for /sbin/init generation +# 1. Default option is to rename original /sbin/init to /sbin/init.orig and place generated init under +# original name, i.e. /sbin/init. It has an advantage that you won't need to change any kernel +# parameters in order to make it work, but it poses a restriction that package-management can't +# be used, becaause updating init manager would remove generated script +# 2. If you are would like to keep original init as is, you can set +# OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "0" +# Then generated init will be named /sbin/preinit and you would need to extend you kernel parameters +# manually in your bootloader configuration. +# +# Regardless which mode you choose, update and migration strategy of configuration files under /etc +# overlay is out of scope of this class + +ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "overlayfs-etc", "create_overlayfs_etc_preinit;", "", d)}' +IMAGE_FEATURES_CONFLICTS_overlayfs-etc = "package-management" + +OVERLAYFS_ETC_MOUNT_POINT ??= "" +OVERLAYFS_ETC_FSTYPE ??= "" +OVERLAYFS_ETC_DEVICE ??= "" +OVERLAYFS_ETC_USE_ORIG_INIT_NAME ??= "1" +OVERLAYFS_ETC_MOUNT_OPTIONS ??= "defaults" +OVERLAYFS_ETC_INIT_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-etc-preinit.sh.in" + +python create_overlayfs_etc_preinit() { + overlayEtcMountPoint = d.getVar("OVERLAYFS_ETC_MOUNT_POINT") + overlayEtcFsType = d.getVar("OVERLAYFS_ETC_FSTYPE") + overlayEtcDevice = d.getVar("OVERLAYFS_ETC_DEVICE") + + if not overlayEtcMountPoint: + bb.fatal("OVERLAYFS_ETC_MOUNT_POINT must be set in your MACHINE configuration") + if not overlayEtcDevice: + bb.fatal("OVERLAYFS_ETC_DEVICE must be set in your MACHINE configuration") + if not overlayEtcFsType: + bb.fatal("OVERLAYFS_ETC_FSTYPE should contain a valid file system type on {0}".format(overlayEtcDevice)) + + with open(d.getVar("OVERLAYFS_ETC_INIT_TEMPLATE"), "r") as f: + PreinitTemplate = f.read() + + useOrigInit = oe.types.boolean(d.getVar('OVERLAYFS_ETC_USE_ORIG_INIT_NAME')) + preinitPath = oe.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("base_sbindir"), "preinit") + initBaseName = oe.path.join(d.getVar("base_sbindir"), "init") + origInitNameSuffix = ".orig" + + args = { + 'OVERLAYFS_ETC_MOUNT_POINT': overlayEtcMountPoint, + 'OVERLAYFS_ETC_MOUNT_OPTIONS': d.getVar('OVERLAYFS_ETC_MOUNT_OPTIONS'), + 'OVERLAYFS_ETC_FSTYPE': overlayEtcFsType, + 'OVERLAYFS_ETC_DEVICE': overlayEtcDevice, + 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName + } + + if useOrigInit: + # rename original /sbin/init + origInit = oe.path.join(d.getVar("IMAGE_ROOTFS"), initBaseName) + bb.debug(1, "rootfs path %s, init path %s, test %s" % (d.getVar('IMAGE_ROOTFS'), origInit, d.getVar("IMAGE_ROOTFS"))) + bb.utils.rename(origInit, origInit + origInitNameSuffix) + preinitPath = origInit + + with open(preinitPath, 'w') as f: + f.write(PreinitTemplate.format(**args)) + os.chmod(preinitPath, 0o755) +} From patchwork Fri Dec 10 13:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26857C433EF for ; Fri, 10 Dec 2021 13:01:55 +0000 (UTC) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.web08.6834.1639141314229182540 for ; Fri, 10 Dec 2021 05:01:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N+mR6cJ4; spf=pass (domain: gmail.com, ip: 209.85.128.42, mailfrom: uvv.mail@gmail.com) Received: by mail-wm1-f42.google.com with SMTP id 137so6766201wma.1 for ; Fri, 10 Dec 2021 05:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=I4idqnW/TYwYOWQCVJv928jk9dIIkPOXyCnEJijf0tc=; b=N+mR6cJ4j/oEaFE2DhLxRr+vLh4FcysE/b7UBblNg4K70kpsbvWG0BQ7ht9t7aiC2u A8Vkwkl/A2srBsPCB4681tOtcoLHpWf9ilyJlmM3obS5I2rjvrLjm7LBpgVL3kpecAl7 8y1AYrLXVFLb3eGWMnQd49Pwz0zdbSQbZp4+WqscKHqB+ZWEj32lQ1BuhNH0xJ1pGE4H T/sGECEP6dkyzHg1rxaS+kwpPuXH3xAcvOoldKA1Eo7hXJZoIKOuhKQL8FDt8IyAVSS8 QFGqT2ncGezTDs9OE3BDqh3IhppYHwz9jxwHHuAuLLCQAU4viQgyK5IagglMWMdUy5ca juTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I4idqnW/TYwYOWQCVJv928jk9dIIkPOXyCnEJijf0tc=; b=B6nNF4QbLCEkGUBuUHP93DAQPS1qF1WokjKdfZnj/BnItpTgh/8/GDEpvPzCE9C1eg BKoAl5gMdLynS0jenbmM2adJ0VW7H8EQIuSBr6eQYljOH/aN0tZxW8SRiiby590yDPKL JKmL0K1SKOlm0XwzRuSMJI96OIyOZ2JhnDOUhJUdOfz1vokomKCyZYNe4W291O0AIr1e IwgkpTwN8YP/caCpejywv8uV6dbwjbfxpabcpQZhlMYv6Hz0bvRMwLBM+2AH/oh2ceRH pEbNSZNDSvtYaas8MeRrU/ewret4KTysUOV9EkKLz2Xy1glvwIfTMcBJ5NRmKPyx92oO k0+A== X-Gm-Message-State: AOAM5324imz3cEKEjr71RrPGVntsN/rHrFER4q+XvKVqQYtmb+FaBO/P QZ1cgLsZvt6BDd95tQWINkxr8j8RIQSyjw== X-Google-Smtp-Source: ABdhPJz3tPRzLk2GBbdMNV6STE4pzFN83s/w6RQML3OgNoftuQWps+gIG1v+b5lxsSha7+wsY6Dlwg== X-Received: by 2002:a1c:f005:: with SMTP id a5mr17157464wmb.19.1639141312447; Fri, 10 Dec 2021 05:01:52 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:51 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/8] wic: image for overlayfs-etc tests Date: Fri, 10 Dec 2021 14:01:40 +0100 Message-Id: <8d51529052e3a7341e1e441c11189fccc3cba744.1639141237.git.uvv.mail@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:55 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159512 Introduce wic image for overlayfs-etc tests with a dedicated /data partition and configurable kernel parameters Signed-off-by: Vyacheslav Yurkov --- meta-selftest/wic/overlayfs_etc.wks.in | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 meta-selftest/wic/overlayfs_etc.wks.in diff --git a/meta-selftest/wic/overlayfs_etc.wks.in b/meta-selftest/wic/overlayfs_etc.wks.in new file mode 100644 index 0000000000..1e1e5836e7 --- /dev/null +++ b/meta-selftest/wic/overlayfs_etc.wks.in @@ -0,0 +1,4 @@ +part /boot --active --source bootimg-biosplusefi --ondisk sda --sourceparams="loader=grub-efi" --align 1024 +part / --source rootfs --ondisk sda --fstype=ext4 --use-uuid --align 1024 +part --ondisk sda --fstype=ext4 --size=5 --align 1024 +bootloader --ptable gpt --timeout=1 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0 ${OVERLAYFS_INIT_OPTION}" From patchwork Fri Dec 10 13:01:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34916C433F5 for ; Fri, 10 Dec 2021 13:01:56 +0000 (UTC) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.web10.6891.1639141315050150312 for ; Fri, 10 Dec 2021 05:01:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PQpBqdfh; spf=pass (domain: gmail.com, ip: 209.85.221.49, mailfrom: uvv.mail@gmail.com) Received: by mail-wr1-f49.google.com with SMTP id j3so14860106wrp.1 for ; Fri, 10 Dec 2021 05:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=329PIbFwhmU8Vpn2rhb0hUILXacfm9wjvO9Q8meObdc=; b=PQpBqdfhTR/AJmQ9TGXIFjmFk1oezgLlu6w8ZI5hlFUhNsgEtsFugjBbNUrIlw16JV otTpuutin5PFLerOrcqoRQecQzChKyzYp2q4eCl69oUABd/DDMsOTG9W49SoN/K6wdWW 5iMSBrbaNjB3euzkKYEHhnmWzvToRSJEmCjduUIaGDyJvBatA0s2mds1dl6FixVefh0Q HMJbST0j4ASWOY5SvSsbK7gH5ses71oscB6G9FMO+Yffflp4nM0FLaJ8ibxym13YFfrG ZAG0fpfR5BqRvQDdgBjsxj50y5fd7aazyjYYSdbNSmNZsW+ThmdM4RXJLUUYNWEvWBwp lVYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=329PIbFwhmU8Vpn2rhb0hUILXacfm9wjvO9Q8meObdc=; b=Ap5+qUbMk8ZjM6OOCr8KSVIjaXvIL+jkr2ICl5lpHugkdvseC8MFJZ+pGxAJNeSDJX c+dPhfdkpBSLB3VlNVCDkF2EhIdS0LqYzIGoQDw2OSQcQ6bJcPEde9VQDodBw2zMlkB5 zI2oofiitbG/7e3TYGjWxvsB/R2GaErNeVjKp+rWfWHnwUEH6CTdt4hnHuCX+Vf2rDDp Vp2nYCYLWeuhZ4ZeooBFshQxrr1Ol+1156sVDf9YS8YWnNi9NPfN+xDn7nIZP10HJ5CS hbEhQ1mLBYiFk45kw41dk/VpZh6/UqN1G9pnOadCrIYxIQTdMpL9AT9GzUQeLGgzlFwp Ikzg== X-Gm-Message-State: AOAM533XpVMvZE4kZ+6Nxzucu8gP3FV+OiCm8bWeE+gt5BaxVr93ndGO I6JvqQ/dbvWJGvHR4dQTxjeq9LTHvotaLA== X-Google-Smtp-Source: ABdhPJwFnpJvxewfCVvV46RtwZaL+WYVb/JowyUENa5uh8odzCSYT+pjHYCYpdFk2zvaDi+oxTzAPQ== X-Received: by 2002:adf:d18f:: with SMTP id v15mr13198536wrc.447.1639141313311; Fri, 10 Dec 2021 05:01:53 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:52 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 4/8] image: add overlayfs-etc image feature Date: Fri, 10 Dec 2021 14:01:41 +0100 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:56 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159513 Signed-off-by: Vyacheslav Yurkov --- meta/classes/image.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 8a46b4852c..2b0ce4a988 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -15,6 +15,7 @@ IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-contain IMGCLASSES += "image_types_wic" IMGCLASSES += "rootfs-postcommands" IMGCLASSES += "image-postinst-intercepts" +IMGCLASSES += "overlayfs-etc" inherit ${IMGCLASSES} TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}" @@ -33,7 +34,7 @@ INHIBIT_DEFAULT_DEPS = "1" # IMAGE_FEATURES may contain any available package group IMAGE_FEATURES ?= "" IMAGE_FEATURES[type] = "list" -IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login post-install-logging" +IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login post-install-logging overlayfs-etc" # Generate companion debugfs? IMAGE_GEN_DEBUGFS ?= "0" From patchwork Fri Dec 10 13:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37A79C433FE for ; Fri, 10 Dec 2021 13:01:57 +0000 (UTC) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.groups.io with SMTP id smtpd.web08.6835.1639141316384587179 for ; Fri, 10 Dec 2021 05:01:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HNr5Hvym; spf=pass (domain: gmail.com, ip: 209.85.128.54, mailfrom: uvv.mail@gmail.com) Received: by mail-wm1-f54.google.com with SMTP id p18so6744500wmq.5 for ; Fri, 10 Dec 2021 05:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3UJuFGvbVcponM0v30fZJsSx0M5YKuiVTs5mv4eTRt4=; b=HNr5HvymMoy9nqiANHdIvqGgP59qfftDx87ju8U9y125SR3DllbkAo2DEg7EDIE9XZ N6YSqGi6nn1NzntOe8dhLWPrxSW0rcuVHtcLMU0HiMhmpOUbBTOmXsKbCo91LrrDYv7Z Sgy5FVNCgGqyJPQRVckAjmtaMbSkO6Q+NWBAFn1myLI7XW+yhGOPSiYxHgz2qlxa5nEy SYXIeWyoLgVlWuMBuFQuWSaCx7vfbL/cFY28GdkZWXvYVFiI8wSdHTiGK0kjNIrfvDZ6 KU5PZc5Fb2ctO3Z/iZBtRTuE/y2T1JN8iveR9RV+ng5d5sEaXHvzCCZTjORvPA6T92KT 9u6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3UJuFGvbVcponM0v30fZJsSx0M5YKuiVTs5mv4eTRt4=; b=JIwh7LKSCS2s6TGrJgh2lTYByrvnhz/c+lc2PrST292V9TIRj0ZPF8neklo39HudK1 q9wPDbzvDsfeI845Jo2v5tTIb9WeKbcHaJJm+sqYiobVeSFQOxhhrdwPm91LAx7sUPH+ JpBsAkLB/3mCzk0Dy4xxUN48vYywfus/MnLQvr75jaOHsiCZQB2aFVttmrejzvsBJMm2 s5uarzhL4MjJ4N8gXH9bpupuNPiC7D+kYVo4tyAcYqsJAJD8V3fdduJ6tcYdzR+gPZR5 czJf3hFQT9C1kYoVwso4Hw//I4g1jWPhKeVE4PeoSWKoVRqe7IlQsBN8l0aFFC6gvcor sXyA== X-Gm-Message-State: AOAM532WsBRytKoh1boqoVTS28qsBlkwC28DaGD2ZTtZIKprL5PFPIIN Y4DeOXYdam8JqWzvifS0H2HVYjXmpoTwUg== X-Google-Smtp-Source: ABdhPJxVClZolEBWUbJPUZevD8V1lcJ6TuOCSiXOWd92cau32y/17n5QuClPx2/UAu4WzNBK1+pbYw== X-Received: by 2002:a05:600c:202:: with SMTP id 2mr16139696wmi.134.1639141314425; Fri, 10 Dec 2021 05:01:54 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:53 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 5/8] oeqa/selftest: overlayfs helper function Date: Fri, 10 Dec 2021 14:01:42 +0100 Message-Id: <65c0ce9cfa72ecdc08cafbc1681b9c57c81c5452.1639141237.git.uvv.mail@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:57 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159514 Move helper functions out of class scope so they can be used in other tests Signed-off-by: Vyacheslav Yurkov --- meta/lib/oeqa/selftest/cases/overlayfs.py | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py index 84242a1605..43415778ce 100644 --- a/meta/lib/oeqa/selftest/cases/overlayfs.py +++ b/meta/lib/oeqa/selftest/cases/overlayfs.py @@ -5,16 +5,16 @@ from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu -class OverlayFSTests(OESelftestTestCase): - """Overlayfs class usage tests""" +def getline_qemu(out, line): + for l in out.split('\n'): + if line in l: + return l - def getline_qemu(self, out, line): - for l in out.split('\n'): - if line in l: - return l +def getline(res, line): + return getline_qemu(res.output, line) - def getline(self, res, line): - return self.getline_qemu(res.output, line) +class OverlayFSTests(OESelftestTestCase): + """Overlayfs class usage tests""" def add_overlay_conf_to_machine(self): machine_inc = """ @@ -40,7 +40,7 @@ inherit overlayfs self.write_recipeinc('overlayfs-user', overlayfs_recipe_append) res = bitbake('core-image-minimal', ignore_status=True) - line = self.getline(res, "overlayfs-user was skipped: missing required distro features") + line = getline(res, "overlayfs-user was skipped: missing required distro features") self.assertTrue("overlayfs" in res.output, msg=res.output) self.assertTrue("systemd" in res.output, msg=res.output) self.assertTrue("ERROR: Required build target 'core-image-minimal' has no buildable providers." in res.output, msg=res.output) @@ -61,9 +61,9 @@ DISTRO_FEATURES += "systemd overlayfs" self.add_overlay_conf_to_machine() res = bitbake('core-image-minimal', ignore_status=True) - line = self.getline(res, "Unit name mnt-overlay.mount not found in systemd unit directories") + line = getline(res, "Unit name mnt-overlay.mount not found in systemd unit directories") self.assertTrue(line and line.startswith("WARNING:"), msg=res.output) - line = self.getline(res, "Not all mount units are installed by the BSP") + line = getline(res, "Not all mount units are installed by the BSP") self.assertTrue(line and line.startswith("ERROR:"), msg=res.output) def test_mount_unit_not_set(self): @@ -81,7 +81,7 @@ DISTRO_FEATURES += "systemd overlayfs" self.write_config(config) res = bitbake('core-image-minimal', ignore_status=True) - line = self.getline(res, "A recipe uses overlayfs class but there is no OVERLAYFS_MOUNT_POINT set in your MACHINE configuration") + line = getline(res, "A recipe uses overlayfs class but there is no OVERLAYFS_MOUNT_POINT set in your MACHINE configuration") self.assertTrue(line and line.startswith("Parsing recipes...ERROR:"), msg=res.output) def test_wrong_mount_unit_set(self): @@ -104,7 +104,7 @@ OVERLAYFS_MOUNT_POINT[usr-share-overlay] = "/usr/share/overlay" self.set_machine_config(wrong_machine_config) res = bitbake('core-image-minimal', ignore_status=True) - line = self.getline(res, "Missing required mount point for OVERLAYFS_MOUNT_POINT[mnt-overlay] in your MACHINE configuration") + line = getline(res, "Missing required mount point for OVERLAYFS_MOUNT_POINT[mnt-overlay] in your MACHINE configuration") self.assertTrue(line and line.startswith("Parsing recipes...ERROR:"), msg=res.output) def test_correct_image(self): @@ -201,11 +201,11 @@ EOT # /usr/share/my-application as an overlay (see overlayfs-user recipe) status, output = qemu.run_serial("/bin/mount -t tmpfs,overlay") - line = self.getline_qemu(output, "on /mnt/overlay") + line = getline_qemu(output, "on /mnt/overlay") self.assertTrue(line and line.startswith("tmpfs"), msg=output) - line = self.getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/my-application") + line = getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/my-application") self.assertTrue(line and line.startswith("overlay"), msg=output) - line = self.getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/another-overlay-mount") + line = getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/another-overlay-mount") self.assertTrue(line and line.startswith("overlay"), msg=output) From patchwork Fri Dec 10 13:01:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25FEFC43217 for ; Fri, 10 Dec 2021 13:01:58 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web10.6892.1639141316828996021 for ; Fri, 10 Dec 2021 05:01:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CX0qd4PR; spf=pass (domain: gmail.com, ip: 209.85.221.42, mailfrom: uvv.mail@gmail.com) Received: by mail-wr1-f42.google.com with SMTP id a9so14787175wrr.8 for ; Fri, 10 Dec 2021 05:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Er9qZlz51L4Iq/e4cfETjfAR1P0weozeGbbZy9LuMpk=; b=CX0qd4PRTbq3jheXy/QV9sjd0bK5cZZjCj+UVZo+kvBPcslxaBAUvi5qwlTwA8Jgoi CkY0cQ+4IQ4G0hKSfZAMRvhvAfW8/Bc/KsR9/KG2Di89JRZTRE1uy9g9PQBClC9FEZLx sDGhljeIvQuWXzvkpV896Nc0W3lSqyoZ4p/GW+7wvuc4ikfFEZhiPttOSfWtYx6gmHhD ppi6nDDJ7srVgJAic6nt6hZh8PFkoQDT9GoYb8MzKzSECsJkS8ck8oRzz2PcbUejaBs6 wLX0KdXY4AUyd/82jya7Ev2PL81/4wGeJYeVi8ffPwomA2noQGMiP1Oq3gBwesrrs+7b /vPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Er9qZlz51L4Iq/e4cfETjfAR1P0weozeGbbZy9LuMpk=; b=7BB1w/mXckC0o3CZf1DHV5LyOHKKU9N86cf4osSoIlPAvlSNdnEhyD3mDRRtaWo/If raPq8Pd2eUQMKsVIqeXkugGtGATx0QAXzZ3QS4LQa/PtQqTWC8nX8UWOdwy6A8mORfaR KspP75Dg9OZuETyn1KVYsTn/1cPrMBWxRMDqK9JyaCi5zoozVsPA1mivSAJbFKxBGR8x w4esCMXVDSKk5AhS865CqmEVuFcSApiwEegNxu/VeISQfHP/30y3LWkaey0oRyg53Rao JZErtdrLw1orNMXAhE4VhAWvpUh5ceqdp88wRIETEMCs5EV63VTOCkoRlE+r9bVGTLhq SaYg== X-Gm-Message-State: AOAM531dzPNYD8wXtKpZfXI/yDd62rpayS18PXXkzLHgsTLg0P565GCB i7zM/pnkAmSRcqiFsPpFR6L3VvlHKqcS3Q== X-Google-Smtp-Source: ABdhPJyjG+1n8MWmeXQdkyk5sxWVJNNRpiJe1oamhv08FYVCDNX8Og1byON5ATjYhnU9J84mvFfSuQ== X-Received: by 2002:adf:d1e2:: with SMTP id g2mr14467890wrd.105.1639141315034; Fri, 10 Dec 2021 05:01:55 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:54 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 6/8] oeqa/selftest: unit tests for overlayfs-etc Date: Fri, 10 Dec 2021 14:01:43 +0100 Message-Id: <75b71051211a3623412d5dab27f48eac5f3d7606.1639141237.git.uvv.mail@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:58 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159515 Signed-off-by: Vyacheslav Yurkov --- meta/lib/oeqa/selftest/cases/overlayfs.py | 184 ++++++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py index 43415778ce..82007fade7 100644 --- a/meta/lib/oeqa/selftest/cases/overlayfs.py +++ b/meta/lib/oeqa/selftest/cases/overlayfs.py @@ -209,3 +209,187 @@ EOT line = getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/another-overlay-mount") self.assertTrue(line and line.startswith("overlay"), msg=output) + +class OverlayFSEtcRunTimeTests(OESelftestTestCase): + """overlayfs-etc class tests""" + + def test_all_required_variables_set(self): + """ + Summary: Check that required variables are set + Expected: Fail when any of required variables is missing + Author: Vyacheslav Yurkov + """ + + configBase = """ +DISTRO_FEATURES += "systemd" + +# Use systemd as init manager +VIRTUAL-RUNTIME_init_manager = "systemd" + +# enable overlayfs in the kernel +KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc" + +# Image configuration for overlayfs-etc +EXTRA_IMAGE_FEATURES += "overlayfs-etc" +IMAGE_FEATURES:remove = "package-management" +""" + configMountPoint = """ +OVERLAYFS_ETC_MOUNT_POINT = "/data" +""" + configDevice = """ +OVERLAYFS_ETC_DEVICE = "/dev/mmcblk0p1" +""" + + self.write_config(configBase) + res = bitbake('core-image-minimal', ignore_status=True) + line = getline(res, "OVERLAYFS_ETC_MOUNT_POINT must be set in your MACHINE configuration") + self.assertTrue(line, msg=res.output) + + self.append_config(configMountPoint) + res = bitbake('core-image-minimal', ignore_status=True) + line = getline(res, "OVERLAYFS_ETC_DEVICE must be set in your MACHINE configuration") + self.assertTrue(line, msg=res.output) + + self.append_config(configDevice) + res = bitbake('core-image-minimal', ignore_status=True) + line = getline(res, "OVERLAYFS_ETC_FSTYPE should contain a valid file system type on /dev/mmcblk0p1") + self.assertTrue(line, msg=res.output) + + def test_image_feature_conflict(self): + """ + Summary: Overlayfs-etc is not allowed to be used with package-management + Expected: Feature conflict + Author: Vyacheslav Yurkov + """ + + config = """ +DISTRO_FEATURES += "systemd" + +# Use systemd as init manager +VIRTUAL-RUNTIME_init_manager = "systemd" + +# enable overlayfs in the kernel +KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc" +EXTRA_IMAGE_FEATURES += "overlayfs-etc" +EXTRA_IMAGE_FEATURES += "package-management" +""" + + self.write_config(config) + + res = bitbake('core-image-minimal', ignore_status=True) + line = getline(res, "contains conflicting IMAGE_FEATURES") + self.assertTrue("overlayfs-etc" in res.output, msg=res.output) + self.assertTrue("package-management" in res.output, msg=res.output) + + def test_image_feature_is_missing_class_included(self): + configAppend = """ +INHERIT += "overlayfs-etc" +""" + self.run_check_image_feature(configAppend) + + def test_image_feature_is_missing(self): + self.run_check_image_feature() + + def run_check_image_feature(self, appendToConfig=""): + """ + Summary: Overlayfs-etc class is not applied when image feature is not set + even if we inherit it directly, + Expected: Image is created successfully but /etc is not an overlay + Author: Vyacheslav Yurkov + """ + + config = f""" +DISTRO_FEATURES += "systemd" + +# Use systemd as init manager +VIRTUAL-RUNTIME_init_manager = "systemd" + +# enable overlayfs in the kernel +KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc" + +IMAGE_FSTYPES += "wic" +WKS_FILE = "overlayfs_etc.wks.in" + +EXTRA_IMAGE_FEATURES += "read-only-rootfs" +# Image configuration for overlayfs-etc +OVERLAYFS_ETC_MOUNT_POINT = "/data" +OVERLAYFS_ETC_DEVICE = "/dev/sda3" +{appendToConfig} +""" + + self.write_config(config) + + bitbake('core-image-minimal') + + with runqemu('core-image-minimal', image_fstype='wic') as qemu: + status, output = qemu.run_serial("/bin/mount") + + line = getline_qemu(output, "upperdir=/data/overlay-etc/upper") + self.assertFalse(line, msg=output) + + def test_sbin_init_preinit(self): + self.run_sbin_init(False) + + def test_sbin_init_original(self): + self.run_sbin_init(True) + + def run_sbin_init(self, origInit): + """ + Summary: Confirm we can replace original init and mount overlay on top of /etc + Expected: Image is created successfully and /etc is mounted as an overlay + Author: Vyacheslav Yurkov + """ + + config = """ +DISTRO_FEATURES += "systemd" + +# Use systemd as init manager +VIRTUAL-RUNTIME_init_manager = "systemd" + +# enable overlayfs in the kernel +KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc" + +IMAGE_FSTYPES += "wic" +OVERLAYFS_INIT_OPTION = "{OVERLAYFS_INIT_OPTION}" +WKS_FILE = "overlayfs_etc.wks.in" + +EXTRA_IMAGE_FEATURES += "read-only-rootfs" +# Image configuration for overlayfs-etc +EXTRA_IMAGE_FEATURES += "overlayfs-etc" +IMAGE_FEATURES:remove = "package-management" +OVERLAYFS_ETC_MOUNT_POINT = "/data" +OVERLAYFS_ETC_FSTYPE = "ext4" +OVERLAYFS_ETC_DEVICE = "/dev/sda3" +OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "{OVERLAYFS_ETC_USE_ORIG_INIT_NAME}" +""" + + args = { + 'OVERLAYFS_INIT_OPTION': "" if origInit else "init=/sbin/preinit", + 'OVERLAYFS_ETC_USE_ORIG_INIT_NAME': int(origInit == True) + } + + self.write_config(config.format(**args)) + + bitbake('core-image-minimal') + testFile = "/etc/my-test-data" + + with runqemu('core-image-minimal', image_fstype='wic', discard_writes=False) as qemu: + status, output = qemu.run_serial("/bin/mount") + + line = getline_qemu(output, "/dev/sda3") + self.assertTrue("/data" in output, msg=output) + + line = getline_qemu(output, "upperdir=/data/overlay-etc/upper") + self.assertTrue(line and line.startswith("/data/overlay-etc/upper on /etc type overlay"), msg=output) + + status, output = qemu.run_serial("touch " + testFile) + status, output = qemu.run_serial("sync") + status, output = qemu.run_serial("ls -1 " + testFile) + line = getline_qemu(output, testFile) + self.assertTrue(line and line.startswith(testFile), msg=output) + + # Check that file exists in /etc after reboot + with runqemu('core-image-minimal', image_fstype='wic') as qemu: + status, output = qemu.run_serial("ls -1 " + testFile) + line = getline_qemu(output, testFile) + self.assertTrue(line and line.startswith(testFile), msg=output) From patchwork Fri Dec 10 13:01:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 210E6C4332F for ; Fri, 10 Dec 2021 13:01:58 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.groups.io with SMTP id smtpd.web08.6836.1639141317578033056 for ; Fri, 10 Dec 2021 05:01:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oZkzO/Ko; spf=pass (domain: gmail.com, ip: 209.85.128.45, mailfrom: uvv.mail@gmail.com) Received: by mail-wm1-f45.google.com with SMTP id j140-20020a1c2392000000b003399ae48f58so8946820wmj.5 for ; Fri, 10 Dec 2021 05:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pvKfVOTcbU397aBsNGOgQSy4hE0CveVv9ErsYglMtQY=; b=oZkzO/KohFgtWWwfDvFkgQvXfOk5mFL6ekdy2huS5zFkjxdtEf9I2JoxYzFWq8kSh4 submV3pU+iI45gmDcQtaEb3hrFLqjK5kVPcHClL7GAipUIN0Cp3JZ1xnXpQScudmIF7T LbFs4ZjiP3QicN59D3gABhdyk7YBEz0C7fUV93deYq5nzM/Wa8+0P7KFeHIsfvx/3Kv0 ZsSXYYIUmOdNLHnSO9kTQ1j/oW38Jj+lgl5+kCh7dWiW34bFRtvmgTRnS1F6O2R7VYoi PFXqyjMq6D9S46Aq8x0+6SDT2dB5aFVuQVGTy7indroBigIRk+ZI9J62dxJrHp5nfZ27 J4GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pvKfVOTcbU397aBsNGOgQSy4hE0CveVv9ErsYglMtQY=; b=vmXXwajHvZiXLt+u6PPI+OWyJ9CZ7bpty0PQRo743IEId+AhWoHdkQvoWVv+vj/PMB 7hvf9KU8aBxCFcOkZ2p8L+hwBONDY9XLF3AqynOmCrf+XKyyFGpqn5oRx/sQD8D0pooz G/21u/xhYmI+KRSU5qjASv8iTZKQUKY9XL7fA1RmXre2aN/fU+ADPJgK12vfKeAl2wqn fbiC3zlVzvfmmC0qnRXzmAqHyXQF/4Q7YlQyN8p/NqNfDD8jxWMGy5lsfUXGPXaY7Sqr YstY5WjWtnKw52iFi8o5SbwrcShpIM3eKh3HkrT08oj0V3DhWx/dtruZEZeir/XS3zc2 N8Ag== X-Gm-Message-State: AOAM530m1kJkpHQQUq/prWRDj/s3nNKSgotYgZlzlfwY78cWY8CCFfUV LydLwhaJMotD8kH7pLRed/IOBSddn/QWcQ== X-Google-Smtp-Source: ABdhPJxgyCVtXkBoysMlgl1y6HY41PDNEBlK2ef0dIxT+9G9zXO5LAy4VARWMXqMDWuEpS7m8G/g8g== X-Received: by 2002:a7b:c157:: with SMTP id z23mr16386767wmi.113.1639141315914; Fri, 10 Dec 2021 05:01:55 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:55 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 7/8] overlayfs: update notes on /etc Date: Fri, 10 Dec 2021 14:01:44 +0100 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:01:58 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159516 Signed-off-by: Vyacheslav Yurkov --- meta/classes/overlayfs.bbclass | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/classes/overlayfs.bbclass b/meta/classes/overlayfs.bbclass index 3c0f4dc882..f1b8086ea8 100644 --- a/meta/classes/overlayfs.bbclass +++ b/meta/classes/overlayfs.bbclass @@ -31,6 +31,7 @@ # OVERLAYFS_WRITABLE_PATHS[mnt-overlay] = "/usr/share/another-application" # # Note: the class does not support /etc directory itself, because systemd depends on it +# For /etc directory use overlayfs-etc class REQUIRED_DISTRO_FEATURES += "systemd overlayfs" From patchwork Fri Dec 10 13:01:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26649C433EF for ; Fri, 10 Dec 2021 13:02:00 +0000 (UTC) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mx.groups.io with SMTP id smtpd.web10.6893.1639141318807600737 for ; Fri, 10 Dec 2021 05:01:59 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NXskoxvJ; spf=pass (domain: gmail.com, ip: 209.85.221.44, mailfrom: uvv.mail@gmail.com) Received: by mail-wr1-f44.google.com with SMTP id c4so14777595wrd.9 for ; Fri, 10 Dec 2021 05:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=//yyx2bjYorCsFwWUhzI7/bdTFJUsYUkWr7HK6+G9fI=; b=NXskoxvJUBRaaam3F5YoyNVENGO7pFelvxYTKx3uccoLHKXvpaz6VpXkOYuLgOcoYC AyURlxbavQTcx43VDdNLJGX2Nh3g+OUySOWgvQdBy4l/pXhoWFZcyjkI/nFQ+ygC2gGE /pk01b6VDSRh3Md9O9vJP/NtxsVssfgKtwBAuCJzKLXemMAuwlbgpSfn0AGoWq3P0AuO S3pWkBypbZvuebUu9BegzsneKtwz/ZZzZ5rOkj+1D8SWseq805O5l7OSZRQPgrlIrmkm xXy/m2CR5AdUKSh7o+ZLM9Ig4u5QLpQjr2+zmXxZ1tcp+QusYtH5668aqSRuqlSpsXrg ovFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=//yyx2bjYorCsFwWUhzI7/bdTFJUsYUkWr7HK6+G9fI=; b=Mkrsvdkm/iwwwah0kwcSclHlyvKtTRDcwNf5sJ01jW3KiTvwLp6nI8Sv/mfd6xnimE wviEFBckLZB0gIufLjQC+7q8/EhXulPDNFIyJyu2mkE9kA3PPi57RjEMaoW2+g2/v3dw bFXgGm3Io8pG4B0P8TfuIMO7sHR+GdIGZCXlonSyDiDz1uDovHlOPrC8xQD5XNlW/84f p9qzXeAoy6b1MOhj5eUBG9kog7S2pcohfGnW0E/eB43Cw4Id0UvxifbHHWygSV+zWFsm St+7f/kgNK6OQOAMY2qseU1iYbz8Z0rw3kvfi0rY468K1u4K1+alPo86ZBbUrP+O5cae ub5w== X-Gm-Message-State: AOAM5326QBXIBISwBxx+JNY4J5b5WFzIy9quQVISKyzER7wnQ7/6y3C+ 1weznt074WDjcdDvGf7OJWlx++sFmZgKMw== X-Google-Smtp-Source: ABdhPJzyygpJlnzV/5GuIshEb+5hVrJS6XLqYdBiCxRxdvAQgsGtCPW8IAymM1/uZdB4nWmsT9/b/A== X-Received: by 2002:a05:6000:1a45:: with SMTP id t5mr14655928wry.306.1639141316904; Fri, 10 Dec 2021 05:01:56 -0800 (PST) Received: from slackware.local (dslb-002-205-007-123.002.205.pools.vodafone-ip.de. [2.205.7.123]) by smtp.gmail.com with ESMTPSA id d2sm2899653wmb.31.2021.12.10.05.01.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 05:01:56 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 8/8] overlayfs: move templates to files directory Date: Fri, 10 Dec 2021 14:01:45 +0100 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Dec 2021 13:02:00 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159517 Signed-off-by: Vyacheslav Yurkov --- meta/classes/overlayfs.bbclass | 52 ++++---------------- meta/files/overlayfs-all-overlays.service.in | 12 +++++ meta/files/overlayfs-create-dirs.service.in | 14 ++++++ meta/files/overlayfs-unit.mount.in | 13 +++++ 4 files changed, 49 insertions(+), 42 deletions(-) create mode 100644 meta/files/overlayfs-all-overlays.service.in create mode 100644 meta/files/overlayfs-create-dirs.service.in create mode 100644 meta/files/overlayfs-unit.mount.in diff --git a/meta/classes/overlayfs.bbclass b/meta/classes/overlayfs.bbclass index f1b8086ea8..4a860f7308 100644 --- a/meta/classes/overlayfs.bbclass +++ b/meta/classes/overlayfs.bbclass @@ -37,51 +37,19 @@ REQUIRED_DISTRO_FEATURES += "systemd overlayfs" inherit systemd features_check +OVERLAYFS_CREATE_DIRS_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-create-dirs.service.in" +OVERLAYFS_MOUNT_UNIT_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-unit.mount.in" +OVERLAYFS_ALL_OVERLAYS_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-all-overlays.service.in" + python do_create_overlayfs_units() { from oe.overlayfs import mountUnitName - CreateDirsUnitTemplate = """[Unit] -Description=Overlayfs directories setup -Requires={DATA_MOUNT_UNIT} -After={DATA_MOUNT_UNIT} -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=mkdir -p {DATA_MOUNT_POINT}/workdir{LOWERDIR} && mkdir -p {DATA_MOUNT_POINT}/upper{LOWERDIR} -RemainAfterExit=true -StandardOutput=journal - -[Install] -WantedBy=multi-user.target -""" - MountUnitTemplate = """[Unit] -Description=Overlayfs mount unit -Requires={CREATE_DIRS_SERVICE} -After={CREATE_DIRS_SERVICE} - -[Mount] -What=overlay -Where={LOWERDIR} -Type=overlay -Options=lowerdir={LOWERDIR},upperdir={DATA_MOUNT_POINT}/upper{LOWERDIR},workdir={DATA_MOUNT_POINT}/workdir{LOWERDIR} - -[Install] -WantedBy=multi-user.target -""" - AllOverlaysTemplate = """[Unit] -Description=Groups all overlays required by {PN} in one unit -After={ALL_OVERLAYFS_UNITS} -Requires={ALL_OVERLAYFS_UNITS} - -[Service] -Type=oneshot -ExecStart=/bin/true -RemainAfterExit=true - -[Install] -WantedBy=local-fs.target -""" + with open(d.getVar("OVERLAYFS_CREATE_DIRS_TEMPLATE"), "r") as f: + CreateDirsUnitTemplate = f.read() + with open(d.getVar("OVERLAYFS_MOUNT_UNIT_TEMPLATE"), "r") as f: + MountUnitTemplate = f.read() + with open(d.getVar("OVERLAYFS_ALL_OVERLAYS_TEMPLATE"), "r") as f: + AllOverlaysTemplate = f.read() def prepareUnits(data, lower): from oe.overlayfs import helperUnitName diff --git a/meta/files/overlayfs-all-overlays.service.in b/meta/files/overlayfs-all-overlays.service.in new file mode 100644 index 0000000000..74ee4e90ae --- /dev/null +++ b/meta/files/overlayfs-all-overlays.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Groups all overlays required by {PN} in one unit +After={ALL_OVERLAYFS_UNITS} +Requires={ALL_OVERLAYFS_UNITS} + +[Service] +Type=oneshot +ExecStart=/bin/true +RemainAfterExit=true + +[Install] +WantedBy=local-fs.target diff --git a/meta/files/overlayfs-create-dirs.service.in b/meta/files/overlayfs-create-dirs.service.in new file mode 100644 index 0000000000..17204145f2 --- /dev/null +++ b/meta/files/overlayfs-create-dirs.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=Overlayfs directories setup +Requires={DATA_MOUNT_UNIT} +After={DATA_MOUNT_UNIT} +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=mkdir -p {DATA_MOUNT_POINT}/workdir{LOWERDIR} && mkdir -p {DATA_MOUNT_POINT}/upper{LOWERDIR} +RemainAfterExit=true +StandardOutput=journal + +[Install] +WantedBy=multi-user.target diff --git a/meta/files/overlayfs-unit.mount.in b/meta/files/overlayfs-unit.mount.in new file mode 100644 index 0000000000..1d33b7e39c --- /dev/null +++ b/meta/files/overlayfs-unit.mount.in @@ -0,0 +1,13 @@ +[Unit] +Description=Overlayfs mount unit +Requires={CREATE_DIRS_SERVICE} +After={CREATE_DIRS_SERVICE} + +[Mount] +What=overlay +Where={LOWERDIR} +Type=overlay +Options=lowerdir={LOWERDIR},upperdir={DATA_MOUNT_POINT}/upper{LOWERDIR},workdir={DATA_MOUNT_POINT}/workdir{LOWERDIR} + +[Install] +WantedBy=multi-user.target