]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
VOLATILE_TMP_DIR: add
authorTrevor Woerner <twoerner@gmail.com>
Mon, 27 Feb 2023 05:00:40 +0000 (00:00 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 27 Feb 2023 22:53:58 +0000 (22:53 +0000)
Provide a mechanism to allow users to choose whether the /tmp directory
is on persistent storage (non-volatile) or a RAM-based tmpfs (volatile).
The default is volatile.

Works for both sysvinit-based and systemd-based systems.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/bitbake.conf
meta/recipes-core/initscripts/initscripts_1.0.bb
meta/recipes-core/systemd/systemd_252.5.bb

index dcf6ce99d138872bbe3ee9da1fc4c1b495464282..afd9e2f5527f512371dde6601418b0f4ff01696c 100644 (file)
@@ -90,6 +90,10 @@ ROOT_HOME ??= "/home/root"
 # If set to boolean false ('no', 'n', 'false', 'f', '0'), /var/log is on persistent storage.
 VOLATILE_LOG_DIR ?= "yes"
 
+# if set to 'yes': /tmp links to /var/tmp which links to /var/volatile/tmp
+# otherwise:       /tmp is on persistent storage
+VOLATILE_TMP_DIR ?= "yes"
+
 BB_RENAMED_VARIABLES[PNBLACKLIST] = "SKIP_RECIPE"
 BB_RENAMED_VARIABLES[CVE_CHECK_PN_WHITELIST] = "CVE_CHECK_SKIP_RECIPE"
 BB_RENAMED_VARIABLES[CVE_CHECK_WHITELIST] = "CVE_CHECK_IGNORE"
index 7c9d9ca4f1070e4c0ad6f6701f9b0553955dbf92..4dc477bb8d694db8fbacdbe63c8c56d429242ec5 100644 (file)
@@ -108,6 +108,9 @@ do_install () {
                sed -i -e '\@^d root root 0755 /var/volatile/log none$@ a\l root root 0755 /var/log /var/volatile/log' \
                        ${D}${sysconfdir}/default/volatiles/00_core
        fi
+       if [ "${VOLATILE_TMP_DIR}" != "yes" ]; then
+               sed -i -e "/\<tmp\>/d" ${D}${sysconfdir}/default/volatiles/00_core
+       fi
        install -m 0755    ${WORKDIR}/dmesg.sh          ${D}${sysconfdir}/init.d
        install -m 0644    ${WORKDIR}/logrotate-dmesg.conf ${D}${sysconfdir}/
 
index ea468da150cec73177b959bc77037793824d449d..8b92b2cf425c3bab73f8d969868bae38e5bac6b9 100644 (file)
@@ -288,6 +288,13 @@ do_install() {
                rm -rf ${D}${localstatedir}/log/journal/remote
        fi
 
+       # if the user requests /tmp be on persistent storage (i.e. not volatile)
+       # then don't use a tmpfs for /tmp
+       if [ "${VOLATILE_TMP_DIR}" != "yes" ]; then
+               rm -f ${D}${rootlibdir}/systemd/system/tmp.mount
+               rm -f ${D}${rootlibdir}/systemd/system/local-fs.target.wants/tmp.mount
+       fi
+
        install -d ${D}${systemd_system_unitdir}/graphical.target.wants
        install -d ${D}${systemd_system_unitdir}/multi-user.target.wants
        install -d ${D}${systemd_system_unitdir}/poweroff.target.wants