Skip to content

Commit

Permalink
VOLATILE_TMP_DIR: Extend to specify the persistence of /var/tmp
Browse files Browse the repository at this point in the history
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.

(From OE-Core rev: 1f1d8be8cbaf965c0826ef56938967acbeb8d846)

Signed-off-by: Changqing Li <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
  • Loading branch information
sandy-lcq authored and rpurdie committed Jul 17, 2024
1 parent d461170 commit 757723a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
5 changes: 4 additions & 1 deletion meta/conf/bitbake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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'}"
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.
Expand Down
34 changes: 34 additions & 0 deletions meta/files/fs-perms-volatile-log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file contains a list of files and directories with known permissions.
# It is used by the packaging class to ensure that the permissions, owners and
# group of listed files and directories are in sync across the system.
#
# The format of this file
#
#<path> <mode> <uid> <gid> <walk> <fmode> <fuid> <fgid>
#
# or
#
#<path> link <target>
#
# <path>: directory path
# <mode>: mode for directory
# <uid>: uid for directory
# <gid>: gid for directory
# <walk>: recursively walk the directory? true or false
# <fmode>: if walking, new mode for files
# <fuid>: if walking, new uid for files
# <fgid>: if walking, new gid for files
# <target>: turn the directory into a symlink point to target
#
# in mode, uid or gid, a "-" means don't change any existing values
#
# /usr/src 0755 root root false - - -
# /usr/share/man 0755 root root true 0644 root root

# Note: all standard config directories are automatically assigned "0755 root root false - - -"

# Documentation should always be corrected

# Items from base-files
# Links
${localstatedir}/log link volatile/log
Original file line number Diff line number Diff line change
Expand Up @@ -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 - - -
3 changes: 0 additions & 3 deletions meta/files/fs-perms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 - - -
Expand All @@ -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 - - -
Expand Down
5 changes: 3 additions & 2 deletions meta/recipes-core/base-files/base-files_3.0.14.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand All @@ -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 \
Expand Down

0 comments on commit 757723a

Please sign in to comment.