Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/contrib/bacman.sh.in
diff options
context:
space:
mode:
authorGordian Edenhofer <gordian.edenhofer@gmail.com>2016-09-04 18:14:01 +0200
committerAllan McRae <allan@archlinux.org>2016-09-25 17:41:10 +1000
commitc7da5a6ef2e7b4a410b7175b04d68499e26c2160 (patch)
tree67fa040172bdb7f189fc80563f4cfc851217f152 /contrib/bacman.sh.in
parent3a00bc31f293e3bbba0b1047e23682914215d217 (diff)
bacman: code structuring
Adding and clarifying comments. Adding and removing some new lines. Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'contrib/bacman.sh.in')
-rw-r--r--contrib/bacman.sh.in25
1 files changed, 8 insertions, 17 deletions
diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 5569530f..aad11f99 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -44,9 +44,7 @@ clean_up() {
# Trap termination signals
trap clean_up SIGHUP SIGINT SIGTERM
-#
-# User Friendliness
-#
+# Print usage information
usage() {
printf "%s (pacman) %s\n" "$myname" "$myver"
echo
@@ -66,6 +64,7 @@ usage() {
echo
}
+# Print version information
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
@@ -114,9 +113,7 @@ if [[ ${#pkg_list[@]} == 0 ]]; then
exit 1
fi
-#
-# Fakeroot support
-#
+# Run with fake root privileges if EUID is not root
if (( EUID )); then
if [[ -f /usr/bin/fakeroot ]]; then
msg "Entering fakeroot environment"
@@ -129,33 +126,25 @@ if (( EUID )); then
fi
fi
-#
-# Setting environmental variables
-#
+# Source environmental variables and specify fallbacks
if [[ ! -r @sysconfdir@/pacman.conf ]]; then
error "unable to read @sysconfdir@/pacman.conf"
exit 1
fi
-
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
-
if [[ ! -r @sysconfdir@/makepkg.conf ]]; then
error "unable to read @sysconfdir@/makepkg.conf"
exit 1
fi
-
source "@sysconfdir@/makepkg.conf"
if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf
fi
-
pkg_dest="${PKGDEST:-$PWD}"
pkg_pkger=${PACKAGER:-'Unknown Packager'}
-#
-# Checks everything is in place
-#
+# Check for an existing database
if [[ ! -d $pac_db ]]; then
error "pacman database directory ${pac_db} not found"
exit 1
@@ -187,6 +176,7 @@ fakebuild() {
# Assemble list of files which belong to the package and tar them
msg2 "Copying package files..."
+
while read i; do
if [[ -z $i ]]; then
continue
@@ -353,6 +343,7 @@ fakebuild() {
pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
ret=0
+ # Move compressed package to destination
# TODO: Maybe this can be set globally for robustness
shopt -s -o pipefail
bsdtar -cf - $comp_files * |
@@ -366,7 +357,7 @@ fakebuild() {
"$PKGEXT"; cat ;;
esac > "${pkg_file}"; ret=$?
- # Move compressed package to destination
+ # Evaluate return code
if (( ret )); then
error "Unable to write package to $pkg_dest"
plain " Maybe the disk is full or you do not have write access"