diff options
author | Dan McGee <dan@archlinux.org> | 2007-05-29 22:53:15 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-05-29 22:53:15 +0200 |
commit | 103c7243a2d50dd46c0b5efefdc2e1b1d24e30e0 (patch) | |
tree | ad7914cb0864b1ae80f44dc49f967e20f888db59 /scripts/pacman-optimize.in | |
parent | 2760828e9dff1250c1160b7df2f376107ffe134f (diff) | |
download | pacman-103c7243a2d50dd46c0b5efefdc2e1b1d24e30e0.tar.gz pacman-103c7243a2d50dd46c0b5efefdc2e1b1d24e30e0.tar.xz |
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>
Diffstat (limited to 'scripts/pacman-optimize.in')
-rw-r--r-- | scripts/pacman-optimize.in | 40 |
1 files changed, 23 insertions, 17 deletions
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." |