Package: debhelper
Tags: patch
X-Debbugs-Cc: debian-rele...@lists.debian.org

[ CC'ed -release as they handle binNMUs and should be the most
  interested party in having a fix. ]

binNMUs for multiarch packages are currently broken as the changelog
will differ between architectures. There are several options to fix this
(split changelog, move changelog from usr/share/doc to DEBIAN/), however
there doesn't seem to be a consensus on the final solution yet.

As development on Wheezy and thus transitions and binNMUs started, I
would like to have at least an intermediate solution so that packages
remain installable and users don't have to fix issues by hand. I
suggested this on -devel in [1].

  [1] <https://lists.debian.org/debian-devel/2013/05/msg00738.html>

The attached patch does split the binNMU into an extra file name
changelog(.Debian).<arch>.gz. There are some limitations:

No changelog is generated if /usr/share/doc/<package> is a symlink. If
it points to an arch:all package, there will be no binNMU changelog
entry at all. I think this is acceptable for an intermediate solution.

The regular expression might match very old changelog entries that do
not use the current changelog format. I think that's fairly unlikely.

As mentioned in my mail to -devel@ this also requires buildds to add
"binary-only=yes" to changelog entries (#681292).

Ansgar
diff -Nru debhelper-9.20130509/dh_installchangelogs debhelper-9.20130509+nmu1/dh_installchangelogs
--- debhelper-9.20130509/dh_installchangelogs	2011-09-12 18:01:19.000000000 +0200
+++ debhelper-9.20130509+nmu1/dh_installchangelogs	2013-05-14 11:10:39.000000000 +0200
@@ -78,6 +78,50 @@
 
 =cut
 
+sub install_changelog
+{
+  my ($package, $input_fn, $changelog_name) = @_;
+
+  my $arch = package_arch($package);
+  my $tmp = tmpdir($package);
+  my $output_fn = "$tmp/usr/share/doc/$package/$changelog_name";
+  my $mask = umask 0022;
+  my @stat = stat $input_fn or error("could not stat $input_fn: $!");
+
+  open my $input, "<", $input_fn
+      or error("could not read $input_fn: $!");
+  open my $output_all, ">", $output_fn
+      or error("could not open $output_fn for writing: $!");
+  my $output_fn_binary = "$output_fn.$arch";
+  my $output_binary = undef;
+
+  my $output = $output_all;
+  while (my $line = <$input>) {
+    if ($line =~ /\A\S.*;.*\bbinary-only=yes/) {
+      if (! defined $output_binary) {
+        open $output_binary, ">", $output_fn_binary
+            or error("could not open $output_fn_binary for writing: $!");
+      }
+      $output = $output_binary;
+    }
+    elsif ($line =~ /\A\S/) {
+      $output = $output_all;
+    }
+
+    print {$output} $line;
+  }
+
+  close $input;
+  close $output;
+  utime $stat[8], $stat[9], $output_fn;
+  if (defined $output_binary) {
+    close $output_binary;
+    utime $stat[8], $stat[9], $output_fn_binary;
+  }
+
+  umask $mask;
+}
+
 init();
 
 my $upstream=shift;
@@ -139,8 +183,7 @@
 	if (! -d "$tmp/usr/share/doc/$package") {
 		doit("install","-d","$tmp/usr/share/doc/$package");
 	}
-	doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
-		"$tmp/usr/share/doc/$package/$changelog_name");
+	install_changelog($package, $changelog, $changelog_name);
 	if (-e $news) {
 		doit("install","-o",0,"-g",0,"-p","-m644",$news,
 			"$tmp/usr/share/doc/$package/$news_name");

Reply via email to