[v2,1/3] fix(rootfs): copy isar-apt packages instead of downloading

Message ID 20260730111933.1237145-2-felix.moessbauer@siemens.com
State New
Headers show
Series [v2,1/3] fix(rootfs): copy isar-apt packages instead of downloading | expand

Commit Message

MOESSBAUER, Felix July 30, 2026, 11:19 a.m. UTC
Previously, the arch part was stripped, hence on multiarch or compat
scenarios the wrong package might have been downloaded. We fix this by
considering the whole filename. For that, we switch to cp, as we
otherwise would have to reconstruct the package name from the filename.
As the whole path is urlencoded, we cannot directly pass the url to cp.
Instead, we reconstruct it based on the base-path (which is taken as-is,
as it does not have any special characters) and the second field emitted
on --print-uris, which provides the decoded filename.

As we now use cp, we also don't need any locking anymore (technically we
did not need it before either, but apt was called in a way that required
it).

Fixes: b90b722f ("rootfs: Deny packages download during install")
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes-recipe/rootfs.bbclass | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Patch

diff --git a/meta/classes-recipe/rootfs.bbclass b/meta/classes-recipe/rootfs.bbclass
index 77e6aefc..2ce8cee3 100644
--- a/meta/classes-recipe/rootfs.bbclass
+++ b/meta/classes-recipe/rootfs.bbclass
@@ -361,23 +361,15 @@  ROOTFS_INSTALL_COMMAND += "rootfs_install_pkgs_isar_download"
 rootfs_install_pkgs_isar_download[weight] = "50"
 rootfs_install_pkgs_isar_download[isar-apt-lock] = "acquire-before release-after"
 rootfs_install_pkgs_isar_download() {
-    mkdir -p "${WORKDIR}/dpkg"
-
-    # Use our own dpkg lock files rather than those in the rootfs since we are not root
-    # (this is safe as there are no concurrent apt/dpkg operations for that rootfs)
-    touch "${WORKDIR}/dpkg/lock" "${WORKDIR}/dpkg/lock-frontend"
-
     # Command apt-get install do not cache packages from local repos
     # We can obtain non cached package URIs by recalling install command here
-    # No need in export those files to dl_dir, so we can run it right after
+    # No need to export those files to dl_dir, so we can run it right after
     rootfs_cmd --bind "${ROOTFSDIR}/var/cache/apt/archives" /var/cache/apt/archives \
-               --bind "${WORKDIR}/dpkg/lock" /var/lib/dpkg/lock \
-               --bind "${WORKDIR}/dpkg/lock-frontend" /var/lib/dpkg/lock-frontend \
                --chdir "/var/cache/apt/archives" \
                ${ROOTFSDIR} \
-               -- /usr/bin/sh -c "apt-get ${ROOTFS_APT_ARGS} --print-uris ${ROOTFS_PACKAGES} | \
-                                  sed -n \"s|^.*/\\(.*\\)_[^_]*_[^_]*\\.deb'.*|\\1|p\" | \
-                                  xargs -r apt-get download"
+               -- /usr/bin/sh -c 'apt-get ${ROOTFS_APT_ARGS} --print-uris ${ROOTFS_PACKAGES} | \
+                                  sed -n "s|^.file:\(/[^'\'']*/\)[^'\'']*\.deb. \([^ ]*\.deb\) .*|\1\2|p" | \
+                                  while read -r path; do cp -n "$path" ./ ; done'
 }
 
 ROOTFS_INSTALL_COMMAND += "${@ 'rootfs_install_clean_files' if (d.getVar('ROOTFS_CLEAN_FILES') or '').strip() else ''}"