[pacman-dev] [PATCH v8 09/12] bacman: add otpion to alter the output directory

Gordian Edenhofer gordian.edenhofer at gmail.com
Sun Sep 4 16:14:04 UTC 2016


Signed-off-by: Gordian Edenhofer <gordian.edenhofer at gmail.com>
---
 contrib/bacman.sh.in | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 4e9e0a3..7e511d6 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -57,10 +57,12 @@ usage() {
 	printf -- "$(gettext "  -h, --help       Show this help message and exit")\n"
 	printf -- "$(gettext "  -q, --quiet      Silence most of the status reporting")\n"
 	printf -- "$(gettext "  -m, --nocolor    Disable colorized output messages")\n"
+	printf -- "$(gettext "  -o, --out <dir>  Write output to specified directory (instead of \$PKGDEST)")\n"
 	printf -- "$(gettext "  --pacnew         Package .pacnew files")\n"
 	echo
 	printf -- "$(gettext "Examples:  %s linux-headers")\n" "$myname"
-	printf -- "$(gettext "  %s --nocolor --pacnew gzip munge binutils")\n" "$myname"
+	printf -- "$(gettext "  %s gzip munge binutils -o ~/Downloads")\n" "$myname"
+	printf -- "$(gettext "  %s --nocolor --pacnew -o /tmp gzip munge binutils")\n" "$myname"
 	printf -- "$(gettext "  %s \$(pacman -Qsq)")\n" "$myname"
 	echo
 }
@@ -81,8 +83,8 @@ for option in "$@"; do
 done
 
 # Parse arguments
-OPT_SHORT=':qmv'
-OPT_LONG=('quiet' 'nocolor' 'pacnew' 'version')
+OPT_SHORT=':o:qmv'
+OPT_LONG=('out:' 'quiet' 'nocolor' 'pacnew' 'version')
 if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
 	usage
 	exit 1
@@ -92,6 +94,10 @@ unset OPT_SHORT OPT_LONG OPTRET
 
 while :; do
 	case "$1" in
+		-o|--out)
+			pkg_dest=$2
+			[[ ! -d "$2" ]] && echo -e "The directory \e[39;1m$2\e[0m does not exist!" && exit 3
+			shift ;;
 		-q|--quiet)
 			QUIET=1 ;;
 		-m|--nocolor)
@@ -143,7 +149,8 @@ source "@sysconfdir@/makepkg.conf"
 if [[ -r ~/.makepkg.conf ]]; then
 	source ~/.makepkg.conf
 fi
-pkg_dest="${PKGDEST:-$PWD}"
+PKGDEST="${PKGDEST:-$PWD}"
+pkg_dest="${pkg_dest:-$PKGDEST}"
 pkg_pkger="${PACKAGER:-'Unknown Packager'}"
 
 # Check for an existing database
-- 
2.9.3


More information about the pacman-dev mailing list