summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchcleanup54
-rw-r--r--libretools.conf17
-rwxr-xr-xmips64el/mipsrelease5
-rwxr-xr-xtoru-path23
-rwxr-xr-xtoru-utils2
-rwxr-xr-xtoru-where10
-rwxr-xr-xtreepkg4
-rwxr-xr-xupdate-cleansystem24
8 files changed, 96 insertions, 43 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/toru-path b/toru-path
index 9bfc3ff..7f1d599 100755
--- a/toru-path
+++ b/toru-path
@@ -2,22 +2,30 @@
source $(dirname $(command -v $0))/toru-utils
+TORUPATH=${T:-${TORUPATH}}
+
if [ ! -w "$TORUPATH" ]; then
error "Toru's path isn't writable. Please check $TORUPATH"
exit 1
fi
LASTSYNCFILE=${TORUPATH}/lastsync.paths
+PATHFILE=${TORUPATH}/paths.tch
+
+if [ ! -e "${PATHFILE}" ]; then
+ tcamgr create "${PATHFILE}"
+fi
# TODO pass other paths via flags
-pkgbuilds=($(get_pkgbuilds ${ABSROOT}))
-paths=()
+# ABSROOT has trailing slash
+fullrepos=($(for _repo in ${REPOS[@]}; do echo "${ABSROOT}${_repo}"; done))
+pkgbuilds=($(get_pkgbuilds ${fullrepos[@]}))
msg "Updating path cache"
msg2 "${#pkgbuilds[@]} PKGBUILDs to update"
for _pkgbuild in ${pkgbuilds[@]}; do
- $DEBUG && plain "$_pkgbuild"
- source ${_pkgbuild} || {
+# plain "$_pkgbuild"
+ source ${_pkgbuild} >/dev/null 2>&1 || {
error "${_pkgbuild} contains errors, skipping"
continue
}
@@ -25,15 +33,10 @@ for _pkgbuild in ${pkgbuilds[@]}; do
fullpath=$(dirname ${_pkgbuild})
for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do
- paths+=(${_pkg/[<>=]*}:${fullpath})
+ tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath}
done
unset pkgbase pkgname provides
done
-
-# TODO remove old paths
-# by joining new paths to old paths and exclude the joining points from the
-# cache (sort of a sql join)
-echo ${paths[@]} | tr ' ' "\n" | sort >> ${TORUPATH}/paths
lastsync ${LASTSYNCFILE}
diff --git a/toru-utils b/toru-utils
index c0918ae..316e6b8 100755
--- a/toru-utils
+++ b/toru-utils
@@ -1,6 +1,4 @@
#!/bin/bash
-#!/bin/bash
-
source /etc/abs.conf
source /etc/libretools.conf
diff --git a/toru-where b/toru-where
index 02a7a88..e9ab29d 100755
--- a/toru-where
+++ b/toru-where
@@ -1,11 +1,7 @@
#!/bin/bash
# Locates a PKGBUILD dir on toru's path cache
+source /etc/libretools.conf
-source $(dirname $(command -v $0))/toru-utils
+PATHFILE=${TORUPATH}/paths.tch
-# Look in all cached but pick the last one
-grep "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \
- tail -n1 2>/dev/null|\
- cut -d: -f2 2>/dev/null
-
-exit $?
+tcamgr get ${PATHFILE} $1 2>/dev/null || echo ""
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..53d21d9 100755
--- a/update-cleansystem
+++ b/update-cleansystem
@@ -3,6 +3,7 @@
# Creates a fake Parabola root and writes to cleansystem all
# packages installable from base and base-devel plus extras.
+set -e
# Copyright 2012 Nicolás Reynolds, Luke Shumaker
# ---------- GNU General Public License 3 ----------
@@ -42,21 +43,18 @@ if [ "$1" == '-h' ]; then
exit 0
fi
-if [ ! -w "$cleansystem" ]; then
- error 'This script must be run as root'
- exit 1
-fi
+# Maintain a clean database in the system
+db_dir="${DB:-/var/lib/libretools/clean}"
-tmpdir="`mktemp -d --tmpdir cleansystem.XXXXXXXXXX`"
-mkdir -p "${tmpdir}"/var/lib/pacman
+[ ! -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=$?
+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 > /etc/libretools.d/cleansystem
-rm -rf "$tmpdir"
+pacman -Sy --needed --noconfirm base base-devel sudo $@
-exit $exitcode
+exit $?