]> git.donarmstrong.com Git - debhelper.git/commitdiff
dh_prep: New program, does the same as dh_clean -k (which will be deprecated later).
authorJoey Hess <joey@kodama.kitenet.net>
Thu, 24 Apr 2008 02:49:22 +0000 (22:49 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Thu, 24 Apr 2008 02:49:22 +0000 (22:49 -0400)
21 files changed:
Debian/Debhelper/Dh_Lib.pm
debian/changelog
dh
dh_clean
dh_installcatalogs
dh_installdocs
dh_installemacsen
dh_installinfo
dh_installinit
dh_installmime
dh_installmodules
dh_installudev
dh_installwm
dh_prep [new file with mode: 0755]
dh_scrollkeeper
dh_usrlocal
doc/TODO
examples/rules.arch
examples/rules.indep
examples/rules.multi
examples/rules.multi2

index c83e42b266aa20f64284399c65610f0604100ca1..badbe87ede4361d8a69b0ed4196a07a4b91a3209 100644 (file)
@@ -14,7 +14,8 @@ use vars qw(@ISA @EXPORT %dh);
            &pkgfile &pkgext &pkgfilename &isnative &autoscript &filearray
            &filedoublearray &getpackages &basename &dirname &xargs %dh
            &compat &addsubstvar &delsubstvar &excludefile &package_arch
-           &is_udeb &udeb_filename &debhelper_script_subst &escape_shell);
+           &is_udeb &udeb_filename &debhelper_script_subst &escape_shell
+           &inhibit_log);
 
 my $max_compat=7;
 
@@ -110,22 +111,23 @@ sub init {
 
 # Run at exit. Add the command to the log files for the packages it acted
 # on, if it's exiting successfully.
+my $write_log=1;
 sub END {
-       if ($? == 0) {
+       if ($? == 0 && $write_log) {
                my $cmd=basename($0);
-               # dh_clean deletes the log, so should not recreate it at
-               # the end
-               if ($cmd ne "dh_clean" && $cmd ne "dh") {
-                       foreach my $package (@{$dh{DOPACKAGES}}) {
-                               my $ext=pkgext($package);
-                               open(LOG, ">>", "debian/${ext}debhelper.log") || error("failed to write to log");
-                               print LOG $cmd."\n";
-                               close LOG;
-                       }
+               foreach my $package (@{$dh{DOPACKAGES}}) {
+                       my $ext=pkgext($package);
+                       open(LOG, ">>", "debian/${ext}debhelper.log") || error("failed to write to log");
+                       print LOG $cmd."\n";
+                       close LOG;
                }
        }
 }
 
+sub inhibit_log {
+       $write_log=0;
+}
+
 # Pass it an array containing the arguments of a shell command like would
 # be run by exec(). It turns that into a line like you might enter at the
 # shell, escaping metacharacters and quoting arguments that contain spaces.
index 00bdeedfb0195bf5e44a50c723705ea56a318f10..6b91af5d7457b470d0f4b0fe4a90be3c8b19e460 100644 (file)
@@ -30,6 +30,8 @@ debhelper (7.0.0) UNRELEASED; urgency=low
     all the new toys.
   * dh_clean: Don't delete core dumps. (Too DWIM, and "core" is not
     necessarily a core dump.) Closes: #477391
+  * dh_prep: New program, does the same as dh_clean -k (which will be
+    deprecated later).
 
  -- Joey Hess <joeyh@debian.org>  Tue, 22 Apr 2008 17:54:20 -0400
 
diff --git a/dh b/dh
index ab814d7f2b98885678059e9628776ae077e3ca00..330b015215df09453b961d6d7af45b1e45add386 100755 (executable)
--- a/dh
+++ b/dh
@@ -172,6 +172,7 @@ that normally come before those in the sequence are still run.
 my @ARGV_orig=@ARGV;
 
 init();
+inhibit_log();
 
 # Definitions of sequences.
 my %sequences;
@@ -188,7 +189,7 @@ $sequences{clean} = [qw{
 }];
 $sequences{install} = [@{$sequences{build}}, qw{
        dh_testroot
-       dh_clean
+       dh_prep
        dh_installdirs
        dh_auto_install
 
@@ -291,6 +292,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
                # Run commands in the sequence that come after the
                # specified command.
                $startpoint{$package}=command_pos($dh{AFTER}, @sequence) + 1;
+               # Write a dummy log entry indicating that the specified
+               # command was, in fact, run. This handles the case where
+               # no commands remain to run after it, communicating to
+               # future dh instances that the specified command should not
+               # be run again.
+               writelog($package, $sequence[$startpoint{$package}-1]);
        }
        elsif ($dh{REMAINING}) {
                # Start at the beginning so all remaining commands will get
@@ -352,11 +359,6 @@ sub run {
        my $command=shift;
        my @options=@_;
        
-       # dh_clean -k is a special case
-       if ($command eq 'dh_clean' && $sequence ne 'clean') {
-               unshift @options, "-k";
-       }
-
        # If a third party command is not in /usr/bin, don't try to run it.
        if ($thirdparty{$command} && ! -x "/usr/bin/$command") {
                return;
@@ -390,6 +392,16 @@ sub loadlog {
        close LOG;
        return @log;
 }
+               
+sub writelog {
+       my $package=shift;
+       my $cmd=shift;
+       my $ext=pkgext($package);
+       
+       open(LOG, ">>", "debian/${ext}debhelper.log") || error("failed to write to log");
+       print LOG $cmd."\n";
+       close LOG;
+}
 
 =head1 SEE ALSO
 
index a08b0b3633792d78081a5edd945eaa7121386b9e..78e43c36f6819499a90421f4eae12adda8ac6d28 100755 (executable)
--- a/dh_clean
+++ b/dh_clean
@@ -33,13 +33,8 @@ The debian/clean file can list other files to be removed.
 
 =item B<-k>, B<--keep>
 
-Do not delete debian/files, or files listed in debian/clean. When do you
-want to use this? Anytime you have a debian/rules that has 2 binary targets
-that build different .deb packages; for example, one target is binary-arch,
-and the other is binary-indep, or one target builds the shared library, and
-the other the -dev package. If you didn't use -k in these cases, then
-debian/files would be deleted in the middle, and your changes file will
-only contain the last binary package that was built.
+This causes L<dh_prep(1)> to be run instead of dh_clean, for backwards
+compatibility.
 
 =item B<-d>, B<--dirs-only>
 
@@ -61,6 +56,12 @@ Delete these files too.
 =cut
 
 init();
+inhibit_log();
+
+if ($dh{K_FLAG}) {
+       # dh_prep will be emulated (mostly) by the code below.
+       # TODO deprecation warning
+}
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
        my $tmp=tmpdir($package);
index 073cbb2b4de57bfeb4f8e8559ef8f7c36f4dd35d..e7ead755e71c17094c55e53e1e383865ebf350db 100755 (executable)
@@ -53,7 +53,7 @@ Do not modify F<postinst>/F<postrm>/F<prerm> scripts.
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be
+Note that this command is not idempotent. L<dh_prep(1)> should be
 called between invocations of this command. Otherwise, it may cause
 multiple instances of the same text to be added to maintainer scripts.
 
index 35672369f319c8c6c37d8fe45351e5187f57ca2c..c20095c0d9f58daaf39f992a278d7932832a1976 100755 (executable)
@@ -90,7 +90,7 @@ Note that dh_installdocs will happily copy entire directory hierarchies if
 you ask it to (similar to cp -a). If it is asked to install a
 directory, it will install the complete contents of the directory.
 
-Note that this command is not idempotent. "dh_clean B<-k>" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index a9227ac204f25174d1c3019c792a58de9afe3ba3..ca0feb6ad7334aff10d7b363d99d662adadb5467 100755 (executable)
@@ -53,7 +53,7 @@ Sets the flavor a site-start.d file will be installed in. Default is
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index e8ef2e0ea28d06e1d312ee1ceff37e35a1d3dfbd..3e6ce87aed9e75442c9739cac0b4d638f53dad83 100755 (executable)
@@ -56,7 +56,7 @@ all packages if -A is specified).
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index 952e2d35096b507958ba1cd6b5abe2f2504d5aa7..248d517f0b1c90e4d6074b24d1ba7563f7bb14c9 100755 (executable)
@@ -98,7 +98,7 @@ function should be provided in the prerm and postinst scripts, before the
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index a1b1b6b105876e2d347436a65005693b3036986d..18abe162ac3556198e5a20cf04ee6ca158b237cd 100755 (executable)
@@ -40,7 +40,7 @@ Do not modify postinst/postrm scripts.
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index 2d1d596945de519f02213bc553a48764438c8e70..6a08eb774bb194cad2d2da588258eedd85157a87 100755 (executable)
@@ -55,7 +55,7 @@ debian/package.modules and debian/package.modprobe
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index 44f3177ac97365b6877ed7cdd65f8abcd575b75f..e5108555c42e3ba676f53f6115882207e2e4f982 100755 (executable)
@@ -45,7 +45,7 @@ Do not modify postinst/postrm scripts.
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index 488258b60a9535022655d02bf0d856141cfc60d9..8fbe5f0a09dcbda813991e8b304accfbb6a81c8c 100755 (executable)
@@ -50,7 +50,7 @@ register.
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
diff --git a/dh_prep b/dh_prep
new file mode 100755 (executable)
index 0000000..747c9c7
--- /dev/null
+++ b/dh_prep
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_prep - preform cleanups in preparation for building a binary package
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_prep> [S<I<debhelper options>>] [B<-X>I<item>]
+
+=head1 DESCRIPTION
+
+dh_prep is a debhelper program that performs some file cleanups in
+preparation for building a package. (This is what dh_clean -k used to do.)
+It removes the package build directories, debian/tmp, and some temp files
+that are generated during the build. Putting this at the start of the build
+process makes the build process idempotent.
+
+=head1 OPTIONS
+
+=item B<-X>I<item> B<--exclude=>I<item>
+
+Exclude files that contain "item" anywhere in their filename from being
+deleted, even if they would normally be deleted. You may use this option
+multiple times to build up a list of things to exclude.
+
+=back
+
+=cut
+
+init();
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+       my $tmp=tmpdir($package);
+       my $ext=pkgext($package);
+
+       doit("rm","-f","debian/${ext}substvars")
+               unless excludefile("debian/${ext}substvars");
+               
+       # These are all debhelper temp files, and so it is safe to 
+       # wildcard them.
+       complex_doit("rm -f debian/$ext*.debhelper");
+       
+       doit ("rm","-rf",$tmp."/")
+               unless excludefile($tmp);
+}
+
+doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' && ! compat(1) &&
+                                   ! excludefile("debian/tmp");
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Joey Hess <joeyh@debian.org>
+
+=cut
index 1c7924926b4fc419b7c01903ddd8bac9816ec535..d2e2145e89904e712da24e994c997792118494a2 100755 (executable)
@@ -41,7 +41,7 @@ Do not modify F<postinst>/F<postrm> scripts.
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be
+Note that this command is not idempotent. L<dh_prep(1)> should be
 called between invocations of this command. Otherwise, it may cause
 multiple instances of the same text to be added to maintainer scripts.
 
index a82e21ca8e47b975f32dddeabad9a7cbf76d1787..db7dfcd8b25b0b6d14bcdf7431cac54ea172ffc8 100755 (executable)
@@ -48,7 +48,7 @@ Do not modify F<postinst>/F<prerm> scripts.
 
 =head1 NOTES
 
-Note that this command is not idempotent. "dh_clean -k" should be called
+Note that this command is not idempotent. L<dh_prep(1)> should be called
 between invocations of this command. Otherwise, it may cause multiple
 instances of the same text to be added to maintainer scripts.
 
index e45e243c53530f52e5ba4eabd0d7cc2a95105ea9..17d7a189e3b82602d9a3f3ba07cf7e9ca1f02222 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -53,3 +53,4 @@ Deprecated:
 * dh_undocumented
 * dh_installinit --init-script
 * dh_python
+* dh_clean -k (make it warn)
index 0324ef5dddffafce45ca65ff2f74ce13b69d832c..8e70ec0adf0d4ee3161341e5cd7c71ef99221fdd 100755 (executable)
@@ -30,7 +30,7 @@ clean:
 install: build
        dh_testdir
        dh_testroot
-       dh_clean -k
+       dh_prep
        dh_installdirs
 
        # Add here commands to install the package into debian/<packagename>
index 37c58e9fd50cd129083633204b854872d6d12f56..c80d416b71cae28e2da19f0bec92c8348cc8c214 100755 (executable)
@@ -30,7 +30,7 @@ clean:
 install: build
        dh_testdir
        dh_testroot
-       dh_clean -k
+       dh_prep
        dh_installdirs
 
        # Add here commands to install the package into debian/<packagename>.
index 11fc085ce22dd8e1026bf1f95f94781707bd54b9..db8ed1e0a11ae9e6fd8abe2a2c14cf59b694d788 100755 (executable)
@@ -33,7 +33,7 @@ install:
 install: build
        dh_testdir
        dh_testroot
-       dh_clean -k
+       dh_prep
        dh_installdirs
 
        # Add here commands to install the package into debian/tmp.
index 4767c48fdca2db589fd1f8ba5fc3049733ee4091..7ed56fb80da1d8ee2830036f6c18dc3cc6e7a7a3 100755 (executable)
@@ -35,7 +35,7 @@ install: DH_OPTIONS=
 install: build
        dh_testdir
        dh_testroot
-       dh_clean -k
+       dh_prep
        dh_installdirs
 
        # Add here commands to install the package into debian/tmp.