[debhelper-devel] [debhelper] 01/01: dh+compat 10: Drop sequence ctrl and logs

Niels Thykier nthykier at moszumanska.debian.org
Sat Jan 9 16:12:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit bca06f8d784fb0d6ac6f1358fc1ea2366fbb774e
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Jan 9 10:28:52 2016 +0000

    dh+compat 10: Drop sequence ctrl and logs
    
    In compat 10, drop the manual sequence ctrl arguments and the
    debhelper sequence logs.  Instead do a simple stamp file to skip the
    build part if already done.
    
    The primary advantage is that now the binary target can trivially be
    re-run, which makes debugging easier/faster.
    
    Closes: #510855
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm |  2 +-
 debhelper.pod              | 44 +++++++++++++++++++++++++++++++++++
 debian/changelog           |  2 ++
 dh                         | 58 +++++++++++++++++++++++++++++++++++++++++-----
 dh_clean                   |  3 +++
 5 files changed, 102 insertions(+), 7 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 09e97bb..3d846b6 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -124,7 +124,7 @@ sub init {
 # on, if it's exiting successfully.
 my $write_log=1;
 sub END {
-	if ($? == 0 && $write_log) {
+	if ($? == 0 && $write_log && (compat(9) || $ENV{DH_INTERNAL_OVERRIDE})) {
 		write_log(basename($0), @{$dh{DOPACKAGES}});
 	}
 }
diff --git a/debhelper.pod b/debhelper.pod
index 858da13..ffd3228 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -545,6 +545,50 @@ Debhelper will default to B<--parallel> for all buildsystems that
 support parallel building.  This can be disabled by using either
 B<--no-parallel> or passing B<--max-parallel> with a value of 1.
 
+=item -
+
+The B<dh> command will not accept any of the deprecated "manual
+sequence control" parameters (B<--before>, B<--after>, etc.).  Please
+migrate to use override targets instead.
+
+=item -
+
+The B<dh> command will no longer use log files to track which commands
+have been run.  The B<dh> command I<still> keeps track of whether it
+already ran the "build" sequence and skip it if it did.
+
+The main affects of this are:
+
+=over 4
+
+=item -
+
+With this, it is now easier to debug the I<install> or/and I<binary>
+sequences because they can now trivially be re-run (without having to
+do a full "clean and rebuild" cycle)
+
+=item -
+
+The main caveat is that the B<--remaining> option for B<dh_*> now only
+keeps track of what happened in a single override target.  When all
+the calls to a given B<dh_cmd> command happens in the same override
+target every thing will work as before.
+
+Example of where it can go wrong:
+
+  override_dh_foo:
+    dh_foo -pmy-pkg
+
+  override_dh_bar:
+    dh_bar
+    dh_foo --remaining
+
+In this case, the call to B<dh_foo --remaining> will I<also> include
+I<my-pkg>, since B<dh_foo -pmy-pkg> was run in a separate override
+target.  If they are run from the same override target, it will work j
+
+=back
+
 =back
 
 =back
diff --git a/debian/changelog b/debian/changelog
index 144365e..9154866 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ debhelper (9.20151225+unreleased) UNRELEASED; urgency=medium
     does not start with debian/tmp.  This should make the
     output on failures less weird.
   * autoscripts/*-makeshlibs: Removed, no longer used.
+  * dh: In compat 10, drop the manual sequence control arguments
+    and the sequence log files.  (Closes: #510855)
 
   [ Dmitry Shachnev ]
   * dh_install: Fail because of missing files only after processing
diff --git a/dh b/dh
index 4d93563..4cf4515 100755
--- a/dh
+++ b/dh
@@ -249,7 +249,8 @@ option to ensure they only work on architecture dependent packages.
 =head1 DEPRECATED OPTIONS
 
 The following options are deprecated. It's much 
-better to use override targets instead.
+better to use override targets instead.  They are B<not> available
+in compat 10.
 
 =over 4
 
@@ -354,16 +355,19 @@ if ($sequence eq 'debian/rules' ||
 
 
 # Definitions of sequences.
+my $build_stamp_file = 'debian/debhelper-build-stamp';
 my %sequences;
 my @bd_minimal = qw{
 	dh_testdir
 };
-my @bd = qw{
+my @bd = (qw{
 	dh_testdir
 	dh_auto_configure
 	dh_auto_build
 	dh_auto_test
-};
+},
+	"create-stamp ${build_stamp_file}",
+);
 my @i = (qw{
 	dh_testroot
 	dh_prep
@@ -621,8 +625,25 @@ while (@ARGV_orig) {
 # Figure out at what point in the sequence to start for each package.
 my %logged;
 my %startpoint;
+my %stamp_file;
+
+if ( -f $build_stamp_file) {
+	open(my $fd, '<', $build_stamp_file) or error("open($build_stamp_file, ro) failed: $!");
+	while (my $line = <$fd>) {
+		chomp($line);
+		$stamp_file{$line} = 1;
+	}
+	close($fd);
+}
+
 foreach my $package (@packages) {
-	my @log=load_log($package, \%logged);
+	my @log;
+	if (compat(9)) {
+		@log = load_log($package, \%logged);
+	} elsif (exists($stamp_file{$package})) {
+		@log = @bd;
+		# We do not need %logged in compat 10
+	}
 	if ($dh{AFTER}) {
 		# Run commands in the sequence that come after the
 		# specified command.
@@ -691,6 +712,18 @@ foreach my $i (0..$stoppoint) {
 		run("debian/rules", $rules_target);
 		next;
 	}
+	if (my $stamp_file = stamp_target($command)) {
+		my @contents;
+		open(my $fd, '+>>', $stamp_file) or error("open($stamp_file, rw) failed: $!");
+		# Seek to the beginning
+		seek($fd, 0, 0) or error("seek($stamp_file) failed: $!");
+		@contents = map { chomp } <$fd>;
+		for my $pkg (@todo) {
+			print {$fd} "$pkg\n";
+		}
+		close($fd) or error("close($stamp_file) failed: $!");
+		next;
+	}
 	
 	# Check for override targets in debian/rules, and run instead of
 	# the usual command. (The non-arch-specific override is tried first,
@@ -804,12 +837,13 @@ sub run_override {
 	run("debian/rules", $override);
 	delete $ENV{DH_INTERNAL_OPTIONS};
 	delete $ENV{DH_INTERNAL_OVERRIDE};
+	complex_doit("rm","-f","debian/*.debhelper.log") if not compat(9);
 
 	# Update log for overridden command now that it has
 	# finished successfully.
 	# (But avoid logging for dh_clean since it removes
 	# the log earlier.)
-	if (! $dh{NO_ACT} && $command ne 'dh_clean') {
+	if (! $dh{NO_ACT} && $command ne 'dh_clean' && compat(9)) {
 		write_log($command, @todo);
 		commit_override_log(@todo);
 	}
@@ -853,6 +887,14 @@ sub rules_target {
 	}
 }
 
+sub stamp_target {
+	my ($command) = @_;
+	if ($command =~ s/^create-stamp\s+//) {
+		return $command;
+	}
+	return;
+}
+
 sub rules {
 	return "debian/rules ".join(" ", @_);
 }
@@ -922,7 +964,11 @@ sub rules_explicit_target {
 sub warn_deprecated {
 	foreach my $deprecated ('until', 'after', 'before', 'remaining') {
 		if (defined $dh{uc $deprecated}) {
-			warning("The --$deprecated option is deprecated. Use override targets instead.");
+			if (compat(9)) {
+				warning("The --$deprecated option is deprecated. Use override targets instead.");
+			} else {
+				error("The --$deprecated option is not supported in compat 10+. Use override targets instead.");
+			}
 		}
 	}
 }
diff --git a/dh_clean b/dh_clean
index 38dc04a..666766d 100755
--- a/dh_clean
+++ b/dh_clean
@@ -93,6 +93,9 @@ if ($dh{K_FLAG}) {
 	warning("dh_clean -k is deprecated; use dh_prep instead");
 }
 
+# Remove the debhelper stamp file
+doit('rm', '-f', 'debian/debhelper-build-stamp') if not $dh{D_FLAG};
+
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp=tmpdir($package);
 	my $ext=pkgext($package);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list