diff options
author | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2012-11-05 16:02:07 -0300 |
---|---|---|
committer | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2012-11-05 16:02:07 -0300 |
commit | 362ec9e880e784ec9bc2858c635b0279e52af82d (patch) | |
tree | ae74b2854fec2d91af706d957287f96208c41ba2 /chcleanup | |
parent | d9efdb903fcd4d3242918910e7d6c00d2e17975d (diff) |
Be even smarter
Only use one pacman call by getting repo.db files from the local cache. Adds
a new libretools.conf array for getting extra packages (other than the base
system): CHROOTEXTRAPKGS.
Diffstat (limited to 'chcleanup')
-rwxr-xr-x | chcleanup | 37 |
1 files changed, 17 insertions, 20 deletions
@@ -9,16 +9,17 @@ set -e -[ ! -f /etc/libretools.d/cleansystem ] && exit 1 -[ ! -d "${DB:-/var/lib/libretools/clean}"/sync ] && exit 1 - source $(dirname $0)/libremessages source /etc/makepkg.conf source ${HOME}/.makepkg.conf 2>/dev/null|| true msg "Cleaning chroot..." -cleanup_log=/tmp/libretools-cleanup.log + +TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" +cleanup_log="${TMPDIR}"/libretools-cleanup.log + +cp -a /var/lib/pacman/sync "${TMPDIR}/" touch ${cleanup_log} # If we're running makepkg @@ -27,24 +28,20 @@ if [ -f PKGBUILD ]; then check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) - if [ ${#check[@]} -ne 0 ]; then - -# Update the cleansystem database - sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy -# Get the full list of packages needed by dependencies - sudo pacman -b "${BD:-/var/lib/libretools/clean}" \ - -Sp \ - --print-format "%n" \ - ${check[@]} \ - >${cleanup_log} - fi fi -# Diff installed packages against a clean chroot and needed packages, -# then remove leftovers +# Get the full list of packages needed by dependencies, including the base system +sudo pacman -b "${TMPDIR}" \ + -Sp \ + --print-format "%n" \ + base base-devel sudo \ + ${CHROOTEXTRAPKG[@]} \ + ${check[@]} \ + >${cleanup_log} + +# Diff installed packages against a clean chroot then remove leftovers packages=($(comm -23 <(pacman -Qq | sort) \ - <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u) - )) + <(sort -u ${cleanup_log}))) [ ${#packages[@]} -eq 0 ] && exit 0 @@ -54,6 +51,6 @@ msg2 "Removing %d packages" ${#packages[@]} sudo pacman --noconfirm -Rn ${packages[@]} # Cleanup -rm -f ${cleanup_log} +rm -fr ${TMPDIR} exit $? |