[debhelper-devel] [debhelper] 01/04: Dh_Lib: Add on_selected_pkgs_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 27d7346bfb6e1ad8bad2e910d44e4db9639cb8ef
Author: Niels Thykier <niels at thykier.net>
Date: Sat Jun 24 11:39:50 2017 +0000
Dh_Lib: Add on_selected_pkgs_in_parallel
Signed-off-by: Niels Thykier <niels at thykier.net>
---
Debian/Debhelper/Dh_Lib.pm | 12 +++++++++---
doc/PROGRAMMING | 10 +++++++---
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 6a5904f..26a8341 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -52,7 +52,7 @@ use vars qw(@EXPORT %dh);
&restore_file_on_clean &restore_all_files
&open_gz &reset_perm_and_owner &deprecated_functionality
&log_installed_files &buildarch &rename_path
- &on_pkgs_in_parallel
+ &on_pkgs_in_parallel &on_selected_pkgs_in_parallel
);
# The Makefile changes this if debhelper is installed in a PREFIX.
@@ -1608,9 +1608,15 @@ sub log_installed_files {
return 1;
}
+
sub on_pkgs_in_parallel(&) {
- my ($code) = @_;
- my @pkgs = @{$dh{DOPACKAGES}};
+ unshift(@_, $dh{DOPACKAGES});
+ goto \&on_selected_pkgs_in_parallel;
+}
+
+sub on_selected_pkgs_in_parallel {
+ my ($pkgs_ref, $code) = @_;
+ my @pkgs = @{$pkgs_ref};
my %pids;
my $parallel = $MAX_PROCS;
my $count_per_proc = int(scalar(@pkgs) / $parallel);
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 1827811..5d1b622 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -358,20 +358,24 @@ log_installed_files($package, @paths)
If a directory is listed, it and all paths recursively beneath is
also considered installed.
on_pkgs_in_parallel($code) - prototype: (&)
- Splits all the packages in $dh{DOPACKAGES} into a number of groups
+ Short hand for on_selected_pkgs_in_parallel with $dh{DOPACKAGES} as
+ as list of packages.
+on_selected_pkgs_in_parallel($pkg_list_ref, $code)
+ Splits all the packages in $pkg_list_ref into a number of groups
based on the max parallel (as decided by DEB_BUILD_OPTIONS)
A subprocess is forked for each group (minimum 1 process will be
forked) and each subprocess will be added a group of packages
to process. Each group is passed to the $code sub, which will
then process it and return normally on success.
Example:
- on_pkgs_in_parallel {
+ my @all_packages = getpackages();
+ on_selected_pkgs_in_parallel(\@all_packages, sub {
for my $package (@_) {
my $tmp=tmpdir($package);
my $pkgfile = pkgfile($package, 'foo');
...;
}
- }
+ });
Keep in mind that the sub will always be run in a subprocess,
so it cannot update global state.
--
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