From patchwork Fri Dec 10 11:50:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 827 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 4EF85C433F5 for ; Fri, 10 Dec 2021 11:50:34 +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.web11.6284.1639137033648532394 for ; Fri, 10 Dec 2021 03:50:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kUacBQVp; 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 i5so14507898wrb.2 for ; Fri, 10 Dec 2021 03:50:33 -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=tom0WCrscSxhltcd5si/W/BP0pbyWIJrwfiDNe+10wQ=; b=kUacBQVpFPYwujOKTGDCDwr5hpRJbhHdiufDdv3J2QevZlHs7HfmH29cViOADCYZ11 pDoErRpJhK9b1GLLLOb/o9/pl+tJ+tGTOd4wiLiKCPheJxF3Mmy8/DCnZxxqWnock39V QHsVKJpC0rG8WSCo1wRSXrE9P7AQAb2UatkI2ysmogcc+VIviGg0WPJHK9nGOHhXyV5S +CWCOhWv1z+RcCt3ALyTGoft3kD0H4Dt9rwnUNmLoVEoqJf5qXGKy9JuMdUn1kGa+DGR uYvyxu2MXD0ntDplL0u32MapNSBI+CsCSUCHmfXtEMNslr36Jy7yautzYCrtnvDPZmZ6 Acdg== 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=tom0WCrscSxhltcd5si/W/BP0pbyWIJrwfiDNe+10wQ=; b=1rTKme9I8lBY5ENfQbSqJPhiLYXoGtXfmy8E5d1nlEaub4YRNf8ErfhqAGo8gn2qVj A9GMQOW/lOZuYGz387Nm1AKpAIn1xfeyf75UKy7l2c5g6XxmoYLX+IIdNPNffVEYz7st tKD9cqC2VkMSuFWQtl1Y3b3IHHhDrpsaDASW02AM6rAuV4NjyG5RNQ8xFQ+g0KwKNXwQ jBjkuKlak1ngryi476AJpp+rwGdEsm2r9I9RfGnb0LayqkbAGh1VGalQoPAmQ6AnQpj5 XLephdO9z8Nbt7HJ6Q9cg0QlFlAVw9yXKAZj88EpaOmWTnQDIU8rultiKoTV4HX2ZZV+ k57A== X-Gm-Message-State: AOAM531I/ny4c+QjOh544eG34/EO6SDchTTGrSoJv/P4iJlCYwCM2gXF xLCMyC8hC1KEjkqlRqCIqvwoXIEpC+nh0A== X-Google-Smtp-Source: ABdhPJx5rsesWSTvDm1rmTAyLGve5j+QgtbPVmOo3cZfmS0ANATfqf5T3/S2/+UAV8hFwhUwRi1FlQ== X-Received: by 2002:a5d:4575:: with SMTP id a21mr13910223wrc.193.1639137031805; Fri, 10 Dec 2021 03:50:31 -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 y6sm11496662wma.37.2021.12.10.03.50.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:31 -0800 (PST) From: Vyacheslav Yurkov To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/8] files: add preinit.sh.in Date: Fri, 10 Dec 2021 12:50:20 +0100 Message-Id: <375fb52dba5ec14ef42748139ea90fabaee87131.1639136706.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 11:50:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159499 A template init script for overlayfs-etc class Signed-off-by: Vyacheslav Yurkov --- meta/files/preinit.sh.in | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 meta/files/preinit.sh.in diff --git a/meta/files/preinit.sh.in b/meta/files/preinit.sh.in new file mode 100644 index 0000000000..2ebb6c9224 --- /dev/null +++ b/meta/files/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 11:50:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 828 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 2ED09C4332F for ; Fri, 10 Dec 2021 11:50:35 +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.web11.6286.1639137034290647822 for ; Fri, 10 Dec 2021 03:50:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MiZzNaIc; 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 q3so14478765wru.5 for ; Fri, 10 Dec 2021 03:50:34 -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=1H7s2iPl5Q0MKvO27Xp6O1+olRjrbFBOpjsIaXBt3Qg=; b=MiZzNaIcrOY3u6/rGf35xfmYSiFh8P2bZNHa8PhWixsV3GW7vFQitRuGXILRZsoyZu mm89RFM4P/FikKod9DHeJri0aWlbjm+Mtpc93YJSHMQAenBXbOpwsT1nq5sJuuO5yHCX YQj1ezkPh8Onq69Bqun+mhVspgiNq/3kkOSEHg1jlXbdrpAT1dXA7EG3brPms1Eidp8K T5tTXlQx5273UgDiq2WJ6kg5mLoRVanha9WxPQ+4lj24raotlLI/97HLsFRkb1YNTI4m dWa4Lw2SAyQQx9pTquRn/0e/P7gAAax8LGXdZecCXiLlG7Pd3L5HIjOxye0n+CqgT72Y DrNw== 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=1H7s2iPl5Q0MKvO27Xp6O1+olRjrbFBOpjsIaXBt3Qg=; b=jOg9VUTTAJRMT+0LIcLT4HuF6BfaEyHK5jZncZ5j/WDS/ARw4Pp3FYLvd6q3qYOcN3 bJhXyJ9GkKm6UBDCwy51mTXZWckTWepJkciB5MVEXkHfKdwm9wAdkSCAh+LH+jBiOyDY GbQNTA6IuIl+jNvco/FtbsvIOcNXJOUAheVUhgG2+UFYFzgf7qV+yHbkyCuBfRbxAx0q dT+5CXzXAgHhj0S41gpvR0g3gnotEUxNzL7nMdvWZ4vHTlTpY6g6GY4gxxrZko0x9FEy mwfcEWA3atRYf4aQ/KRdetE9Uy7C3r16QnSeoKGIaqa0aoBGLq2WDRPMmlq/sqbXpc2G /OFg== X-Gm-Message-State: AOAM530L/Q4n6CvX3btCeTdO0E3rYn6Jt2HDJeWRPKcfXb9eCaffieMD 8X2hW7peAAQteq0pyuYx1oN5j4rNQljr9Q== X-Google-Smtp-Source: ABdhPJyDWakLyh/Qd1q6OVBCI8C0miz+mFhESSHq3E2NGKzDVwpkP48gRyUjUfjgy6MhlQaNjsJAlw== X-Received: by 2002:a5d:6dc1:: with SMTP id d1mr13222368wrz.282.1639137032547; Fri, 10 Dec 2021 03:50:32 -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 y6sm11496662wma.37.2021.12.10.03.50.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:32 -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 12:50:21 +0100 Message-Id: <28b7b8f434ffa0b4dd43a6cd369097e9b39708fd.1639136706.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 11:50:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159500 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..5e89339269 --- /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/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 11:50:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 829 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 28A98C433EF for ; Fri, 10 Dec 2021 11:50:36 +0000 (UTC) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.groups.io with SMTP id smtpd.web12.6106.1639137035052426815 for ; Fri, 10 Dec 2021 03:50:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fP1ekC9t; spf=pass (domain: gmail.com, ip: 209.85.221.51, mailfrom: uvv.mail@gmail.com) Received: by mail-wr1-f51.google.com with SMTP id a9so14464258wrr.8 for ; Fri, 10 Dec 2021 03:50:34 -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=fP1ekC9tDyys5rPtjEtghNiQEuD7M14KZYJKsS82n0hAxu9GHC2jMOwon8W/fxCB6G EbqlA4Eby3MaJuYkdzKunOYSUzVKaOqj5RfcJc2LNok7MCAZE1JbmaceVGPG1dFChIAh iuSDxP+s20o8AkpusNm0MIsTI4q2ECM+EMRCbD+ME0tD+RBLTa2zH/mNZsh/nF5jlF8S 8rKbvdlRXHlyIy7lEN84UvagPUr1aoAlaaiyP9soKrcH9bwsu2PVpnuNmHS3vBaRGUDs OVXMgLzjOPB7Y6ubdM2K8KnZSGXe+o9NcYK4lDyZDWQLb/s8PeOAX8jyXr0WZZimBgHD qRrw== 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=5LlkGTSO8+c3OLJs6bCYZFqpuQqctO2YACu6Ua/oKhmFsm+ABxw+px+9iSWqnIiFBm GGFYMyChp6ngdq8wvRdc8nDWKdkahdpJOszcx9u/bHh429UIWcg0wxgDAV8554iCOfSz Uj2MR5K60EswlQuQidP8g3dzCuO9cfsEgBCWN2NwF9IFIVEnvYpzz8F7A7sHeic21lk8 HDdaUVQsvBT3Kij7mRuD+86Izk5kyiCuWgiRHeQhPk36sbGYJLkA2SI/o+8iOXl/pfNS 4ZR3bypqge1RhjsmLw/YGm4Vm2P0BD9zspGtH2Exke/hJEG8sxVizWxgJwxGQCfueBVF kV3Q== X-Gm-Message-State: AOAM532SD89gFQNOozRXgL5Q+xI6GqPBz+6gFNZwQ4yTYx5buP+d5gfx ihs3Z0WF9LaCgf6LTuBSmQKt8oykpVJK+Q== X-Google-Smtp-Source: ABdhPJzs2+2d+wsqngvouA7xWDut0k4j2S7IkKP2T9w88n92QHVFzVC7ZS+FcEbTsBb20hs+2maBnQ== X-Received: by 2002:a05:6000:2a4:: with SMTP id l4mr13667522wry.238.1639137033410; Fri, 10 Dec 2021 03:50:33 -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 y6sm11496662wma.37.2021.12.10.03.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:32 -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 12:50:22 +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 11:50:36 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159501 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 11:50:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 830 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 28F34C433F5 for ; Fri, 10 Dec 2021 11:50:37 +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.web12.6107.1639137035892974765 for ; Fri, 10 Dec 2021 03:50:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JQSb2CkI; 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 t18so14437166wrg.11 for ; Fri, 10 Dec 2021 03:50:35 -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=JQSb2CkI+tixuZZSU15pCmdGYzuFQSWUObtqp01chjC8ROxG2wgwN/0Q7FwJgJCS1q qmc8CePiNiIfKXCenDhDOPDDgZbBHymeBU9ylCNtjy0CeIp3gVUxFRJey3XidEkzlcJq B9nXDyF9ufA/g3pYbxzVryty1rjPc6e7Axm8iqSKbweloAq/aDFGo0gyAvxmyuvQ1W7b 6zNousQz1jEjMqD//ruG67pr0a3JBOtnzmYttbjXvl84S6Z7PmNaKVNopncVLdQfUpNF IR4EBfuPNFItf2o02zcGgskzs3RkvKi9QhRharF3ZCqRIAFWL4QC8xD9ysjkmOPLKr4J 4vhQ== 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=KRtzoqMpNWdp17QqVmQlBg1E7L9ORk4HLahfn/9p9gM/c2JEAxdsrlwtFhDGaV7kW8 t/ioFTDhjME1r/1gbypqlqpulpGYAfxl0XhoiVA/TJb8FrhOc/B+oVidtZlq8ilNT7fL eiUL4rzES8xLcjWPzc6YRRqy9MnY2AFwa3k7r7HVsNEGkdnk+s0yhbjeFg25L9yfInP6 WY4zWyjPLAc0LkDc3FFu7M0WcuI/lahmkjQKA+YP4MC6az0O1DikWDbKc+ukus0sCLnf F2CQ+aPKAKwPkEzSF8za9a0s1IKOYVBXevh8NpslTcwtzoBhTknjW/vUwB8jzyguw+qS 6yeg== X-Gm-Message-State: AOAM530PBy1R/qFfQifQCS40DXAzqYECWqVXPGRFGReIyeuAZgcEb3gc wItE7V/L5+y0nG5N8a+EwzBjt3xv54K7Tg== X-Google-Smtp-Source: ABdhPJxvjUJ3AZz6zxK5252IBL23euEU+GGQj5mFCvgJauFHmJe4kSUERY4uEzFVk7tGtTk4fZhzTQ== X-Received: by 2002:a05:6000:82:: with SMTP id m2mr13210605wrx.202.1639137034214; Fri, 10 Dec 2021 03:50:34 -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 y6sm11496662wma.37.2021.12.10.03.50.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:33 -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 12:50:23 +0100 Message-Id: <0868e1b6fa2054521e0cde0a59e1d2606d6ab845.1639136706.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 11:50:37 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159502 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 11:50:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 831 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 41075C433EF for ; Fri, 10 Dec 2021 11:50:38 +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.web09.6028.1639137037153415655 for ; Fri, 10 Dec 2021 03:50:37 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PcEWlacU; 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 i12so6607527wmq.4 for ; Fri, 10 Dec 2021 03:50:36 -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=PcEWlacUjfwKfiaiuGuGhHGUk00BWZamyxq1T6To34qFeUwK+LKsHRkfd4p1bNQwzW 33x62fXZaHDaMAbOEhSIlMQSPkQJiuXiDNc1X6KdWViSKs84XuR270vKVWZ19NFT4Kx7 //r0euuUqAfripv+4jAYwmPfXjtFEN5QHk1iEWT0D8wTAup5oU7hUME9bE762WAcDsqO 1P4+YUcL+VG2hXtnxYeQRr4cLxAVt6mPdyZFC9/Me27e6BDsAucqH+MOCi6VGlT4Oyio MusCZVceW/5OVpROFglRmuh+LKOsO3mJJ17oZRbks1UmOB8jefWwhUabRDFtYu5M54O+ 1Raw== 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=AuknOyScLAnSW7is4HenKRKdxpT+Tk2+KH1YoJszRV9x2iEw6lviovFkD6TBsOOXBe +g84c0Kcdh6OXCbcy+uk0/NvjTPxp0KsUZa8L9bmbfuPRkbErqK88UlLMig91PNJ8112 8TdQOiaomNrt7yCPUFYYAQg0aYb3Kd63Fk/++LcThtg+SCUYpsewUY49m3FRecsIDW+8 lgozB9JC9yVc0NvcrC8Gho+AwMrETYpOryeAp8aaZtGaK9jnED5Kl4tG0kuSXCGhsI26 yi3A8TjL6QzjAEwLsD13r7VJcw6MXhNQn94BQRHI/acS9hZ4YQv9mFBCi3Zj6dhTd5mQ sFvw== X-Gm-Message-State: AOAM533QLrmuGvPDwnnCUIeF93lDMiEy7/xlsu0HUC2DYzTviEKawTS8 Y0H1Ouc0bgrxweSTneB9uWVxr8LMNA6iFA== X-Google-Smtp-Source: ABdhPJwnx2b1+2H8aajxGtjw64sfl+XztSdUC+stiosZhlfe6yvBj2TSw+aA6fxRhiqB4Xc76e7mqA== X-Received: by 2002:a7b:ce16:: with SMTP id m22mr15967618wmc.39.1639137035134; Fri, 10 Dec 2021 03:50:35 -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 y6sm11496662wma.37.2021.12.10.03.50.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:34 -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 12:50:24 +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 11:50:38 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159503 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 11:50:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 832 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 2FFE8C433F5 for ; Fri, 10 Dec 2021 11:50:39 +0000 (UTC) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.groups.io with SMTP id smtpd.web11.6287.1639137037717720631 for ; Fri, 10 Dec 2021 03:50:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aEBcrWGO; spf=pass (domain: gmail.com, ip: 209.85.128.46, mailfrom: uvv.mail@gmail.com) Received: by mail-wm1-f46.google.com with SMTP id r9-20020a7bc089000000b00332f4abf43fso7023960wmh.0 for ; Fri, 10 Dec 2021 03:50:37 -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=aEBcrWGOLP/NANv2F5AMO4qm5OiZ5YqpjxVjq+bSqGXQ1ALOKNcb87ahuoFe4HOqgR BCv6n6CsEO8gRdz4ilUXhBST8SEZ0yuiko9jTRbhSd7LfnTuBmrk5dNSUjOltzeuM7nF TZRjjDsp7kfiPZ7x4whQCkJU6k/CrIbWFS1ZKVeY7+I1jxh7nvZO1PC6pUK0bZanSrQt dghDwq2jAih7/EFrBC2fO7Ap20t1lYMiByg4EkFyVUTI1OtLEazm6PJ7/qE2Xhsgy74m xXuirRqqpphcZKf6EDlKsh9eFfREiIcOtRfyMEnJTdYWnb8Uwj+ZmMuGDMWTI1D1R0i/ HJqQ== 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=FiF1ncftwLOBapD8g+yGZquaaU2Ai1cj6H/LLhdJ7oXVXHGsLPLFyyXnlF6T8lawlK kmVpz9xEOqEpNGE9MRusRqBMCUoOrsOn0aejfPPdont9+PQ2Y8WNLXsgV40VP8+B995I DAfEKIhpwH/tr5UYeEatHHadwB5vNF8Hd3jg1oNXHE7piG5qq9tRBGuNNW3RjQbASngn vs+gqRokinNUUFxg06BZZWGkl+YXHN4ispxl5jMk0Eij+Egdd0/8XsiyONFn5l6xHu2f +7kDOjDS1eOnDPIBmwHHPbgvDqmm+V7CC9+c53plEvc1XeyN8yPr6nck57FUReDJtKi4 /lSw== X-Gm-Message-State: AOAM533svWqhdhof4uYJpEZMfW7H4kvQrLySgJqkgtVyA5KA80SVmwZc J1pRHB28IZLTbzficd9f4GzxyedCF0N+og== X-Google-Smtp-Source: ABdhPJzxwCh/sqG6oscC0YZpVW/6n1KiVk5tSqzP0s9+JGqEex0nmSH7697cWLZoys0YdFtRaI5SrQ== X-Received: by 2002:a7b:c3c6:: with SMTP id t6mr15897924wmj.119.1639137035810; Fri, 10 Dec 2021 03:50:35 -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 y6sm11496662wma.37.2021.12.10.03.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:35 -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 12:50:25 +0100 Message-Id: <83c3860c58f9c621bd76166365fd0be107bd762f.1639136706.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 11:50:39 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159504 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 11:50:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 833 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 2EFC1C433FE for ; Fri, 10 Dec 2021 11:50:40 +0000 (UTC) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.groups.io with SMTP id smtpd.web12.6109.1639137038752752845 for ; Fri, 10 Dec 2021 03:50:39 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FwaQ13ZE; spf=pass (domain: gmail.com, ip: 209.85.128.46, mailfrom: uvv.mail@gmail.com) Received: by mail-wm1-f46.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so6412505wme.4 for ; Fri, 10 Dec 2021 03:50:38 -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=FwaQ13ZE1TD8lCngp6+EslXvxqcFo/+139SVwLhKnI3eR/gHsZcT+A9O3Y91p+p5kR nlbtOL72AfUpW8c/HNhgb+CNX1C2EHk5Ttx5AQCmtXr8F+qFPEWP2+ZjpDQZVXFGjOUA yZuSDuDu7dNWlbb4M5OByORt3fbHrRWpsi7Hmq+Ui+tjqW1bntTVssVurm0XqesipwiP nU5o8aFVVf5QlUlsCZJZbaq8tFISoKq5J61dq9nYXjIriFJZZtPhqNC816F2NbeqG2a8 VFeMhlv5bm13m+1HdQe6++fuJZszyXtAZ+QCm+et847Ln+Ca2yg3fKBC19gV5zTBIIaI 4JoQ== 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=3I8l7ReZsz8pp/srvuyfftt1z/8ypldMkl5CaUYDNXYEsTtoySnNa2zZ60O0pFcgwR MnAmo55JxUr25FacU1VIf4kn8cL1Xil5GEWtsZOfTf8I22tpErE4iiwgbgxO88/8Lq6x WcKJEbQZ43Xa98g1cFziRS2je4/MN+CCtIbgw8SeZY+hDm02l7p8mz+P/1ttM8I7jYGi 0uL2DCpg+kM/euEpcZboNwpztk9V0ibW5OsCjLeBmV97lKzjy++JiskA0DHSs75AY4oH MO/G6714Lv5PhA3xvAorQHtejAu569wB/zMJqiiB0SX/cYXe+p509OnZez5QUS/NGGMr Zkfg== X-Gm-Message-State: AOAM533jSme2tUQnUsLTm6xFJlanKnWt2UChZF/2YpFE1UIQ57VvM4Qh FFQz7Gv5w0ru6+x7YPw7kz3fU9sSZsERzA== X-Google-Smtp-Source: ABdhPJyhwVDqbRrLBvlAo7WY6Dg32Y1bqJJ8Q4orzkzSKvWyfgOJEXtPGIwPyKLNI/RJXmuzDW/6TA== X-Received: by 2002:a1c:f70c:: with SMTP id v12mr15497088wmh.18.1639137036962; Fri, 10 Dec 2021 03:50:36 -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 y6sm11496662wma.37.2021.12.10.03.50.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:36 -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 12:50:26 +0100 Message-Id: <1cd96f8198395146577771a450ec5953bc2509b1.1639136706.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 11:50:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159505 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 11:50:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vyacheslav Yurkov X-Patchwork-Id: 834 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 2F8B1C4332F for ; Fri, 10 Dec 2021 11:50:40 +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.web11.6288.1639137039423485852 for ; Fri, 10 Dec 2021 03:50:39 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PUm7Ehrw; 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 137so6612173wma.1 for ; Fri, 10 Dec 2021 03:50:39 -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=PUm7EhrwqPNbgv5KHUk+1/psRnp/j5fMVZlfqZdtrV6vgR4rxbtl2OiBIzJ9EP8GSI 0rjMjx/ZYPje0LW7dpxQZY1Afs9Ei3qF6GWu/YQ/2+TTG8ZEGI6YPbIrcfRSz2Aaiddk jEZK6HgugFx43s1NnV0FcmKVsCd9r4wR0cqZDzYJopv2v+q7gvwafr0UX3N+UevWWHhT QNXuMRrXCbWNMP/otFdefm/chtvg6jzdLERBzZCx43yPf69CMpCc91yVUp5lOWkNjhEy AnhZGUMozSfOo3vPsSs0dJF0STLrYo5yBgRJ1NyDr/dBqR1XpWYAgAhHSxAOvkaI7sQR whgg== 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=VkfWQOTB8AGU+nBrHlSlC8wt0uQEvd4/E2QHe9UphMb0snwPPz2uCsZI8rB6zvaRr0 RRQu8PJtvgJor/ihBuKFSyM1Si35y86cShmWbWSLvaZ4rJxNsAWiAyNHvVTaGW6nFBte PyXchFSOqWU+WkK7j5mhD+E/a7GwTS3j4wQsqVhZQAQaDtKu1N/ewDspzLUpZwy/QIBg NYr0PK0UdECcc2AQ1MiFIBTliOyR/2EA/E9kKZvN2SCsVYp4LWIkIHzdsMfwRfYoMsdh IqZO5hprxDvqFYS+QrQf4Dz9xKoDvnm/o4W5eWWRHZ3pTyumaaQcpgjtPETxNTFpxLPG /JtQ== X-Gm-Message-State: AOAM532m4b25klNDg6JW/de8ElYacr8LfwUkOFY+Sd9hESNUTUrT6QFb kU9L+oPN+CPlP6xIZ+IIi5B7yaegOq+yBg== X-Google-Smtp-Source: ABdhPJzh0V1738/Qz5B8ofUcZkopDAmJZdL8/A+uUhGgDR09HR+aQqy5vxgeaOqd4H49no8/MxxpnQ== X-Received: by 2002:a05:600c:34c2:: with SMTP id d2mr16576271wmq.102.1639137037727; Fri, 10 Dec 2021 03:50:37 -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 y6sm11496662wma.37.2021.12.10.03.50.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 03:50:37 -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 12:50:27 +0100 Message-Id: <2bf815fb272d04fd82965e014d69504ef52cfcad.1639136706.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 11:50:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/159506 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