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

Allan McRae allan at archlinux.org
Mon Mar 3 22:52:29 EST 2014


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.

> @@ -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.

>  		# 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.

> -		-h|--help)        usage; exit 0 ;; # E_OK
>  		-V|--version)     version; exit 0 ;; # E_OK

These looked kept separate for a reason...

>  
> +		# Pacman Options
> +		--asdeps)         ASDEPS=1;;
> +		--needed)         NEEDED=1;;
> +		--noconfirm)      PACMAN_OPTS+=" --noconfirm" ;;
> +		--noprogressbar)  PACMAN_OPTS+=" --noprogressbar" ;;
> +
>  		--)               OPT_IND=0; shift; break 2;;
>  	esac
>  	shift
> 



More information about the pacman-dev mailing list