summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernandez <hahj87@gmail.com>2011-05-19 02:29:20 -0500
committerJoshua Ismael Haase Hernandez <hahj87@gmail.com>2011-05-19 02:29:20 -0500
commitaf81fffea91ae472a9b0bbee7ed88317fbff468a (patch)
tree18b46feab0dfa64c62f1ade82df04b6419727fc5
parent2e4d78c7768119a75bba8ae5eab98c1a6026ea89 (diff)
Fullpkg cleanup and exec quit on exit
-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