summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfullpkg61
1 files changed, 34 insertions, 27 deletions
diff --git a/fullpkg b/fullpkg
index 41bc5c5..692ddb0 100755
--- a/fullpkg
+++ b/fullpkg
@@ -26,6 +26,8 @@ function usage {
}
force_build='n'
+failed=()
+missing=()
while getopts 'hfn:r' arg; do
case $arg in
@@ -45,14 +47,8 @@ done
tmp_dir=$(mktemp -d /tmp/$(basename $PWD).XXXXXX)
queue_file=$(mktemp /tmp/queue.XXXXXX)
-ban_file=$(mktemp)
-if [[ ! -w $queue_file ]]; then
- error "can't write queue file"
- exit 1
-elif [[ ! -w $ban_file ]] ; then
- error "can't write ban file"
- exit 1
-fi
+ban_file=$(mktemp /tmp/ban.XXXXXX)
+repo=${repo:-$(guess_repo)}
## START FUNCTIONS ##
@@ -124,7 +120,6 @@ is_banned() {
grep -w $1 $ban_file >/dev/null 2>&1
local rt=$?
- rm $ban_file
return $rt
}
@@ -138,32 +133,44 @@ quit() {
exit 1
}
-## END FUNCTIONS ##
+function cleanup {
+ rm $ban_file $queue_file
+ rm -rf $tmp_dir
+}
-repo=${repo:-$(guess_repo)}
+## END FUNCTIONS ##
source PKGBUILD
msg "Building ${repo:-missing repo}/${pkgbase:-${pkgname[@]}}: $pkgdesc"
-if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then
- msg2 "This package is built."
- if [ $force_build == 'n' ]; then
+# Pre build tests
+if [ $force_build == 'n' ]; then
+
+ # Be able to write files
+ if [[ ! -w $queue_file ]]; then
+ error "can't write queue file"
+ exit 1
+ elif [[ ! -w $ban_file ]] ; then
+ error "can't write ban file"
+ exit 1
+ fi
+
+ if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then
+ msg2 "This package is built."
exit 0
fi
- plain "Building anyway ..."
-fi
-trap "quit" TERM KILL INT
+ if is_banned ${pkgbase:-$pkgname}; then
+ error "This package is banned from building. Check the ban list"
+ exit 1
+ fi
+
+ check_queue || exit 1
-if is_banned ${pkgbase:-$pkgname}; then
- error "This package is banned from building. Check the ban list"
- exit 1
fi
-check_queue || exit 1
-
-failed=()
-missing=()
+# This will be executed at exit for any reason.
+trap "quit" EXIT INT QUIT TERM KILL HUP
if ! grep mips64el PKGBUILD >/dev/null; then
msg "Adding mips64el arch"
@@ -233,12 +240,12 @@ case $r in
mipsrelease *.pkg.tar.*
librestage $repo
librerelease
- sudo pacman -Sy ;;
+ sudo pacman -Sy
+ # cleanup is only on succesfull build so failed can be inspected
+ cleanup;;
1) error "There were errors while trying to build the package." ;;
2) error "The build failed." ;;
esac
-remove_queue
-
exit $r