[2/2] image: move deb-src-caching functionality after image creation

Message ID 20250403125857.2525698-2-srinuvasan.a@siemens.com
State New
Headers show
Series [1/2] meta/classes/rootfs: carry bootstrap list file until the image rootfs | expand

Commit Message

srinuvasan.a April 3, 2025, 12:58 p.m. UTC
From: srinuvasan <srinuvasan.a@siemens.com>

When we do deb-src caching, we are missing to cache imager related packages, because the deb-src-caching
functionality runs in the stage of ROOTFS_POSTPROCESS_COMAMND, but image creation task runs after the
rootfs creation, hence imager related packages are missing in rootfs's var/cache/apt/archives.

To solve this issue run the deb-src-caching after image creation, now we can able to download deb-src for
all the deb packages.

Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
---
 meta/classes/image.bbclass  | 7 ++++++-
 meta/classes/rootfs.bbclass | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index ff3cd737..0789e0b6 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -72,7 +72,12 @@  ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}"
 ROOTFS_DPKGSTATUS_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}"
 ROOTFS_PACKAGE_SUFFIX ?= "${PN}-${DISTRO}-${MACHINE}"
 
-ROOTFS_POSTPROCESS_COMMAND:prepend = "${@bb.utils.contains('BASE_REPO_FEATURES', 'cache-deb-src', 'cache_deb_src', '', d)} "
+CACHE_DEB_SRC = "${@bb.utils.contains('BASE_REPO_FEATURES', 'cache-deb-src', '1', '0', d)}"
+python () {
+    if bb.utils.to_boolean(d.getVar('CACHE_DEB_SRC')):
+        bb.build.addtask('do_cache_deb_src', 'do_deploy', 'do_image', d)
+}
+
 ROOTFS_POSTPROCESS_COMMAND:prepend = "${@bb.utils.contains('BASE_REPO_FEATURES', 'cache-dbg-pkgs', 'cache_dbg_pkgs', '', d)} "
 
 inherit rootfs
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 406e9192..3055b0fc 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -272,7 +272,8 @@  python do_rootfs_install() {
 }
 addtask rootfs_install before do_rootfs_postprocess after do_unpack
 
-cache_deb_src() {
+do_cache_deb_src[network] = "${TASK_USE_SUDO}"
+do_cache_deb_src() {
     if [ -e "${ROOTFSDIR}"/etc/resolv.conf ] ||
        [ -h "${ROOTFSDIR}"/etc/resolv.conf ]; then
         sudo mv "${ROOTFSDIR}"/etc/resolv.conf "${ROOTFSDIR}"/etc/resolv.conf.isar