systemd: Do not install anything in /var/volatile
PATCH v4 1/4 systemd: Do not install anything in /var/volatile
/var/log is typically a symbolic link to inside /var/volatile, which is expected to be empty. Check ${VOLATILE_LOG_DIR} to see if it is ok to install /var/log.
---
PATCHv2: Added check for ${VOLATILE_LOG_DIR} before removing /var/log.
PATCHv3: No changes.
PATCHv4: No changes.
meta/recipes-core/systemd/systemd_249.5.bb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
meta/recipes-core/systemd/systemd_249.5.bb +9 -6
@@ -270,13 +270,16 @@ do_install() { install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${systemd_system_unitdir}d-sysv-install fi - chown root:systemd-journal ${D}/${localstatedir}/log/journal - - # Delete journal README, as log can be symlinked inside volatile. - rm -f ${D}/${localstatedir}/log/README + if "${@'true' if oe.types.boolean(d.getVar('VOLATILE_LOG_DIR')) else 'false'}"; then + # /var/log is typically a symbolic link to inside /var/volatile, + # which is expected to be empty. + rm -rf ${D}${localstatedir}/log + else + chown root:systemd-journal ${D}${localstatedir}/log/journal - # journal-remote creates this at start - rm -rf ${D}/${localstatedir}/log/journal/remote + # journal-remote creates this at start + rm -rf ${D}${localstatedir}/log/journal/remote + fi install -d ${D}${systemd_system_unitdir}/graphical.target.wants install -d ${D}${systemd_system_unitdir}/multi-user.target.wants
PATCH v4 2/4 base-files: Ignore the empty-dirs QA error due to files in /var/volatile
---
PATCHv3: An alternative to skipping the empty-dirs QA test for base-files would be to remove /var/volatile/tmp and /var/volatile/log, but I do not know if there are any consequences of doing that, e.g., due to them not existing before the tmpfs has been mounted on top of /var/volatile. Thus I have left them in place.
PATCHv4: No changes.
meta/recipes-core/base-files/base-files_3.0.14.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-core/base-files/base-files_3.0.14.bb +2 -0
@@ -182,3 +182,5 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" CONFFILES:${PN} = "${sysconfdir}/fstab ${@['', '${sysconfdir}/hostname ${sysconfdir}/hosts'][(d.getVar('hostname') != '')]} ${sysconfdir}/shells" CONFFILES:${PN} += "${sysconfdir}/motd ${sysconfdir}/nsswitch.conf ${sysconfdir}/profile" + +INSANE_SKIP:${PN} += "empty-dirs"
PATCH v4 3/4 apt: Do not install /var/log/apt
In reply to Peter Kjellerstedt/var/log is normally a link to /var/volatile/log and /var/volatile is a tmpfs mount. So anything created in /var/log will not be available when the tmpfs is mounted.
Also some whitespace clean up.
--- meta/recipes-devtools/apt/apt_2.2.4.bb | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/apt/apt_2.2.4.bb +16 -14
@@ -51,9 +51,8 @@ EXTRA_OECMAKE:append = " -DCURRENT_VENDOR=debian -DWITH_DOC=False \ -DWITH_TESTS=False \ " -do_configure:prepend () { - echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH )" >> ${WORKDIR}/toolchain.cmake - +do_configure:prepend() { + echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH )" >> ${WORKDIR}/toolchain.cmake } # Unfortunately apt hardcodes this all over the place
@@ -61,7 +60,7 @@ FILES:${PN} += "${prefix}/lib/dpkg ${prefix}/lib/apt" RDEPENDS:${PN} += "bash perl dpkg" customize_apt_conf_sample() { - cat > ${D}${sysconfdir}/apt/apt.conf.sample << EOF + cat > ${D}${sysconfdir}/apt/apt.conf.sample << EOF Dir "${STAGING_DIR_NATIVE}/" { State "var/lib/apt/"
@@ -114,22 +113,25 @@ EOF } do_install:append:class-native() { - customize_apt_conf_sample + customize_apt_conf_sample } do_install:append:class-nativesdk() { - customize_apt_conf_sample + customize_apt_conf_sample } - do_install:append:class-target() { - #Write the correct apt-architecture to apt.conf - APT_CONF=${D}/etc/apt/apt.conf - echo 'APT::Architecture "${DPKG_ARCH}";' > ${APT_CONF} + # Write the correct apt-architecture to apt.conf + APT_CONF=${D}${sysconfdir}/apt/apt.conf + echo 'APT::Architecture "${DPKG_ARCH}";' > ${APT_CONF} } -# Avoid non-reproducible -src package -do_install:append () { - sed -i -e "s,${B},,g" \ - ${B}/apt-pkg/tagfile-keys.cc +do_install:append() { + # Remove /var/log/apt. /var/log is normally a link to /var/volatile/log + # and /var/volatile is a tmpfs mount. So anything created in /var/log + # will not be available when the tmpfs is mounted. + rm -rf ${D}${localstatedir}/log + + # Avoid non-reproducible -src package + sed -i -e "s,${B},,g" ${B}/apt-pkg/tagfile-keys.cc }
Re: [OE-core] [PATCHv4 3/4] apt: Do not install /var/log/apt
Quoted 62 lines · Peter Kjellerstedt
/var/logis normally a link to/var/volatile/logand/var/volatileis a tmpfs mount. So anything created in/var/logwill not be available when the tmpfs is mounted.Also some whitespace clean up.
Signed-off-by Peter Kjellerstedt <[email protected]>--- meta/recipes-devtools/apt/apt_2.2.4.bb | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-)meta/recipes-devtools/apt/apt_2.2.4.bb +8
-13@@ -51,9 +51,8 @@ EXTRA_OECMAKE:append = " -DCURRENT_VENDOR=debian -DWITH_DOC=False \ -DWITH_TESTS=False \ " -do_configure:prepend () { - echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH )" >> ${WORKDIR}/toolchain.cmake - +do_configure:prepend() { + echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH )" >> ${WORKDIR}/toolchain.cmake } # Unfortunately apt hardcodes this all over the place@@ -61,7 +60,7 @@ FILES:${PN} += "${prefix}/lib/dpkg ${prefix}/lib/apt" RDEPENDS:${PN} += "bash perl dpkg" customize_apt_conf_sample() { - cat > ${D}${sysconfdir}/apt/apt.conf.sample << EOF + cat > ${D}${sysconfdir}/apt/apt.conf.sample << EOF Dir "${STAGING_DIR_NATIVE}/" { State "var/lib/apt/"@@ -114,22 +113,25 @@ EOF } do_install:append:class-native() { - customize_apt_conf_sample + customize_apt_conf_sample } do_install:append:class-nativesdk() { - customize_apt_conf_sample + customize_apt_conf_sample } - do_install:append:class-target() { - #Write the correct apt-architecture to apt.conf - APT_CONF=${D}/etc/apt/apt.conf - echo 'APT::Architecture "${DPKG_ARCH}";' > ${APT_CONF} + # Write the correct apt-architecture to apt.conf + APT_CONF=${D}${sysconfdir}/apt/apt.conf + echo 'APT::Architecture "${DPKG_ARCH}";' > ${APT_CONF} } -# Avoid non-reproducible -src package -do_install:append () { - sed -i -e "s,${B},,g" \
meta/recipes-devtools/apt/apt_2.2.4.bb EOF · line 137
Quoted 10 lines
meta/recipes-devtools/apt/apt_2.2.4.bb +8
-1- ${B}/apt-pkg/tagfile-keys.cc +do_install:append() { + # Remove /var/log/apt. /var/log is normally a link to /var/volatile/log + # and /var/volatile is a tmpfs mount. So anything created in /var/log + # will not be available when the tmpfs is mounted. + rm -rf ${D}${localstatedir}/log + + # Avoid non-reproducible -src package + sed -i -e "s,${B},,g" ${B}/apt-pkg/tagfile-keys.cc }
I didn't bisect it down but this looks likely to be from this change:
https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/2796/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/50/builds/4279/steps/11/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/76/builds/4260/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/115/builds/919/steps/12/logs/stdio
(and more)
Cheers,
Richard
PATCH v4 4/4 insane.bbclass: Add a check for directories that are expected to be empty
In reply to Peter KjellerstedtThe empty-dirs QA check verifies that all directories specified in QA_EMPTY_DIRS are empty. It is possible to specify why a directory is expected to be empty by defining QA_EMPTY_DIRS_RECOMMENDATION:<path>, which will then be included in the error message if the directory is not empty. If it is not specified for a directory, then "but it is expected to be empty" will be used.
---
PATCHv2: No changes.
PATCHv3: No changes.
PATCHv4: No changes.
meta/classes/insane.bbclass | 33 ++++++++++++++++++++++++++++++++- meta/conf/documentation.conf | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-)
meta/classes/insane.bbclass +32 -1
@@ -37,7 +37,7 @@ ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \ configure-gettext perllocalpod shebang-size \ already-stripped installed-vs-shipped ldflags compile-host-path \ install-host-path pn-overrides unknown-configure-option \ - useless-rpaths rpaths staticdev \ + useless-rpaths rpaths staticdev empty-dirs \ " # Add usrmerge QA check based on distro feature ERROR_QA:append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}"
@@ -50,6 +50,21 @@ ALL_QA = "${WARN_QA} ${ERROR_QA}" UNKNOWN_CONFIGURE_WHITELIST ?= "--enable-nls --disable-nls --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot --disable-static" +# This is a list of directories that are expected to be empty. +QA_EMPTY_DIRS ?= " \ + /dev/pts \ + /media \ + /proc \ + /run \ + /tmp \ + ${localstatedir}/run \ + ${localstatedir}/volatile \ +" +# It is possible to specify why a directory is expected to be empty by defining +# QA_EMPTY_DIRS_RECOMMENDATION:<path>, which will then be included in the error +# message if the directory is not empty. If it is not specified for a directory, +# then "but it is expected to be empty" will be used. + def package_qa_clean_path(path, d, pkg=None): """ Remove redundant paths from the path for display. If pkg isn't set then
@@ -885,6 +900,22 @@ def package_qa_check_unlisted_pkg_lics(package, d, messages): "listed in LICENSE" % (package, ' '.join(unlisted))) return False +QAPKGTEST[empty-dirs] = "package_qa_check_empty_dirs" +def package_qa_check_empty_dirs(pkg, d, messages): + """ + Check for the existence of files in directories that are expected to be + empty. + """ + + pkgd = oe.path.join(d.getVar('PKGDEST'), pkg) + for dir in (d.getVar('QA_EMPTY_DIRS') or "").split(): + empty_dir = oe.path.join(pkgd, dir) + if os.path.exists(empty_dir) and os.listdir(empty_dir): + recommendation = (d.getVar('QA_EMPTY_DIRS_RECOMMENDATION:' + dir) or + "but it is expected to be empty") + msg = "%s installs files in %s, %s" % (pkg, dir, recommendation) + oe.qa.add_message(messages, "empty-dirs", msg) + def package_qa_check_encoding(keys, encode, d): def check_encoding(key, enc): sane = True
meta/conf/documentation.conf +2 -0
@@ -345,6 +345,8 @@ PYPI_SRC_URI[doc] = "The URI to use to fetch from pypi, default uses pythonhoste #Q +QA_EMPTY_DIRS[doc] = "A list of directories that are expected to be empty." +QA_EMPTY_DIRS_RECOMMENDATION[doc] = "This specifies a recommendation for a directory why it must be empty, which will be included in the error message if the directory is not empty." QMAKE_PROFILES[doc] = "Specifies your own subset of .pro files to be built for use with qmake." #R