diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2012-11-05 16:39:27 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2012-11-05 16:39:27 -0300 |
commit | 070d785ab1f5a72ed52680b18a5120bb2c46c847 (patch) | |
tree | 19336516d152fcac874fa97febee37daeb312575 /chcleanup | |
parent | 369245e8dbee7ad97acec087de77081627a255db (diff) | |
parent | 83dd1498e580510023b63611bb25feedd3699b8c (diff) |
Merge branch 'master' of git://ponape.local/libretools
Diffstat (limited to 'chcleanup')
-rwxr-xr-x | chcleanup | 41 |
1 files changed, 19 insertions, 22 deletions
@@ -9,16 +9,16 @@ 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 /etc/libretools.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,33 +27,30 @@ 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 msg2 "Removing %d packages" ${#packages[@]} # Only remove leftovers, -Rcs removes too much -sudo pacman --noconfirm -Rn ${packages[@]} +${DRYRUN} || sudo pacman --noconfirm -Rn ${packages[@]} +${DRYRUN} && echo ${packages[@]} # Cleanup -rm -f ${cleanup_log} +${DRYRUN} || rm -fr ${TMPDIR} exit $? |