diff options
author | Vyacheslav Yurkov <v.yurkov@precitec.de> | 2022-09-07 21:51:38 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-10-29 16:32:24 +0100 |
commit | ff28239bbf73535eee46322aff982c61bf603d06 (patch) | |
tree | fd2e82e8249d16fc12b23cb5c69c289b111fca4b | |
parent | 80092ba3abb03af7b110967219e91c6b34910e2a (diff) | |
download | poky-ff28239bbf73535eee46322aff982c61bf603d06.tar.gz |
classes: files: Extend overlayfs-etc class
Add the ability to expose the lower layer of /etc when mounting overlay.
This is the similar to what overlayroot script from initramfs-framework does.
By default, this option is turned off to keep an old behavior intact.
(From OE-Core rev: 6ad25304abefcbe538db7745e17ac213fa7d0719)
Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 791e8a8bacce5a7f31f4d7bcbfb17df2967fd258)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/overlayfs-etc.bbclass | 5 | ||||
-rw-r--r-- | meta/files/overlayfs-etc-preinit.sh.in | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/meta/classes/overlayfs-etc.bbclass b/meta/classes/overlayfs-etc.bbclass index 91afee695c..40116e4c6e 100644 --- a/meta/classes/overlayfs-etc.bbclass +++ b/meta/classes/overlayfs-etc.bbclass | |||
@@ -34,6 +34,7 @@ OVERLAYFS_ETC_DEVICE ??= "" | |||
34 | OVERLAYFS_ETC_USE_ORIG_INIT_NAME ??= "1" | 34 | OVERLAYFS_ETC_USE_ORIG_INIT_NAME ??= "1" |
35 | OVERLAYFS_ETC_MOUNT_OPTIONS ??= "defaults" | 35 | OVERLAYFS_ETC_MOUNT_OPTIONS ??= "defaults" |
36 | OVERLAYFS_ETC_INIT_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-etc-preinit.sh.in" | 36 | OVERLAYFS_ETC_INIT_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-etc-preinit.sh.in" |
37 | OVERLAYFS_ETC_EXPOSE_LOWER ??= "0" | ||
37 | 38 | ||
38 | python create_overlayfs_etc_preinit() { | 39 | python create_overlayfs_etc_preinit() { |
39 | overlayEtcMountPoint = d.getVar("OVERLAYFS_ETC_MOUNT_POINT") | 40 | overlayEtcMountPoint = d.getVar("OVERLAYFS_ETC_MOUNT_POINT") |
@@ -54,13 +55,15 @@ python create_overlayfs_etc_preinit() { | |||
54 | preinitPath = oe.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("base_sbindir"), "preinit") | 55 | preinitPath = oe.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("base_sbindir"), "preinit") |
55 | initBaseName = oe.path.join(d.getVar("base_sbindir"), "init") | 56 | initBaseName = oe.path.join(d.getVar("base_sbindir"), "init") |
56 | origInitNameSuffix = ".orig" | 57 | origInitNameSuffix = ".orig" |
58 | exposeLower = oe.types.boolean(d.getVar('OVERLAYFS_ETC_EXPOSE_LOWER')) | ||
57 | 59 | ||
58 | args = { | 60 | args = { |
59 | 'OVERLAYFS_ETC_MOUNT_POINT': overlayEtcMountPoint, | 61 | 'OVERLAYFS_ETC_MOUNT_POINT': overlayEtcMountPoint, |
60 | 'OVERLAYFS_ETC_MOUNT_OPTIONS': d.getVar('OVERLAYFS_ETC_MOUNT_OPTIONS'), | 62 | 'OVERLAYFS_ETC_MOUNT_OPTIONS': d.getVar('OVERLAYFS_ETC_MOUNT_OPTIONS'), |
61 | 'OVERLAYFS_ETC_FSTYPE': overlayEtcFsType, | 63 | 'OVERLAYFS_ETC_FSTYPE': overlayEtcFsType, |
62 | 'OVERLAYFS_ETC_DEVICE': overlayEtcDevice, | 64 | 'OVERLAYFS_ETC_DEVICE': overlayEtcDevice, |
63 | 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName | 65 | 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName, |
66 | 'OVERLAYFS_ETC_EXPOSE_LOWER': "true" if exposeLower else "false" | ||
64 | } | 67 | } |
65 | 68 | ||
66 | if useOrigInit: | 69 | if useOrigInit: |
diff --git a/meta/files/overlayfs-etc-preinit.sh.in b/meta/files/overlayfs-etc-preinit.sh.in index 0e80849f12..8db076f4ba 100644 --- a/meta/files/overlayfs-etc-preinit.sh.in +++ b/meta/files/overlayfs-etc-preinit.sh.in | |||
@@ -18,6 +18,7 @@ mount -t sysfs sysfs /sys | |||
18 | BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc | 18 | BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc |
19 | UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper | 19 | UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper |
20 | WORK_DIR=$BASE_OVERLAY_ETC_DIR/work | 20 | WORK_DIR=$BASE_OVERLAY_ETC_DIR/work |
21 | LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower | ||
21 | 22 | ||
22 | mkdir -p {OVERLAYFS_ETC_MOUNT_POINT} | 23 | mkdir -p {OVERLAYFS_ETC_MOUNT_POINT} |
23 | if mount -n -t {OVERLAYFS_ETC_FSTYPE} \ | 24 | if mount -n -t {OVERLAYFS_ETC_FSTYPE} \ |
@@ -26,6 +27,14 @@ if mount -n -t {OVERLAYFS_ETC_FSTYPE} \ | |||
26 | then | 27 | then |
27 | mkdir -p $UPPER_DIR | 28 | mkdir -p $UPPER_DIR |
28 | mkdir -p $WORK_DIR | 29 | mkdir -p $WORK_DIR |
30 | |||
31 | if {OVERLAYFS_ETC_EXPOSE_LOWER}; then | ||
32 | mkdir -p $LOWER_DIR | ||
33 | |||
34 | # provide read-only access to original /etc content | ||
35 | mount -o bind,ro /etc $LOWER_DIR | ||
36 | fi | ||
37 | |||
29 | mount -n -t overlay \ | 38 | mount -n -t overlay \ |
30 | -o upperdir=$UPPER_DIR \ | 39 | -o upperdir=$UPPER_DIR \ |
31 | -o lowerdir=/etc \ | 40 | -o lowerdir=/etc \ |