summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-05-18 10:48:46 -0400
committerJoey Hess <joey@kitenet.net>2013-05-18 10:48:46 -0400
commite004f193b15b7d1f2b398f8469de74b1d45e67be (patch)
tree4b4caeb984e1b93cfcc99d81a4e308bf2f081dd8
parente069a27b2a8348d39b06a2911418d73336bdf86f (diff)
only run slower changelog splitting code in binNMU mode
-rwxr-xr-xdh_installchangelogs62
1 files changed, 35 insertions, 27 deletions
diff --git a/dh_installchangelogs b/dh_installchangelogs
index 1e3dbeb3..ae61f1ee 100755
--- a/dh_installchangelogs
+++ b/dh_installchangelogs
@@ -78,47 +78,50 @@ Install this file as the upstream changelog.
=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
-{
+# For binNMUs the first changelog entry is written into an extra file to
+# keep the packages coinstallable.
+sub install_binNMU_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: $!");
-
+ open (my $input, "<", $input_fn);
my $line=<$input>;
- if ($line =~ /\A\S.*;.*\bbinary-only=yes/) {
+ if (defined $line && $line =~ /\A\S.*;.*\bbinary-only=yes/) {
+ my $mask=umask 0022;
+
+ my @stat=stat $input_fn or error("could not stat $input_fn: $!");
+ my $tmp=tmpdir($package);
+ my $output_fn="$tmp/usr/share/doc/$package/$changelog_name";
+ open my $output, ">", $output_fn
+ or error("could not open $output_fn for writing: $!");
+ my $arch=package_arch($package);
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>));
+ 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;
- 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;
- umask $mask;
+ return 1;
+ }
+ else {
+ close $input;
+ return 0;
+ }
}
init();
@@ -182,7 +185,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
if (! -d "$tmp/usr/share/doc/$package") {
doit("install","-d","$tmp/usr/share/doc/$package");
}
- install_changelog($package, $changelog, $changelog_name);
+
+ if (! install_binNMU_changelog($package, $changelog, $changelog_name)) {
+ doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
+ "$tmp/usr/share/doc/$package/$changelog_name");
+ }
+
if (-e $news) {
doit("install","-o",0,"-g",0,"-p","-m644",$news,
"$tmp/usr/share/doc/$package/$news_name");