Joey Hess <jo...@debian.org> writes:
> Ansgar Burchardt wrote:
>> 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.
>
> Isn't this just a special case of the larger problem that multiarch
> falls over when any shared file varies, including other files in 
> /usr/share/doc?
> It seems odd that none of these proposed solutions deal with the larger
> problem.

Yes, but it's the only one that is currently guaranteed to happen.

>> +sub install_changelog
>> +{
>> +  my ($package, $input_fn, $changelog_name) = @_;
> <snip 41 lines>
>
> This is not following debhelper's code formatting style.

Right, it started as a proof of concept to see how much work this is. I
have changed the code formatting as far as I could get it from the other
code.

> It's also not following debhelper's design to put such a lot of code into
> a debhelper command. This deserves to be its own utility, which
> dh_installchangelogs can run, and packages not using debhelper could also run.
> dpkg-dev seems a good place to put such a thing.
>
> Not that I want to put up roadblocks to a pragmatic fix getting in place.

A more permanent solution shouldn't be implemented (only) in
debhelper. But I'm not sure it's worth doing so for an intermediate
solution? It would give more resistance to later changes as then
coordination between multiple packages might be needed.

>> +  while (my $line = <$input>) {
>> +    if ($line =~ /\A\S.*;.*\bbinary-only=yes/) {
>
> Considering the length of some changelogs, and that this should only
> ever appear on the first line of the file, this is a pretty inneficcient
> implementation. It could be sped up a lot I think by just checking the first
> line and falling back to the current copy method.

I changed it such that the regular expressions are only checked for the
first entry.

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 19:26:54.000000000 +0200
@@ -78,6 +78,49 @@
 
 =cut
 
+# Install a changelog into a package.
+# For binNMUs the first changelog entry is written into an extra file to keep
+# the packages coinstallable.
+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, ">", $output_fn
+		or error("could not open $output_fn for writing: $!");
+
+	my $line=<$input>;
+	if ($line =~ /\A\S.*;.*\bbinary-only=yes/) {
+		my $output_fn_binary="$output_fn.$arch";
+		open my $output_binary, ">", $output_fn_binary
+			or error("could not open $output_fn_binary for writing: $!");
+		do {
+			print {$output_binary} $line
+				or error("Could not write to $output_fn_binary: $!");
+		} while(defined($line=<$input>) && $line !~ /\A\S/);
+		close $output_binary or error("Couldn't close $output_fn_binary: $!");
+		utime $stat[8], $stat[9], $output_fn_binary;
+	}
+
+	do {
+		print {$output} $line
+			or error("Could not write to $output_fn: $!");
+	} while(defined($line=<$input>));
+
+	close $input or error("Couldn't close $input_fn: $!");
+	close $output or error("Couldn't close $output_fn: $!");
+	utime $stat[8], $stat[9], $output_fn;
+
+	umask $mask;
+}
+
 init();
 
 my $upstream=shift;
@@ -139,8 +182,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