Now builds things, next step is adjusting the pipeline to use the new script/
This commit is contained in:
parent
6119261c10
commit
ff475a48b8
1 changed files with 65 additions and 21 deletions
86
build.pl
86
build.pl
|
@ -13,6 +13,7 @@ use Path::Tiny;
|
||||||
use IPC::Run;
|
use IPC::Run;
|
||||||
use Time::HiRes qw/time/;
|
use Time::HiRes qw/time/;
|
||||||
use Syntax::Keyword::Try;
|
use Syntax::Keyword::Try;
|
||||||
|
use Time::Piece;
|
||||||
|
|
||||||
my @bases = qw/bullseye-backports bookworm-backports/;
|
my @bases = qw/bullseye-backports bookworm-backports/;
|
||||||
my @options = ("main", "main-threaded", "main-longdouble", "main-quadmath", "main-debugging", "main-longdouble-threaded", "main-quadmath-threaded", "main-debugging-threaded", "main-debugging-longdouble-threaded", "main-debugging-quadmath-threaded", "main-debugging-longdouble", "main-debugging-quadmath");
|
my @options = ("main", "main-threaded", "main-longdouble", "main-quadmath", "main-debugging", "main-longdouble-threaded", "main-quadmath-threaded", "main-debugging-threaded", "main-debugging-longdouble-threaded", "main-debugging-quadmath-threaded", "main-debugging-longdouble", "main-debugging-quadmath");
|
||||||
|
@ -20,8 +21,9 @@ my @versions = ("5.20.3", "5.22.4", "5.24.4", "5.26.3", "5.28.3", "5.30.3", "5.3
|
||||||
my $max_workers = 8;
|
my $max_workers = 8;
|
||||||
my $verbose = 1;
|
my $verbose = 1;
|
||||||
my $suffix = "";
|
my $suffix = "";
|
||||||
my $push_repo = "";
|
my $push_repo = "gitea.simcop2387.info/simcop2387/perl-container";
|
||||||
my $arch = 'amd64';
|
my $arch = 'amd64';
|
||||||
|
my %build_args = ();
|
||||||
|
|
||||||
GetOptions('verbose' => \$verbose,
|
GetOptions('verbose' => \$verbose,
|
||||||
'quiet' => sub {$verbose = 0},
|
'quiet' => sub {$verbose = 0},
|
||||||
|
@ -29,6 +31,7 @@ GetOptions('verbose' => \$verbose,
|
||||||
'suffix=s' => \$suffix,
|
'suffix=s' => \$suffix,
|
||||||
'push_repo=s' => \$push_repo,
|
'push_repo=s' => \$push_repo,
|
||||||
'arch=s' => \$arch,
|
'arch=s' => \$arch,
|
||||||
|
'build_args=s%' => \%build_args,
|
||||||
);
|
);
|
||||||
|
|
||||||
my $arch_suffix="-$arch";
|
my $arch_suffix="-$arch";
|
||||||
|
@ -92,6 +95,9 @@ sub run_cmd {
|
||||||
my $e = $@;
|
my $e = $@;
|
||||||
|
|
||||||
print "$disp_prefix: $e\n";
|
print "$disp_prefix: $e\n";
|
||||||
|
print $log_fh "---------------------\n";
|
||||||
|
print $log_fh "Exception: $e\n";
|
||||||
|
print $log_fh "---------------------\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,30 +106,63 @@ my $builder = IO::Async::Function->new(
|
||||||
code => sub {
|
code => sub {
|
||||||
my ( $version, $options, $os_base ) = @_;
|
my ( $version, $options, $os_base ) = @_;
|
||||||
|
|
||||||
my $expanded_version = $version =~ s/(?<major>5)\.(?<minor>\d+)\.(?<patch>\d+)/sprintf "%d.%03d.%03d", $+{major}, $+{minor}, $+{patch}/er;
|
try {
|
||||||
|
my $expanded_version = $version =~ s/(?<major>5)\.(?<minor>\d+)\.(?<patch>\d+)/sprintf "%d.%03d.%03d", $+{major}, $+{minor}, $+{patch}/er;
|
||||||
|
|
||||||
my $tags = ["$push_repo$version-$options-$os_base$suffix$arch_suffix", "$push_repo$expanded_version-$options-$os_base$suffix$arch_suffix"];
|
# TODO other calcs for image names
|
||||||
|
my $tags = ["$push_repo/$version-$options-$os_base$suffix$arch_suffix", "$push_repo/$expanded_version-$options-$os_base$suffix$arch_suffix"];
|
||||||
|
|
||||||
my ($total_output, $total_error, $retval);
|
my $build_date = Time::Piece::gmtime()->datetime();
|
||||||
|
|
||||||
my $startdir = path("output/perls");
|
my %labels = (
|
||||||
my $log_dir = path("output/logs");
|
"org.opencontainers.image.created"=>$build_date,
|
||||||
$log_dir->mkdir();
|
"org.label-schema.build-date"=>$build_date,
|
||||||
my $log_file = $log_dir->child("$expanded_version-$options-$os_base$suffix$arch_suffix-build.log");
|
"org.opencontainers.image.source"=>"https://gitea.simcop2387.info/simcop2387/docker-perl.git",
|
||||||
my $log_fh = $log_file->openw_utf8();
|
"org.label-schema.vcs-url"=> "https://gitea.simcop2387.info/simcop2387/docker-perl.git",
|
||||||
my $workdir = $startdir->child("$expanded_version-$options-$os_base/");
|
"org.opencontainers.image.url"=>"https://gitea.simcop2387.info/simcop2387/docker-perl",
|
||||||
|
"org.label-schema.url"=>"https://gitea.simcop2387.info/simcop2387/docker-perl",
|
||||||
|
"org.label-schema.usage"=> "https://gitea.simcop2387.info/simcop2387/docker-perl",
|
||||||
|
"org.opencontainers.image.revision"=>$ENV{CI_COMMIT_REF},
|
||||||
|
"org.label-schema.vcs-ref"=> $ENV{CI_COMMIT_REF},
|
||||||
|
"org.label-schema.version"=> $version,
|
||||||
|
"org.label-schema.name"=> "perl-$options",
|
||||||
|
"org.label-schema.schema-version"=> "1.0",
|
||||||
|
);
|
||||||
|
|
||||||
if ($workdir->exists()) {
|
my ($total_output, $total_error, $retval);
|
||||||
chdir($workdir);
|
|
||||||
my ($output, $error, $retval) = run_cmd(["ls"], $tags->[0], $log_fh, "");
|
my $startdir = path("output/perls");
|
||||||
} else {
|
my $log_dir = path("output/logs");
|
||||||
print "Failed to find $workdir\n";
|
$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 @tag_args = map {("-t", $_)} @$tags;
|
||||||
|
my @labels = map {my $k=$_; my $v=$labels{$k}; ("--label", "$k=$v")} keys %labels;
|
||||||
|
my @buildargs = map {my $k=$_; my $v=$build_args{$k}; ("--build-arg", "$k=$v")} keys %build_args;
|
||||||
|
|
||||||
|
my $cmd = [qw(docker buildx build --rm=true -f Dockerfile ./ --push --pull=true), @buildargs, @tag_args, @labels];
|
||||||
|
use Data::Dumper;
|
||||||
|
print Dumper($cmd);
|
||||||
|
|
||||||
|
my ($output, $error, $retval) = run_cmd($cmd, $tags->[0], $log_fh, "");
|
||||||
|
} else {
|
||||||
|
print "Failed to find $workdir\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$log_fh->close();
|
||||||
|
|
||||||
|
# Should probably return a success or failure
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
my $e = $@;
|
||||||
|
|
||||||
|
print "EXCEPTION: $e\n";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log_fh->close();
|
|
||||||
|
|
||||||
# Should probably return a success or failure
|
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
max_workers => $max_workers,
|
max_workers => $max_workers,
|
||||||
|
@ -137,9 +176,14 @@ $builder->start();
|
||||||
|
|
||||||
my %calls;
|
my %calls;
|
||||||
|
|
||||||
for my $version (@versions) {
|
my $count = 0;
|
||||||
|
|
||||||
|
ALL: for my $version (@versions) {
|
||||||
for my $option (@options) {
|
for my $option (@options) {
|
||||||
for my $base (@bases) {
|
for my $base (@bases) {
|
||||||
|
print "---> $count\n";
|
||||||
|
last ALL if $count++ == 10;
|
||||||
|
|
||||||
my $rend = "$version-$option-$base";
|
my $rend = "$version-$option-$base";
|
||||||
my $future = $builder->call(args => [$version, $option, $base])->on_ready(sub {
|
my $future = $builder->call(args => [$version, $option, $base])->on_ready(sub {
|
||||||
delete $calls{$rend};
|
delete $calls{$rend};
|
||||||
|
|
Loading…
Add table
Reference in a new issue