r49570 - /scripts/examples/clean_sourcetree

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Wed Dec 30 22:55:30 UTC 2009


Author: gregoa
Date: Wed Dec 30 22:55:25 2009
New Revision: 49570

URL: http://svn.debian.org/wsvn/?sc=1&rev=49570
Log:
add a path argument, default: "build-area:tarballs"

Modified:
    scripts/examples/clean_sourcetree

Modified: scripts/examples/clean_sourcetree
URL: http://svn.debian.org/wsvn/scripts/examples/clean_sourcetree?rev=49570&op=diff
==============================================================================
--- scripts/examples/clean_sourcetree (original)
+++ scripts/examples/clean_sourcetree Wed Dec 30 22:55:25 2009
@@ -14,6 +14,7 @@
 SRCDIR=~/src
 AGE=365
 DELETE=-print
+PATHARGS=build-area:tarballs
 
 # helper functions
 usage() {
@@ -22,17 +23,29 @@
 	Usage for $(basename $0):
 	
 	-s DIR   Top of source directory, defaults to ~/src.
+	-p PATHS List of directories, colon-separated, 
+	         default: "build-area:tarballs".
 	-a DAYS  Age (mtime >= days), defaults to 365.
 	-d       Delete!, defaults to print only.
 	-h       Help.
 	HERE
 }
 
+createpath(){
+	for PATHPART in $(echo $1 | cut --fields=1- --delimiter=":" --output-delimiter=" ") ; do
+		FINDPATH="$FINDPATH -path */$PATHPART/* -o"
+	done
+	FINDPATH=${FINDPATH% -o}
+}
+
 # command line options
-while getopts :s:a:dh OPTION; do
+while getopts :s:p:a:dh OPTION; do
 	case "$OPTION" in
 		s)
 			SRCDIR=$OPTARG
+			;;
+		p)
+			PATHARGS=$OPTARG
 			;;
 		a)
 			AGE=$OPTARG
@@ -60,9 +73,10 @@
 echo "I: done"
 
 # remove old stuff from build-area and tarballs
+createpath $PATHARGS
 echo "I: looking for Debian packages older then $AGE days ..."
-find $SRCDIR -type f -mtime $AGE \
-	\( -path '*/build-area/*' -o -path '*/tarballs/*' \) \
+find $SRCDIR -type f -mtime +$AGE \
+	\( $FINDPATH \) \
 	\( -name '*.deb' -o \
 		-name '*.orig.tar.gz' -o -name '*.dsc' -o -name '*.diff.gz' -o -name '*.debian.tar.gz' -o \
 		-name '*.build' -o -name '*.changes' -o -name '*.upload' \) \




More information about the Pkg-perl-cvs-commits mailing list