Skip to contentSkip to conversation

VOLATILE_TMP_DIR: Extend to specify the persistence of /var/tmp

PATCH Changqing Li 2 participants 2 messages Jun 12, 2024 – Jul 4, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi,

Any concern about this patch? VOLATILE_TMP_DIR is originally added to specify the persistence of /tmp,

and I think it named as "VOLATILE_TMP", so maybe it is ok to extend to specify the persistence of /var/tmp (which by default is /var/volatile/tmp).

And this will cause doc change.

Regards

Changqing

Quoted 200 lines · Changqing Li

From: Changqing Li<[email protected]>

Currently, set VOLATILE_TMP_DIR to "no", only make /tmp as persistent. This patch extends VOLATILE_TMP_DIR to also specify the persistence of /var/tmp by following changes:

* change FILESYSTEM_PERMS_TABLES to remove symlink /var/tmp -> /var/volatile/tmp for the packaging process
* update base-files to create /var/tmp as a dir not symlink to /var/volatile/tmp

Here is an use case:
Steps:
1. docker import core-image-minimal-qemux86-64.tar.bz2 poky:latest
2. docker run -it --rm poky:latest /bin/sh
3. /var/log /var/tmp are deadlinks, and cause "No such file or directory" errors

Root cause:
By default, /var/tmp links to /var/volatile/tmp, and /var/volatile/tmp usually created by initscript(sysV) or systemd-tmpfile.d(systemd) during boot up, but for container, initscript/systemd-tmpfile.d will not be executed, so /var/volatile/tmp is not created.

This patch provides an option for user want to use container, set VOLATILE_TMP_DIR to "no" can resolve above case.

---
  meta/conf/bitbake.conf                        |  5 ++-
  ...fs-perms.txt => fs-perms-volatile-log.txt} | 32 -------------------
  ...tent-log.txt => fs-perms-volatile-tmp.txt} | 27 ----------------
  meta/files/fs-perms.txt                       |  3 --
  .../base-files/base-files_3.0.14.bb           |  5 +--
  5 files changed, 7 insertions(+), 65 deletions(-)

copy meta/files/{fs-perms.txt => fs-perms-volatile-log.txt} (53%) rename meta/files/{fs-perms-persistent-log.txt => fs-perms-volatile-tmp.txt} (59%)

meta/conf/bitbake.conf +0 -1
index 3ef2deb088..e6ec640809 100644
@@ -384,7 +384,10 @@ FILESEXTRAPATHS ?= "__default:"
  #  base_prefix, prefix, exec_prefix, base_bindir, base_sbindir, base_libdir,
  #  datadir, sysconfdir, servicedir, sharedstatedir, localstatedir, infodir,
  #  mandir, docdir, bindir, sbindir, libexecdir, libdir and includedir
-FILESYSTEM_PERMS_TABLES ?="${@'files/fs-perms.txt' if 

oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'files/fs-perms-persistent-log.txt'}"

meta/conf/bitbake.conf +4 -0
+FILESYSTEM_PERMS_TABLES ?=  " files/fs-perms.txt \
+                              ${@'files/fs-perms-volatile-log.txt' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else ''} \
+                              ${@'files/fs-perms-volatile-tmp.txt' if oe.types.boolean(d.getVar('VOLATILE_TMP_DIR')) else ''} \
+                            "
 
  ##################################################################
  # General work and output directories for the build system.
meta/files/fs-perms-volatile-log.txt renamed from meta/files/fs-perms.txt +0 -32
similarity index 53%
copy from meta/files/fs-perms.txt
copy to meta/files/fs-perms-volatile-log.txt
index 48191f504c..fc846bbdc5 100644
@@ -28,39 +28,7 @@
  # Note: all standard config directories are automatically assigned "0755 root root false - - -"
 
  # Documentation should always be corrected
-${mandir}		0755	root	root	true	0644	root	root
-${infodir}		0755	root	root	true	0644	root	root
-${docdir}		0755	root	root	true	0644	root	root
-${datadir}/gtk-doc	0755	root	root	true	0644	root	root
-
-# Fixup locales
-${datadir}/locale	0755	root	root	true	0644	root	root
-
-# Cleanup headers
-${includedir}		0755	root	root	true	0644	root	root
-
-# Cleanup debug src
-/usr/src/debug		0755	root	root	true	0644	root	root
 
  # Items from base-files
  # Links
-${localstatedir}/run	link	/run
  ${localstatedir}/log	link	volatile/log
-${localstatedir}/lock	link	/run/lock
-${localstatedir}/tmp	link	volatile/tmp
-
-/home				0755	root	root	false - - -
-/srv				0755	root	root	false - - -
-${prefix}/src			0755	root	root	false - - -
-${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 - - -
-
-# Set 2775-lsb
-${localstatedir}/mail		02775	root	mail	false - - -
meta/files/fs-perms-volatile-tmp.txt renamed from meta/files/fs-perms-persistent-log.txt +0 -27
similarity index 59%
rename from meta/files/fs-perms-persistent-log.txt
rename to meta/files/fs-perms-volatile-tmp.txt
index 61f0a6e26a..26247acda8 100644
@@ -28,38 +28,11 @@
  # Note: all standard config directories are automatically assigned "0755 root root false - - -"
 
  # Documentation should always be corrected
-${mandir}		0755	root	root	true	0644	root	root
-${infodir}		0755	root	root	true	0644	root	root
-${docdir}		0755	root	root	true	0644	root	root
-${datadir}/gtk-doc	0755	root	root	true	0644	root	root
-
-# Fixup locales
-${datadir}/locale	0755	root	root	true	0644	root	root
-
-# Cleanup headers
-${includedir}		0755	root	root	true	0644	root	root
-
-# Cleanup debug src
-/usr/src/debug		0755	root	root	true	0644	root	root
 
  # Items from base-files
  # 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 - - -
-${prefix}/src			0755	root	root	false - - -
-${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 - - -
-
-# Set 2775-lsb
-${localstatedir}/mail		02775	root	mail	false - - -
meta/files/fs-perms.txt +0 -3
index 48191f504c..d2266c1b26 100644
@@ -45,9 +45,7 @@ ${includedir}		0755	root	root	true	0644	root	root
  # Items from base-files
  # Links
  ${localstatedir}/run	link	/run
-${localstatedir}/log	link	volatile/log
  ${localstatedir}/lock	link	/run/lock
-${localstatedir}/tmp	link	volatile/tmp
 
  /home				0755	root	root	false - - -
  /srv				0755	root	root	false - - -
@@ -57,7 +55,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 - - -
meta/recipes-core/base-files/base-files_3.0.14.bb +2 -2
index 1b6e9671e4..256dfb214e 100644
@@ -31,7 +31,7 @@ UNPACKDIR = "${S}"
  INHIBIT_DEFAULT_DEPS = "1"
 
  docdir:append = "/${P}"
-dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
+dirs1777 = "/tmp ${localstatedir}/${@'volatile/' if oe.types.boolean('${VOLATILE_TMP_DIR}') else ''}tmp"
  dirs2775 = ""
  dirs555 = "/sys /proc"
  dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
@@ -55,7 +55,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_LOG_DIR}') else ''} \ + 

${@'tmp' if oe.types.boolean('${VOLATILE_TMP_DIR}') else ''}"

  conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
               ${sysconfdir}/issue /${sysconfdir}/issue.net \
               ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#200015):https://lists.openembedded.org/g/openembedded-core/message/200015 Mute This Topic:https://lists.openembedded.org/mt/106385197/3616873
Group Owner:[email protected] Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

I'd suggest we look at this patch again. IMHO, this patch brings the following benefits.

1) Variable names are more consistent

The current situation:
VOLATILE_LOG_DIR handles /var/log.
VOLATILE_TMP_DIR handles /tmp.

After this patch, the situation is:
VOLATILE_LOG_DIR hanldes /var/log.
VOLATILE_TMP_DIR handles /var/tmp.

2) /var/tmp being persistent in fact indicates that /tmp is persistent

This is because /tmp is a symlink to /var/tmp by default. And the tmp.mount has been handled well in systemd recipe.

3) Yocto can now build out container image inside which tools using /var/tmp can run.

4) When people use a separate partition for /var, they probably want persistent /var/tmp. This patch makes it easy to build out such image.

Regards,
Qi

Quoted 215 lines · Changqing Li via lists.openembedded.org

Hi,

Any concern about this patch? VOLATILE_TMP_DIR is originally added to specify the persistence of /tmp,

and I think it named as "VOLATILE_TMP", so maybe it is ok to extend to specify the persistence of /var/tmp (which by default is /var/volatile/tmp).

And this will cause doc change.

Regards

Changqing

Quoted 188 lines · Changqing Li

From: Changqing Li<[email protected]>

Currently, set VOLATILE_TMP_DIR to "no", only make /tmp as persistent. This patch extends VOLATILE_TMP_DIR to also specify the persistence of /var/tmp by following changes:

* change FILESYSTEM_PERMS_TABLES to remove symlink /var/tmp -> /var/volatile/tmp for the packaging process
* update base-files to create /var/tmp as a dir not symlink to /var/volatile/tmp

Here is an use case:
Steps:
1. docker import core-image-minimal-qemux86-64.tar.bz2 poky:latest
2. docker run -it --rm poky:latest /bin/sh
3. /var/log /var/tmp are deadlinks, and cause "No such file or directory" errors

Root cause:
By default, /var/tmp links to /var/volatile/tmp, and /var/volatile/tmp usually created by initscript(sysV) or systemd-tmpfile.d(systemd) during boot up, but for container, initscript/systemd-tmpfile.d will not be executed, so /var/volatile/tmp is not created.

This patch provides an option for user want to use container, set VOLATILE_TMP_DIR to "no" can resolve above case.

---
  meta/conf/bitbake.conf                        |  5 ++-
  ...fs-perms.txt => fs-perms-volatile-log.txt} | 32 -------------------
  ...tent-log.txt => fs-perms-volatile-tmp.txt} | 27 ----------------
  meta/files/fs-perms.txt                       |  3 --
  .../base-files/base-files_3.0.14.bb           |  5 +--
  5 files changed, 7 insertions(+), 65 deletions(-)

copy meta/files/{fs-perms.txt => fs-perms-volatile-log.txt} (53%) rename meta/files/{fs-perms-persistent-log.txt => fs-perms-volatile-tmp.txt} (59%)

meta/conf/bitbake.conf +0 -1
index 3ef2deb088..e6ec640809 100644
@@ -384,7 +384,10 @@ FILESEXTRAPATHS ?= "__default:"
  #  base_prefix, prefix, exec_prefix, base_bindir, base_sbindir, base_libdir,
  #  datadir, sysconfdir, servicedir, sharedstatedir, localstatedir, infodir,
  #  mandir, docdir, bindir, sbindir, libexecdir, libdir and includedir
-FILESYSTEM_PERMS_TABLES ?="${@'files/fs-perms.txt' if 

oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'files/fs-perms-persistent-log.txt'}"

meta/conf/bitbake.conf +4 -0
+FILESYSTEM_PERMS_TABLES ?=  " files/fs-perms.txt \
+                              ${@'files/fs-perms-volatile-log.txt' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else ''} \
+                              ${@'files/fs-perms-volatile-tmp.txt' if oe.types.boolean(d.getVar('VOLATILE_TMP_DIR')) else ''} \
+                            "
 
  ##################################################################
  # General work and output directories for the build system.
meta/files/fs-perms-volatile-log.txt renamed from meta/files/fs-perms.txt +0 -32
similarity index 53%
copy from meta/files/fs-perms.txt
copy to meta/files/fs-perms-volatile-log.txt
index 48191f504c..fc846bbdc5 100644
@@ -28,39 +28,7 @@
  # Note: all standard config directories are automatically assigned "0755 root root false - - -"
 
  # Documentation should always be corrected
-${mandir}		0755	root	root	true	0644	root	root
-${infodir}		0755	root	root	true	0644	root	root
-${docdir}		0755	root	root	true	0644	root	root
-${datadir}/gtk-doc	0755	root	root	true	0644	root	root
-
-# Fixup locales
-${datadir}/locale	0755	root	root	true	0644	root	root
-
-# Cleanup headers
-${includedir}		0755	root	root	true	0644	root	root
-
-# Cleanup debug src
-/usr/src/debug		0755	root	root	true	0644	root	root
 
  # Items from base-files
  # Links
-${localstatedir}/run	link	/run
  ${localstatedir}/log	link	volatile/log
-${localstatedir}/lock	link	/run/lock
-${localstatedir}/tmp	link	volatile/tmp
-
-/home				0755	root	root	false - - -
-/srv				0755	root	root	false - - -
-${prefix}/src			0755	root	root	false - - -
-${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 - - -
-
-# Set 2775-lsb
-${localstatedir}/mail		02775	root	mail	false - - -
meta/files/fs-perms-volatile-tmp.txt renamed from meta/files/fs-perms-persistent-log.txt +0 -27
similarity index 59%
rename from meta/files/fs-perms-persistent-log.txt
rename to meta/files/fs-perms-volatile-tmp.txt
index 61f0a6e26a..26247acda8 100644
@@ -28,38 +28,11 @@
  # Note: all standard config directories are automatically assigned "0755 root root false - - -"
 
  # Documentation should always be corrected
-${mandir}		0755	root	root	true	0644	root	root
-${infodir}		0755	root	root	true	0644	root	root
-${docdir}		0755	root	root	true	0644	root	root
-${datadir}/gtk-doc	0755	root	root	true	0644	root	root
-
-# Fixup locales
-${datadir}/locale	0755	root	root	true	0644	root	root
-
-# Cleanup headers
-${includedir}		0755	root	root	true	0644	root	root
-
-# Cleanup debug src
-/usr/src/debug		0755	root	root	true	0644	root	root
 
  # Items from base-files
  # 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 - - -
-${prefix}/src			0755	root	root	false - - -
-${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 - - -
-
-# Set 2775-lsb
-${localstatedir}/mail		02775	root	mail	false - - -
meta/files/fs-perms.txt +0 -3
index 48191f504c..d2266c1b26 100644
@@ -45,9 +45,7 @@ ${includedir}		0755	root	root	true	0644	root	root
  # Items from base-files
  # Links
  ${localstatedir}/run	link	/run
-${localstatedir}/log	link	volatile/log
  ${localstatedir}/lock	link	/run/lock
-${localstatedir}/tmp	link	volatile/tmp
 
  /home				0755	root	root	false - - -
  /srv				0755	root	root	false - - -
@@ -57,7 +55,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 - - -
meta/recipes-core/base-files/base-files_3.0.14.bb +2 -2
index 1b6e9671e4..256dfb214e 100644
@@ -31,7 +31,7 @@ UNPACKDIR = "${S}"
  INHIBIT_DEFAULT_DEPS = "1"
 
  docdir:append = "/${P}"
-dirs1777 = "/tmp ${localstatedir}/volatile/tmp"
+dirs1777 = "/tmp ${localstatedir}/${@'volatile/' if oe.types.boolean('${VOLATILE_TMP_DIR}') else ''}tmp"
  dirs2775 = ""
  dirs555 = "/sys /proc"
  dirs755 = "/boot /dev ${base_bindir} ${base_sbindir} ${base_libdir} \
@@ -55,7 +55,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_LOG_DIR}') else ''} \ + 

${@'tmp' if oe.types.boolean('${VOLATILE_TMP_DIR}') else ''}"

Quoted 4 lines
  conffiles = "${sysconfdir}/debian_version ${sysconfdir}/host.conf \
               ${sysconfdir}/issue /${sysconfdir}/issue.net \
               ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile \

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#200553): https://lists.openembedded.org/g/openembedded-core/message/200553
Mute This Topic: https://lists.openembedded.org/mt/106385197/7304865
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-