Browse Source

More options!

Douglas William Thrift 14 years ago
parent
commit
b35e11dfdc
2 changed files with 34 additions and 16 deletions
  1. 28 10
      apt-p2p-clean
  2. 6 6
      apt-p2p-clean.8.in

+ 28 - 10
apt-p2p-clean

@@ -25,10 +25,15 @@ function usage()
 	Usage: $program [options]
 	Usage: $program [options]
 
 
 	Options:
 	Options:
-	  -e, --execute     clean up the apt-p2p cache
-	  -h, --help        show this help message and exit
-	  -n, --no-execute  show what would be done to clean up the apt-p2p cache
-	  -v, --version     show version information and exit
+	  -a ARCHIVE, --archive=ARCHIVE   set the APT archive directory (default:
+	                                  $_apt_archive)
+	  -c CACHE, --cache=CACHE         set the Apt-P2P cache directory (default:
+	                                  $_apt_p2p_cache)
+	  -e, --execute                   clean up the Apt-P2P cache
+	  -h, --help                      show this help message and exit
+	  -n, --no-execute                show what would be done to clean up the
+	                                  Apt-P2P cache
+	  -v, --version                   show version information and exit
 	EOF
 	EOF
 	exit $@
 	exit $@
 }
 }
@@ -40,19 +45,31 @@ function version()
 }
 }
 
 
 program=`basename $0`
 program=`basename $0`
-version='1.0'
+version='1.0.1'
 apt_p2p_cache='/var/cache/apt-p2p/cache'
 apt_p2p_cache='/var/cache/apt-p2p/cache'
+_apt_p2p_cache="$apt_p2p_cache"
 apt_archive='/var/cache/apt/archives'
 apt_archive='/var/cache/apt/archives'
-args=`getopt -l 'execute,help,no-execute,version' -n "$program" -o 'ehnv' -- "$@"`
-val=$?
+_apt_archive="$apt_archive"
+args=`getopt -l 'archive:,cache:,execute,help,no-execute,version' -n "$program" -o 'a:c:ehnv' -- "$@"`
+value=$?
 
 
-[[ $val != 0 ]] && usage $val
+[[ $value != 0 ]] && usage $value
 
 
 eval set -- "$args"
 eval set -- "$args"
-unset args val
+unset args
 
 
 until [[ "$1" == -- ]]; do
 until [[ "$1" == -- ]]; do
+	value=1
+
 	case "$1" in
 	case "$1" in
+	(-a|--archive)
+		apt_archive="$2"
+		value=2
+		;;
+	(-c|--cache)
+		apt_p2p_cache="$2"
+		value=2
+		;;
 	(-e|--execute)
 	(-e|--execute)
 		execute=1
 		execute=1
 		;;
 		;;
@@ -67,11 +84,12 @@ until [[ "$1" == -- ]]; do
 		;;
 		;;
 	esac
 	esac
 
 
-	shift
+	shift $value
 done
 done
 
 
 [[ -z $execute ]] && usage
 [[ -z $execute ]] && usage
 
 
+unset value
 set -e
 set -e
 
 
 for directory in "$apt_p2p_cache" "$apt_archive"; do
 for directory in "$apt_p2p_cache" "$apt_archive"; do

+ 6 - 6
apt-p2p-clean.8.in

@@ -1,16 +1,16 @@
 [DESCRIPTION]
 [DESCRIPTION]
-.B apt-p2p-clean
-cleans up the Apt-P2P cache by checking if .deb files in the cache not are also
-in the APT cache (after it is cleaned by \fBapt-get\fR \fIautoclean\fR or
+.B apt\-p2p\-clean
+cleans up the Apt\-P2P cache by checking if .deb files in the cache not are also
+in the APT cache (after it is cleaned by \fBapt\-get\fR \fIautoclean\fR or
 \fBaptitude\fR \fIautoclean\fR) and removing those .deb files that are not
 \fBaptitude\fR \fIautoclean\fR) and removing those .deb files that are not
 present.
 present.
 [AUTHOR]
 [AUTHOR]
 Written by \fBDouglas Thrift\fR <\fIdouglas@douglasthrift.net\fR>.
 Written by \fBDouglas Thrift\fR <\fIdouglas@douglasthrift.net\fR>.
 [SEE ALSO]
 [SEE ALSO]
 .PP
 .PP
-\fBapt-get\fR(8),
+\fBapt\-get\fR(8),
 \fBaptitude\fR(8),
 \fBaptitude\fR(8),
-\fBapt-p2p\fR(8).
+\fBapt\-p2p\fR(8).
 [COPYRIGHT]
 [COPYRIGHT]
 .PP
 .PP
 Copyright 2010 Douglas Thrift
 Copyright 2010 Douglas Thrift
@@ -19,7 +19,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 You may obtain a copy of the License at
 .PP
 .PP
-   \fIhttp://www.apache.org/licenses/LICENSE-2.0\fR
+   \fIhttp://www.apache.org/licenses/LICENSE\-2.0\fR
 .PP
 .PP
 Unless required by applicable law or agreed to in writing, software
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an \fB"AS IS" BASIS,
 distributed under the License is distributed on an \fB"AS IS" BASIS,