From a120bc54458c38636aec3f414af02f449ecaa44f Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Tue, 11 Feb 2020 21:00:14 +0000 Subject: [PATCH] firmware: avoid potentially duplicate work addressing an old fixme, should distro and parent-distro be identical (in a derivative build) we want to avoid wasting effort downloading and processing the same content files twice. since parent and non-parent have separate archive-area lists though we should perhaps not just assume that they are identical or ignore any differences; thus here in such a situation we ensure that we handle any archive areas not already done for parent-distro handling in such a case, while skipping those already done. i notice that the fixme actually also refers to avoiding actual overlapping of the cached files, however the cached files are (currently) always ignored anyway, so this is of no concern. reusing the cached files is an entirely separate issue. Gbp-Dch: Short Closes: #952909 --- scripts/build/chroot_firmware | 20 ++++++++++++++++++-- scripts/build/installer_debian-installer | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/build/chroot_firmware b/scripts/build/chroot_firmware index 4a65d552a..7fdd7605d 100755 --- a/scripts/build/chroot_firmware +++ b/scripts/build/chroot_firmware @@ -79,9 +79,25 @@ Firmware_List_From_Contents "${LB_PARENT_MIRROR_CHROOT}" "${LB_PARENT_DISTRIBUTI if [ "${LB_DERIVATIVE}" = "true" ] then - # FIXME: account for the fact that PARENT_DISTRIBUTION and DISTRIBUTION might be the same (to not have overlapping cache files for contents). + # Avoid downloading things twice if distributions are identical + DERIVATIVE_ARCHIVE_AREAS="" + if [ "${LB_DISTRIBUTION_CHROOT}" != "${LB_PARENT_DISTRIBUTION_CHROOT}" ] + then + DERIVATIVE_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS}" + else + for _ARCHIVE_AREA in ${LB_ARCHIVE_AREAS} + do + if ! In_list ${_ARCHIVE_AREA} "${LB_PARENT_ARCHIVE_AREAS}" + then + DERIVATIVE_ARCHIVE_AREAS="${DERIVATIVE_ARCHIVE_AREAS} ${_ARCHIVE_AREA}" + fi + done + fi - Firmware_List_From_Contents "${LB_MIRROR_CHROOT}" "${LB_DISTRIBUTION_CHROOT}" "${LB_ARCHIVE_AREAS}" + if [ ! -z "${DERIVATIVE_ARCHIVE_AREAS}" ] + then + Firmware_List_From_Contents "${LB_MIRROR_CHROOT}" "${LB_DISTRIBUTION_CHROOT}" "${DERIVATIVE_ARCHIVE_AREAS}" + fi fi # Drop section and keep package names only diff --git a/scripts/build/installer_debian-installer b/scripts/build/installer_debian-installer index 67573f2e6..64375e85c 100755 --- a/scripts/build/installer_debian-installer +++ b/scripts/build/installer_debian-installer @@ -367,9 +367,25 @@ then if [ "${LB_DERIVATIVE}" = "true" ] then - # FIXME: account for the fact that PARENT_DISTRIBUTION and DISTRIBUTION might be the same (to not have overlapping cache files for contents). + # Avoid downloading things twice if distributions are identical + DERIVATIVE_ARCHIVE_AREAS="" + if [ "${LB_DISTRIBUTION_CHROOT}" != "${LB_PARENT_DISTRIBUTION_CHROOT}" ] + then + DERIVATIVE_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS}" + else + for _ARCHIVE_AREA in ${LB_ARCHIVE_AREAS} + do + if ! In_list ${_ARCHIVE_AREA} "${LB_PARENT_ARCHIVE_AREAS}" + then + DERIVATIVE_ARCHIVE_AREAS="${DERIVATIVE_ARCHIVE_AREAS} ${DERIVATIVE_ARCHIVE_AREAS}" + fi + done + fi - Firmware_List_From_Contents "${LB_MIRROR_CHROOT}" "${LB_DISTRIBUTION_CHROOT}" "${LB_ARCHIVE_AREAS}" + if [ ! -z "${DERIVATIVE_ARCHIVE_AREAS}" ] + then + Firmware_List_From_Contents "${LB_MIRROR_CHROOT}" "${LB_DISTRIBUTION_CHROOT}" "${DERIVATIVE_ARCHIVE_AREAS}" + fi fi # Drop section and keep package names only