summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchcleanup37
-rw-r--r--libretools.conf2
2 files changed, 19 insertions, 20 deletions
diff --git a/chcleanup b/chcleanup
index b5f631c..e732b8c 100755
--- a/chcleanup
+++ b/chcleanup
@@ -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 $?
diff --git a/libretools.conf b/libretools.conf
index 88ba515..8032397 100644
--- a/libretools.conf
+++ b/libretools.conf
@@ -19,6 +19,8 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any')
## The directory where the chroots are stored
CHROOTDIR=/home/chroot
+# Extra packages to have installed on the chroot (besides base base-devel and sudo)
+CHROOTEXTRAPKG=(distcc ccache tsocks tokyocabinet)
## The working chroot
## A chroot is useful to build packages isolated from the current system and avoid