commitpkg: introduce abort function for errors

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
Evangelos Foutras 2009-09-23 12:06:25 -07:00 committed by Aaron Griffin
parent fa47bd1a17
commit 381f91c336
1 changed files with 13 additions and 29 deletions

View File

@ -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 <reponame> [-l limit] [commit message]"
exit 1
abort "usage: commitpkg <reponame> [-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