Douglas William Thrift 14 years ago
parent
commit
94a13488be
3 changed files with 23 additions and 6 deletions
  1. 1 0
      .gitignore
  2. 7 4
      GNUmakefile
  3. 15 2
      apt-p2p-clean

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+*.8

+ 7 - 4
GNUmakefile

@@ -1,14 +1,17 @@
-# APT P2P Clean
+# Apt-P2P Clean
 #
 # Douglas Thrift
 #
 # $Id$
 
+all := apt-p2p-clean.8
+
 .PHONY: all clean
 
-all: apt-p2p-clean.8
+all: $(all)
 
-%.8: %
-	help2man -N -s 8 $(shell realpath $<) > $@
+%.8: % GNUmakefile
+	help2man -Nn '$(shell sed -e '$$ s/^# //p;d' $<)' -o $@ -s 8 $(shell realpath $<)
 
 clean:
+	rm -f $(all)

+ 15 - 2
apt-p2p-clean

@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# APT P2P Clean
+# Apt-P2P Clean
 #
 # Douglas Thrift
 #
@@ -14,12 +14,20 @@ function usage()
 	  -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 $@
 }
 
+function version()
+{
+	echo "$program $version"
+	exit
+}
+
 program=`basename $0`
-args=`getopt -l 'execute,help,no-execute' -n "$program" -o 'ehn' -- "$@"`
+version='1.0'
+args=`getopt -l 'execute,help,no-execute,version' -n "$program" -o 'ehnv' -- "$@"`
 val=$?
 
 [[ $val != 0 ]] && usage $val
@@ -38,6 +46,9 @@ until [[ "$1" == -- ]]; do
 	(-n|--no-execute)
 		execute=0
 		;;
+	(-v|--version)
+		version
+		;;
 	esac
 
 	shift
@@ -80,3 +91,5 @@ find /var/cache/apt-p2p/cache -name '*.deb' | (
 	if (freed >= 1024 ^ 3) print freed / 1024 ^ 3, "G" else if (freed >= 1024 ^ 2) print freed / 1024 ^ 2, "M" else if (freed >= 1024) print freed / 1024, "K" else freed
 	EOF`B of disk space"
 )
+
+# Clean up Apt-P2P cache