summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-04-23 22:49:22 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-04-23 22:49:22 -0400
commit4f8a46b36e961d1a64d466a63f3a7ef6c90bafe2 (patch)
tree5bbb9dde41b2c9d87c7b544e7e3adeded0b7863d
parent28f84cd5c972f683506bee5f201cd93a2c09ee56 (diff)
dh_prep: New program, does the same as dh_clean -k (which will be deprecated later).
-rw-r--r--Debian/Debhelper/Dh_Lib.pm24
-rw-r--r--debian/changelog2
-rwxr-xr-xdh24
-rwxr-xr-xdh_clean15
-rwxr-xr-xdh_installcatalogs2
-rwxr-xr-xdh_installdocs2
-rwxr-xr-xdh_installemacsen2
-rwxr-xr-xdh_installinfo2
-rwxr-xr-xdh_installinit2
-rwxr-xr-xdh_installmime2
-rwxr-xr-xdh_installmodules2
-rwxr-xr-xdh_installudev2
-rwxr-xr-xdh_installwm2
-rwxr-xr-xdh_prep66
-rwxr-xr-xdh_scrollkeeper2
-rwxr-xr-xdh_usrlocal2
-rw-r--r--doc/TODO1
-rwxr-xr-xexamples/rules.arch2
-rwxr-xr-xexamples/rules.indep2
-rwxr-xr-xexamples/rules.multi2
-rwxr-xr-xexamples/rules.multi22
21 files changed, 123 insertions, 39 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index c83e42b2..badbe87e 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -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.
diff --git a/debian/changelog b/debian/changelog
index 00bdeedf..6b91af5d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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 ab814d7f..330b0152 100755
--- 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
diff --git a/dh_clean b/dh_clean
index a08b0b36..78e43c36 100755
--- 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);
diff --git a/dh_installcatalogs b/dh_installcatalogs
index 073cbb2b..e7ead755 100755
--- a/dh_installcatalogs
+++ b/dh_installcatalogs
@@ -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.
diff --git a/dh_installdocs b/dh_installdocs
index 35672369..c20095c0 100755
--- a/dh_installdocs
+++ b/dh_installdocs
@@ -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.
diff --git a/dh_installemacsen b/dh_installemacsen
index a9227ac2..ca0feb6a 100755
--- a/dh_installemacsen
+++ b/dh_installemacsen
@@ -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.
diff --git a/dh_installinfo b/dh_installinfo
index e8ef2e0e..3e6ce87a 100755
--- a/dh_installinfo
+++ b/dh_installinfo
@@ -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.
diff --git a/dh_installinit b/dh_installinit
index 952e2d35..248d517f 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -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.
diff --git a/dh_installmime b/dh_installmime
index a1b1b6b1..18abe162 100755
--- a/dh_installmime
+++ b/dh_installmime
@@ -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.
diff --git a/dh_installmodules b/dh_installmodules
index 2d1d5969..6a08eb77 100755
--- a/dh_installmodules
+++ b/dh_installmodules
@@ -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.
diff --git a/dh_installudev b/dh_installudev
index 44f3177a..e5108555 100755
--- a/dh_installudev
+++ b/dh_installudev
@@ -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.
diff --git a/dh_installwm b/dh_installwm
index 488258b6..8fbe5f0a 100755
--- a/dh_installwm
+++ b/dh_installwm
@@ -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
index 00000000..747c9c70
--- /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
diff --git a/dh_scrollkeeper b/dh_scrollkeeper
index 1c792492..d2e2145e 100755
--- a/dh_scrollkeeper
+++ b/dh_scrollkeeper
@@ -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.
diff --git a/dh_usrlocal b/dh_usrlocal
index a82e21ca..db7dfcd8 100755
--- a/dh_usrlocal
+++ b/dh_usrlocal
@@ -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.
diff --git a/doc/TODO b/doc/TODO
index e45e243c..17d7a189 100644
--- 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)
diff --git a/examples/rules.arch b/examples/rules.arch
index 0324ef5d..8e70ec0a 100755
--- a/examples/rules.arch
+++ b/examples/rules.arch
@@ -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>
diff --git a/examples/rules.indep b/examples/rules.indep
index 37c58e9f..c80d416b 100755
--- a/examples/rules.indep
+++ b/examples/rules.indep
@@ -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>.
diff --git a/examples/rules.multi b/examples/rules.multi
index 11fc085c..db8ed1e0 100755
--- a/examples/rules.multi
+++ b/examples/rules.multi
@@ -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.
diff --git a/examples/rules.multi2 b/examples/rules.multi2
index 4767c48f..7ed56fb8 100755
--- a/examples/rules.multi2
+++ b/examples/rules.multi2
@@ -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.