diff --git a/goconserver/mockbuild.pl b/goconserver/mockbuild.pl index 9e586ea..e1889a7 100755 --- a/goconserver/mockbuild.pl +++ b/goconserver/mockbuild.pl @@ -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}"; +} diff --git a/ipmitool/mockbuild.pl b/ipmitool/mockbuild.pl index 262d653..3f377b9 100755 --- a/ipmitool/mockbuild.pl +++ b/ipmitool/mockbuild.pl @@ -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}"; +} diff --git a/mockbuild-all.pl b/mockbuild-all.pl index 755a855..e168220 100755 --- a/mockbuild-all.pl +++ b/mockbuild-all.pl @@ -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) = @_; diff --git a/xnba/mockbuild.pl b/xnba/mockbuild.pl index 6ca2336..bda758d 100755 --- a/xnba/mockbuild.pl +++ b/xnba/mockbuild.pl @@ -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}"; +}