summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchcleanup54
-rw-r--r--libretools.conf17
-rwxr-xr-xmips64el/mipsrelease5
-rwxr-xr-xtreepkg4
-rwxr-xr-xupdate-cleansystem23
5 files changed, 81 insertions, 22 deletions
diff --git a/chcleanup b/chcleanup
index 7074b84..b5f631c 100755
--- a/chcleanup
+++ b/chcleanup
@@ -1,11 +1,59 @@
#!/bin/bash
+# (c) Nicolás Reynolds <fauno@parabola.nu>
+# Released under GPLv3
+#
+# Performs chroot cleanup smartly, it only removes the unneeded packages or
+# leaves you with a cleansystem
+#
+# See: HOOKPREBUILD
+
+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
+touch ${cleanup_log}
+
+# If we're running makepkg
+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
+# 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
+packages=($(comm -23 <(pacman -Qq | sort) \
+ <(cat /etc/libretools.d/cleansystem ${cleanup_log} | sort -u)
+ ))
+
+[ ${#packages[@]} -eq 0 ] && exit 0
-packages=($(comm -23 <(pacman -Qq | sort) <(sort /etc/libretools.d/cleansystem)))
+msg2 "Removing %d packages" ${#packages[@]}
-echo "Removing: ${packages[@]}"
+# Only remove leftovers, -Rcs removes too much
+sudo pacman --noconfirm -Rn ${packages[@]}
-sudo pacman --noconfirm -Rcs ${packages[@]}
+# Cleanup
+rm -f ${cleanup_log}
exit $?
diff --git a/libretools.conf b/libretools.conf
index 514c37d..40f92dc 100644
--- a/libretools.conf
+++ b/libretools.conf
@@ -30,9 +30,6 @@ CACHEDIR=`grep "^#\?CacheDir" /etc/pacman.conf | cut -d'=' -f2`
## Parabola hostname (should be the same used on ssh_config
PARABOLAHOST=parabola
-## Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.)
-HOOKPRERELEASE="ssh -fN parabola"
-
## Server destination of libre packages
# Don't change unless you know what you're doing and you won't screw
# anything ;)
@@ -52,6 +49,20 @@ ABSLIBREGIT=http://projects.parabolagnulinux.org/abslibre.git
FULLBUILDCMD="sudo libremakepkg -cuN"
# Cross compiling fullkpg
# FULLBUILDCMD="sudo libremakepkg -cuN -d '/path/to/cross-compiling/chroot'"
+# Build from within the chroot (or host system)
+# FULLBUILDCMD="makepkg -sL --noconfirm"
+
+# Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.)
+HOOKPRERELEASE="ssh -fN parabola"
+
+# Run a command before running FULLBUILDCMD, usually to cleanup uneeded packages
+# Note! chcleanup *is not* chroot aware, if you run it as it is it will cleanup
+# your system
+# HOOKPREBUILD="chcleanup"
+
+# Locally release the package or any other action after running FULLBUILDCMD
+# succesfully
+# HOOKLOCALRELEASE=""
## Toru
# Section for toru's vars
diff --git a/mips64el/mipsrelease b/mips64el/mipsrelease
index f245c47..4d7a7de 100755
--- a/mips64el/mipsrelease
+++ b/mips64el/mipsrelease
@@ -43,7 +43,7 @@ fi
source PKGBUILD
fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})
pkgs=()
-makepkg --source -f
+makepkg --source -f --skippgpcheck
msg "Adding packages to [stage3]..."
for name in ${pkgname[@]}; do
@@ -53,7 +53,6 @@ done
repo-add ${PKGDEST}/stage3.db.tar.gz ${pkgs[@]}
-#sudo pacman -Sy
librestage ${repo}
@@ -63,6 +62,4 @@ pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null
tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT}
popd >/dev/null
-$libretoolsdir/chcleanup || true
-
exit $?
diff --git a/treepkg b/treepkg
index 8a243e4..a22df71 100755
--- a/treepkg
+++ b/treepkg
@@ -195,7 +195,7 @@ if [ ${DEPTH} -eq 0 ]; then
# Ignore if there's no PKGBUILD
if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi
# Skip if already built (faster than calling is_build again)
- if [ -f built_ok ]; then continue; fi
+ if [ -f "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi
${VERBOSE} && msg "Building ${_pkg/_/ }" || true
@@ -203,6 +203,8 @@ if [ ${DEPTH} -eq 0 ]; then
pushd "${BUILDDIR}/${_pkg}" >/dev/null
sudo pacman -Syu --noconfirm
+ ${HOOKPREBUILD}
+
${FULLBUILDCMD}
# Run local release hook with $1 = $repo
${HOOKLOCALRELEASE} $(egrep ";${_pkg#*_};" "${BUILDORDER}" | cut -d';' -f6)
diff --git a/update-cleansystem b/update-cleansystem
index 4ea6a24..7c652ab 100755
--- a/update-cleansystem
+++ b/update-cleansystem
@@ -22,6 +22,9 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+set -e
+
+# libretools.conf gives us libremessages
source /etc/libretools.conf
cleansystem=/etc/libretools.d/cleansystem
@@ -47,16 +50,14 @@ if [ ! -w "$cleansystem" ]; then
exit 1
fi
-tmpdir="`mktemp -d --tmpdir cleansystem.XXXXXXXXXX`"
-mkdir -p "${tmpdir}"/var/lib/pacman
+# Maintain a clean database in the system
+db_dir="${DB:-/var/lib/libretools/clean}"
+[ ! -d "${db_dir}" ] && mkdir -p "${db_dir}"
# We sync first because updating info gets printed to stdout too
-pacman -r "${tmpdir}" --config /etc/pacman.conf -Sy 2>/dev/null
-pacman -r "${tmpdir}" --config /etc/pacman.conf \
- -Sp --print-format "%n" \
- base base-devel sudo "$@" | sort > "$cleansystem"
-exitcode=$?
-
-rm -rf "$tmpdir"
-
-exit $exitcode
+pacman -b "${db_dir}" --config /etc/pacman.conf -Sy 2>/dev/null
+pacman -b "${db_dir}" \
+ --config /etc/pacman.conf \
+ -Sp --print-format "%n" \
+ base base-devel sudo "$@" | sort > "$cleansystem"
+pacman -Sy --needed --noconfirm base base-devel sudo "$@"