Преглед изворни кода

Handle aborted builds so that the script doesn't hang after waiting for
childs to finish.
Change some quotes to single quotes.

Markus Hennecke пре 9 година
родитељ
комит
ff1d62b4de
1 измењених фајлова са 17 додато и 12 уклоњено
  1. 17 12
      autoupdate.pl

+ 17 - 12
autoupdate.pl

@@ -1,5 +1,5 @@
 #! /usr/bin/perl -w
-# $Id: autoupdate.pl,v 1.35 2014/09/07 07:11:10 markus Exp $
+# $Id: autoupdate.pl,v 1.36 2014/09/07 07:35:06 markus Exp $
 # Copyright (c) 2007,2008,2009
 #    Markus Hennecke <markus-hennecke@markus-hennecke.de>
 #
@@ -67,9 +67,9 @@ my $jobs = 0;
 my %forked_builds = ();
 
 # Regex used to match a flavor
-my $regex_flavor = "((,[a-z][a-z0-9_]*)*)";
+my $regex_flavor = '((,[a-z][a-z0-9_]*)*)';
 # Regex used to match a subpackage
-my $regex_subpkg = "(,-[a-z][a-z0-9_+-]*)?";
+my $regex_subpkg = '(,-[a-z][a-z0-9_+-]*)?';
 
 # List of pseudo flavors we apply if the port supports them
 my %pseudo_flavors = ();
@@ -173,7 +173,7 @@ sub read_rc_file {
 
 		# Check if the line has a = character, if not issue an error
 		if (! m/=/) {
-			print STDERR "Not a valid config in line " 
+			print STDERR 'Not a valid config in line ' 
 			    . $real_lineno . "\n";
 			return undef;
 		}
@@ -188,8 +188,8 @@ sub read_rc_file {
 			$config{$var} = $val;
 		}
 		else {
-			print STDERR "Warning: Unknown variable '$var' "
-			    . "in config file\n";
+			print STDERR 'Warning: Unknown variable "' . $var
+			    . '" in config file' . "\n";
 		}
 	}
 	return \%config;
@@ -229,8 +229,8 @@ sub setup_logging {
 		open STDERR, ">&TEE"
 		    or die "Unable to redirect STDERR to log file.\n";
 
-		print STDOUT "Logging builds in '$logdir'\n";
-		print STDOUT "Using \"$logfile\" as mainlog\n";
+		print STDOUT 'Logging builds in "' . $logdir . '"' . "\n";
+		print STDOUT 'Using "' . $logfile . '" as mainlog' . "\n";
 	}
 }
 
@@ -326,7 +326,7 @@ sub read_update_package_list {
 		}
 	}
 	elsif ($input eq '-') {
-		unless (open($in, "<&=STDIN")) {
+		unless (open($in, '<&=STDIN')) {
 			print STDERR "Unable to open stdin\n";
 			exit 1;
 		}
@@ -591,7 +591,7 @@ sub build_pkg {
 		$tmp =~ s/\//_/g;
 		$logfilename = "$logdir/$tmp.log";
 		open($logfile, '>>', $logfilename)
-		    or print STDERR "Warning: Unable to create log file"
+		    or print STDERR 'Warning: Unable to create log file'
 			. " for $info->{pkg}\n";
 	}
 	while (<$in>) {
@@ -877,10 +877,10 @@ foreach my $pkg_name (@pkg_list)  {
 # Wait for all childs to finish
 while (scalar (keys %forked_builds)) {
 	sleep 1;
+	reap();
 }
 
-die 'Abort requested by child' if ($abort != 0);
-print STDOUT "Done.\n";
+$SIG{CHLD} = 'DEFAULT';
 
 # Close the pipe to our log file if we were logging
 if (defined $config->{logging} && $config->{logging} != 0) {
@@ -888,3 +888,8 @@ if (defined $config->{logging} && $config->{logging} != 0) {
 	close STDERR;
 	close TEE;
 }
+
+die 'Abort requested by child' if ($abort != 0);
+print STDOUT "Done.\n";
+
+exit 0;