>From f5c5a277e2df14650ae441f32950aa6d4deee50f Mon Sep 17 00:00:00 2001
From: Xavier Chantry <shiningxc@gmail.com>
Date: Wed, 28 May 2008 21:57:28 +0200
Subject: [PATCH] makepkg : switch from getopt to getopts builtin
getopt is an external script for parsing and is less portable than getopts
which is a bash builtin.
The main problem is that it only supports short opts, so long opts had to be
dropped.
The benefits are a much better portability and a simpler code for the
arguments parsing.
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index cc44c68..f880091 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -27,7 +27,7 @@
# makepkg uses quite a few external programs during its execution. You
# need to have at least the following installed for makepkg to function:
# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
-# getopt (util-linux), gettext, grep, gzip, sed
+# gettext, grep, gzip, sed
# gettext initialization
export TEXTDOMAIN='pacman'
@@ -1056,31 +1056,31 @@ usage() {
printf "$(gettext "Usage: %s [options]")
" "$0"
echo
echo "$(gettext "Options:")"
- printf "$(gettext " -A, --ignorearch Ignore incomplete arch field
in %s")
" "$BUILDSCRIPT"
- echo "$(gettext " -c, --clean Clean up work files after build")"
- echo "$(gettext " -C, --cleancache Clean up source files from the cache")"
- echo "$(gettext " -d, --nodeps Skip all dependency checks")"
- echo "$(gettext " -e, --noextract Do not extract source files (use
existing src/ dir)")"
- echo "$(gettext " -f, --force Overwrite existing package")"
- echo "$(gettext " -g, --geninteg Generate integrity checks for
source files")"
- echo "$(gettext " -h, --help This help")"
- echo "$(gettext " -i, --install Install package after successful build")"
- echo "$(gettext " -L, --log Log package build process")"
- echo "$(gettext " -m, --nocolor Disable colorized output messages")"
- echo "$(gettext " -o, --nobuild Download and extract files only")"
+ printf "$(gettext " -A Ignore incomplete arch field in %s")
"
"$BUILDSCRIPT"
+ echo "$(gettext " -c Clean up work files after build")"
+ echo "$(gettext " -C Clean up source files from the cache")"
+ echo "$(gettext " -d Skip all dependency checks")"
+ echo "$(gettext " -e Do not extract source files (use existing
src/ dir)")"
+ echo "$(gettext " -f Overwrite existing package")"
+ echo "$(gettext " -g Generate integrity checks for source files")"
+ echo "$(gettext " -h This help")"
+ echo "$(gettext " -i Install package after successful build")"
+ echo "$(gettext " -L Log package build process")"
+ echo "$(gettext " -m Disable colorized output messages")"
+ echo "$(gettext " -o Download and extract files only")"
printf "$(gettext " -p <buildscript> Use an alternate build script
(instead of '%s')")
" "$BUILDSCRIPT"
- echo "$(gettext " -r, --rmdeps Remove installed dependencies
after a successful build")"
+ echo "$(gettext " -r Remove installed dependencies after a
successful build")"
# fix flyspray feature request #2978
- echo "$(gettext " -R, --repackage Repackage contents of pkg/
without building")"
- echo "$(gettext " -s, --syncdeps Install missing dependencies
with pacman")"
- echo "$(gettext " --asroot Allow makepkg to run as root user")"
- echo "$(gettext " --holdver Prevent automatic version
bumping for development PKGBUILDs")"
- echo "$(gettext " --source Do not build package; generate a
source-only tarball")"
+ echo "$(gettext " -R Repackage contents of pkg/ without building")"
+ echo "$(gettext " -s Install missing dependencies with pacman")"
+ echo "$(gettext " -O Allow makepkg to run as root user")"
+ echo "$(gettext " -H Prevent automatic version bumping for
development PKGBUILDs")"
+ echo "$(gettext " -S Do not build package; generate a
source-only tarball")"
echo
echo "$(gettext "These options can be passed to pacman:")"
echo
- echo "$(gettext " --noconfirm Do not ask for confirmation
when resolving dependencies")"
- echo "$(gettext " --noprogressbar Do not show a progress bar
when downloading files")"
+ echo "$(gettext " -n Do not ask for confirmation when
resolving dependencies")"
+ echo "$(gettext " -N Do not show a progress bar when
downloading files")"
echo
printf "$(gettext "If -p is not specified, makepkg will look for
'%s'")
" "$BUILDSCRIPT"
echo
@@ -1130,66 +1130,49 @@ SRCDEST=${_SRCDEST:-$SRCDEST}
SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
# Parse Command Line Options.
-OPT_SHORT="AbcCdefFghiLmop:rRsSV"
-OPT_LONG="ignorearch,asroot,builddeps,clean,cleanc ache,nodeps,noextract,force,forcever:,geninteg,hel p,holdver"
-OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rm deps,repackage,source,syncdeps,usesudo,version"
-# Pacman Options
-OPT_LONG="$OPT_LONG,noconfirm,noprogressbar"
-OPT_TEMP="$(getopt -o "$OPT_SHORT" -l "$OPT_LONG" -n "$(basename
"$0")" -- "$@" || echo 'GETOPT GO BANG!')"
-if echo "$OPT_TEMP" | grep -q 'GETOPT GO BANG!'; then
- # This is a small hack to stop the script bailing with 'set -e'
- echo; usage; exit 1 # E_INVALID_OPTION;
-fi
-eval set -- "$OPT_TEMP"
-unset OPT_SHORT OPT_LONG OPT_TEMP
+OPT_SHORT="AcCdefF:ghHiLmnNoOp:rRsSVX"
-while true; do
- case "$1" in
+while getopts "$OPT_SHORT" name; do
+ case $name in
# Pacman Options
- --noconfirm) PACMAN_OPTS="$PACMAN_OPTS --noconfirm" ;;
- --noprogressbar) PACMAN_OPTS="$PACMAN_OPTS --noprogressbar" ;;
+ n) PACMAN_OPTS="$PACMAN_OPTS --noconfirm" ;;
+ N) PACMAN_OPTS="$PACMAN_OPTS --noprogressbar" ;;
if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then
- # The extra '--' is here to prevent gettext from thinking --holdver is
+ # The extra '--' is here to prevent gettext from thinking -H is
# an option
- error "$(gettext "