From: Changqing Li <changqing...@windriver.com>

Steps:
1. build out rootfs core-image-minimal-qemux86-64-20200514073622.rootfs.tar.bz2
2. docker import
./core-image-minimal-qemux86-64-20200514073622.rootfs.tar.bz2 poky:1.0
3. docker run -it --rm poky:1.0 /bin/sh
4. cd /var; ls -al
   there is link: tmp -> volatile/tmp
5. cd ./volatile; ls -al
   empty dir, this make link in step 4 is dad link.

in step3, since we don't launch container with init system,
volatile/tmp is not created, and the dad link may cause
error. support persistent /var/tmp can resolve this problem

And we can also resolve the problem by run with init system:
docker run -it --rm poky:1.0 /sbin/init
but maybe provide a selection to use persistent storeage is better.

To support persistent /var/tmp, rename VOLATILE_LOG_DIR
to VOLATILE_DIR

Don't use VOLATILE_LOG_DIR/VOLATILE_TMP_DIR
to control it separately since it will make things complicated,
we need to make kinds of fs-perms*.txt for kinds of combination
of the two variables.

Signed-off-by: Changqing Li <changqing...@windriver.com>
---
 meta/conf/bitbake.conf                                 | 10 ++++++----
 ...erms-persistent-log.txt => fs-perms-persistent.txt} |  2 --
 meta/recipes-core/base-files/base-files_3.0.14.bb      |  7 ++++---
 .../recipes-core/initscripts/initscripts-1.0/volatiles |  3 ---
 meta/recipes-core/initscripts/initscripts_1.0.bb       |  8 +++++++-
 meta/recipes-core/systemd/systemd_245.5.bb             |  4 +++-
 meta/recipes-core/udev/eudev_3.2.9.bb                  |  3 +++
 7 files changed, 23 insertions(+), 14 deletions(-)
 rename meta/files/{fs-perms-persistent-log.txt => fs-perms-persistent.txt} 
(95%)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index bdade79abe..8fd688c793 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -86,9 +86,11 @@ USRBINPATH_class-nativesdk = "/usr/bin"
 # Root home directory
 ROOT_HOME ??= "/home/root"
 
-# If set to boolean true ('yes', 'y', 'true', 't', '1'), /var/log links to 
/var/volatile/log.
-# If set to boolean false ('no', 'n', 'false', 'f', '0'), /var/log is on 
persistent storage.
-VOLATILE_LOG_DIR ?= "yes"
+# If set to boolean true ('yes', 'y', 'true', 't', '1'), /var/log links to
+# /var/volatile/log, /var/tmp links to /var/volatile/tmp
+# If set to boolean false ('no', 'n', 'false', 'f', '0'), /var/log and /var/tmp
+# is on persistent storage.
+VOLATILE_DIR ?= "yes"
 
 ##################################################################
 # Architecture-dependent build variables.
@@ -350,7 +352,7 @@ FILESEXTRAPATHS ?= "__default:"
 #  datadir, sysconfdir, servicedir, sharedstatedir, localstatedir, infodir,
 #  mandir, docdir, bindir, sbindir, libexecdir, libdir, includedir and
 #  oldincludedir
-FILESYSTEM_PERMS_TABLES ?= "${@'files/fs-perms.txt' if 
oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 
'files/fs-perms-persistent-log.txt'}"
+FILESYSTEM_PERMS_TABLES ?= "${@'files/fs-perms.txt' if 
oe.types.boolean(d.getVar('VOLATILE_DIR')) else 
'files/fs-perms-persistent.txt'}"
 
 ##################################################################
 # General work and output directories for the build system.
diff --git a/meta/files/fs-perms-persistent-log.txt 
b/meta/files/fs-perms-persistent.txt
similarity index 95%
rename from meta/files/fs-perms-persistent-log.txt
rename to meta/files/fs-perms-persistent.txt
index 3a7cf3ab94..9ca9571e6e 100644
--- a/meta/files/fs-perms-persistent-log.txt
+++ b/meta/files/fs-perms-persistent.txt
@@ -47,7 +47,6 @@ ${oldincludedir}      0755    root    root    true    0644    
root    root
 # Links
 ${localstatedir}/run   link    /run
 ${localstatedir}/lock  link    /run/lock
-${localstatedir}/tmp   link    volatile/tmp
 
 /home                          0755    root    root    false - - -
 /srv                           0755    root    root    false - - -
@@ -57,7 +56,6 @@ ${localstatedir}/local                0755    root    root    
false - - -
 # Special permissions from base-files
 # Set 1777
 /tmp                           01777   root    root    false - - -
-${localstatedir}/volatile/tmp  01777   root    root    false - - -
 
 # Set 0700
 ${ROOT_HOME}                   0700    root    root    false - - -
diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb 
b/meta/recipes-core/base-files/base-files_3.0.14.bb
index 94299431f6..0e06629bbd 100644
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -29,7 +29,7 @@ S = "${WORKDIR}"
 INHIBIT_DEFAULT_DEPS = "1"
 
 docdir_append = "/${P}"
-dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
+dirs1777 = "/tmp ${localstatedir}/${@'volatile/' if 
oe.types.boolean('${VOLATILE_DIR}') else ''}tmp"
 dirs2775 = ""
 dirs555 = "/sys /proc"
 dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
@@ -42,7 +42,7 @@ dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} 
${base_libdir} \
            ${localstatedir}/backups ${localstatedir}/lib \
            ${localstatedir}/lib/misc ${localstatedir}/spool \
            ${localstatedir}/volatile \
-           ${localstatedir}/${@'volatile/' if 
oe.types.boolean('${VOLATILE_LOG_DIR}') else ''}log \
+           ${localstatedir}/${@'volatile/' if 
oe.types.boolean('${VOLATILE_DIR}') else ''}log \
            /home ${prefix}/src ${localstatedir}/local \
            /media"
 
@@ -53,7 +53,8 @@ dirs755-lsb = "/srv  \
                ${prefix}/lib/locale"
 dirs2775-lsb = "/var/mail"
 
-volatiles = "${@'log' if oe.types.boolean('${VOLATILE_LOG_DIR}') else ''} tmp"
+volatiles = "${@'log' if oe.types.boolean('${VOLATILE_DIR}') else ''} \
+             ${@'tmp' if oe.types.boolean('${VOLATILE_DIR}') else ''}"
 conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
              ${sysconfdir}/issue /${sysconfdir}/issue.net \
              ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/volatiles 
b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
index cd8a4be05f..eeeb8905da 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
+++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
@@ -24,11 +24,8 @@
 # a link will be created at /var/test pointing to /tmp/testfile and due to this
 # link the file defined as /var/test will actually be created as /tmp/testfile.
 d root root 1777 /run/lock none
-d root root 0755 /var/volatile/log none
-d root root 1777 /var/volatile/tmp none
 l root root 1777 /var/lock /run/lock
 l root root 0755 /var/run /run
-l root root 1777 /var/tmp /var/volatile/tmp
 l root root 1777 /tmp /var/tmp
 d root root 0755 /var/lock/subsys none
 f root root 0664 /var/log/wtmp none
diff --git a/meta/recipes-core/initscripts/initscripts_1.0.bb 
b/meta/recipes-core/initscripts/initscripts_1.0.bb
index 1a59b82fbf..ba6dc068c9 100644
--- a/meta/recipes-core/initscripts/initscripts_1.0.bb
+++ b/meta/recipes-core/initscripts/initscripts_1.0.bb
@@ -104,8 +104,14 @@ do_install () {
        install -m 0755    ${WORKDIR}/read-only-rootfs-hook.sh 
${D}${sysconfdir}/init.d
        install -m 0755    ${WORKDIR}/save-rtc.sh       ${D}${sysconfdir}/init.d
        install -m 0644    ${WORKDIR}/volatiles         
${D}${sysconfdir}/default/volatiles/00_core
-       if [ ${@ oe.types.boolean('${VOLATILE_LOG_DIR}') } = True ]; then
+       if [ ${@ oe.types.boolean('${VOLATILE_DIR}') } = True ]; then
+               echo "d root root 0755 /var/volatile/log none" >> 
${D}${sysconfdir}/default/volatiles/00_core
+               echo "d root root 1777 /var/volatile/tmp none" >> 
${D}${sysconfdir}/default/volatiles/00_core
                echo "l root root 0755 /var/log /var/volatile/log" >> 
${D}${sysconfdir}/default/volatiles/00_core
+               echo "l root root 0755 /var/tmp /var/volatile/tmp" >> 
${D}${sysconfdir}/default/volatiles/00_core
+       else
+               sed -i -e 
's;TMPROOT="${ROOT_DIR}/var/volatile/tmp";TMPROOT="${ROOT_DIR}/var/tmp";g' \
+                    ${D}${sysconfdir}/init.d/populate-volatile.sh
        fi
        install -m 0755    ${WORKDIR}/dmesg.sh          ${D}${sysconfdir}/init.d
        install -m 0644    ${WORKDIR}/logrotate-dmesg.conf ${D}${sysconfdir}/
diff --git a/meta/recipes-core/systemd/systemd_245.5.bb 
b/meta/recipes-core/systemd/systemd_245.5.bb
index ece4220987..a2aed13f4a 100644
--- a/meta/recipes-core/systemd/systemd_245.5.bb
+++ b/meta/recipes-core/systemd/systemd_245.5.bb
@@ -230,7 +230,9 @@ do_install() {
        install -d ${D}${sysconfdir}/tmpfiles.d
        install -m 0644 ${WORKDIR}/*.rules ${D}${sysconfdir}/udev/rules.d/
 
-       install -m 0644 ${WORKDIR}/00-create-volatile.conf 
${D}${sysconfdir}/tmpfiles.d/
+       if [ ${@ oe.types.boolean('${VOLATILE_DIR}') } = True ]; then
+               install -m 0644 ${WORKDIR}/00-create-volatile.conf 
${D}${sysconfdir}/tmpfiles.d/
+       fi
 
        if 
${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
                install -d ${D}${sysconfdir}/init.d
diff --git a/meta/recipes-core/udev/eudev_3.2.9.bb 
b/meta/recipes-core/udev/eudev_3.2.9.bb
index f96f8cbe78..fc9a73cf8f 100644
--- a/meta/recipes-core/udev/eudev_3.2.9.bb
+++ b/meta/recipes-core/udev/eudev_3.2.9.bb
@@ -41,6 +41,9 @@ do_install_append() {
        install -d ${D}${sysconfdir}/init.d
        install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/udev
        sed -i s%@UDEVD@%${base_sbindir}/udevd% ${D}${sysconfdir}/init.d/udev
+        if [ ${@ oe.types.boolean('${VOLATILE_DIR}') } = False ]; then
+            sed -i -e 's%mkdir -m 1777 -p /var/volatile/tmp%mkdir -m 1777 -p 
/var/tmp%g' ${D}${sysconfdir}/init.d/udev
+        fi
 
        install -d ${D}${sysconfdir}/udev/rules.d
        install -m 0644 ${WORKDIR}/local.rules 
${D}${sysconfdir}/udev/rules.d/local.rules
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#138314): 
https://lists.openembedded.org/g/openembedded-core/message/138314
Mute This Topic: https://lists.openembedded.org/mt/74222396/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to