More boilerplate ready, now to build all the docker commands
This commit is contained in:
parent
e49cd5e723
commit
6119261c10
1 changed files with 47 additions and 33 deletions
80
build.pl
80
build.pl
|
@ -19,12 +19,24 @@ my @options = ("main", "main-threaded", "main-longdouble", "main-quadmath", "mai
|
|||
my @versions = ("5.20.3", "5.22.4", "5.24.4", "5.26.3", "5.28.3", "5.30.3", "5.32.1", "5.34.0", "5.34.1", "5.36.0");
|
||||
my $max_workers = 8;
|
||||
my $verbose = 1;
|
||||
my $suffix = "";
|
||||
my $push_repo = "";
|
||||
my $arch = 'amd64';
|
||||
|
||||
GetOptions('verbose' => \$verbose,
|
||||
'quiet' => sub {$verbose = 0},
|
||||
'workers=i' => \$max_workers,
|
||||
'suffix=s' => \$suffix,
|
||||
'push_repo=s' => \$push_repo,
|
||||
'arch=s' => \$arch,
|
||||
);
|
||||
|
||||
my $arch_suffix="-$arch";
|
||||
|
||||
if ($suffix) {
|
||||
$suffix = "-$suffix";
|
||||
}
|
||||
|
||||
my $loop = IO::Async::Loop::Epoll->new();
|
||||
|
||||
sub get_ts {
|
||||
|
@ -34,27 +46,24 @@ sub get_ts {
|
|||
}
|
||||
|
||||
sub process_lines {
|
||||
my ($disp_prefix, $lines) = @_;
|
||||
my $output = "";
|
||||
my ($disp_prefix, $type, $log_fh, $lines) = @_;
|
||||
|
||||
while ($$lines =~ /\n/m) {
|
||||
my $ts = get_ts();
|
||||
$$lines =~ s/^(.*?)\n//m;
|
||||
my $raw_line = $1;
|
||||
|
||||
my $log_line = $ts.": ".$raw_line;
|
||||
my $disp_line = $disp_prefix." - ".$ts.": ".$raw_line;
|
||||
print "out: ", $disp_line, "\n";
|
||||
$output .= $log_line;
|
||||
my $log_line = "$ts $type: $raw_line\n";
|
||||
my $disp_line = "$disp_prefix - $ts $type: $raw_line\n";
|
||||
print $disp_line;
|
||||
$log_fh->print($log_line);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
sub run_cmd {
|
||||
my ($cmd,$disp_prefix,$log_file,$input) = @_;
|
||||
my ($cmd,$disp_prefix,$log_fh,$input) = @_;
|
||||
|
||||
my ($output, $error, $raw_out, $raw_err);
|
||||
my ($raw_out, $raw_err);
|
||||
|
||||
try {
|
||||
|
||||
|
@ -62,15 +71,13 @@ sub run_cmd {
|
|||
|
||||
my $handle = IPC::Run::start $cmd, \$input, \$raw_out, \$raw_err; # no timeout here, that's part of the ::Function
|
||||
|
||||
print "started, $handle\n";
|
||||
print "pumpable? ", $handle->pumpable?"yes":"no", "\n";
|
||||
|
||||
while ($handle->pumpable) {
|
||||
$handle->pump();
|
||||
|
||||
print "pumping $disp_prefix\n";
|
||||
$output .= process_lines($disp_prefix, \$raw_out);
|
||||
$error .= process_lines($disp_prefix."[ERR]", \$raw_err);
|
||||
process_lines($disp_prefix, "[OUT]", $log_fh, \$raw_out);
|
||||
process_lines($disp_prefix, "[ERR]", $log_fh, \$raw_err);
|
||||
|
||||
$handle->reap_nb();
|
||||
}
|
||||
|
||||
# Nothing we do here is a fatal error.
|
||||
|
@ -78,13 +85,14 @@ sub run_cmd {
|
|||
|
||||
my $return = $?;
|
||||
|
||||
print "Finished $disp_prefix\n";
|
||||
print "Finished $disp_prefix => $return\n";
|
||||
|
||||
return ($output, $error, $return);
|
||||
return ($return);
|
||||
} catch {
|
||||
my $e = $@;
|
||||
|
||||
print "$disp_prefix: $e\n";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,27 +102,33 @@ my $builder = IO::Async::Function->new(
|
|||
|
||||
my $expanded_version = $version =~ s/(?<major>5)\.(?<minor>\d+)\.(?<patch>\d+)/sprintf "%d.%03d.%03d", $+{major}, $+{minor}, $+{patch}/er;
|
||||
|
||||
my $tags = ["$version-$options-$os_base", "$expanded_version-$options-$os_base"];
|
||||
my $tags = ["$push_repo$version-$options-$os_base$suffix$arch_suffix", "$push_repo$expanded_version-$options-$os_base$suffix$arch_suffix"];
|
||||
|
||||
my ($output, $error, $retval) = run_cmd(["ls"], $tags->[0], "", "");
|
||||
# my ($output, $return) = tee_merged sub {
|
||||
# my $workdir = path("output/perls")->child("$expanded_version-$options-$os_base");
|
||||
#
|
||||
# if ($workdir->exists()) {
|
||||
#
|
||||
# chdir($workdir);
|
||||
# #print "$workdir\n";
|
||||
# #system("ls");
|
||||
# } else {
|
||||
# print "Failed to find $workdir\n";
|
||||
# }
|
||||
# };
|
||||
my ($total_output, $total_error, $retval);
|
||||
|
||||
return $output;
|
||||
my $startdir = path("output/perls");
|
||||
my $log_dir = path("output/logs");
|
||||
$log_dir->mkdir();
|
||||
my $log_file = $log_dir->child("$expanded_version-$options-$os_base$suffix$arch_suffix-build.log");
|
||||
my $log_fh = $log_file->openw_utf8();
|
||||
my $workdir = $startdir->child("$expanded_version-$options-$os_base/");
|
||||
|
||||
if ($workdir->exists()) {
|
||||
chdir($workdir);
|
||||
my ($output, $error, $retval) = run_cmd(["ls"], $tags->[0], $log_fh, "");
|
||||
} else {
|
||||
print "Failed to find $workdir\n";
|
||||
}
|
||||
|
||||
$log_fh->close();
|
||||
|
||||
# Should probably return a success or failure
|
||||
return;
|
||||
},
|
||||
|
||||
max_workers => $max_workers,
|
||||
min_workers => 1,
|
||||
max_worker_calls => 1, # always restart, we want to throw away side effects like chdir
|
||||
model => "fork",
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue