summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2012-01-22 22:53:26 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2012-01-22 22:53:26 -0300
commit787ef61e1997deeda97e055f7f0fe27a1b7ab2b5 (patch)
tree6b8f9c376230e6e8077d5cb30f9abeefdcce0f7a
parent61b19919818a0b87aef5544ce2853f2ef2b76e58 (diff)
Create a work dir and build in order
-rwxr-xr-xtreepkg51
1 files changed, 44 insertions, 7 deletions
diff --git a/treepkg b/treepkg
index 4ad02fc..622b979 100755
--- a/treepkg
+++ b/treepkg
@@ -69,11 +69,15 @@ done
pkgbase="${pkgbase:-${pkgname[0]}}"
fullver=$(get_fullver ${epoch:-0} ${pkgver} ${pkgrel})
-# Get or set the build order cache (canonical)
-BUILDORDER="$(readlink -f "${1:-$(mktemp /tmp/${pkgbase}.buildorder.XXXX)}")"
+# Get or set the work dir
+BUILDDIR="${1:-$(mktemp -d /tmp/${pkgbase}-treepkg-XXXx)}"
+BUILDORDER="${BUILDDIR}/BUILDORDER"
DEPTH=${2:-0}
NEXTDEPTH=$((${DEPTH} + 1))
-VERBOSE=true
+# This can be set as env vars (ie: $ V=false B=false treepkg)
+# TODO Turn into flags?
+VERBOSE=${V:-true}
+BUILD=${B:-true}
# ensure it exists
touch "${BUILDORDER}"
@@ -90,6 +94,10 @@ egrep -q ";${pkgbase};" "${BUILDORDER}" && exit 0
# Add pkgbase to build order
add_order "build"
+# Copy the directory to the build dir
+# TODO run makepkg --source to avoid moving garbage around?
+cp -r "${PWD}" "${BUILDDIR}/$(printf "%03d" ${DEPTH})_${pkgbase}"
+
# Cleanup dep versioning
deps=($(echo "${depends[@]} ${makedepends[@]}" | \
sed "s/[=<>]\+[^ ]\+//g" | \
@@ -99,12 +107,18 @@ deps=($(echo "${depends[@]} ${makedepends[@]}" | \
# NOTE: getting depends from package() is a PITA
for _dep in ${deps[@]}; do
# Ignore if already in build order
+# TODO move deps deeper in the tree if
+# pkgbase - dep1
+# \ dep2 - dep1
+# dep1 should be depth + 1
egrep -q ";${_dep};" "${BUILDORDER}" && continue
+# Ask toru where's a PKGBUILD
depdir="$(where_is ${_dep})"
if [ -z "${depdir}" -o ! -d "${depdir}" ]; then
# We specify the pkgname because we can't source the dep PKGBUILD
+# Normally 'any' packages are missing from our work ABS
add_order "missing" "${_dep}"
continue
fi
@@ -112,14 +126,37 @@ for _dep in ${deps[@]}; do
pushd "${depdir}" >/dev/null
# Run itself over dependencies
- $0 "${BUILDORDER}" ${NEXTDEPTH}
+ $0 "${BUILDDIR}" ${NEXTDEPTH}
done
-# Only print build order at the end
+# Only build at the end
if [ ${DEPTH} -eq 0 ]; then
- ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true
- ${VERBOSE} || echo "${BUILDORDER}" || true
+
+# TODO fill this var with a flag
+ if ${BUILD}; then
+ ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true
+
+# Build everything sorting the build dir
+# The reverse order ensures we start by the deepest packages
+ ${VERBOSE} && msg "Starting build" || true
+ for _pkg in $(ls -r "${BUILDDIR}"); do
+# Ignore if there's no PKGBUILD
+ if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi
+
+ ${VERBOSE} && msg "Building ${_pkg/_/ }" || true
+
+# Run build command
+ pushd "${BUILDDIR}/${_pkg}" >/dev/null
+ ${FULLBUILDCMD}
+ popd >/dev/null
+ done
+
+ else
+# Just print the working dir
+ ${VERBOSE} || echo "${BUILDORDER}" || true
+ fi
+
fi
exit $?