From 6faf57c73c9bf035744080805048121b6a49aa5f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 6 Aug 2018 15:36:20 -0400 Subject: chcleanup: Try preloading the scratch DB to speed things up. --- src/chroot-tools/chcleanup.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in index 89339a6..e311d4b 100644 --- a/src/chroot-tools/chcleanup.in +++ b/src/chroot-tools/chcleanup.in @@ -86,6 +86,19 @@ cp -a -t "${TEMPDIR}/db" -- /var/lib/pacman/sync done done pacman=(pacman --dbpath="$TEMPDIR/db" --hookdir="$TEMPDIR/hooks") + +# Do our best to preload the scratch DB with CHROOTPKG and +# CHROOTEXTRAPKG packages. This is purely an optimization step. The +# safety of this optimization assumes that none of CHROOTPKG, +# CHROOTEXTRAPKG, *or their dependancies* are virtual packages. We +# don't include DEPENDS in this optimization, because this assumption +# doesn't hold for them. +while read -r pkg; do + if [[ -d /var/lib/pacman/local/$pkg ]]; then + cp -a -T -- "/var/lib/pacman/local/$pkg" "$TEMPDIR/db/local/$pkg" + fi +done < <("${pacman[@]}" -Sp --print-format='%n-%v' -- "${CHROOTPKG[@]}" "${CHROOTEXTRAPKG[@]}") + # Get the full list of packages needed by dependencies, including the base system msg2 "Creating a full list of packages..." for var in CHROOTPKG CHROOTEXTRAPKG DEPENDS; do -- cgit v1.2.2