diff options
Diffstat (limited to 'libremakepkg')
-rwxr-xr-x | libremakepkg | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/libremakepkg b/libremakepkg index babed47..e446833 100755 --- a/libremakepkg +++ b/libremakepkg @@ -51,6 +51,32 @@ function buildenv { done } +# Clean packages with pacman +function clean_chroot { + plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" + cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" + (cat <<EOF +#!/bin/bash +export LANG=C + +clean='false' + +while [ "\$clean" = 'false' ]; do + + pkgs=(\$(comm -23 <(pacman -Qq | sort) <(sort /root/cleansystem))) + + if [ \${#pkgs[@]} -gt 0 ]; then + pacman --noconfirm -Rcs \${pkgs[@]} + else + clean="true" + echo "clean" + fi +done +EOF + ) > "${CHROOTDIR}/${CHROOTNAME}/clean" + mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" +} + # End inmediately but print a useful message trap_exit() { @@ -120,21 +146,7 @@ fi if [ "${CLEAN_FIRST}" = y ]; then msg "Cleaning" - plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/" - cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem" - (cat <<EOF -#!/bin/bash -export LANG=C - -pkgs=(\$(comm -23 <(pacman -Qq | sort) <(sort /root/cleansystem))) - -[ \${#pkgs[@]} -gt 0 ] && pacman --noconfirm -Rcs \${pkgs} || echo "done" - -EOF - ) > "${CHROOTDIR}/${CHROOTNAME}/clean" - echo -n "doing cleanup..." - mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}" - + clean_chroot fi msg "Creating the package" |