| version 1.2, 2002/06/15 13:21:27 |
version 1.3, 2002/07/12 15:31:27 |
|
|
| fi |
fi |
| } |
} |
| |
|
| |
usage() |
| |
{ |
| |
cat << EOF |
| |
Usage: ./packages-log.sh [-d DIR] [--suffix SUFFIX] [--daily] |
| |
|
| |
--daily Silently exit if today logfile already exists, |
| |
don't remove old logfiles. |
| |
--directory=DIR Set output directory to DIR. |
| |
--suffix=SUFFIX Add suffix to logfiles. Use this if you wish |
| |
keep some logfiles. Parameter is added |
| |
to the name of logfile. |
| |
EOF |
| |
exit 1; |
| |
} |
| |
|
| directory="." |
directory="." |
| suffix="" |
suffix="" |
| |
|
| # Cmdline parsing {{{ |
# Cmdline parsing {{{ |
| for option |
for option |
| do |
do |
| # If the previous option needs an argument, assign it. |
# If the previous option needs an argument, assign it. |
| if test -n "$prev"; then |
if test -n "$prev"; then |
| eval "$prev=\$option" |
eval "$prev=\$option" |
| prev= |
prev= |
| continue |
continue |
| fi |
fi |
| |
|
| case "$option" in |
case "$option" in |
| -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; |
-*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; |
| *) optarg= ;; |
*) optarg= ;; |
| esac |
esac |
| |
|
| |
case "$option" in |
| |
--daily | --dail | --dai | --da | \ |
| |
-daily | -dail | -dai | -da) |
| |
prev=daily ; daily="yes" ;; |
| |
--daily=* | --dail=* | --dai=* | --da=* | \ |
| |
-daily=* | -dail=* | -dai=* | -da=*) |
| |
daily="$optarg" ;; |
| |
|
| case "$option" in |
|
| --directory | --director | --directo | --direct | --direc | --dire | \ |
--directory | --director | --directo | --direct | --direc | --dire | \ |
| --dir | --di | --d | -d) |
--dir | --di | \ |
| |
-directory | -director | -directo | -direct | -direc | -dire | \ |
| |
-dir | -di) |
| prev=directory ;; |
prev=directory ;; |
| --directory=* | --director=* | --directo=* | --direct=* | --direc=* | --dire=* | \ |
--directory=* | --director=* | --directo=* | --direct=* | --direc=* | --dire=* | \ |
| --dir=* | --di=* | --d=* | -d=*) |
--dir=* | --di=* | \ |
| |
-directory=* | -director=* | -directo=* | -direct=* | -direc=* | -dire=* | \ |
| |
-dir=* | -di=*) |
| directory="$optarg" ;; |
directory="$optarg" ;; |
| |
|
| --suffix | --suffi | --suff | --suf | --su | --s | -s) |
--suffix | --suffi | --suff | --suf | --su | --s | -s) |
|
|
| --suffix=* | --suffi=* | --suff=* | --suf=* | --su=* | --s=* | -s=*) |
--suffix=* | --suffi=* | --suff=* | --suf=* | --su=* | --s=* | -s=*) |
| suffix="$optarg" ;; |
suffix="$optarg" ;; |
| |
|
| -help | --help | --hel | --he | --h | -h) |
--help | --hel | --he | --h | -h | \ |
| cat << EOF |
-help | -hel | -he | -h | -h) |
| Usage: ./packages-log.sh [-d DIR] [--suffix SUFFIX] |
usage ;; |
| |
|
| --directory=DIR Set output directory to Directory |
|
| --suffix=SUFFIX Add suffix to logfiles. Use this if you wish |
|
| keep some logfiles. Parameter is added |
|
| to the name of logfile |
|
| EOF |
|
| ;; |
|
| |
|
| -*) { echo "error: $option: invalid option; use --help to show usage" 1>&2; exit 1; } |
-*) { echo "error: $option: invalid option; use --help to show usage" 1>&2; exit 1; } |
| ;; |
;; |
| Line 76 PREVIOUS_LOG="$directory/`previous 1`$su |
|
| Line 95 PREVIOUS_LOG="$directory/`previous 1`$su |
|
| OLD_LOG="$directory/`previous 2`$suffix" |
OLD_LOG="$directory/`previous 2`$suffix" |
| DIFF_LOG="$directory/`previous 1`-`previous 0`$suffix.diff" |
DIFF_LOG="$directory/`previous 1`-`previous 0`$suffix.diff" |
| |
|
| |
|
| |
# if argument '--daily' is specified, silently exit if $LOG already exists |
| |
if [ ! -z "$daily" ]; then |
| |
if [ -f "$LOG" ]; then |
| |
exit; |
| |
fi |
| |
fi |
| |
|
| # If you have 'dpkg', probably you are on Linux Debian. |
# If you have 'dpkg', probably you are on Linux Debian. |
| # If dpkg not found (or not executable), use rpm |
# If dpkg not found (or not executable), use rpm |
| # (Linux Mandrake, RedHat, etc.. probably doesn't have dpkg) |
# (Linux Mandrake, RedHat, etc.. probably doesn't have dpkg) |
|
|
| rm -f "$DIFF_LOG" |
rm -f "$DIFF_LOG" |
| fi |
fi |
| |
|
| # remove old log |
# remove old log if '--daily' parameter is NOT specified |
| rm -f "$OLD_LOG" |
if [ -z "$daily" ]; then |
| |
rm -f "$OLD_LOG" |
| |
fi |
| |
|
| # Modeline for ViM |
# Modeline for ViM |
| # vim600: fdm=marker fdl=0 |
# vim600: fdm=marker fdl=0 |
| |
|
| |
|