[1/6] rootfs: add feature to clean isar generated dpkg config

Message ID 20260924073811.4058349-2-felix.moessbauer@siemens.com
State Under Review
Headers show
Series Model isar-exclude-docs as rootfs feature | expand

Commit Message

MOESSBAUER, Felix Sept. 24, 2026, 7:38 a.m. UTC
It depends on the use-case if the isar generated dpkg config should be
preserved or not. At least for the image is should not be preserved, but
for other rootfs (like the sbuild ones) it should be.

We now add a rootfs feature to model this.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes-recipe/image.bbclass  | 1 +
 meta/classes-recipe/rootfs.bbclass | 6 ++++++
 2 files changed, 7 insertions(+)

Patch

diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass
index d17d1860..290d6d5c 100644
--- a/meta/classes-recipe/image.bbclass
+++ b/meta/classes-recipe/image.bbclass
@@ -100,6 +100,7 @@  ROOTFS_FEATURES += "\
     populate-systemd-preset \
     generate-sbom \
     clean-apt-credentials \
+    clean-dpkg-config \
     "
 ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${@isar_multiarch_packages('IMAGE_INSTALL', d)}"
 ROOTFS_VARDEPS += "IMAGE_INSTALL"
diff --git a/meta/classes-recipe/rootfs.bbclass b/meta/classes-recipe/rootfs.bbclass
index d3b0d471..f7822351 100644
--- a/meta/classes-recipe/rootfs.bbclass
+++ b/meta/classes-recipe/rootfs.bbclass
@@ -40,6 +40,7 @@  ROOTFS_BASE_DISTRO ?= "${BASE_DISTRO}"
 # 'clean-log-files' - delete log files that are not owned by packages
 # 'populate-systemd-preset' - enable systemd units according to systemd presets
 # 'clean-apt-credentials' - remove apt auth credentials written by ISAR_APT_CREDS
+# 'clean-dpkg-config' - remove ISAR-specific dpkg configuration files from the rootfs
 
 # convenience variable to enable all features needed for a reproducible rootfs build
 ROOTFS_FEATURES_REPRODUCIBLE = " \
@@ -577,6 +578,11 @@  rootfs_postprocess_clean_apt_credentials() {
     run_privileged rm -f "${ROOTFSDIR}/etc/apt/auth.conf.d/isar.conf"
 }
 
+ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'clean-dpkg-config', 'rootfs_postprocess_clean_dpkg_config', '', d)}"
+rootfs_postprocess_clean_dpkg_config() {
+    run_privileged find "${ROOTFSDIR}/etc/dpkg/dpkg.cfg.d" -type f -name '*isar*.cfg' -delete
+}
+
 ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'clean-pycache', 'rootfs_postprocess_clean_pycache', '', d)}"
 rootfs_postprocess_clean_pycache() {
     run_privileged find ${ROOTFSDIR}/usr -type f -name '*.pyc'       -delete -print