]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_clean
r421: use strict
[debhelper.git] / dh_clean
index 1ca1012510cba863df9a989ea56f74d35b870f11..fb4e3a886ed89021c2589ec00cbd909eda888fdb 100755 (executable)
--- a/dh_clean
+++ b/dh_clean
@@ -1,24 +1,25 @@
 #!/usr/bin/perl -w
 #
-# Clean up $TMP and other tepmorary files generated by the
+# Clean up $tmp and other tepmorary files generated by the
 # build process.
 
+use strict;
 use Debian::Debhelper::Dh_Lib;
 init();
 
-foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
-       $TMP=tmpdir($PACKAGE);
-       $EXT=pkgext($PACKAGE);
+foreach my $package (@{$dh{DOPACKAGES}}) {
+       my $tmp=tmpdir($package);
+       my $ext=pkgext($package);
 
        if (! $dh{D_FLAG}) {
-               doit("rm","-f","debian/${EXT}substvars",
-                       "debian/${EXT}postinst.debhelper",
-                       "debian/${EXT}postrm.debhelper",
-                       "debian/${EXT}preinst.debhelper",
-                       "debian/${EXT}prerm.debhelper");
+               doit("rm","-f","debian/${ext}substvars",
+                       "debian/${ext}postinst.debhelper",
+                       "debian/${ext}postrm.debhelper",
+                       "debian/${ext}preinst.debhelper",
+                       "debian/${ext}prerm.debhelper");
        }
        
-       doit ("rm","-rf",$TMP);
+       doit ("rm","-rf",$tmp);
 }
 
 if (! $dh{D_FLAG}) {
@@ -30,6 +31,12 @@ if (! $dh{D_FLAG}) {
                doit("rm","-f","debian/files");
        }
 
+       # See if some files that would normally be deleted are excluded.
+       my $find_options='';
+       if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
+               $find_options="-a ! ( $dh{EXCLUDE_FIND} )";
+       }
+
        # Remove other temp files.
        # (The \s+ is important, \s won't work because find would get null
        # parameters). Note that you _don't_ quote wildcards used by find
@@ -39,9 +46,8 @@ if (! $dh{D_FLAG}) {
                 -o -name *.orig -o -name *.rej -o -name *.bak
                 -o -name .*.orig -o -name .*.rej -o -name .SUMS
                 -o -name TAGS -o -name core -o ( -path */.deps/* -a -name *.P )
-               ) -exec rm -f {} ;"));
+               ) $find_options -exec rm -f {} ;"));
 }
 
-doit('rm', '-rf', 'debian/tmp')
-       if -x 'debian/tmp' && ! Debian::Debhelper::Dh_Lib::compat(1);
+doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1);