From: Joey Hess Date: Thu, 24 Apr 2008 02:49:22 +0000 (-0400) Subject: dh_prep: New program, does the same as dh_clean -k (which will be deprecated later). X-Git-Tag: 7.0.0~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4f8a46b36e961d1a64d466a63f3a7ef6c90bafe2;p=debhelper.git dh_prep: New program, does the same as dh_clean -k (which will be deprecated later). --- diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index c83e42b..badbe87 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 00bdeed..6b91af5 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 Tue, 22 Apr 2008 17:54:20 -0400 diff --git a/dh b/dh index ab814d7..330b015 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 a08b0b3..78e43c3 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 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 073cbb2..e7ead75 100755 --- a/dh_installcatalogs +++ b/dh_installcatalogs @@ -53,7 +53,7 @@ Do not modify F/F/F scripts. =head1 NOTES -Note that this command is not idempotent. "dh_clean -k" should be +Note that this command is not idempotent. L 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 3567236..c20095c 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 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 a9227ac..ca0feb6 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 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 e8ef2e0..3e6ce87 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 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 952e2d3..248d517 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 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 a1b1b6b..18abe16 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 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 2d1d596..6a08eb7 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 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 44f3177..e510855 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 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 488258b..8fbe5f0 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 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 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 [S>] [B<-X>I] + +=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 B<--exclude=>I + +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 + +This program is a part of debhelper. + +=head1 AUTHOR + +Joey Hess + +=cut diff --git a/dh_scrollkeeper b/dh_scrollkeeper index 1c79249..d2e2145 100755 --- a/dh_scrollkeeper +++ b/dh_scrollkeeper @@ -41,7 +41,7 @@ Do not modify F/F scripts. =head1 NOTES -Note that this command is not idempotent. "dh_clean -k" should be +Note that this command is not idempotent. L 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 a82e21c..db7dfcd 100755 --- a/dh_usrlocal +++ b/dh_usrlocal @@ -48,7 +48,7 @@ Do not modify F/F scripts. =head1 NOTES -Note that this command is not idempotent. "dh_clean -k" should be called +Note that this command is not idempotent. L 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 e45e243..17d7a18 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 0324ef5..8e70ec0 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/ diff --git a/examples/rules.indep b/examples/rules.indep index 37c58e9..c80d416 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/. diff --git a/examples/rules.multi b/examples/rules.multi index 11fc085..db8ed1e 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 4767c48..7ed56fb 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.