Browse Source

Determine if a build can be done in parallel

For ports known to fail to build in parallel the PARALLEL_BUILD
variable was introduced to the ports makefiles. Use it so we
don't have to keep around our own list in the config file.
Markus Hennecke 7 years ago
parent
commit
f9934b4263
2 changed files with 33 additions and 21 deletions
  1. 31 18
      autoupdate.pl
  2. 2 3
      autoupdaterc

+ 31 - 18
autoupdate.pl

@@ -77,9 +77,6 @@ my $regex_subpkg = '(,-[a-z][a-z0-9_+-]*)?';
 # List of pseudo flavors we apply if the port supports them
 my %pseudo_flavors = ();
 
-# List of ports that need MAKE_JOBS=1 to build successful
-my %nonconcurrent_builds = ();
-
 # Global abort flag, only set from the reaper func
 my $abort = 0;
 
@@ -388,7 +385,12 @@ sub create_package_information {
 		#	identifier
 		# $6 :	a list with optional flavors. Each flavor starts with
 		#	a comma and may be an alphanumeric identifier
-		if ($pkg =~ m/^([a-z][a-z0-9]*)\/([A-Za-z][\.A-Za-z0-9-+_]*)((\/[a-z0-9._-]*)*)?$regex_subpkg$regex_flavor/) {
+		if ($pkg =~ m/^
+				([a-z][a-z0-9]*)\/
+				([A-Za-z][\.A-Za-z0-9-+_]*)
+				((\/[a-z0-9._-]*)*)?
+				$regex_subpkg
+				$regex_flavor/x) {
 			$category = $1;
 			$port = $2;
 			$subdir = $3;
@@ -403,15 +405,6 @@ sub create_package_information {
 			$flavor =~ s/,/ /g;
 			$flavor =~ s/^ //g;
 
-			my $lookup_name = $category . '/' . $port;
-			$lookup_name .= '/' . $subdir if $subdir;
-			my $jobs = $make_jobs;
-			$jobs = 1 if exists $nonconcurrent_builds{$lookup_name};
-			print STDOUT 'Disabling concurrent builds for '
-			  .$lookup_name . "\n"
-			    if (exists $nonconcurrent_builds{$lookup_name}
-			      && ($make_jobs > 1));
-
 			my %p = (
 				category => $category,
 				port     => $port,
@@ -419,9 +412,9 @@ sub create_package_information {
 				subpkg	 => $subpackage,
 				flavor	 => $flavor,
 				pkg	 => $pkg,
-				jobs     => $jobs,
 			);
 			$p{dependencies} = create_dependencies_list(\%p);
+			$p{jobs} = set_parallel_build(\%p);
 			$p{deppkgs} 
 				= create_dependencies_hash($p{dependencies});
 			$p{pseudo_flavors} = create_pseudo_flavors_list(\%p);
@@ -647,6 +640,29 @@ sub build_pkg {
 }
 
 
+sub set_parallel_build {
+	my $info = shift;
+
+	my $cur_dir = getcwd;
+	my $cmd = 'make show=PARALLEL_BUILD';
+	my ($port, $port_dir) = find_newer_ports_dir($info);
+	chdir $port_dir or die "Unable to change to '$port_dir'\n";
+
+	my $parallel = 1;
+	open(my $in, "$cmd |")
+	    or die "Unable to determine parallel build info for \"$port\"\n";
+	while (<$in>) {
+		chomp;
+		$parallel &= ($_ eq 'Yes');
+	}
+	close($in);
+	chdir $cur_dir;
+
+	$info->{jobs} = ($parallel) ? $make_jobs : 1;
+	return $info->{jobs};
+}
+
+
 # Creates the dependencies list for a given port from the port information
 # hash
 sub create_dependencies_list {
@@ -666,7 +682,7 @@ sub create_dependencies_list {
 	chdir $port_dir or die "Unable to change to \"$port_dir\"\n";
 
 	open(my $in, "$cmd |") 
-	    or die "Unable to get get dependencies for \"$port\"\n";
+	    or die "Unable to get dependencies for \"$port\"\n";
 	while (<$in>) {
 		chomp;
 		push @dep_list, ($_);
@@ -773,7 +789,6 @@ chdir($basedir);
 # Fill the hash with the allowed variables
 my %valid_vars = ( 'logging', 1,
 		   'make_jobs', 1,
-		   'nonconcurrent_builds', 1,
 		   'sudo_make_clean', 1,
 		   'pseudo_flavors', 1 );
 
@@ -783,8 +798,6 @@ setup_logging($config);
 $make_jobs = $config->{make_jobs} if $config->{make_jobs};
 setup_lookup_hash($config->{pseudo_flavors}, \%pseudo_flavors,
 		  'pseudo flavors');
-setup_lookup_hash($config->{nonconcurrent_builds}, \%nonconcurrent_builds,
-		  'nonconcurrent_builds');
 $sudo_make_clean = $config->{sudo_make_clean}
     if (defined $config->{sudo_make_clean});
 

+ 2 - 3
autoupdaterc

@@ -22,7 +22,6 @@ logging = 1
 # SUDO will be used for the make clean stage while building a package
 sudo_make_clean = 1
 
+# Number of jobs to run concurrently when the port is able to do parallel
+# builds
 make_jobs = 2
-nonconcurrent_builds = security/nss security/libgpg-error mail/alpine \
-	lang/python/2.7 misc/shared-mime-info editors/vim textproc/libxml \
-	lang/python/3.4 devel/avrdude x11/motif