bacman: add option to alter the output directory

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:04 +02:00 committed by Allan McRae
parent 130c0d5496
commit 5fcc054421
1 changed files with 10 additions and 3 deletions

View File

@ -57,10 +57,12 @@ usage() {
printf -- "$(gettext " -h, --help Show this help message and exit")\n" printf -- "$(gettext " -h, --help Show this help message and exit")\n"
printf -- "$(gettext " -q, --quiet Silence most of the status reporting")\n" printf -- "$(gettext " -q, --quiet Silence most of the status reporting")\n"
printf -- "$(gettext " -m, --nocolor Disable colorized output messages")\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" printf -- "$(gettext " --pacnew Package .pacnew files")\n"
echo echo
printf -- "$(gettext "Examples:")" printf -- "$(gettext "Examples:")"
printf -- " %s linux-headers\n" "$myname" printf -- " %s linux-headers\n" "$myname"
printf -- " %s -o ~/packages libarchive\n" "$myname"
printf -- " %s --nocolor --pacnew gzip make binutils\n" "$myname" printf -- " %s --nocolor --pacnew gzip make binutils\n" "$myname"
printf -- " %s \$(pacman -Qq)\n" "$myname" printf -- " %s \$(pacman -Qq)\n" "$myname"
echo echo
@ -80,8 +82,8 @@ for option in "$@"; do
done done
# Parse arguments # Parse arguments
OPT_SHORT='qmv' OPT_SHORT='o:qmv'
OPT_LONG=('quiet' 'nocolor' 'pacnew' 'version') OPT_LONG=('out:' 'quiet' 'nocolor' 'pacnew' 'version')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
usage usage
exit 1 exit 1
@ -91,6 +93,10 @@ unset OPT_SHORT OPT_LONG OPTRET
while :; do while :; do
case "$1" in 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) -q|--quiet)
QUIET=1 ;; QUIET=1 ;;
-m|--nocolor) -m|--nocolor)
@ -145,7 +151,8 @@ 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}" PKGDEST="${PKGDEST:-$PWD}"
pkg_dest="${pkg_dest:-$PKGDEST}"
pkg_pkger="${PACKAGER:-'Unknown Packager'}" pkg_pkger="${PACKAGER:-'Unknown Packager'}"
# Check for an existing database # Check for an existing database