From eda9bd59c2d8919f90aa72cf6cffd545d7bd2295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 17 Oct 2012 22:39:27 -0300 Subject: Don't fail if depends are empty --- chcleanup | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/chcleanup b/chcleanup index 9a27d49..5fdbc58 100755 --- a/chcleanup +++ b/chcleanup @@ -25,14 +25,19 @@ touch ${cleanup_log} if [ -f PKGBUILD ]; then source PKGBUILD || true + check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) + + if [ ${#check[@]} -ne 0 ]; then + # Update the cleansystem database - sudo pacman -b "${BD:-/var/lib/libretools/clean}" -Sy + 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" \ - ${depends[@]} ${makedepends[@]} ${checkdepends[@]} \ - >${cleanup_log} + 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, @@ -43,7 +48,7 @@ packages=($(comm -23 <(pacman -Qq | sort) \ [ ${#packages[@]} -eq 0 ] && exit 0 -msg2 "Removing ${#packages[@]} packages: ${packages[@]}" +msg2 "Removing %d packages: %s" ${#packages[@]} "${packages[@]}" # Only remove leftovers, -Rcs removes too much sudo pacman --noconfirm -Rn ${packages[@]} -- cgit v1.2.2