diff options
author | Niels Thykier <niels@thykier.net> | 2019-09-29 20:48:48 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2019-09-29 20:48:52 +0000 |
commit | c07134c6a844e9b5cc3a44748ba35fa6916cff9d (patch) | |
tree | abcaff5d1bb4c440677b49a9a42bc7512d47fadf /dh_installman | |
parent | 488e6310d5c512b12079f4b353c039deefca3dea (diff) | |
download | debhelper-c07134c6a844e9b5cc3a44748ba35fa6916cff9d.tar.gz |
dh_installman: Use man-recode(1) when present
It is a lot faster for any package with a non-trivial amount of
manpages-
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_installman')
-rwxr-xr-x | dh_installman | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/dh_installman b/dh_installman index 55a13fa5..461764d0 100755 --- a/dh_installman +++ b/dh_installman @@ -272,6 +272,9 @@ on_items_in_parallel(\@all_packages, sub { }); # Now utf-8 conversion. +my $has_man_recode = 0; +$has_man_recode = 1 if has_man_db_tool('man-recode'); + if (has_man_db_tool('man')) { my (@manpages_to_reencode, @issues); for my $package (@{$dh{DOPACKAGES}}) { @@ -296,19 +299,7 @@ if (has_man_db_tool('man')) { } } if (@manpages_to_reencode) { - on_items_in_parallel(\@manpages_to_reencode, sub { - for my $manpage (@_) { - my $manpage_tmp = "${manpage}.dh-new"; - my $manpage_cmd = ($manpage =~ m{^/}) ? $manpage : "./${manpage}"; - doit({ stdout => $manpage_tmp }, 'man', '-l', '--recode', 'UTF-8', $manpage_cmd); - # recode uncompresses compressed pages - my $orig = $manpage; - rm_files($orig) if $manpage =~ s/\.(gz|Z)$//; - rename_path($manpage_tmp, $manpage); - } - # Bulk reset permissions of all re-encoded files - xargs(\@_, 'chmod', '0644', '--'); - }); + on_items_in_parallel(\@manpages_to_reencode, \&reencode_manpages); } } else { # Should only occur during debhelper building itself (to avoid a B-D on man-db). @@ -370,6 +361,26 @@ sub has_man_db_tool { return $res; } +sub reencode_manpages { + my (@manpages) = @_; + if ($has_man_recode) { + xargs(\@manpages, 'man-recode', '--to-code', 'UTF-8', '--suffix', '.dh-new'); + } + for my $manpage (@manpages) { + my $manpage_tmp = "${manpage}.dh-new"; + if (not $has_man_recode) { + my $manpage_cmd = ($manpage =~ m{^/}) ? $manpage : "./${manpage}"; + doit({ stdout => $manpage_tmp }, 'man', '-l', '--recode', 'UTF-8', $manpage_cmd); + } + # recode uncompresses compressed pages + my $orig = $manpage; + rm_files($orig) if $manpage =~ s/\.(gz|Z)$//; + rename_path($manpage_tmp, $manpage); + } + # Bulk reset permissions of all re-encoded files + xargs(\@manpages, 'chmod', '0644', '--'); +} + =head1 SEE ALSO L<debhelper(7)> |