Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-05-10 18:06:29 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-05-10 18:06:29 -0400
commit33730fc272bec6376a28d8f813e9e35ec4f84175 (patch)
tree0b85c3687a968fe83baa879952984f18f75f3061 /lib
parent534d2015b45e013b37e1edbb997bd4df27d7b8fd (diff)
parent905198295dcb4fffcd16edff3fd7052a4cfc5788 (diff)
Merge remote-tracking branch 'arch/master'
Conflicts: lib/common.sh makechrootpkg.in
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/common.sh b/lib/common.sh
index dff9b43..455e841 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -71,12 +71,12 @@ cleanup() {
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
rm -rf "$WORKDIR"
fi
- [[ -n ${1:-} ]] && exit $1
+ exit ${1:-0}
}
abort() {
- msg 'Aborting...'
- cleanup 0
+ error 'Aborting...'
+ cleanup 255
}
trap_abort() {
@@ -91,7 +91,7 @@ trap_exit() {
die() {
(( $# )) && error "$@"
- cleanup 1
+ cleanup 255
}
##
@@ -117,7 +117,7 @@ get_full_version() {
pkgbase=${pkgbase:-${pkgname[0]}}
epoch=${epoch:-0}
if [[ -z $1 ]]; then
- if [[ $epoch ]] && (( ! $epoch )); then
+ if (( ! epoch )); then
echo $pkgver-$pkgrel
else
echo $epoch:$pkgver-$pkgrel
@@ -258,3 +258,16 @@ find_cached_package() {
return 1
esac
}
+
+##
+# usage : check_root ("$0" "$@")
+##
+check_root() {
+ (( EUID == 0 )) && return
+ if type -P sudo >/dev/null; then
+ exec sudo -- "$@"
+ else
+ exec su root -c "$(printf '%q' "$@")"
+ fi
+ die 'This script must be run as root.'
+}