[v2] dpkg-base: Fix and improve handling of multiple apt sources per package

Message ID 20240127075617.26804-1-ubely@ilbers.de
State Accepted, archived
Headers show
Series [v2] dpkg-base: Fix and improve handling of multiple apt sources per package | expand

Commit Message

Uladzimir Bely Jan. 27, 2024, 7:56 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Due to overeager quoting, multiple entries in SRC_APT would have led to
build errors, rather than mulitple invocations of the fetching and
unpacking steps.

While fixing that, also avoid pointless re-entries into the schroot by
simply pulling the loop into it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Uladzimir Bely <ubely@ilbers.de>
---

This goes on top of https://groups.google.com/g/isar-users/c/k8ZNw3OkWLw/m/1s_CPTlPAAAJ
[PATCH v7] dpkg: Restore support for replacing pre-installed packages in sbuild-chroot.

Tested in CI.

We need v2 since previous version conflicts with new changes of "parent" patch v7.

 meta/classes/dpkg-base.bbclass | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

Comments

Uladzimir Bely Jan. 29, 2024, 10:49 a.m. UTC | #1
On Sat, 2024-01-27 at 08:56 +0100, Uladzimir Bely wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Due to overeager quoting, multiple entries in SRC_APT would have led
> to
> build errors, rather than mulitple invocations of the fetching and
> unpacking steps.
> 
> While fixing that, also avoid pointless re-entries into the schroot
> by
> simply pulling the loop into it.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Reviewed-by: Uladzimir Bely <ubely@ilbers.de>
> ---
> 
Applied to next, thanks.

Patch

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 86466b57..a8263046 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -119,10 +119,15 @@  do_apt_fetch() {
 
     schroot -r -c ${session_id} -d / -u root -- \
         rm /etc/apt/sources.list.d/isar-apt.list /etc/apt/preferences.d/isar-apt
-    for uri in "${SRC_APT}"; do
-        schroot -r -c ${session_id} -d / -- \
-            sh -c 'mkdir -p /downloads/deb-src/"$1"/"$2" && cd /downloads/deb-src/"$1"/"$2" && apt-get -y --download-only --only-source source "$2"' my_script "${BASE_DISTRO}-${BASE_DISTRO_CODENAME}" "${uri}"
-    done
+    schroot -r -c ${session_id} -d / -- \
+        sh -c '
+            set -e
+            for uri in $2; do
+                mkdir -p /downloads/deb-src/"$1"/${uri}
+                cd /downloads/deb-src/"$1"/${uri}
+                apt-get -y --download-only --only-source source ${uri}
+            done' \
+                my_script "${BASE_DISTRO}-${BASE_DISTRO_CODENAME}" "${SRC_APT}"
 
     schroot -e -c ${session_id}
     schroot_delete_configs
@@ -145,16 +150,16 @@  do_apt_unpack() {
     trap 'exit 1' INT HUP QUIT TERM ALRM USR1
     trap 'schroot_cleanup' EXIT
 
-    for uri in "${SRC_APT}"; do
-        schroot -d / -c ${SBUILD_CHROOT} -- \
-            sh -c ' \
-                set -e
-                dscfile="$(apt-get -y -qq --print-uris --only-source source "${2}" | cut -d " " -f2 | grep -E "*.dsc")"
+    schroot -d / -c ${SBUILD_CHROOT} -- \
+        sh -c '
+            set -e
+            for uri in $2; do
+                dscfile="$(apt-get -y -qq --print-uris --only-source source $uri | cut -d " " -f2 | grep -E "*.dsc")"
                 cd ${PP}
-                cp /downloads/deb-src/"${1}"/"${2}"/* ${PP}
-                dpkg-source -x "${dscfile}" "${PPS}"' \
-                    my_script "${BASE_DISTRO}-${BASE_DISTRO_CODENAME}" "${uri}"
-    done
+                cp /downloads/deb-src/"${1}"/${uri}/* ${PP}
+                dpkg-source -x "${dscfile}" "${PPS}"
+            done' \
+                my_script "${BASE_DISTRO}-${BASE_DISTRO_CODENAME}" "${SRC_APT}"
     schroot_delete_configs
 }
 do_apt_unpack[network] = "${TASK_USE_SUDO}"