summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2012-02-08 14:09:53 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2012-02-08 14:09:53 -0300
commit6fbba8f74c28d58731c9611839e31955708d4b65 (patch)
tree772ad515f09d60f2190af5c72f2b5a123172fef7
parentebc66c503aad4df99f8660f2e4557c23cdc24fd3 (diff)
Perform cleanups + "bury" packages if needed
-rwxr-xr-xtreepkg40
1 files changed, 37 insertions, 3 deletions
diff --git a/treepkg b/treepkg
index bd95253..b3e4fe0 100755
--- a/treepkg
+++ b/treepkg
@@ -7,9 +7,9 @@ source $XDG_CONFIG_HOME/libretools/libretools.conf >/dev/null 2>&1|| true
source /etc/makepkg.conf
source $HOME/makepkg.conf >/dev/null 2>&1|| true
-# End inmediately but print a useful message
+# End inmediately but print an useful message
trap_exit() {
- error "($(basename $0)) $@"
+ error "($(basename $0)) $@ (leftovers on ${BUILDDIR})"
exit 1
}
@@ -32,6 +32,8 @@ get_fullver() {
}
# Add line to build order cache in CSV format
+# *must* be run from the PKGBUILD path
+# status;depth;pkgbase;[epoch:]pkgver-pkgrel;path;repo
# $1 status
# $2 pkgname
add_order() {
@@ -39,6 +41,30 @@ add_order() {
${VERBOSE} && msg2 "%${DEPTH}s${2:-${pkgbase}} [${1}]" || true
}
+# Bury a package deeper in the tree
+# $1 pkgbase
+# $2 nextdepth
+bury() {
+# Bury only if we are going to build the dep
+# Get it's current depth and dir name
+ local current_depth=$(egrep "build;[0-9]\+;${1};" "${BUILDORDER}" | cut -d ';' -f 2)
+ local current_name="$(printf "%03d" ${current_depth})_${1}"
+
+# If there's a depth or the package is not the root of the build tree (which
+# can lead to funny chicken-and-egg problems), update the depth to the current
+# package next-depth and rename the dir too
+ if [ -z "${current_depth}" ]; then return; fi
+ if [ -z "${current_name}" ]; then return; fi
+ if [ ${current_depth} -eq 0 ]; then return; fi
+
+ ${VERBOSE} && msg "Burying ${1} from ${current_depth} to ${2}"
+
+ {
+ sed -i "s|^\(build;\)\([0-9]\+\)\(;${1};.*\)$|\1${2}\3|" "${BUILDORDER}" && \
+ mv "${BUILDDIR}/${current_name}" "${BUILDDIR}/$(printf "%03d" ${2})_${1}"
+ } || return 1
+}
+
# Finds a PKGBUILD on toru's path cache
# Look in all caches but pick the first one
# TODO move to a toru flag (-p?)
@@ -87,6 +113,7 @@ NEXTDEPTH=$((${DEPTH} + 1))
# TODO Turn into flags?
VERBOSE=${V:-true}
BUILD=${B:-true}
+CLEANUP=${C:-true}
# ensure it exists
touch "${BUILDORDER}"
@@ -120,7 +147,9 @@ for _dep in ${deps[@]}; do
# pkgbase - dep1
# \ dep2 - dep1
# dep1 should be depth + 1
- egrep -q ";${_dep};" "${BUILDORDER}" && continue
+# probably sed -i buildorder and increase dep's dep depth :D
+# remember to change dir name from xxx_pkgbase to xxx+1_pkgbase
+ egrep -q ";${_dep};" "${BUILDORDER}" && bury "${_dep}" ${NEXTDEPTH}
# Ask toru where's a PKGBUILD
depdir="$(where_is ${_dep})"
@@ -167,6 +196,11 @@ if [ ${DEPTH} -eq 0 ]; then
${VERBOSE} || echo "${BUILDORDER}" || true
fi
+if (( CLEANUP )); then
+ msg2 "Removing ${BUILDDIR}"
+ rm -rf "${BUILDDIR}"
+fi
+
fi
exit $?