From 93399d3e1775c50151b3a8024937e7a194e967a1 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Mon, 4 Nov 2024 19:58:28 +0100 Subject: [PATCH 1/2] get-sources: resolve source package names ourselves Avoids restarting apt for each package. --- .../config/scripts/GRMLBASE/03-get-sources | 55 +++++++------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources index 0a68a994..a359d750 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources +++ b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources @@ -15,54 +15,37 @@ fi set -u -PACKAGE_LIST=$(mktemp) +ERRORS_LOG=$(mktemp) SOURCES_PATH=/grml-live/grml_sources/ -SOURCES_ERRORS_LOG="${SOURCES_PATH}"errors.log bailout() { - rm -f "${target}${SOURCES_ERRORS_LOG}" - rm -f "$PACKAGE_LIST" + rm -f "$ERRORS_LOG" } +mkdir -p "${target}${SOURCES_PATH}" + $ROOTCMD apt-get update -$ROOTCMD dpkg-query -W -f='${Package}\n' > "${PACKAGE_LIST}" +# Collect *source* package names +$ROOTCMD dpkg-query -W -f='${Source} ${Package}\n' | sed -e 's/^ //' | awk '{ print $1 }' | sort -u | \ + chroot "${target}" /bin/bash -c "cd \"${SOURCES_PATH}\" && xargs apt-get --download-only source" 2> "${ERRORS_LOG}" -if ! [ -r "${PACKAGE_LIST}" ] ; then - echo "Can not read ${PACKAGE_LIST}, can not download source packages as requested." >&2 +if grep -q '^E:' "${ERRORS_LOG}" ; then + echo "Errors noticed while retrieving sources:" >&2 + cat "${ERRORS_LOG}" >&2 + bailout + exit 1 +elif grep -q '^W:' "${ERRORS_LOG}" ; then + echo "Warnings noticed while retrieving sources (not failing the build though):" + cat "${ERRORS_LOG}" +elif grep -q '.' "${ERRORS_LOG}" ; then + echo "Unclassified problems noticed while retrieving sources:" >&2 + cat "${ERRORS_LOG}" >&2 bailout exit 1 -else - mkdir -p "${target}${SOURCES_PATH}" - - # needs to be done for each package to get: - # | Picking 'acpi-support' as source package instead of 'acpi-fakekey' - # instead of: - # | E: Unable to find a source package for acpi-fakekey - for package in $(grep -v '^#' ${PACKAGE_LIST}) ; do - cat << EOT | chroot "$target" /bin/bash -cd "${SOURCES_PATH}" -apt-get --download-only source "$package" 2>>"${SOURCES_ERRORS_LOG}" -EOT - done - - if grep -q '^E:' "${target}${SOURCES_ERRORS_LOG}" ; then - echo "Errors noticed while retrieving sources:" >&2 - cat "${target}${SOURCES_ERRORS_LOG}" >&2 - bailout - exit 1 - elif grep -q '^W:' "${target}${SOURCES_ERRORS_LOG}" ; then - echo "Warnings noticed while retrieving sources (not failing the build though):" - cat "${target}${SOURCES_ERRORS_LOG}" - elif grep -q '.' "${target}${SOURCES_ERRORS_LOG}" ; then - echo "Unclassified problems noticed while retrieving sources:" >&2 - cat "${target}${SOURCES_ERRORS_LOG}" >&2 - bailout - exit 1 - fi - fi + bailout ## END OF FILE ################################################################# From 5db208d10b98a41f5edd99783ea39ec13c0291b3 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Tue, 5 Nov 2024 00:37:32 +0100 Subject: [PATCH 2/2] get-sources: run apt-get source parallelized Saves about 8min (~40%!) on a GRML_SMALL build. --- etc/grml/fai/config/scripts/GRMLBASE/03-get-sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources index a359d750..3a3023e9 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources +++ b/etc/grml/fai/config/scripts/GRMLBASE/03-get-sources @@ -28,7 +28,7 @@ $ROOTCMD apt-get update # Collect *source* package names $ROOTCMD dpkg-query -W -f='${Source} ${Package}\n' | sed -e 's/^ //' | awk '{ print $1 }' | sort -u | \ - chroot "${target}" /bin/bash -c "cd \"${SOURCES_PATH}\" && xargs apt-get --download-only source" 2> "${ERRORS_LOG}" + chroot "${target}" /bin/bash -c "cd \"${SOURCES_PATH}\" && xargs --max-args=32 --max-procs=12 apt-get --download-only source" 2> "${ERRORS_LOG}" if grep -q '^E:' "${ERRORS_LOG}" ; then echo "Errors noticed while retrieving sources:" >&2