[pacman-dev] [PATCH v5 4/8] bacman: rewrite usage page and version information

Gordian Edenhofer gordian.edenhofer at gmail.com
Fri Sep 2 12:51:47 UTC 2016


Signed-off-by: Gordian Edenhofer <gordian.edenhofer at gmail.com>
---
Use the same format for the usage section as makepkg.

 contrib/bacman.sh.in | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 8656c5c..3868750 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -41,25 +41,33 @@ clean_up() {
 	echo
 	exit
 }
-
 # Trap termination signals
 trap clean_up SIGHUP SIGINT SIGTERM
 
 # Print usage information
 usage() {
-	echo "${myname} (pacman) v${myver}"
+	printf "%s (pacman) %s\n" "$myname" "$myver"
+	echo
+	printf -- "$(gettext "Recreate packages using pacman's database and system files")\n"
+	echo
+	printf -- "$(gettext "Usage: %s [options] <package(s)>")\n" "$0"
 	echo
-	echo "Recreate a package using pacman's database and system files"
+	printf -- "$(gettext "Options:")\n"
+	printf -- "$(gettext "  -h, --help       Show this help message and exit")\n"
+	printf -- "$(gettext "  -m, --nocolor    Disable colorized output messages")\n"
+	printf -- "$(gettext "  --pacnew         Package .pacnew files")\n"
 	echo
-	echo "Usage: ${myname} [--nocolor] [--pacnew] <installed package name>"
+	printf -- "$(gettext "Examples:  %s linux-headers")\n" "$myname"
+	printf -- "$(gettext "  %s --nocolor --pacnew gzip munge binutils")\n" "$myname"
+	printf -- "$(gettext "  %s \$(pacman -Qsq)")\n" "$myname"
 	echo
-	echo "Example: ${myname} linux-headers"
 }
 
 # Print version information
 version() {
 	printf "%s %s\n" "$myname" "$myver"
 	echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
+	echo 'Copyright (C) 2016 Gordian Edenhofer <gordian.edenhofer at gmail.com>'
 	echo 'Copyright (C) 2008-2016 Pacman Development Team <pacman-dev at archlinux.org>'
 }
 
@@ -123,7 +131,7 @@ if (( EUID )); then
 	fi
 fi
 
-# Source environmental variables and specify fallbacks
+# Read in environmental variables
 if [[ ! -r @sysconfdir@/pacman.conf ]]; then
 	error "unable to read @sysconfdir@/pacman.conf"
 	exit 1
@@ -139,7 +147,7 @@ if [[ -r ~/.makepkg.conf ]]; then
 	source ~/.makepkg.conf
 fi
 pkg_dest="${PKGDEST:-$PWD}"
-pkg_pkger=${PACKAGER:-'Unknown Packager'}
+pkg_pkger="${PACKAGER:-'Unknown Packager'}"
 
 # Check for an existing database
 if [[ ! -d $pac_db ]]; then
@@ -339,6 +347,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 * |
@@ -352,7 +361,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"
-- 
2.9.3


More information about the pacman-dev mailing list