Browse Source

More options!

Douglas William Thrift 11 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]
 
 	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
 	exit $@
 }
@@ -40,19 +45,31 @@ function version()
 }
 
 program=`basename $0`
-version='1.0'
+version='1.0.1'
 apt_p2p_cache='/var/cache/apt-p2p/cache'
+_apt_p2p_cache="$apt_p2p_cache"
 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"
-unset args val
+unset args
 
 until [[ "$1" == -- ]]; do
+	value=1
+
 	case "$1" in
+	(-a|--archive)
+		apt_archive="$2"
+		value=2
+		;;
+	(-c|--cache)
+		apt_p2p_cache="$2"
+		value=2
+		;;
 	(-e|--execute)
 		execute=1
 		;;
@@ -67,11 +84,12 @@ until [[ "$1" == -- ]]; do
 		;;
 	esac
 
-	shift
+	shift $value
 done
 
 [[ -z $execute ]] && usage
 
+unset value
 set -e
 
 for directory in "$apt_p2p_cache" "$apt_archive"; do

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

@@ -1,16 +1,16 @@
 [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
 present.
 [AUTHOR]
 Written by \fBDouglas Thrift\fR <\fIdouglas@douglasthrift.net\fR>.
 [SEE ALSO]
 .PP
-\fBapt-get\fR(8),
+\fBapt\-get\fR(8),
 \fBaptitude\fR(8),
-\fBapt-p2p\fR(8).
+\fBapt\-p2p\fR(8).
 [COPYRIGHT]
 .PP
 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 obtain a copy of the License at
 .PP
-   \fIhttp://www.apache.org/licenses/LICENSE-2.0\fR
+   \fIhttp://www.apache.org/licenses/LICENSE\-2.0\fR
 .PP
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an \fB"AS IS" BASIS,