&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;
# 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.
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
my @ARGV_orig=@ARGV;
init();
+inhibit_log();
# Definitions of sequences.
my %sequences;
}];
$sequences{install} = [@{$sequences{build}}, qw{
dh_testroot
- dh_clean
+ dh_prep
dh_installdirs
dh_auto_install
# 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
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;
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
=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>
=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);
=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.
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.
=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.
=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.
=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.
=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.
=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.
=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.
=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.
--- /dev/null
+#!/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
=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.
=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.
* dh_undocumented
* dh_installinit --init-script
* dh_python
+* dh_clean -k (make it warn)
install: build
dh_testdir
dh_testroot
- dh_clean -k
+ dh_prep
dh_installdirs
# Add here commands to install the package into debian/<packagename>
install: build
dh_testdir
dh_testroot
- dh_clean -k
+ dh_prep
dh_installdirs
# Add here commands to install the package into debian/<packagename>.
install: build
dh_testdir
dh_testroot
- dh_clean -k
+ dh_prep
dh_installdirs
# Add here commands to install the package into debian/tmp.
install: build
dh_testdir
dh_testroot
- dh_clean -k
+ dh_prep
dh_installdirs
# Add here commands to install the package into debian/tmp.