diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chroot-tools/chcleanup.in | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in index 317bf10..d114080 100644 --- a/src/chroot-tools/chcleanup.in +++ b/src/chroot-tools/chcleanup.in @@ -59,8 +59,9 @@ if [[ -f ./PKGBUILD ]]; then sudo -u "#$(stat -c %u -- ./PKGBUILD)" sh -c 'makepkg --printsrcinfo > .SRCINFO' fi CARCH="$(. /etc/makepkg.conf; printf '%s' "$CARCH")" - mapfile -t all_depends < <(sed -nE "s/^\\s+(|make|check)depends(|_${CARCH}) = //p" < .SRCINFO) - CHROOTEXTRAPKG+=("${all_depends[@]}") + mapfile -t DEPENDS < <(sed -nE "s/^\\s+(|make|check)depends(|_${CARCH}) = //p" < .SRCINFO) +else + DEPENDS=() fi msg "Cleaning chroot..." @@ -77,13 +78,14 @@ pkglist="${TEMPDIR}"/pkglist.txt # Get the full list of packages needed by dependencies, including the base system msg2 "Creating a full list of packages..." -pacman -b "${TEMPDIR}" \ - -Sp --print-format "%n" base-devel "${CHROOTEXTRAPKG[@]}" >"$pkglist" || { - ret=$? - error "Could not create a full list of packages, exiting." - plain "This is likely caused by a dependency that could not be found." - exit $ret -} +pacman --dbpath="$TEMPDIR" --hookdir=/var/empty -Sq --needed --dbonly --noconfirm -- base-devel >/dev/null +if (( ${#CHROOTEXTRAPKG[@]} > 0 )); then + pacman --dbpath="$TEMPDIR" --hookdir=/var/empty -Sq --needed --dbonly --noconfirm -- "${CHROOTEXTRAPKG[@]}" >/dev/null +fi +if (( ${#DEPENDS[@]} > 0 )); then + pacman --dbpath="$TEMPDIR" --hookdir=/var/empty -Sq --needed --dbonly --noconfirm -- "${DEPENDS[@]}" >/dev/null +fi +pacman --dbpath="$TEMPDIR" -Qq >"$pkglist" # Diff installed packages against a clean chroot then remove leftovers packages=($(comm -23 <(pacman -Qq | sort -u) \ |