diff options
Diffstat (limited to 'dh_installchangelogs')
-rwxr-xr-x | dh_installchangelogs | 130 |
1 files changed, 63 insertions, 67 deletions
diff --git a/dh_installchangelogs b/dh_installchangelogs index b5e26a7d..5ae9be3a 100755 --- a/dh_installchangelogs +++ b/dh_installchangelogs @@ -10,6 +10,8 @@ use strict; use warnings; use Debian::Debhelper::Dh_Lib; +our $VERSION = DH_BUILTIN_VERSION; + =head1 SYNOPSIS B<dh_installchangelogs> [S<I<debhelper options>>] [B<-k>] [B<-X>I<item>] [I<upstream>] @@ -97,7 +99,7 @@ sub install_binNMU_changelog { 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 $arch=package_binary_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: $!"); @@ -118,8 +120,9 @@ sub install_binNMU_changelog { close $output or error("Couldn't close $output_fn: $!"); utime $stat[8], $stat[9], $output_fn; - chown 0, 0, $output_fn, $output_fn_binary - or error "chown: $!"; + if (should_use_root()) { + chown(0, 0, $output_fn, $output_fn_binary) or error("chown: $!"); + } umask $mask; @@ -146,7 +149,7 @@ if (! defined $upstream) { foreach my $suffix ('', qw(.txt .md .rst)) { foreach my $name (qw{changelog changes history}) { my @matches=grep { - lc basename($_) eq "$name$suffix" && -s $_ && ! excludefile($_) + lc basename($_) eq "$name$suffix" && -f $_ && -s _ && ! excludefile($_) } @files; if (@matches) { $upstream=shift @matches; @@ -166,77 +169,76 @@ elsif ($upstream=~m/\.html?$/i) { $upstream_text=shift; } -foreach my $package (@{$dh{DOPACKAGES}}) { - next if is_udeb($package); +on_pkgs_in_parallel { + foreach my $package (@_) { + next if is_udeb($package); - my $tmp=tmpdir($package); - my $changelog=pkgfile($package,"changelog"); - my $news=pkgfile($package,"NEWS"); + my $tmp=tmpdir($package); + my $changelog=pkgfile($package,"changelog"); + my $news=pkgfile($package,"NEWS"); - if (!$changelog) { - $changelog="debian/changelog"; - } - if (!$news) { - $news="debian/NEWS"; - } + if (!$changelog) { + $changelog="debian/changelog"; + } + if (!$news) { + $news="debian/NEWS"; + } - if (! -e $changelog) { - error("could not find changelog $changelog"); - } + if (! -e $changelog) { + error("could not find changelog $changelog"); + } - # If it is a symlink to a documentation directory from the same - # source package, then don't do anything. Think multi-binary - # packages that depend on each other and want to link doc dirs. - if (-l "$tmp/usr/share/doc/$package") { - my $linkval=readlink("$tmp/usr/share/doc/$package"); - my %allpackages=map { $_ => 1 } getpackages(); - if ($allpackages{basename($linkval)}) { - next; + # If it is a symlink to a documentation directory from the same + # source package, then don't do anything. Think multi-binary + # packages that depend on each other and want to link doc dirs. + if (-l "$tmp/usr/share/doc/$package") { + my $linkval=readlink("$tmp/usr/share/doc/$package"); + my %allpackages=map { $_ => 1 } getpackages(); + if ($allpackages{basename($linkval)}) { + next; + } + # Even if the target doesn't seem to be a doc dir from the + # same source package, don't do anything if it's a dangling + # symlink. + next unless -d "$tmp/usr/share/doc/$package"; } - # Even if the target doesn't seem to be a doc dir from the - # same source package, don't do anything if it's a dangling - # symlink. - next unless -d "$tmp/usr/share/doc/$package"; - } - if (! -d "$tmp/usr/share/doc/$package") { install_dir("$tmp/usr/share/doc/$package"); - } - if (! $dh{NO_ACT}) { - if (! install_binNMU_changelog($package, $changelog, $changelog_name)) { - install_file($changelog, - "$tmp/usr/share/doc/$package/$changelog_name"); + if (! $dh{NO_ACT}) { + if (! install_binNMU_changelog($package, $changelog, $changelog_name)) { + install_file($changelog, + "$tmp/usr/share/doc/$package/$changelog_name"); + } } - } - - if (-e $news) { - install_file($news, "$tmp/usr/share/doc/$package/$news_name"); - } - if (defined $upstream) { - my $link_to; - my $base="$tmp/usr/share/doc/$package"; - if (defined $upstream_text) { - install_file($upstream_text, "$base/changelog"); - $link_to='changelog'; + if (-e $news) { + install_file($news, "$tmp/usr/share/doc/$package/$news_name"); } - if (defined $upstream_html) { - install_file($upstream_html,"$base/changelog.html"); - $link_to='changelog.html'; - if (! defined $upstream_text) { - complex_doit("echo 'See changelog.html.gz' > $base/changelog"); - doit("chmod","644","$base/changelog"); - doit("chown","0:0","$base/changelog"); + + if (defined $upstream) { + my $link_to; + my $base="$tmp/usr/share/doc/$package"; + if (defined $upstream_text) { + install_file($upstream_text, "$base/changelog"); + $link_to='changelog'; + } + if (defined $upstream_html) { + install_file($upstream_html,"$base/changelog.html"); + $link_to='changelog.html'; + if (! defined $upstream_text) { + complex_doit("echo 'See changelog.html.gz' > $base/changelog"); + reset_perm_and_owner(0644,"$base/changelog"); + } + } + if ($dh{K_FLAG}) { + # Install symlink to original name of the upstream changelog file. + # Use basename in case original file was in a subdirectory or something. + doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream)); } - } - if ($dh{K_FLAG}) { - # Install symlink to original name of the upstream changelog file. - # Use basename in case original file was in a subdirectory or something. - doit("ln","-sf",$link_to,"$tmp/usr/share/doc/$package/".basename($upstream)); } } -} +}; =head1 SEE ALSO @@ -249,9 +251,3 @@ This program is a part of debhelper. Joey Hess <joeyh@debian.org> =cut - -# Local Variables: -# indent-tabs-mode: t -# tab-width: 4 -# cperl-indent-level: 4 -# End: |