summaryrefslogtreecommitdiff
path: root/src/treepkg
diff options
context:
space:
mode:
Diffstat (limited to 'src/treepkg')
-rwxr-xr-xsrc/treepkg40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/treepkg b/src/treepkg
index a1b4e38..73ef93b 100755
--- a/src/treepkg
+++ b/src/treepkg
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#set -x
-# (c) 2012 Nicolás Reynolds <fauno@parabola.nu>
+# Copyright (C) 2012 Nicolás Reynolds <fauno@parabola.nu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,15 +19,15 @@ source libremessages
source $(librelib conf.sh)
load_files libretools
-check_vars libretools HOOKPREBUILD FULLBUILDCMD HOOKLOCALRELEASE
+check_vars libretools HOOKPREBUILD FULLBUILDCMD HOOKLOCALRELEASE || exit 1
load_files makepkg
-term_title "$(basename $0)"
+term_title "${0##*/}"
# End inmediately but print an useful message
trap_exit() {
- term_title "error!"
- error "($(basename $0)) $@ (leftovers on ${BUILDDIR})"
+ term_title "${0##*/}: $(_ 'Error!')"
+ error "%s: %s (leftovers on %s" "${0##*/}" "$*" "${BUILDDIR}"
exit 1
}
@@ -59,10 +59,10 @@ bury() {
# 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
- if [ ${current_depth} -ge $2 ]; then return; fi
+ if [[ -z "${current_depth}" ]]; then return; fi
+ if [[ -z "${current_name}" ]]; then return; fi
+ if [[ ${current_depth} -eq 0 ]]; then return; fi
+ if [[ ${current_depth} -ge $2 ]]; then return; fi
${VERBOSE} && msg "Burying ${1} from ${current_depth} to ${2}"
@@ -78,8 +78,8 @@ guess_repo() {
basename "$(dirname "${1}")"
}
-if [ ! -f PKGBUILD ]; then
- error "Missing PKGBUILD ($PWD)"
+if [[ ! -f PKGBUILD ]]; then
+ error "Missing PKGBUILD (%s)" "$PWD"
exit 1
fi
@@ -97,13 +97,13 @@ unset build package >/dev/null 2>&1
for _pkg in "${pkgname[@]}"; do
unset package_${_pkg} >/dev/null 2>&1 || true
done
-##
+##
# Get useful values
pkgbase="${pkgbase:-${pkgname[0]}}"
# Get or set the work dir
-BUILDDIR="${1:-$(mktemp -d /tmp/${pkgbase}-treepkg-XXXx)}"
+BUILDDIR="${1:-$(mktemp --tmpdir -d ${pkgbase}-treepkg.XXXXXXXXXX)}"
BUILDORDER="${BUILDDIR}/BUILDORDER"
DEPTH=${2:-0}
NEXTDEPTH=$((${DEPTH} + 1))
@@ -182,21 +182,21 @@ if ! ${BUILDNOW}; then
fi
# Only build at the end
-if [ ${DEPTH} -eq 0 ]; then
+if [[ ${DEPTH} -eq 0 ]]; then
${VERBOSE} && msg "Starting build" || true
if ${BUILD}; then
- ${VERBOSE} && msg "Build tree stored in ${BUILDORDER}" || true
+ ${VERBOSE} && msg "Build tree stored in %s" "${BUILDORDER}" || true
# Build everything sorting the build dir
# The reverse order ensures we start by the deepest packages
for _pkg in $(ls -r "${BUILDDIR}"); do
# Ignore if there's no PKGBUILD
- if [ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]; then continue; fi
+ if [[ ! -f "${BUILDDIR}/${_pkg}/PKGBUILD" ]]; then continue; fi
# Skip if already built (faster than calling is_build again)
- if [ -f "${BUILDDIR}/${_pkg}/built_ok" ]; then continue; fi
+ if [[ -f "${BUILDDIR}/${_pkg}/built_ok" ]]; then continue; fi
- ${VERBOSE} && msg "Building ${_pkg/_/ }" || true
+ ${VERBOSE} && msg "Building %s" "${_pkg/_/ }" || true
# Remove leading zeros and space if any
term_title "$(echo ${_pkg/_/ } | sed "s/^0\+ \?//")"
@@ -221,11 +221,11 @@ if [ ${DEPTH} -eq 0 ]; then
fi
if (( CLEANUP )) ; then
- msg2 "Removing ${BUILDDIR}"
+ msg2 "Removing %s" "${BUILDDIR}"
rm -rf "${BUILDDIR}"
fi
fi
-term_title "done"
+term_title "$(_ Done)"
exit $?