From d85c71865ee826041c85cd47189ea43b44ce52cc Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 8 Apr 2012 13:13:07 -0400 Subject: makepkg: adopt parseopts for option parsing Signed-off-by: Dave Reisner --- scripts/makepkg.sh.in | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'scripts/makepkg.sh.in') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 46191ee4..663fdc68 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1885,7 +1885,7 @@ canonicalize_path() { fi } -m4_include(library/parse_options.sh) +m4_include(library/parseopts.sh) usage() { printf "makepkg (pacman) %s\n" "$myver" @@ -1954,19 +1954,20 @@ ARGLIST=("$@") # Parse Command Line Options. OPT_SHORT="AcdefFghiLmop:rRsSV" -OPT_LONG="allsource,asroot,ignorearch,check,clean,nodeps" -OPT_LONG+=",noextract,force,forcever:,geninteg,help,holdver,skippgpcheck" -OPT_LONG+=",install,key:,log,nocolor,nobuild,nocheck,nosign,pkg:,rmdeps" -OPT_LONG+=",repackage,skipchecksums,skipinteg,skippgpcheck,sign,source,syncdeps" -OPT_LONG+=",version,config:" +OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean' 'nodeps' + 'noextract' 'force' 'forcever:' 'geninteg' 'help' 'holdver' 'skippgpcheck' + 'install' 'key:' 'log' 'nocolor' 'nobuild' 'nocheck' 'nosign' 'pkg:' 'rmdeps' + 'repackage' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'sign' 'source' 'syncdeps' + 'version' 'config:') # Pacman Options -OPT_LONG+=",noconfirm,noprogressbar" -if ! OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@")"; then +OPT_LONG+=('noconfirm' 'noprogressbar') + +if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then echo; usage; exit 1 # E_INVALID_OPTION; fi -eval set -- "$OPT_TEMP" -unset OPT_SHORT OPT_LONG OPT_TEMP +set -- "${OPTRET[@]}" +unset OPT_SHORT OPT_LONG OPTRET while true; do case "$1" in @@ -1997,7 +1998,7 @@ while true; do --nosign) SIGNPKG='n' ;; -o|--nobuild) NOBUILD=1 ;; -p) shift; BUILDFILE=$1 ;; - --pkg) shift; PKGLIST=($1) ;; + --pkg) shift; IFS=, read -ra PKGLIST <<<"$1" ;; -r|--rmdeps) RMDEPS=1 ;; -R|--repackage) REPKG=1 ;; --skipchecksums) SKIPCHECKSUMS=1 ;; @@ -2010,8 +2011,7 @@ while true; do -h|--help) usage; exit 0 ;; # E_OK -V|--version) version; exit 0 ;; # E_OK - --) OPT_IND=0; shift; break;; - *) usage; exit 1 ;; # E_INVALID_OPTION + --) OPT_IND=0; shift; break 2;; esac shift done -- cgit v1.2.3-70-g09d2 From 3f9cf8471f9c6faecba8e09deb97a8d042525307 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 8 Apr 2012 13:26:41 -0400 Subject: makepkg: allow specifying --pkg multiple times Make this option additive, so that the following two operations are equivalent: makepkg --pkg foo --pkg bar makepkg --pkg foo,bar --- doc/makepkg.8.txt | 2 +- scripts/makepkg.sh.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/makepkg.sh.in') diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt index f80d7f20..57af98f7 100644 --- a/doc/makepkg.8.txt +++ b/doc/makepkg.8.txt @@ -154,7 +154,7 @@ Options *\--pkg *:: Only build listed packages from a split package. Multiple packages should - be comma separated in the list. + be comma separated in the list. This option can be specified multiple times. *\--check*:: Run the check() function in the PKGBUILD, overriding the setting in diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 663fdc68..959c6b00 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1998,7 +1998,7 @@ while true; do --nosign) SIGNPKG='n' ;; -o|--nobuild) NOBUILD=1 ;; -p) shift; BUILDFILE=$1 ;; - --pkg) shift; IFS=, read -ra PKGLIST <<<"$1" ;; + --pkg) shift; IFS=, read -ra p <<<"$1"; PKGLIST+=("${p[@]}"); unset p ;; -r|--rmdeps) RMDEPS=1 ;; -R|--repackage) REPKG=1 ;; --skipchecksums) SKIPCHECKSUMS=1 ;; -- cgit v1.2.3-70-g09d2 From 62dbf7ec43f4420c20b78ec647594c3f63558a39 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 17 Apr 2012 00:27:37 -0400 Subject: scripts: avoid dumping usage on parser fail Avoid letting the error message from parseopts get lost in the usage output from pacman-key and makepkg (which is already verbose). --- scripts/makepkg.sh.in | 2 +- scripts/pacman-key.sh.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/makepkg.sh.in') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 959c6b00..8b3c80ce 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1964,7 +1964,7 @@ OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean' 'nodeps' OPT_LONG+=('noconfirm' 'noprogressbar') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then - echo; usage; exit 1 # E_INVALID_OPTION; + exit 1 # E_INVALID_OPTION; fi set -- "${OPTRET[@]}" unset OPT_SHORT OPT_LONG OPTRET diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in index 2ee05c51..75564930 100644 --- a/scripts/pacman-key.sh.in +++ b/scripts/pacman-key.sh.in @@ -466,7 +466,7 @@ OPT_LONG=('add' 'config:' 'delete' 'edit-key' 'export' 'finger' 'gpgdir:' 'lsign-key' 'populate' 'recv-keys' 'refresh-keys' 'updatedb' 'verify' 'version') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then - echo; usage; exit 1 # E_INVALID_OPTION; + exit 1 # E_INVALID_OPTION; fi set -- "${OPTRET[@]}" unset OPT_SHORT OPT_LONG OPTRET -- cgit v1.2.3-70-g09d2