2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-05-17 03:44:21 +00:00

fix: Resolve mock config for AlmaLinux and Rocky Linux builders

Auto-detection used OS ID directly (e.g. almalinux+epel-10-ppc64le)
but mock configs use short forms (alma+epel-10-ppc64le). Add
resolve_mock_cfg helper that tries the full ID first, then falls
back to known short forms.
This commit is contained in:
Vinícius Ferrão
2026-05-10 14:03:48 -03:00
parent 2913d072ab
commit eeb06fbb42
4 changed files with 70 additions and 4 deletions
+15 -1
View File
@@ -43,7 +43,7 @@ for my $bin (qw(go git rpmbuild rpm)) {
my $arch = capture('uname -m');
if (!$mock_cfg) {
my $os_id = capture(q{bash -lc 'source /etc/os-release; echo $ID'});
$mock_cfg = "${os_id}+epel-10-${arch}";
$mock_cfg = resolve_mock_cfg($os_id, '10', $arch);
}
my ($rel) = $mock_cfg =~ /-(\d+)-/;
@@ -298,3 +298,17 @@ sub write_file {
print $fh $content;
close $fh;
}
sub resolve_mock_cfg {
my ($os_id, $rel, $arch) = @_;
my %short_forms = (almalinux => 'alma', rocky => 'rocky');
my $candidate = "${os_id}+epel-${rel}-${arch}";
my $rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
return $candidate if $rc == 0;
if (exists $short_forms{$os_id}) {
$candidate = "$short_forms{$os_id}+epel-${rel}-${arch}";
$rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
return $candidate if $rc == 0;
}
return "${os_id}+epel-${rel}-${arch}";
}
+15 -1
View File
@@ -51,7 +51,7 @@ my $source_path = "$pkg_dir/$source_file";
my $arch = capture('uname -m');
if (!$mock_cfg) {
my $os_id = capture(q{bash -lc 'source /etc/os-release; echo $ID'});
$mock_cfg = "${os_id}+epel-10-${arch}";
$mock_cfg = resolve_mock_cfg($os_id, '10', $arch);
}
my $mock_uniqueext_opt = $mock_uniqueext ne ''
? ' --uniqueext ' . sh_quote($mock_uniqueext)
@@ -354,3 +354,17 @@ sub slurp {
close $fh;
return $content;
}
sub resolve_mock_cfg {
my ($os_id, $rel, $arch) = @_;
my %short_forms = (almalinux => 'alma', rocky => 'rocky');
my $candidate = "${os_id}+epel-${rel}-${arch}";
my $rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
return $candidate if $rc == 0;
if (exists $short_forms{$os_id}) {
$candidate = "$short_forms{$os_id}+epel-${rel}-${arch}";
$rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
return $candidate if $rc == 0;
}
return "${os_id}+epel-${rel}-${arch}";
}
+25 -1
View File
@@ -69,7 +69,7 @@ die "Could not resolve major release from VERSION_ID='$version_id' in /etc/os-re
if !defined($rel) || $rel eq '';
if (!$target) {
$target = "${os_id}+epel-${rel}-${arch}";
$target = resolve_mock_cfg($os_id, $rel, $arch);
}
for my $bin (qw(perl uname createrepo tar find rpm)) {
require_command($bin);
@@ -622,6 +622,30 @@ sub collect_srpms {
return ($copied, $skipped_non_src, $missing_roots);
}
sub resolve_mock_cfg {
my ($os_id, $rel, $arch) = @_;
my %short_forms = (
almalinux => 'alma',
'centos-stream' => 'centos-stream',
rocky => 'rocky',
);
my $candidate = "${os_id}+epel-${rel}-${arch}";
my $rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
if ($rc == 0) {
return $candidate;
}
if (exists $short_forms{$os_id}) {
my $short = $short_forms{$os_id};
$candidate = "${short}+epel-${rel}-${arch}";
$rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
if ($rc == 0) {
print "Mock config resolved (short form): $candidate\n";
return $candidate;
}
}
die "Could not find mock config for ${os_id}+epel-${rel}-${arch}\n";
}
sub build_mock_uniqueext {
my ($run, $seq, $label) = @_;
+15 -1
View File
@@ -43,7 +43,7 @@ for my $bin (qw(rpmbuild rpm tar)) {
my $arch = capture('uname -m');
if (!$mock_cfg) {
my $os_id = capture(q{bash -lc 'source /etc/os-release; echo $ID'});
$mock_cfg = "${os_id}+epel-10-${arch}";
$mock_cfg = resolve_mock_cfg($os_id, '10', $arch);
}
print_step("Configuration");
@@ -186,3 +186,17 @@ sub basename {
$path =~ s{.*/}{};
return $path;
}
sub resolve_mock_cfg {
my ($os_id, $rel, $arch) = @_;
my %short_forms = (almalinux => 'alma', rocky => 'rocky');
my $candidate = "${os_id}+epel-${rel}-${arch}";
my $rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
return $candidate if $rc == 0;
if (exists $short_forms{$os_id}) {
$candidate = "$short_forms{$os_id}+epel-${rel}-${arch}";
$rc = system("mock -r " . sh_quote($candidate) . " --print-root-path >/dev/null 2>&1");
return $candidate if $rc == 0;
}
return "${os_id}+epel-${rel}-${arch}";
}