From 381f91c33602e624bc6ac5ce7e7b65eecaf6088f Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Wed, 23 Sep 2009 12:06:25 -0700 Subject: commitpkg: introduce abort function for errors Signed-off-by: Aaron Griffin --- commitpkg | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/commitpkg b/commitpkg index 5a37ae3..ba98490 100755 --- a/commitpkg +++ b/commitpkg @@ -1,11 +1,15 @@ #!/bin/bash +abort() { + echo ${1:-"Cancelled"} + exit 1 +} + # Source makepkg.conf; fail if it is not found if [ -r "/etc/makepkg.conf" ]; then source "/etc/makepkg.conf" else - echo "/etc/makepkg.conf not found!" - exit 1 + abort "/etc/makepkg.conf not found!" fi # Source user-specific makepkg.conf overrides @@ -16,8 +20,7 @@ fi cmd=$(basename $0) if [ ! -f PKGBUILD ]; then - echo "No PKGBUILD file" - exit 1 + abort "No PKGBUILD file" fi source PKGBUILD @@ -39,8 +42,7 @@ elif [ "$cmd" == "community-testingpkg" ]; then server="aur.archlinux.org" else if [ $# -eq 0 ]; then - echo "usage: commitpkg [-l limit] [commit message]" - exit 1 + abort "usage: commitpkg [-l limit] [commit message]" fi repo="$1" shift @@ -70,46 +72,28 @@ for CARCH in ${arch[@]}; do uploadto="staging/${repo}/$(basename ${pkgfile})" # don't re-upload the same package (useful for -any sub packages) if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then - scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" + scp ${scpopts} "${pkgfile}" "${server}:${uploadto}" || abort fi if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh ${server} md5sum "${uploadto}" | cut -d' ' -f1)" ]; then - echo "File got corrupted during upload, cancelled." - exit 1 + abort "File got corrupted during upload, cancelled." else echo "File integrity okay." fi - - if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 - fi echo "===> Uploaded $pkgfile" done if [ "$1" != "" ]; then svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel - $1" > /dev/null - if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 - fi + $1" > /dev/null || abort echo "===> Commited with message: upgpkg: $pkgbase $pkgver-$pkgrel $1" else - svn commit - if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 - fi + svn commit || abort echo "===> Commited" fi - archrelease $repo-$CARCH - if [ $? -ne 0 ]; then - echo "Cancelled" - exit 1 - fi + archrelease $repo-$CARCH || abort echo "===> Tagged for $repo-$CARCH" done -- cgit v1.2.3-24-g4f1b