diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/chroot-tools/chcleanup | 72 | ||||
-rwxr-xr-x | src/chroot-tools/librechroot | 11 | ||||
-rwxr-xr-x | src/chroot-tools/libremakepkg.gpl2 | 2 |
3 files changed, 48 insertions, 37 deletions
diff --git a/src/chroot-tools/chcleanup b/src/chroot-tools/chcleanup index 17c1f02..821c572 100755 --- a/src/chroot-tools/chcleanup +++ b/src/chroot-tools/chcleanup @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -eE # (c) Nicolás Reynolds <fauno@parabola.nu> # Released under GPLv3 # @@ -7,51 +7,51 @@ # # See: HOOKPREBUILD -set -e DRYRUN=${DRYRUN:-false} +source "$(which libremessages)" -source /etc/makepkg.conf -source /etc/libretools.conf -source ${HOME}/.makepkg.conf 2>/dev/null|| true - -msg "Cleaning chroot..." - -TMPDIR="$(mktemp -d /tmp/$(basename $0)-XXXXX)" -cleanup_log="${TMPDIR}"/libretools-cleanup.log - -cp -a /var/lib/pacman/sync "${TMPDIR}/" -touch ${cleanup_log} +if [[ ! -f /.arch-chroot ]] && ! ${DRYRUN}; then + error "(chcleanup): Must be run inside of a chroot" + exit 1 +fi +source /etc/libretools.d/chroot.conf # If we're running makepkg if [ -f PKGBUILD ]; then - source PKGBUILD || true + source PKGBUILD + CHROOTEXTRAPKG+=("${depends[@]}" + "${makedepends[@]}" + "${checkdepends[@]}") +fi - check=(${depends[@]} ${makedepends[@]} ${checkdepends[@]}) +msg "Cleaning chroot..." -fi +TEMPDIR="$(mktemp --tmpdir -d $(basename $0).XXXXX)" +cp -a /var/lib/pacman/sync "${TEMPDIR}/" +cleanup_log="${TEMPDIR}"/libretools-cleanup.log # 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} +pacman -b "${TEMPDIR}" \ + -Sp --print-format "%n" \ + base base-devel sudo "${CHROOTEXTRAPKG[@]}" \ + >"${cleanup_log}" # Diff installed packages against a clean chroot then remove leftovers -packages=($(comm -23 <(pacman -Qq | sort) \ - <(sort -u ${cleanup_log}))) - -[ ${#packages[@]} -eq 0 ] && exit 0 - -msg2 "Removing %d packages" ${#packages[@]} - -# Only remove leftovers, -Rcs removes too much -${DRYRUN} || sudo pacman --noconfirm -Rn ${packages[@]} -${DRYRUN} && echo ${packages[@]} - +packages=($(comm -23 <(pacman -Qq | sort -u) \ + <(sort -u "${cleanup_log}"))) + +RET=0 +if [[ ${#packages[@]} != 0 ]]; then + msg2 "Removing %d packages" ${#packages[@]} + + if ${DRYRUN}; then + echo "${packages[@]}" + else + # Only remove leftovers, -Rcs removes too much + pacman --noconfirm -Rn "${packages[@]}" || RET=$? + fi +fi # Cleanup -${DRYRUN} || rm -fr ${TMPDIR} +rm -rf "${TEMPDIR}" -exit $? +exit $RET diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 0a7ba65..52a3bdf 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -116,6 +116,17 @@ main() { sync fi + mkdir -p $copydir/etc/libretools.d + { + if [[ -n ${CHROOTEXTRAPKG[@]:-} ]]; then + printf 'CHROOTEXTRAPKG=(' + printf "'%s' " "${CHROOTEXTRAPKG[@]}" + printf ')\n' + else + printf 'CHROOTEXTRAPKG=()\n' + fi + } > $copydir/etc/libretools.d/chroot.conf + ######################################################################## trap cleanup EXIT diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index 9c600ed..3f66589 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -98,7 +98,7 @@ cd /build ${cmd} EOF chmod 755 "$copydir/chrootexec" - archroot $flags "$copydir" -r /chrootexec + librechroot $flags -n "$CHROOT" -l "$CHROOTCOPY" -r /chrootexec fi } |