mirror of
https://github.com/xcat2/xcat-dep.git
synced 2026-12-01 14:52:13 +00:00
Merge pull request #97 from VersatusHPC/fix/dep-leap-chroot-builds
fix(xcat-dep): three packages cannot build in an openSUSE Leap chroot
This commit is contained in:
@@ -28,6 +28,7 @@ our @EXPORT_OK = qw(
|
||||
build_mock_uniqueext rpm_in_cell resolve_mock_cfg mock_chroot_uid mock_result_dirs
|
||||
packaged_path
|
||||
make_traversable_path epel_target_profile epel_cell_path cell_lock_path
|
||||
perl_buildreq_compat_needed perl_buildreq_compat_spec perl_mock_cfg_text
|
||||
native_owner_command NATIVE_BUILD_GID
|
||||
openeuler_build_target openeuler_repo_subdir
|
||||
recover_common_repository
|
||||
@@ -1151,6 +1152,55 @@ sub dep_repo_label {
|
||||
return defined $arch ? "$dir $arch" : $cell;
|
||||
}
|
||||
|
||||
# The Fedora perl source rpms BuildRequire perl-generators and perl-interpreter. openSUSE has
|
||||
# neither: there perl provides the interpreter and rpm generates the perl dependencies itself, so
|
||||
# dnf builddep stops before the build. A build-only rpm provides those names and pulls the real
|
||||
# perl. It is never shipped: only the mock configuration of a SUSE target sees its repository.
|
||||
sub perl_buildreq_compat_needed {
|
||||
my ($base_cfg) = @_;
|
||||
return 0 unless defined $base_cfg;
|
||||
return $base_cfg =~ /opensuse|sles|suse/i ? 1 : 0;
|
||||
}
|
||||
|
||||
sub perl_buildreq_compat_spec {
|
||||
return <<'SPEC';
|
||||
Name: xcat-perl-buildreq-compat
|
||||
Version: 1
|
||||
Release: 1
|
||||
Summary: Build-only compat: provide Fedora perl BuildRequires names on SUSE
|
||||
License: MIT
|
||||
BuildArch: noarch
|
||||
Provides: perl-generators
|
||||
Provides: perl-interpreter
|
||||
Provides: perl-devel
|
||||
Requires: perl
|
||||
%description
|
||||
Satisfies the perl-generators, perl-interpreter and perl-devel BuildRequires of
|
||||
Fedora perl source rpms in an openSUSE chroot. SUSE ships the perl development
|
||||
headers inside perl itself. Never shipped.
|
||||
%files
|
||||
%changelog
|
||||
SPEC
|
||||
}
|
||||
|
||||
# The deterministic mock configuration one perl build uses. $compat_repo is the directory
|
||||
# perl_buildreq_compat_needed asked the caller to build; a SUSE target without one is refused,
|
||||
# because building without the compat is the failure this exists to prevent.
|
||||
sub perl_mock_cfg_text {
|
||||
my ($base_cfg, $epoch, $compat_repo) = @_;
|
||||
my $text = "include('/etc/mock/${base_cfg}.cfg')\n"
|
||||
. "config_opts['environment']['SOURCE_DATE_EPOCH'] = '$epoch'\n";
|
||||
return $text unless perl_buildreq_compat_needed($base_cfg);
|
||||
die "perl_mock_cfg_text: $base_cfg needs the perl BuildRequires"
|
||||
. " compat repository and none was given\n"
|
||||
unless defined $compat_repo && length $compat_repo;
|
||||
# priority=1 so the compat rpm wins over anything of the same name in the target repositories.
|
||||
$text .= "config_opts['dnf.conf'] += \"\"\"\n[xcat-buildreq-compat]\n"
|
||||
. "name=xcat perl BuildRequires compat\n"
|
||||
. "baseurl=file://$compat_repo\nenabled=1\ngpgcheck=0\npriority=1\n\"\"\"\n";
|
||||
return $text;
|
||||
}
|
||||
|
||||
# mock's own loader reads the configuration, so include() and the assignments around it resolve as
|
||||
# they do in a build. With no chrootuid, the loader returns the caller, as mock does: as root, the
|
||||
# user that SUDO_UID, USERHELPER_UID or PKEXEC_UID names.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/xcat2/goconserver
|
||||
|
||||
go 1.25.12
|
||||
go 1.25.0
|
||||
|
||||
replace github.com/kr/pty => github.com/creack/pty v1.1.21
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ Source2: grubriscv64.efi
|
||||
# and the /boot/grub2 prefix grub2.ppc uses. grub2-efi-aa64-modules is noarch, so the
|
||||
# image builds on every EL build host. The openEuler x86_64 repositories carry no
|
||||
# grub2-efi-aa64-modules and openEuler has no aarch64 target, so it ships without the image.
|
||||
%if ! 0%{?openEuler}
|
||||
# openSUSE packages grub2 under other names, so its package ships without the image too.
|
||||
%if ! 0%{?openEuler} && ! 0%{?suse_version}
|
||||
BuildRequires: grub2-tools
|
||||
BuildRequires: grub2-efi-aa64-modules
|
||||
%endif
|
||||
@@ -57,7 +58,7 @@ aarch64 nodes, which boot through UEFI and grub2 only.
|
||||
#%endif
|
||||
|
||||
%build
|
||||
%if ! 0%{?openEuler}
|
||||
%if ! 0%{?openEuler} && ! 0%{?suse_version}
|
||||
# The aarch64 network loader: net search finds the boot/grub2/grub.cfg-<HEXIP> that
|
||||
# nodeset links. efi_uga is left out: it is x86 only, and grub2-mkimage aborts on it
|
||||
# for arm64-efi.
|
||||
@@ -83,7 +84,7 @@ tar -xf grub2-res.tar
|
||||
%endif
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/riscv64-efi
|
||||
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/%{prefix}/riscv64-efi/grubriscv64.efi
|
||||
%if ! 0%{?openEuler}
|
||||
%if ! 0%{?openEuler} && ! 0%{?suse_version}
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/aarch64-efi
|
||||
install -m 0644 %{_builddir}/grubaa64.efi $RPM_BUILD_ROOT/%{prefix}/aarch64-efi/grubaa64.efi
|
||||
%endif
|
||||
@@ -111,7 +112,7 @@ exit 0
|
||||
# one for sles, one for rhel. yes, it's ugly...
|
||||
%{prefix}/powerpc-ieee1275/
|
||||
%{prefix}/riscv64-efi/
|
||||
%if ! 0%{?openEuler}
|
||||
%if ! 0%{?openEuler} && ! 0%{?suse_version}
|
||||
%{prefix}/aarch64-efi/
|
||||
%endif
|
||||
%defattr(-,root,root)
|
||||
|
||||
@@ -208,8 +208,9 @@ run(
|
||||
"rpm -qpl " . sh_quote($main_rpm) .
|
||||
" | grep -Fx /tftpboot/boot/grub2/riscv64-efi/grubriscv64.efi >/dev/null"
|
||||
);
|
||||
# The aarch64 image is generated in %build (grub2-mkimage -O arm64-efi); openEuler ships without it.
|
||||
if ($mock_cfg !~ /^openeuler-/) {
|
||||
# The aarch64 image is generated in %build (grub2-mkimage -O arm64-efi); openEuler and openSUSE
|
||||
# ship without it.
|
||||
if ($mock_cfg !~ /^(?:openeuler|opensuse)-/) {
|
||||
run(
|
||||
"rpm -qpl " . sh_quote($main_rpm) .
|
||||
" | grep -Fx /tftpboot/boot/grub2/aarch64-efi/grubaa64.efi >/dev/null"
|
||||
|
||||
@@ -10,7 +10,8 @@ use FindBin qw($RealBin);
|
||||
use Getopt::Long qw(GetOptions);
|
||||
use Parallel::ForkManager;
|
||||
use lib $RealBin, "$RealBin/lib";
|
||||
use MockBuildUtils qw(mock_result_dirs make_traversable_path);
|
||||
use MockBuildUtils qw(mock_result_dirs make_traversable_path
|
||||
perl_buildreq_compat_needed perl_buildreq_compat_spec perl_mock_cfg_text);
|
||||
|
||||
my $repo_root = abs_path(dirname(__FILE__));
|
||||
my $work_dir = '/tmp/perl-list6-mockbuild';
|
||||
@@ -965,13 +966,38 @@ sub resolve_mock_cfg {
|
||||
sub create_deterministic_mock_cfg {
|
||||
my ($base_cfg, $epoch, $dir) = @_;
|
||||
my $cfg_path = "$dir/mock-deterministic.cfg";
|
||||
my $compat = perl_buildreq_compat_needed($base_cfg)
|
||||
? suse_buildreq_compat_repo($dir) : undef;
|
||||
open my $fh, '>', $cfg_path or die "Cannot write $cfg_path: $!\n";
|
||||
print $fh "include('/etc/mock/${base_cfg}.cfg')\n";
|
||||
print $fh "config_opts['environment']['SOURCE_DATE_EPOCH'] = '$epoch'\n";
|
||||
print $fh perl_mock_cfg_text($base_cfg, $epoch, $compat);
|
||||
close $fh;
|
||||
return $cfg_path;
|
||||
}
|
||||
|
||||
# Build the compat rpm named by perl_buildreq_compat_spec and leave it in a local createrepo'd
|
||||
# directory; return that directory. It is built UNDER the caller's per-package build directory,
|
||||
# never a shared path: each build_package fork runs this once for its own package, and
|
||||
# mockbuild-all gives every (run, target, arch) its own work directory, so parallel perl builds
|
||||
# cannot race on it. Idempotent within a directory.
|
||||
sub suse_buildreq_compat_repo {
|
||||
my ($base_dir) = @_;
|
||||
my $base = "$base_dir/suse-buildreq-compat";
|
||||
return "$base/repo" if -f "$base/repo/repodata/repomd.xml";
|
||||
my $rpmroot = "$base/rpmbuild";
|
||||
make_path("$rpmroot/SPECS", "$base/repo");
|
||||
my $spec = "$rpmroot/SPECS/xcat-perl-buildreq-compat.spec";
|
||||
open my $s, '>', $spec or die "Cannot write $spec: $!\n";
|
||||
print {$s} perl_buildreq_compat_spec();
|
||||
close $s;
|
||||
system("rpmbuild --define " . sh_quote("_topdir $rpmroot") . " -bb " . sh_quote($spec)
|
||||
. " >/dev/null 2>&1") == 0
|
||||
or die "FATAL: could not build the perl BuildRequires compat rpm\n";
|
||||
system("cp " . sh_quote("$rpmroot/RPMS/noarch/") . "xcat-perl-buildreq-compat-*.noarch.rpm "
|
||||
. sh_quote("$base/repo/") . " && createrepo_c " . sh_quote("$base/repo") . " >/dev/null 2>&1") == 0
|
||||
or die "FATAL: could not index the perl BuildRequires compat repository\n";
|
||||
return "$base/repo";
|
||||
}
|
||||
|
||||
sub resolve_source_urls {
|
||||
my ($spec_path) = @_;
|
||||
open my $fh, '<', $spec_path or return ();
|
||||
|
||||
+8
-1
@@ -112,7 +112,7 @@ my $grub_spec = slurp($grub_spec_file);
|
||||
'%postun removes grub2.aarch64');
|
||||
|
||||
SKIP: {
|
||||
skip 'rpmspec not available', 4 unless $have_rpmspec;
|
||||
skip 'rpmspec not available', 6 unless $have_rpmspec;
|
||||
my $el = parsed_spec($grub_spec_file, rhel => 10);
|
||||
ok(defined $el, 'rpmspec parses grub2-xcat.spec for EL10') or $el = '';
|
||||
like($el, qr/^BuildRequires:\s*grub2-efi-aa64-modules\s*$/m, '... and EL keeps the aarch64 image');
|
||||
@@ -124,6 +124,13 @@ my $grub_spec = slurp($grub_spec_file);
|
||||
'openEuler builds without the aarch64 image');
|
||||
like($oe // '', qr{if \[ -f /tftpboot/boot/grub2/aarch64-efi/grubaa64\.efi \]},
|
||||
'... and its %post copies grub2.aarch64 only when the image exists');
|
||||
|
||||
# openSUSE packages grub2 under other names: its package is built without the image too.
|
||||
my $suse = parsed_spec($grub_spec_file, suse_version => 1500);
|
||||
ok(defined $suse && $suse !~ /grub2-tools|grub2-efi-aa64-modules|grub2-mkimage|aarch64-efi\/$/m,
|
||||
'openSUSE builds without the aarch64 image');
|
||||
like($suse // '', qr{if \[ -f /tftpboot/boot/grub2/aarch64-efi/grubaa64\.efi \]},
|
||||
'... and its %post copies grub2.aarch64 only when the image exists');
|
||||
}
|
||||
|
||||
# Run the spec's own command where the arm64-efi modules are installed: a module the grub
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env perl
|
||||
# The go directive of the pinned goconserver module graph must not exceed the oldest Go any
|
||||
# xcat-dep target provides.
|
||||
#
|
||||
# goconserver/mockbuild.pl compiles inside the chroot with BuildRequires: golang and
|
||||
# GOTOOLCHAIN=local, so Go never downloads a newer toolchain: a directive above the chroot's Go
|
||||
# stops the build before the compiler starts. Measured in a Leap 15.6 chroot on 2026-10-23:
|
||||
#
|
||||
# go: go.mod requires go >= 1.25.12 (running go 1.25.8; GOTOOLCHAIN=local)
|
||||
#
|
||||
# 1.25.12 was the patch level of the toolchain that regenerated go.mod, not a requirement of the
|
||||
# code. go.mod and mockbuild.pl are the artifacts, so this reads them and runs no Go.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use File::Slurper qw(read_text);
|
||||
use Test::More;
|
||||
|
||||
my $repo = "$RealBin/..";
|
||||
|
||||
# The oldest Go a target resolves BuildRequires: golang to. Leap 15.6 is the floor today; EL 10
|
||||
# and openEuler are newer. Raise this only with the chroot that reports the new value.
|
||||
my $FLOOR = '1.25.8';
|
||||
|
||||
sub as_tuple { return [ map { $_ + 0 } (split /\./, $_[0], 3), 0, 0 ]; }
|
||||
sub cmp_ver {
|
||||
my ($a, $b) = map { as_tuple($_) } @_;
|
||||
return $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2];
|
||||
}
|
||||
|
||||
is(cmp_ver('1.25.8', '1.25.12'), -1, 'the comparison reads 1.25.8 as older than 1.25.12');
|
||||
is(cmp_ver('1.25.0', '1.25.8'), -1, '... and 1.25.0 as older than 1.25.8');
|
||||
is(cmp_ver('1.25.12', '1.25.12'), 0, '... and equal versions as equal');
|
||||
|
||||
my $gomod = read_text("$repo/goconserver/gomod/go.mod");
|
||||
my ($directive) = $gomod =~ /^go\s+(\d+\.\d+(?:\.\d+)?)\s*$/m;
|
||||
ok(defined $directive, 'goconserver/gomod/go.mod declares a go directive') or done_testing(), exit;
|
||||
|
||||
cmp_ok(cmp_ver($directive, $FLOOR), '<=', 0,
|
||||
"the go directive $directive is within the oldest target Go $FLOOR");
|
||||
|
||||
# The directive still has to be high enough for the pinned graph, so this is a window and not a
|
||||
# race to the bottom.
|
||||
cmp_ok(cmp_ver($directive, '1.25.0'), '>=', 0,
|
||||
"the go directive $directive is at or above the 1.25.0 the pinned graph needs");
|
||||
|
||||
# The floor binds only because the build refuses to fetch a newer toolchain. If this changes, the
|
||||
# directive stops mattering and this test is measuring nothing.
|
||||
my $mockbuild = read_text("$repo/goconserver/mockbuild.pl");
|
||||
like($mockbuild, qr/GOTOOLCHAIN=local/,
|
||||
'the chroot build pins the chroot Go, which is what makes the directive binding');
|
||||
like($mockbuild, qr/\$go_requires\s*=\s*'golang'/,
|
||||
'... and takes its Go from the target repositories');
|
||||
|
||||
done_testing();
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env perl
|
||||
# The Fedora perl source rpms BuildRequire perl-generators and perl-interpreter. openSUSE has
|
||||
# neither: there `perl` provides the interpreter and rpm generates the perl dependencies itself,
|
||||
# so `dnf builddep` stops before the build. Every one of the four perl packages fails that way in
|
||||
# a Leap chroot.
|
||||
#
|
||||
# The answer is a build-only compat rpm that provides those names, in a local repository injected
|
||||
# into the mock configuration for SUSE targets alone. The configuration text and the decision
|
||||
# behind it are pure, so this writes no rpm and runs no mock.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use Test::More;
|
||||
|
||||
use lib $RealBin, "$RealBin/..", "$RealBin/../lib";
|
||||
use MockBuildUtils ();
|
||||
|
||||
my $needed = MockBuildUtils->can('perl_buildreq_compat_needed');
|
||||
my $spec = MockBuildUtils->can('perl_buildreq_compat_spec');
|
||||
my $text = MockBuildUtils->can('perl_mock_cfg_text');
|
||||
ok($needed, 'MockBuildUtils decides which targets need the perl BuildRequires compat');
|
||||
ok($spec, 'MockBuildUtils carries the compat spec');
|
||||
ok($text, 'MockBuildUtils writes the perl mock configuration');
|
||||
|
||||
subtest 'only a SUSE target needs the compat' => sub {
|
||||
plan skip_all => 'MockBuildUtils has no perl_buildreq_compat_needed' unless $needed;
|
||||
ok($needed->($_), "$_ needs the compat") for qw(
|
||||
opensuse-leap-15.6-x86_64 opensuse-leap-42.3-x86_64 opensuse-leap-15.6-ppc64le
|
||||
);
|
||||
ok(!$needed->($_), "$_ does not need the compat") for qw(
|
||||
alma+epel-8-x86_64 alma+epel-10-x86_64 openeuler-24.03sp4-x86_64
|
||||
openeuler-24.03-ppc64le rocky-10-riscv64-xcat
|
||||
);
|
||||
};
|
||||
|
||||
subtest 'the compat package provides the names and nothing else' => sub {
|
||||
plan skip_all => 'MockBuildUtils has no perl_buildreq_compat_spec' unless $spec;
|
||||
my $s = $spec->();
|
||||
like($s, qr/^BuildArch:\s+noarch$/m, 'the compat rpm is noarch');
|
||||
like($s, qr/^Provides:\s+perl-generators$/m, '... provides perl-generators');
|
||||
like($s, qr/^Provides:\s+perl-interpreter$/m, '... provides perl-interpreter');
|
||||
like($s, qr/^Provides:\s+perl-devel$/m, '... provides perl-devel');
|
||||
like($s, qr/^Requires:\s+perl$/m, '... and pulls the real perl');
|
||||
like($s, qr/^%files\n%changelog\n/m,
|
||||
'... and lists no file between %files and %changelog, so it installs nothing');
|
||||
};
|
||||
|
||||
subtest 'the configuration carries the repository only for a SUSE target' => sub {
|
||||
plan skip_all => 'MockBuildUtils has no perl_mock_cfg_text' unless $text;
|
||||
my $suse = $text->('opensuse-leap-15.6-x86_64', '1700000000', '/work/compat/repo');
|
||||
like($suse, qr{^include\('/etc/mock/opensuse-leap-15\.6-x86_64\.cfg'\)$}m,
|
||||
'the SUSE configuration includes its base');
|
||||
like($suse, qr/SOURCE_DATE_EPOCH'\] = '1700000000'/,
|
||||
'... and keeps the deterministic epoch');
|
||||
like($suse, qr{\[xcat-buildreq-compat\]}, '... and adds the compat repository');
|
||||
like($suse, qr{baseurl=file:///work/compat/repo}, '... at the directory it was given');
|
||||
like($suse, qr/gpgcheck=0/, '... unsigned, because it is built locally for this build');
|
||||
|
||||
my $el = $text->('alma+epel-10-x86_64', '1700000000', undef);
|
||||
like($el, qr{^include\('/etc/mock/alma\+epel-10-x86_64\.cfg'\)$}m,
|
||||
'the EL configuration includes its base');
|
||||
unlike($el, qr/xcat-buildreq-compat/, '... and adds no compat repository');
|
||||
|
||||
# A SUSE target with no repository is a programming error, not a build without the compat.
|
||||
my $missed = eval { $text->('opensuse-leap-15.6-x86_64', '1700000000', undef); 1 };
|
||||
ok(!$missed, 'a SUSE target with no compat repository is refused');
|
||||
like($@, qr/compat repository/, '... and says what was missing');
|
||||
};
|
||||
|
||||
done_testing();
|
||||
Reference in New Issue
Block a user