1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-02-28 09:21:53 -05:00

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>
This commit is contained in:
Gordian Edenhofer 2016-09-04 18:14:01 +02:00 committed by Allan McRae
parent 3a00bc31f2
commit c7da5a6ef2

View File

@ -44,9 +44,7 @@ clean_up() {
# Trap termination signals # Trap termination signals
trap clean_up SIGHUP SIGINT SIGTERM trap clean_up SIGHUP SIGINT SIGTERM
# # Print usage information
# User Friendliness
#
usage() { usage() {
printf "%s (pacman) %s\n" "$myname" "$myver" printf "%s (pacman) %s\n" "$myname" "$myver"
echo echo
@ -66,6 +64,7 @@ usage() {
echo echo
} }
# Print version information
version() { version() {
printf "%s %s\n" "$myname" "$myver" printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>' echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
@ -114,9 +113,7 @@ if [[ ${#pkg_list[@]} == 0 ]]; then
exit 1 exit 1
fi fi
# # Run with fake root privileges if EUID is not root
# Fakeroot support
#
if (( EUID )); then if (( EUID )); then
if [[ -f /usr/bin/fakeroot ]]; then if [[ -f /usr/bin/fakeroot ]]; then
msg "Entering fakeroot environment" msg "Entering fakeroot environment"
@ -129,33 +126,25 @@ if (( EUID )); then
fi fi
fi fi
# # Source environmental variables and specify fallbacks
# Setting environmental variables
#
if [[ ! -r @sysconfdir@/pacman.conf ]]; then if [[ ! -r @sysconfdir@/pacman.conf ]]; then
error "unable to read @sysconfdir@/pacman.conf" error "unable to read @sysconfdir@/pacman.conf"
exit 1 exit 1
fi fi
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local" pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
if [[ ! -r @sysconfdir@/makepkg.conf ]]; then if [[ ! -r @sysconfdir@/makepkg.conf ]]; then
error "unable to read @sysconfdir@/makepkg.conf" error "unable to read @sysconfdir@/makepkg.conf"
exit 1 exit 1
fi fi
source "@sysconfdir@/makepkg.conf" source "@sysconfdir@/makepkg.conf"
if [[ -r ~/.makepkg.conf ]]; then if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf source ~/.makepkg.conf
fi fi
pkg_dest="${PKGDEST:-$PWD}" pkg_dest="${PKGDEST:-$PWD}"
pkg_pkger=${PACKAGER:-'Unknown Packager'} pkg_pkger=${PACKAGER:-'Unknown Packager'}
# # Check for an existing database
# Checks everything is in place
#
if [[ ! -d $pac_db ]]; then if [[ ! -d $pac_db ]]; then
error "pacman database directory ${pac_db} not found" error "pacman database directory ${pac_db} not found"
exit 1 exit 1
@ -187,6 +176,7 @@ fakebuild() {
# Assemble list of files which belong to the package and tar them # Assemble list of files which belong to the package and tar them
msg2 "Copying package files..." msg2 "Copying package files..."
while read i; do while read i; do
if [[ -z $i ]]; then if [[ -z $i ]]; then
continue continue
@ -353,6 +343,7 @@ fakebuild() {
pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}" pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
ret=0 ret=0
# Move compressed package to destination
# TODO: Maybe this can be set globally for robustness # TODO: Maybe this can be set globally for robustness
shopt -s -o pipefail shopt -s -o pipefail
bsdtar -cf - $comp_files * | bsdtar -cf - $comp_files * |
@ -366,7 +357,7 @@ fakebuild() {
"$PKGEXT"; cat ;; "$PKGEXT"; cat ;;
esac > "${pkg_file}"; ret=$? esac > "${pkg_file}"; ret=$?
# Move compressed package to destination # Evaluate return code
if (( ret )); then if (( ret )); then
error "Unable to write package to $pkg_dest" error "Unable to write package to $pkg_dest"
plain " Maybe the disk is full or you do not have write access" plain " Maybe the disk is full or you do not have write access"