diff --git a/MockBuildUtils.pm b/MockBuildUtils.pm index b42c4b1..41e4b26 100644 --- a/MockBuildUtils.pm +++ b/MockBuildUtils.pm @@ -30,7 +30,7 @@ our @EXPORT_OK = qw( make_traversable_path epel_target_profile epel_cell_path cell_lock_path native_owner_command NATIVE_BUILD_GID openeuler_build_target openeuler_repo_subdir - goconserver_needs_pinned_go + goconserver_needs_pinned_go goconserver_pinned_go_buildrequires recover_common_repository ); @@ -100,6 +100,25 @@ sub goconserver_needs_pinned_go { return 0; } +# goconserver_pinned_go_buildrequires($target): what a pinned-Go build needs IN the chroot, +# beyond the toolchain archive it brings itself. undef when the chroot supplies Go. +# +# go build fetches the pinned modules over HTTPS, so the chroot must hold CA roots. openSUSE +# splits them: 'ca-certificates' is the tooling and carries no root, and the roots are in +# 'ca-certificates-mozilla'. Asking for the tooling alone is worse than asking for nothing. +# Measured in a Leap 42.3 chroot, Go's system pool holds 146 roots before 'ca-certificates' is +# installed and 0 after it, because the package takes the trust store over without filling it; +# go build then fails every module fetch with "x509: certificate signed by unknown authority". +# With 'ca-certificates-mozilla' the pool holds 201. EL and openEuler keep the roots in +# 'ca-certificates' itself and need no second package. +sub goconserver_pinned_go_buildrequires { + my ($target) = @_; + return undef unless goconserver_needs_pinned_go($target); + my @req = qw(coreutils tar gzip ca-certificates); + push @req, 'ca-certificates-mozilla' if $target =~ /\Aopensuse-/; + return join(' ', @req); +} + # missing_perl_modules(@modules): those that cannot be loaded, in order. The point of --install-deps # is that the run AFTER it cannot die on a missing module, so the modules are proven by loading # them, not by trusting the package manager's exit code. diff --git a/goconserver/mockbuild.pl b/goconserver/mockbuild.pl index 364b89e..8bb6f7f 100755 --- a/goconserver/mockbuild.pl +++ b/goconserver/mockbuild.pl @@ -11,7 +11,7 @@ use POSIX qw(strftime); use FindBin; use lib "$FindBin::Bin/..", "$FindBin::Bin/../lib"; use MockBuildUtils qw(openeuler_build_target openeuler_repo_subdir - goconserver_needs_pinned_go); + goconserver_needs_pinned_go goconserver_pinned_go_buildrequires); use XCAT::BuildUtils qw(digest_file read_lines); my $script_dir = abs_path(dirname(__FILE__)); @@ -240,7 +240,7 @@ if ($pinned_go) { run("wget --https-only --tries=3 --timeout=60 -q -O " . sh_quote($go_archive) . " " . sh_quote($go_url)); die "Go toolchain checksum mismatch: $go_file\n" unless digest_file($go_archive) eq $go_hash; $go_source = "Source3: $go_url\n"; - $go_requires = 'coreutils tar gzip ca-certificates'; + $go_requires = goconserver_pinned_go_buildrequires($mock_cfg); $go_prep = "echo '$go_hash %{SOURCE3}' | sha256sum -c -\ntar -C %{_builddir} -xzf %{SOURCE3}\n"; $go_environment = 'export PATH=%{_builddir}/go/bin:$PATH' . "\ngo version\n"; } diff --git a/t/goconserver_pinned_go.t b/t/goconserver_pinned_go.t index 9d0ed83..735242e 100755 --- a/t/goconserver_pinned_go.t +++ b/t/goconserver_pinned_go.t @@ -54,4 +54,29 @@ for my $target (sort keys %pinned) { is($needs->(undef) ? 1 : 0, 0, 'an undefined target does not ask for the toolchain archive'); is($needs->('') ? 1 : 0, 0, 'an empty target does not ask for the toolchain archive'); +# go build fetches modules over HTTPS, so a pinned-Go chroot needs CA roots. openSUSE keeps the +# roots in ca-certificates-mozilla and ships only tooling in ca-certificates; EL and openEuler +# keep them in ca-certificates itself. Measured in a Leap 42.3 chroot: Go's system pool holds 146 +# roots with no ca-certificates package, 0 once ca-certificates alone is installed, and 201 once +# ca-certificates-mozilla is added. +my $req = MockBuildUtils->can('goconserver_pinned_go_buildrequires'); +ok($req, 'MockBuildUtils says what a pinned-Go chroot needs installed') + or do { done_testing(); exit 0 }; + +for my $target (sort keys %pinned) { + my $got = $req->($target); + if (!$pinned{$target}) { + is($got, undef, "$target needs no toolchain dependencies"); + next; + } + like($got, qr/\bca-certificates\b/, "$target installs the CA tooling"); + if ($target =~ /\Aopensuse-/) { + like($got, qr/\bca-certificates-mozilla\b/, + "$target also installs the roots, which openSUSE packages separately"); + } else { + unlike($got, qr/ca-certificates-mozilla/, + "$target keeps its roots in ca-certificates and asks for no openSUSE package"); + } +} + done_testing();