[pacman-dev] [PATCHv3 2/3] makepkg: Sort CLI options in usage() and in getopts

Pierre Neidhardt ambrevar at gmail.com
Tue Mar 4 03:28:03 EST 2014


On 14-03-04 13:52:29, Allan McRae wrote:
> On 04/03/14 05:29, Pierre Neidhardt wrote:
> > Before usage() and 'getopts' lines where not sorted consistently. Now the same
> > sorting is used: the output of 'sort' using en_US.utf8 locale. (Case and
> > punctuation characters are ignored.)
> > 
> > Signed-off-by: Pierre Neidhardt <ambrevar at gmail.com>
> > ---
> >  scripts/makepkg.sh.in | 59 +++++++++++++++++++++++++--------------------------
> >  1 file changed, 29 insertions(+), 30 deletions(-)
> > 
> > diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> > index 9d2b43f..aa02fa6 100644
> > --- a/scripts/makepkg.sh.in
> > +++ b/scripts/makepkg.sh.in
> > @@ -2516,45 +2516,45 @@ usage() {
> >  	echo
> >  	printf -- "$(gettext "Options:")\n"
> >  	printf -- "$(gettext "  -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
> > -	printf -- "$(gettext "  -c, --clean      Clean up work files after build")\n"
> > +	printf -- "$(gettext "  --allsource      Generate a source-only tarball including downloaded sources")\n"
> > +	printf -- "$(gettext "  --asroot         Allow %s to run as root user")\n" "makepkg"
> >  	printf -- "$(gettext "  -C, --cleanbuild Remove %s dir before building the package")\n" "\$srcdir/"
> > +	printf -- "$(gettext "  -c, --clean      Clean up work files after build")\n"
> > +	printf -- "$(gettext "  --check          Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
> > +	printf -- "$(gettext "  --config <file>  Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
> >  	printf -- "$(gettext "  -d, --nodeps     Skip all dependency checks")\n"
> >  	printf -- "$(gettext "  -e, --noextract  Do not extract source files (use existing %s dir)")\n" "\$srcdir/"
> >  	printf -- "$(gettext "  -f, --force      Overwrite existing package")\n"
> >  	printf -- "$(gettext "  -g, --geninteg   Generate integrity checks for source files")\n"
> >  	printf -- "$(gettext "  -h, --help       Show this help message and exit")\n"
> > +	printf -- "$(gettext "  --holdver        Do not update VCS sources")\n"
> >  	printf -- "$(gettext "  -i, --install    Install package after successful build")\n"
> > +	printf -- "$(gettext "  --key <key>      Specify a key to use for %s signing instead of the default")\n" "gpg"
> >  	printf -- "$(gettext "  -L, --log        Log package build process")\n"
> >  	printf -- "$(gettext "  -m, --nocolor    Disable colorized output messages")\n"
> > -	printf -- "$(gettext "  -o, --nobuild    Download and extract files only")\n"
> > -	printf -- "$(gettext "  -p <file>        Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
> > -	printf -- "$(gettext "  -r, --rmdeps     Remove installed dependencies after a successful build")\n"
> > -	printf -- "$(gettext "  -R, --repackage  Repackage contents of the package without rebuilding")\n"
> > -	printf -- "$(gettext "  -s, --syncdeps   Install missing dependencies with %s")\n" "pacman"
> > -	printf -- "$(gettext "  -S, --source     Generate a source-only tarball without downloaded sources")\n"
> > -	printf -- "$(gettext "  -V, --version    Show version information and exit")\n"
> > -	printf -- "$(gettext "  --allsource      Generate a source-only tarball including downloaded sources")\n"
> > -	printf -- "$(gettext "  --verifysource   Download source files (if needed) and perform integrity checks")\n"
> > -	printf -- "$(gettext "  --asroot         Allow %s to run as root user")\n" "makepkg"
> > -	printf -- "$(gettext "  --check          Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
> > -	printf -- "$(gettext "  --config <file>  Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
> > -	printf -- "$(gettext "  --holdver        Do not update VCS sources")\n"
> > -	printf -- "$(gettext "  --key <key>      Specify a key to use for %s signing instead of the default")\n" "gpg"
> >  	printf -- "$(gettext "  --noarchive      Do not create archive")\n"
> >  	printf -- "$(gettext "  --nocheck        Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
> >  	printf -- "$(gettext "  --noprepare      Do not run the %s function in the %s")\n" "prepare()" "$BUILDSCRIPT"
> >  	printf -- "$(gettext "  --nosign         Do not create a signature for the package")\n"
> > +	printf -- "$(gettext "  -o, --nobuild    Download and extract files only")\n"
> > +	printf -- "$(gettext "  -p <file>        Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
> >  	printf -- "$(gettext "  --pkg <list>     Only build listed packages from a split package")\n"
> > +	printf -- "$(gettext "  -R, --repackage  Repackage contents of the package without rebuilding")\n"
> > +	printf -- "$(gettext "  -r, --rmdeps     Remove installed dependencies after a successful build")\n"
> >  	printf -- "$(gettext "  --sign           Sign the resulting package with %s")\n" "gpg"
> >  	printf -- "$(gettext "  --skipchecksums  Do not verify checksums of the source files")\n"
> >  	printf -- "$(gettext "  --skipinteg      Do not perform any verification checks on source files")\n"
> >  	printf -- "$(gettext "  --skippgpcheck   Do not verify source files with PGP signatures")\n"
> > +	printf -- "$(gettext "  -S, --source     Generate a source-only tarball without downloaded sources")\n"
> > +	printf -- "$(gettext "  -s, --syncdeps   Install missing dependencies with %s")\n" "pacman"
> > +	printf -- "$(gettext "  --verifysource   Download source files (if needed) and perform integrity checks")\n"
> > +	printf -- "$(gettext "  -V, --version    Show version information and exit")\n"
> >  	echo
> >  	printf -- "$(gettext "These options can be passed to %s:")\n" "pacman"
> >  	echo
> >  	printf -- "$(gettext "  --asdeps         Install packages as non-explicitly installed")\n"
> > -	printf -- "$(gettext "  --noconfirm      Do not ask for confirmation when resolving dependencies")\n"
> >  	printf -- "$(gettext "  --needed         Do not reinstall the targets that are already up to date")\n"
> > +	printf -- "$(gettext "  --noconfirm      Do not ask for confirmation when resolving dependencies")\n"
> >  	printf -- "$(gettext "  --noprogressbar  Do not show a progress bar when downloading files")\n"
> >  	echo
> >  	printf -- "$(gettext "If %s is not specified, %s will look for '%s'")\n" "-p" "makepkg" "$BUILDSCRIPT"
> 
> This was set to show all sort options first (because they are most
> frequently used), follow by the long options without a short equivalent.
>   I see there were some places where keeping that order still needs
> adjustment (--noconfirm stands out, and I could accept the upper versus
> lower case letter adjustment), but I do not like the global change.

Actually the original sorting order here was rather fine to me. But not the one
in usage(). I changed it here to keep them in sync. See below for another
suggestion.

"--verifysource" was put completely randomly in the list, I suppose.

> > @@ -2604,18 +2604,12 @@ unset OPT_SHORT OPT_LONG OPTRET
> >  
> >  while true; do
> >  	case "$1" in
> > -		# Pacman Options
> > -		--asdeps)         ASDEPS=1;;
> > -		--noconfirm)      PACMAN_OPTS+=" --noconfirm" ;;
> > -		--needed)         NEEDED=1;;
> > -		--noprogressbar)  PACMAN_OPTS+=" --noprogressbar" ;;
> > -
> 
> Seems pointless just moving a block.

But it does keep in sync with the usage() part.

> >  		# Makepkg Options
> > +		-A|--ignorearch)  IGNOREARCH=1 ;;
> >  		--allsource)      SOURCEONLY=2 ;;
> >  		--asroot)         ASROOT=1 ;;
> > -		-A|--ignorearch)  IGNOREARCH=1 ;;
> > -		-c|--clean)       CLEANUP=1 ;;
> >  		-C|--cleanbuild)  CLEANBUILD=1 ;;
> > +		-c|--clean)       CLEANUP=1 ;;
> >  		--check)          RUN_CHECK='y' ;;
> >  		--config)         shift; MAKEPKG_CONF=$1 ;;
> >  		-d|--nodeps)      NODEPS=1 ;;
> > @@ -2623,6 +2617,7 @@ while true; do
> >  		-f|--force)       FORCE=1 ;;
> >  		-F)               INFAKEROOT=1 ;;
> >  		-g|--geninteg)    GENINTEG=1 ;;
> > +		-h|--help)        usage; exit 0 ;; # E_OK
> >  		--holdver)        HOLDVER=1 ;;
> >  		-i|--install)     INSTALL=1 ;;
> >  		--key)            shift; GPGKEY=$1 ;;
> > @@ -2633,21 +2628,25 @@ while true; do
> >  		--noprepare)      RUN_PREPARE='n' ;;
> >  		--nosign)         SIGNPKG='n' ;;
> >  		-o|--nobuild)     NOBUILD=1 ;;
> > -		-p)               shift; BUILDFILE=$1 ;;
> >  		--pkg)            shift; IFS=, read -ra p <<<"$1"; PKGLIST+=("${p[@]}"); unset p ;;
> > -		-r|--rmdeps)      RMDEPS=1 ;;
> > +		-p)               shift; BUILDFILE=$1 ;;
> >  		-R|--repackage)   REPKG=1 ;;
> > +		-r|--rmdeps)      RMDEPS=1 ;;
> > +		--sign)           SIGNPKG='y' ;;
> >  		--skipchecksums)  SKIPCHECKSUMS=1 ;;
> >  		--skipinteg)      SKIPCHECKSUMS=1; SKIPPGPCHECK=1 ;;
> >  		--skippgpcheck)   SKIPPGPCHECK=1;;
> > -		--sign)           SIGNPKG='y' ;;
> > -		-s|--syncdeps)    DEP_BIN=1 ;;
> >  		-S|--source)      SOURCEONLY=1 ;;
> > +		-s|--syncdeps)    DEP_BIN=1 ;;
> >  		--verifysource)   VERIFYSOURCE=1 ;;
> > -
> 
> Moving --sign into order is fine.  I think the upper vs lower case and
> single vs double hyphen ordering here is really unnecessary churn.

Again, the point is to write them the same way as in usage().

-- 
Pierre Neidhardt

Having no talent is no longer enough.
		-- Gore Vidal


More information about the pacman-dev mailing list