Get --help and --version options working on all scripts
Added the autoconf option std-options to the scripts/ directory, which checks to ensure all programs have both --help and --version options. A few things needed cleaning up to get this working. To test these types of options, use the 'make distcheck' target. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
2760828e9d
commit
103c7243a2
|
@ -1,4 +1,7 @@
|
||||||
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
dnl Minimum version of autoconf required
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ(2.59)
|
||||||
|
|
||||||
dnl Update it right before the release since $pkgver_foo are all _post_ release snapshots
|
dnl Update it right before the release since $pkgver_foo are all _post_ release snapshots
|
||||||
AC_INIT([Pacman package manager], 3.1.0-dev, [pacman-dev@archlinux.org], [pacman])
|
AC_INIT([Pacman package manager], 3.1.0-dev, [pacman-dev@archlinux.org], [pacman])
|
||||||
AC_LANG([C])
|
AC_LANG([C])
|
||||||
|
@ -222,6 +225,7 @@ scripts/gensync
|
||||||
scripts/makepkg
|
scripts/makepkg
|
||||||
scripts/makeworld
|
scripts/makeworld
|
||||||
scripts/pacman-optimize
|
scripts/pacman-optimize
|
||||||
|
scripts/rankmirrors
|
||||||
scripts/repo-add
|
scripts/repo-add
|
||||||
scripts/repo-remove
|
scripts/repo-remove
|
||||||
scripts/updatesync
|
scripts/updatesync
|
||||||
|
|
|
@ -3,6 +3,7 @@ gensync
|
||||||
makepkg
|
makepkg
|
||||||
makeworld
|
makeworld
|
||||||
pacman-optimize
|
pacman-optimize
|
||||||
|
rankmirrors
|
||||||
repo-add
|
repo-add
|
||||||
repo-remove
|
repo-remove
|
||||||
updatesync
|
updatesync
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# TODO: this would be nice to enable, but we need --help and --version
|
# enforce that all scripts have a --help and --version option
|
||||||
# flags on all of our scripts first (this is what it checks)
|
AUTOMAKE_OPTIONS = std-options
|
||||||
#AUTOMAKE_OPTIONS = std-options
|
|
||||||
|
|
||||||
bin_SCRIPTS = \
|
bin_SCRIPTS = \
|
||||||
abs \
|
abs \
|
||||||
|
|
|
@ -67,12 +67,12 @@ update() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "-V" ] || [ "$1" = "--version" ]; then
|
if [ "$1" = "-V" -o "$1" = "--version" ]; then
|
||||||
version
|
version
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -600,7 +600,7 @@ installpackage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf "$(gettext "makepkg version %s")\n" "$myver"
|
printf "$(gettext "makepkg (pacman) %s")\n" "$myver"
|
||||||
echo
|
echo
|
||||||
printf "$(gettext "Usage: %s [options]")\n" "$0"
|
printf "$(gettext "Usage: %s [options]")\n" "$0"
|
||||||
echo
|
echo
|
||||||
|
@ -633,6 +633,15 @@ usage() {
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version() {
|
||||||
|
printf "$(gettext "makepkg (pacman) %s")\n" "$myver"
|
||||||
|
echo "$(gettext "Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.")"
|
||||||
|
echo
|
||||||
|
echo "$(gettext "This is free software; see the source for copying conditions.")"
|
||||||
|
echo "$(gettext "There is NO WARRANTY, to the extent permitted by law.")"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
ARGLIST=$@
|
ARGLIST=$@
|
||||||
|
|
||||||
#preserve environment variables
|
#preserve environment variables
|
||||||
|
@ -684,6 +693,10 @@ while [ "$#" -ne "0" ]; do
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
--version)
|
||||||
|
version
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
--*)
|
--*)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -699,10 +712,6 @@ while [ "$#" -ne "0" ]; do
|
||||||
f) FORCE=1 ;;
|
f) FORCE=1 ;;
|
||||||
F) INFAKEROOT=1 ;;
|
F) INFAKEROOT=1 ;;
|
||||||
g) GENINTEG=1 ;;
|
g) GENINTEG=1 ;;
|
||||||
h)
|
|
||||||
usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
i) INSTALL=1 ;;
|
i) INSTALL=1 ;;
|
||||||
L) LOGGING=1 ;;
|
L) LOGGING=1 ;;
|
||||||
m) USE_COLOR="n" ;;
|
m) USE_COLOR="n" ;;
|
||||||
|
@ -712,6 +721,14 @@ while [ "$#" -ne "0" ]; do
|
||||||
R) REPKG=1 ;;
|
R) REPKG=1 ;;
|
||||||
s) DEP_BIN=1 ;;
|
s) DEP_BIN=1 ;;
|
||||||
S) SUDO=1 ;;
|
S) SUDO=1 ;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
V)
|
||||||
|
version
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
-)
|
-)
|
||||||
OPTIND=0
|
OPTIND=0
|
||||||
break
|
break
|
||||||
|
|
|
@ -58,7 +58,7 @@ version() {
|
||||||
printf "Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n"
|
printf "Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n"
|
||||||
echo
|
echo
|
||||||
printf "This is free software; see the source for copying conditions.\n"
|
printf "This is free software; see the source for copying conditions.\n"
|
||||||
printf "There is NO WARRANTY, to the extent permitted by the law.\n"
|
printf "There is NO WARRANTY, to the extent permitted by law.\n"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,53 +83,53 @@ for arg in $*; do
|
||||||
--nobuild) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
|
--nobuild) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
|
||||||
--nocolor) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
|
--nocolor) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
|
||||||
--help)
|
--help)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--version)
|
--version)
|
||||||
version
|
version
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--*)
|
--*)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
while getopts "chisSbdfrBCemoSV-" opt; do
|
while getopts "chisSbdfrBCemoSV-" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
c) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
|
c) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
|
||||||
i) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
|
i) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
|
||||||
s) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
|
s) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
|
||||||
b) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
|
b) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
|
||||||
d) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
|
d) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
|
||||||
f) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
|
f) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
|
||||||
r) MAKEPKG_OPTS="$MAKEPKG_OPTS -r" ;;
|
r) MAKEPKG_OPTS="$MAKEPKG_OPTS -r" ;;
|
||||||
B) MAKEPKG_OPTS="$MAKEPKG_OPTS -B" ;;
|
B) MAKEPKG_OPTS="$MAKEPKG_OPTS -B" ;;
|
||||||
C) MAKEPKG_OPTS="$MAKEPKG_OPTS -C" ;;
|
C) MAKEPKG_OPTS="$MAKEPKG_OPTS -C" ;;
|
||||||
e) MAKEPKG_OPTS="$MAKEPKG_OPTS -e" ;;
|
e) MAKEPKG_OPTS="$MAKEPKG_OPTS -e" ;;
|
||||||
m) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
|
m) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
|
||||||
o) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
|
o) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
|
||||||
S) MAKEPKG_OPTS="$MAKEPKG_OPTS -S" ;;
|
S) MAKEPKG_OPTS="$MAKEPKG_OPTS -S" ;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
V)
|
V)
|
||||||
version
|
version
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-)
|
-)
|
||||||
OPTIND=0
|
OPTIND=0
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
dest=$arg
|
dest=$arg
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
if [ "$dest" != "" ]; then
|
if [ "$dest" != "" ]; then
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
myver='@PACKAGE_VERSION@'
|
myver='@PACKAGE_VERSION@'
|
||||||
|
#TODO replace with configure-time db location
|
||||||
|
dbroot="/var/lib/pacman"
|
||||||
|
#TODO replace with configure-time lockfile location
|
||||||
|
lockfile="/tmp/pacman.lck"
|
||||||
|
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
|
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
|
||||||
|
@ -30,11 +35,12 @@ error() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
source /etc/rc.conf #for USECOLOR
|
# determine current USECOLOR setting
|
||||||
source /etc/rc.d/functions
|
#[ -f "/etc/rc.conf" ] && source /etc/rc.conf
|
||||||
|
#[ -f "/etc/rc.d/functions" ] && source /etc/rc.d/functions
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "pacman-optimize $myver"
|
echo "pacman-optimize (pacman) $myver"
|
||||||
echo "usage: $0 [pacman_db_root]"
|
echo "usage: $0 [pacman_db_root]"
|
||||||
echo
|
echo
|
||||||
echo "pacman-optimize is a little hack that should improve the performance"
|
echo "pacman-optimize is a little hack that should improve the performance"
|
||||||
|
@ -64,26 +70,26 @@ die() {
|
||||||
}
|
}
|
||||||
|
|
||||||
die_r() {
|
die_r() {
|
||||||
rm -f /tmp/pacman.lck
|
rm -f $lockfile
|
||||||
die $@
|
die $@
|
||||||
}
|
}
|
||||||
|
|
||||||
dbroot="/var/lib/pacman"
|
if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "-V" -o "$1" = "--version" ]; then
|
||||||
|
version
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$1" != "" ]; then
|
if [ "$1" != "" ]; then
|
||||||
if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
|
||||||
usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if [ "$1" = "-V" -o "$1" = "--version" ]; then
|
|
||||||
version
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
dbroot="$1"
|
dbroot="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# make sure pacman isn't running
|
# make sure pacman isn't running
|
||||||
if [ -f /tmp/pacman.lck ]; then
|
if [ -f $lockfile ]; then
|
||||||
die "Pacman lockfile was found. Cannot run while pacman is running."
|
die "Pacman lockfile was found. Cannot run while pacman is running."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -96,7 +102,7 @@ if [ ! -w "$dbroot" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# do not let pacman run while we do this
|
# do not let pacman run while we do this
|
||||||
touch /tmp/pacman.lck
|
touch $lockfile
|
||||||
|
|
||||||
# step 1: sum the old db
|
# step 1: sum the old db
|
||||||
stat_busy "Md5sum'ing the old database"
|
stat_busy "Md5sum'ing the old database"
|
||||||
|
@ -134,7 +140,7 @@ if [ $? -ne 0 ]; then
|
||||||
# failed
|
# failed
|
||||||
stat_fail
|
stat_fail
|
||||||
# leave /tmp/pacsums.old and .new for checking to see what doesn't match up
|
# leave /tmp/pacsums.old and .new for checking to see what doesn't match up
|
||||||
rm -rf "$dbroot.new" /tmp/pacman.lck /tmp/pacmanDB.tgz
|
rm -rf "$dbroot.new" $lockfile /tmp/pacmanDB.tgz
|
||||||
die_r "integrity check FAILED, reverting to old database"
|
die_r "integrity check FAILED, reverting to old database"
|
||||||
fi
|
fi
|
||||||
stat_done
|
stat_done
|
||||||
|
@ -147,7 +153,7 @@ tar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/
|
||||||
stat_done
|
stat_done
|
||||||
|
|
||||||
# remove the lock file, sum files, and .tgz of database
|
# remove the lock file, sum files, and .tgz of database
|
||||||
rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz
|
rm -f $lockfile /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Finished. Your pacman database has been optimized."
|
echo "Finished. Your pacman database has been optimized."
|
||||||
|
|
|
@ -25,10 +25,12 @@ from optparse import OptionParser
|
||||||
|
|
||||||
def createOptParser():
|
def createOptParser():
|
||||||
usage = "usage: %prog [options] MIRRORFILE | URL"
|
usage = "usage: %prog [options] MIRRORFILE | URL"
|
||||||
|
version = '%prog (pacman) @PACKAGE_VERSION@'
|
||||||
description = "Ranks pacman mirrors by their connection and opening " \
|
description = "Ranks pacman mirrors by their connection and opening " \
|
||||||
"speed. Pacman mirror files are located in /etc/pacman.d/. It " \
|
"speed. Pacman mirror files are located in /etc/pacman.d/. It " \
|
||||||
"can also rank one mirror if the URL is provided."
|
"can also rank one mirror if the URL is provided."
|
||||||
parser = OptionParser(usage = usage, description = description)
|
parser = OptionParser(usage = usage, version = version,
|
||||||
|
description = description)
|
||||||
parser.add_option("-n", type = "int", dest = "num", default = 0,
|
parser.add_option("-n", type = "int", dest = "num", default = 0,
|
||||||
help = "number of servers to output, 0 for all")
|
help = "number of servers to output, 0 for all")
|
||||||
parser.add_option("-t", "--times", action = "store_true",
|
parser.add_option("-t", "--times", action = "store_true",
|
||||||
|
@ -39,6 +41,9 @@ def createOptParser():
|
||||||
parser.add_option("-v", "--verbose", action = "store_true",
|
parser.add_option("-v", "--verbose", action = "store_true",
|
||||||
dest = "verbose", default = False,
|
dest = "verbose", default = False,
|
||||||
help = "be verbose in ouptut")
|
help = "be verbose in ouptut")
|
||||||
|
# The following two options should be automatic
|
||||||
|
#parser.add_option("-h", "--help", action = "help")
|
||||||
|
#parser.add_option("-V", "--version", action = "version")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def timeCmd(cmd):
|
def timeCmd(cmd):
|
Loading…
Reference in New Issue