Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-05-29 16:53:15 -0400
committerDan McGee <dan@archlinux.org>2007-05-29 16:53:15 -0400
commit103c7243a2d50dd46c0b5efefdc2e1b1d24e30e0 (patch)
treead7914cb0864b1ae80f44dc49f967e20f888db59
parent2760828e9dff1250c1160b7df2f376107ffe134f (diff)
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>
-rw-r--r--configure.ac4
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Makefile.am5
-rw-r--r--scripts/abs.in4
-rw-r--r--scripts/makepkg.in27
-rw-r--r--scripts/makeworld.in88
-rw-r--r--scripts/pacman-optimize.in40
-rw-r--r--[-rwxr-xr-x]scripts/rankmirrors.in (renamed from scripts/rankmirrors)7
8 files changed, 104 insertions, 72 deletions
diff --git a/configure.ac b/configure.ac
index dec2bb44..c79cea8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
+
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_LANG([C])
@@ -222,6 +225,7 @@ scripts/gensync
scripts/makepkg
scripts/makeworld
scripts/pacman-optimize
+scripts/rankmirrors
scripts/repo-add
scripts/repo-remove
scripts/updatesync
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 58630324..17a2a41e 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -3,6 +3,7 @@ gensync
makepkg
makeworld
pacman-optimize
+rankmirrors
repo-add
repo-remove
updatesync
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index ddacb0e6..45f0957d 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,6 +1,5 @@
-# TODO: this would be nice to enable, but we need --help and --version
-# flags on all of our scripts first (this is what it checks)
-#AUTOMAKE_OPTIONS = std-options
+# enforce that all scripts have a --help and --version option
+AUTOMAKE_OPTIONS = std-options
bin_SCRIPTS = \
abs \
diff --git a/scripts/abs.in b/scripts/abs.in
index b30c1752..7ed677d4 100644
--- a/scripts/abs.in
+++ b/scripts/abs.in
@@ -67,12 +67,12 @@ update() {
done
}
-if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
-if [ "$1" = "-V" ] || [ "$1" = "--version" ]; then
+if [ "$1" = "-V" -o "$1" = "--version" ]; then
version
exit 0
fi
diff --git a/scripts/makepkg.in b/scripts/makepkg.in
index 0d147041..2884e5db 100644
--- a/scripts/makepkg.in
+++ b/scripts/makepkg.in
@@ -600,7 +600,7 @@ installpackage() {
}
usage() {
- printf "$(gettext "makepkg version %s")\n" "$myver"
+ printf "$(gettext "makepkg (pacman) %s")\n" "$myver"
echo
printf "$(gettext "Usage: %s [options]")\n" "$0"
echo
@@ -633,6 +633,15 @@ usage() {
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=$@
#preserve environment variables
@@ -684,6 +693,10 @@ while [ "$#" -ne "0" ]; do
usage
exit 0
;;
+ --version)
+ version
+ exit 0
+ ;;
--*)
usage
exit 1
@@ -699,10 +712,6 @@ while [ "$#" -ne "0" ]; do
f) FORCE=1 ;;
F) INFAKEROOT=1 ;;
g) GENINTEG=1 ;;
- h)
- usage
- exit 0
- ;;
i) INSTALL=1 ;;
L) LOGGING=1 ;;
m) USE_COLOR="n" ;;
@@ -712,6 +721,14 @@ while [ "$#" -ne "0" ]; do
R) REPKG=1 ;;
s) DEP_BIN=1 ;;
S) SUDO=1 ;;
+ h)
+ usage
+ exit 0
+ ;;
+ V)
+ version
+ exit 0
+ ;;
-)
OPTIND=0
break
diff --git a/scripts/makeworld.in b/scripts/makeworld.in
index 8783fc9d..ca5b7261 100644
--- a/scripts/makeworld.in
+++ b/scripts/makeworld.in
@@ -58,7 +58,7 @@ version() {
printf "Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n"
echo
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
}
@@ -83,53 +83,53 @@ for arg in $*; do
--nobuild) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
--nocolor) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
--help)
- usage
- exit 0
- ;;
+ usage
+ exit 0
+ ;;
--version)
- version
- exit 0
- ;;
+ version
+ exit 0
+ ;;
--*)
- usage
- exit 1
- ;;
+ usage
+ exit 1
+ ;;
-*)
- while getopts "chisSbdfrBCemoSV-" opt; do
- case $opt in
- c) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
- i) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
- s) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
- b) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
- d) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
- f) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
- r) MAKEPKG_OPTS="$MAKEPKG_OPTS -r" ;;
- B) MAKEPKG_OPTS="$MAKEPKG_OPTS -B" ;;
- C) MAKEPKG_OPTS="$MAKEPKG_OPTS -C" ;;
- e) MAKEPKG_OPTS="$MAKEPKG_OPTS -e" ;;
- m) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
- o) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
- S) MAKEPKG_OPTS="$MAKEPKG_OPTS -S" ;;
- h)
- usage
- exit 0
- ;;
- V)
- version
- exit 0
- ;;
- -)
- OPTIND=0
- break
- ;;
- esac
- done
- ;;
+ while getopts "chisSbdfrBCemoSV-" opt; do
+ case $opt in
+ c) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
+ i) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
+ s) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
+ b) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
+ d) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
+ f) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
+ r) MAKEPKG_OPTS="$MAKEPKG_OPTS -r" ;;
+ B) MAKEPKG_OPTS="$MAKEPKG_OPTS -B" ;;
+ C) MAKEPKG_OPTS="$MAKEPKG_OPTS -C" ;;
+ e) MAKEPKG_OPTS="$MAKEPKG_OPTS -e" ;;
+ m) MAKEPKG_OPTS="$MAKEPKG_OPTS -m" ;;
+ o) MAKEPKG_OPTS="$MAKEPKG_OPTS -o" ;;
+ S) MAKEPKG_OPTS="$MAKEPKG_OPTS -S" ;;
+ h)
+ usage
+ exit 0
+ ;;
+ V)
+ version
+ exit 0
+ ;;
+ -)
+ OPTIND=0
+ break
+ ;;
+ esac
+ done
+ ;;
*)
- dest=$arg
- shift
- break
- ;;
+ dest=$arg
+ shift
+ break
+ ;;
esac
shift
if [ "$dest" != "" ]; then
diff --git a/scripts/pacman-optimize.in b/scripts/pacman-optimize.in
index 2bfec40e..cce4a5c1 100644
--- a/scripts/pacman-optimize.in
+++ b/scripts/pacman-optimize.in
@@ -21,6 +21,11 @@
#
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() {
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
@@ -30,11 +35,12 @@ error() {
fi
}
-source /etc/rc.conf #for USECOLOR
-source /etc/rc.d/functions
+# determine current USECOLOR setting
+#[ -f "/etc/rc.conf" ] && source /etc/rc.conf
+#[ -f "/etc/rc.d/functions" ] && source /etc/rc.d/functions
usage() {
- echo "pacman-optimize $myver"
+ echo "pacman-optimize (pacman) $myver"
echo "usage: $0 [pacman_db_root]"
echo
echo "pacman-optimize is a little hack that should improve the performance"
@@ -64,26 +70,26 @@ die() {
}
die_r() {
- rm -f /tmp/pacman.lck
+ rm -f $lockfile
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" = "-h" -o "$1" = "--help" ]; then
- usage
- exit 0
- fi
- if [ "$1" = "-V" -o "$1" = "--version" ]; then
- version
- exit 0
- fi
dbroot="$1"
fi
# 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."
fi
@@ -96,7 +102,7 @@ if [ ! -w "$dbroot" ]; then
fi
# do not let pacman run while we do this
-touch /tmp/pacman.lck
+touch $lockfile
# step 1: sum the old db
stat_busy "Md5sum'ing the old database"
@@ -134,7 +140,7 @@ if [ $? -ne 0 ]; then
# failed
stat_fail
# 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"
fi
stat_done
@@ -147,7 +153,7 @@ tar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/
stat_done
# 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 "Finished. Your pacman database has been optimized."
diff --git a/scripts/rankmirrors b/scripts/rankmirrors.in
index 3eb10b5a..da0811c0 100755..100644
--- a/scripts/rankmirrors
+++ b/scripts/rankmirrors.in
@@ -25,10 +25,12 @@ from optparse import OptionParser
def createOptParser():
usage = "usage: %prog [options] MIRRORFILE | URL"
+ version = '%prog (pacman) @PACKAGE_VERSION@'
description = "Ranks pacman mirrors by their connection and opening " \
"speed. Pacman mirror files are located in /etc/pacman.d/. It " \
"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,
help = "number of servers to output, 0 for all")
parser.add_option("-t", "--times", action = "store_true",
@@ -39,6 +41,9 @@ def createOptParser():
parser.add_option("-v", "--verbose", action = "store_true",
dest = "verbose", default = False,
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
def timeCmd(cmd):