[debhelper-devel] [debhelper] 02/04: dh_installman: Run in parallel

Niels Thykier nthykier at moszumanska.debian.org
Sat Jun 24 12:32:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit dad4760a29685bee1a468d5ca163f928cec927c0
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Jun 24 11:40:49 2017 +0000

    dh_installman: Run in parallel
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |   1 +
 dh_installman    | 230 ++++++++++++++++++++++++++++---------------------------
 2 files changed, 118 insertions(+), 113 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 518031c..ee475c7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,6 +28,7 @@ debhelper (10.5) UNRELEASED; urgency=medium
     permits it.
   * dh_installchangelogs: Ditto.
   * dh_compress: Ditto
+  * dh_installman: Ditto
   * dh_shlibdeps: Avoid calling file(1) on debug symbols.
   * SUPPORT-POLICY: Include new document that describes the current
     support policy of debhelper compat levels.
diff --git a/dh_installman b/dh_installman
index e8edc6a..29f93f7 100755
--- a/dh_installman
+++ b/dh_installman
@@ -118,138 +118,142 @@ init(options => {
 	"language=s" => \$dh{LANGUAGE},
 });
 
-my @sofiles;
-my @sodests;
 
 # PROMISE: DH NOOP WITHOUT manpages tmp(usr/share/man)
 
-foreach my $package (getpackages()) {
-	next if is_udeb($package);
+my (@sofiles, @sodests);
+my @all_packages = getpackages();
+on_selected_pkgs_in_parallel(\@all_packages, sub {
 
-	my $tmp=tmpdir($package);
-	my $file=pkgfile($package,"manpages");
-	my $skip_install=! grep { $_ eq $package } @{$dh{DOPACKAGES}};
-	my @manpages;
+	foreach my $package (@_) {
+		next if is_udeb($package);
 
-	@manpages=filearray($file, ".") if $file;
+		my $tmp = tmpdir($package);
+		my $file = pkgfile($package, "manpages");
+		my $skip_install = !grep { $_ eq $package } @{$dh{DOPACKAGES}};
+		my @manpages;
 
-	if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
-		push @manpages, @ARGV;
-	}
+		@manpages = filearray($file, ".") if $file;
 
-	log_installed_files($package, @manpages);
+		if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+			push @manpages, @ARGV;
+		}
 
-	next if $skip_install;
+		log_installed_files($package, @manpages);
 
-	foreach my $page (@manpages) {
-		my $basename=basename($page);
+		next if $skip_install;
 
-		# Support compressed pages.
-		my $gz='';
-		if ($basename=~m/(.*)(\.gz)/) {
-			$basename=$1;
-			$gz=$2;
-		}
+		foreach my $page (@manpages) {
+			my $basename = basename($page);
 
-		my ($fd, $section);
-		# See if there is a .TH or .Dt entry in the man page. If so,
-		# we'll pull the section field from that.
-		if ($gz) {
-			$fd = open_gz($page) or die "$page: $!";
-		}
-		else {
-			open($fd, '<', $page) or die "$page: $!";
-		}
-		while (<$fd>) {
-			if (/^\.TH\s+\S+\s+"?(\d+[^"\s]*)"?/ ||
-			    /^\.Dt\s+\S+\s+(\d+[^\s]*)/) {
-				$section=$1;
-				last;
+			# Support compressed pages.
+			my $gz = '';
+			if ($basename =~ m/(.*)(\.gz)/) {
+				$basename = $1;
+				$gz = $2;
 			}
-		}
-		close($fd);
-		# Failing that, we can try to get it from the filename.
-		if (! $section) {
-			($section)=$basename=~m/\.([1-9]\S*)/;
-		}
 
-		# Now get the numeric component of the section.
-		my ($realsection)=$section=~m/^(\d)/ if defined $section;
-		if (! $realsection) {
-			error("Could not determine section for $page");
-		}
-		
-		# Get the man page's name -- everything up to the last dot.
-		my ($instname)=$basename=~m/^(.*)\./;
-	
-		my $destdir="$tmp/usr/share/man/man$realsection/";
-		my $langcode;
-		if (! defined $dh{LANGUAGE} || ! exists $dh{LANGUAGE}) {
-			# Translated man pages are typically specified by adding the
-			# language code to the filename, so detect that and
-			# redirect to appropriate directory, stripping the code.
-			($langcode)=$basename=~m/\.([a-z][a-z](?:_[A-Z][A-Z])?)\.(?:[1-9]|man)/;
-		}
-		elsif ($dh{LANGUAGE} ne 'C') {
-			$langcode=$dh{LANGUAGE};
-		}
-		
-		if (defined $langcode && $langcode ne '') {
-			# Strip the language code from the instname.
-			$instname=~s/\.$langcode$//;
-		}
-		
-		if (defined $langcode && $langcode ne '') {
-			$destdir="$tmp/usr/share/man/$langcode/man$realsection/";
-		}
-		$destdir=~tr:/:/:s; # just for looks
-		my $instpage="$destdir$instname.$section";
+			my ($fd, $section);
+			# See if there is a .TH or .Dt entry in the man page. If so,
+			# we'll pull the section field from that.
+			if ($gz) {
+				$fd = open_gz($page) or die "$page: $!";
+			}
+			else {
+				open($fd, '<', $page) or die "$page: $!";
+			}
+			while (<$fd>) {
+				if (/^\.TH\s+\S+\s+"?(\d+[^"\s]*)"?/ ||
+					/^\.Dt\s+\S+\s+(\d+[^\s]*)/) {
+					$section = $1;
+					last;
+				}
+			}
+			close($fd);
+			# Failing that, we can try to get it from the filename.
+			if (!$section) {
+				($section) = $basename =~ m/\.([1-9]\S*)/;
+			}
 
-		next if -l $instpage;
-		next if compat(5) && -e $instpage;
+			# Now get the numeric component of the section.
+			my ($realsection) = $section =~ m/^(\d)/ if defined $section;
+			if (!$realsection) {
+				error("Could not determine section for $page");
+			}
 
-		install_dir($destdir);
-		if ($gz) {
-			complex_doit "zcat \Q$page\E > \Q$instpage\E";
-		}
-		else {
-			install_file($page, $instpage);
-		}
-	}
+			# Get the man page's name -- everything up to the last dot.
+			my ($instname) = $basename =~ m/^(.*)\./;
+
+			my $destdir = "$tmp/usr/share/man/man$realsection/";
+			my $langcode;
+			if (!defined $dh{LANGUAGE} || !exists $dh{LANGUAGE}) {
+				# Translated man pages are typically specified by adding the
+				# language code to the filename, so detect that and
+				# redirect to appropriate directory, stripping the code.
+				($langcode) = $basename =~ m/\.([a-z][a-z](?:_[A-Z][A-Z])?)\.(?:[1-9]|man)/;
+			}
+			elsif ($dh{LANGUAGE} ne 'C') {
+				$langcode = $dh{LANGUAGE};
+			}
+
+			if (defined $langcode && $langcode ne '') {
+				# Strip the language code from the instname.
+				$instname =~ s/\.$langcode$//;
+			}
+
+			if (defined $langcode && $langcode ne '') {
+				$destdir = "$tmp/usr/share/man/$langcode/man$realsection/";
+			}
+			$destdir =~ tr:/:/:s; # just for looks
+			my $instpage = "$destdir$instname.$section";
 
-	# Now the .so conversion.
-	@sofiles=@sodests=();
-	foreach my $dir (qw{usr/share/man}) {
-		if (-e "$tmp/$dir") {
-			find(\&find_so_man, "$tmp/$dir");
+			next if -l $instpage;
+			next if compat(5) && -e $instpage;
+
+			install_dir($destdir);
+			if ($gz) {
+				complex_doit "zcat \Q$page\E > \Q$instpage\E";
+			}
+			else {
+				install_file($page, $instpage);
+			}
 		}
-	}
-	foreach my $sofile (@sofiles) {
-		my $sodest=shift(@sodests);
-		doit "rm","-f",$sofile;
-		doit "ln","-sf",$sodest,$sofile;
-	}
 
-	# Now utf-8 conversion.
-	if (defined `man --version`) {
+		# Now the .so conversion.
+		@sofiles = @sodests = ();
 		foreach my $dir (qw{usr/share/man}) {
-			next unless -e "$tmp/$dir";
-			my @files;
-			find(sub {
-				return if ! -f $_ || -l $_;
-				my ($tmp, $orig)=($_.".new", $_);
-				complex_doit "man --recode UTF-8 ./\Q$orig\E > \Q$tmp\E";
-				# recode uncompresses compressed pages
-				doit "rm", "-f", $orig if s/\.(gz|Z)$//;
-				doit "mv", "-f", $tmp, $_;
-				# Schedule a permission reset
-				push(@files, "${File::Find::dir}/${_}");
-			}, "$tmp/$dir");
-			# Bulk reset permissions of all re-encoded files
-			xargs(\@files, 'chmod', '0644', '--') if @files;
+			if (-e "$tmp/$dir") {
+				find(\&find_so_man, "$tmp/$dir");
+			}
+		}
+		foreach my $sofile (@sofiles) {
+			my $sodest = shift(@sodests);
+			doit "rm", "-f", $sofile;
+			doit "ln", "-sf", $sodest, $sofile;
+		}
+
+		# Now utf-8 conversion.
+		if (defined `man --version`) {
+			foreach my $dir (qw{usr/share/man}) {
+				next unless -e "$tmp/$dir";
+				my @files;
+				find(sub {
+						return if !-f $_ || -l $_;
+						my ($tmp, $orig) = ($_.".new", $_);
+						complex_doit "man --recode UTF-8 ./\Q$orig\E > \Q$tmp\E";
+						# recode uncompresses compressed pages
+						doit "rm", "-f", $orig if s/\.(gz|Z)$//;
+						doit "mv", "-f", $tmp, $_;
+						# Schedule a permission reset
+						push(@files, "${File::Find::dir}/${_}");
+					}, "$tmp/$dir");
+				# Bulk reset permissions of all re-encoded files
+				xargs(\@files, 'chmod', '0644', '--') if @files;
+			}
 		}
 	}
-}
+
+});
 
 # Check if a file is a .so man page, for use by File::Find.
 sub find_so_man {
@@ -273,7 +277,7 @@ sub find_so_man {
 	if (! defined $l) {
 		error("failed to read $_");
 	}
-	
+
 	if ($l=~m/\.so\s+(.*)\s*/) {
 		my $solink=$1;
 		# This test is here to prevent links like ... man8/../man8/foo.8
@@ -287,7 +291,7 @@ sub find_so_man {
 		elsif ($solink =~ m!/!) {
 			$solink="../$solink";
 		}
-	
+
 		if (-e $solink || -e "$solink.gz") {
 			push @sofiles,"$File::Find::dir/$_";
 			push @sodests,$solink;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list