diff --git a/conserver/mockbuild.pl b/conserver/mockbuild.pl index d8a1eb1..61fca86 100755 --- a/conserver/mockbuild.pl +++ b/conserver/mockbuild.pl @@ -102,7 +102,7 @@ print "SRPM: $srpm\n"; print "== mock --rebuild ($mock_cfg) ==\n"; my $mock_result = "$work_dir/mock-result"; make_path($mock_result); -run("mock -r " . sh_quote($mock_cfg) . $uniq +run_mock("mock -r " . sh_quote($mock_cfg) . $uniq . " --rebuild " . sh_quote($srpm) . " --resultdir " . sh_quote($mock_result) . " > " . sh_quote("$log_dir/mock-rebuild.log") . " 2>&1"); @@ -146,6 +146,18 @@ sub capture { chomp $out if defined $out; return $out // ''; } +# mock exits 30 when its package manager failed (chroot init, build deps), which against public +# mirrors is most often a transient download error (stale mirror metadata): retry such a run once. +sub run_mock { + my ($cmd) = @_; + my $rc = system('bash', '-c', $cmd); + if ($rc != -1 && ($rc >> 8) == 30) { + print "mock failed with rc=30 (package manager); retrying once\n"; + $rc = system('bash', '-c', $cmd); + } + die "FATAL: command failed (rc=" . ($rc >> 8) . "): $cmd\n" if $rc != 0; + return 1; +} sub sh_quote { my ($s) = @_; $s =~ s/'/'\\''/g; return "'$s'"; } sub usage { return "usage: mockbuild.pl --mock-cfg [--target-arch ARCH] [--result-dir DIR] [--work-dir DIR]\n" diff --git a/grub2-xcat/mockbuild.pl b/grub2-xcat/mockbuild.pl index e0815ab..9c978d9 100644 --- a/grub2-xcat/mockbuild.pl +++ b/grub2-xcat/mockbuild.pl @@ -152,7 +152,7 @@ print "Prep dry run passed. Applied patches: $patch_count\n"; print_step("Build SRPM with mock"); my $srpm_out = "$work_dir/srpm"; make_path($srpm_out); -run( +run_mock( "mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --buildsrpm --spec " . sh_quote($spec_file) . " --sources " . sh_quote($pkg_dir) . @@ -170,7 +170,7 @@ print "SRPM: $srpm\n"; print_step("Rebuild RPM with mock"); my $rpm_out = "$work_dir/rpm"; make_path($rpm_out); -run( +run_mock( "mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --rebuild " . sh_quote($srpm) . " --resultdir " . sh_quote($rpm_out) . @@ -384,6 +384,22 @@ sub capture { return $out; } +# mock exits 30 when its package manager failed (chroot init, build deps), which against public +# mirrors is most often a transient download error (stale mirror metadata): retry such a run once. +sub run_mock { + my ($cmd) = @_; + print "+ $cmd\n"; + my $rc = system($cmd); + if ($rc != -1 && ($rc >> 8) == 30) { + print "mock failed with rc=30 (package manager); retrying once\n"; + $rc = system($cmd); + } + if ($rc != 0) { + my $exit = $rc == -1 ? 255 : ($rc >> 8); + die "Command failed (rc=$exit): $cmd\n"; + } +} + sub run_capture_rc { my ($cmd, $log_file) = @_; my $full = "$cmd > " . sh_quote($log_file) . " 2>&1"; diff --git a/ipmitool/mockbuild.pl b/ipmitool/mockbuild.pl old mode 100755 new mode 100644 index 6f7094c..9a5bba8 --- a/ipmitool/mockbuild.pl +++ b/ipmitool/mockbuild.pl @@ -138,7 +138,7 @@ print "Patch application check passed. Applied patches: $patch_count\n"; print_step("Build SRPM with mock"); my $srpm_out = "$work_dir/srpm"; make_path($srpm_out); -run( +run_mock( "mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --buildsrpm --spec " . sh_quote($spec_file) . " --sources " . sh_quote($pkg_dir) . @@ -156,7 +156,7 @@ print "SRPM: $srpm\n"; print_step("Rebuild RPM with mock"); my $rpm_out = "$work_dir/rpm"; make_path($rpm_out); -run( +run_mock( "mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --rebuild " . sh_quote($srpm) . " --define " . sh_quote("use_source_date_epoch_as_buildtime 1") . @@ -205,7 +205,7 @@ if (!$skip_install && $target_arch ne $arch) { # A cross-built rpm cannot be installed on this host: install it into the (emulated) build # chroot instead and run the binary there. print_step("Install RPM into the chroot and run smoke tests"); - run("mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --install " . sh_quote($main_rpm) + run_mock("mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --install " . sh_quote($main_rpm) . " > " . sh_quote("$log_dir/smoke-chroot-install.log") . " 2>&1"); my $bin = '/opt/xcat/bin/ipmitool-xcat'; my $version_log = "$log_dir/smoke-version.log"; @@ -403,6 +403,22 @@ sub capture { return $out; } +# mock exits 30 when its package manager failed (chroot init, build deps), which against public +# mirrors is most often a transient download error (stale mirror metadata): retry such a run once. +sub run_mock { + my ($cmd) = @_; + print "+ $cmd\n"; + my $rc = system($cmd); + if ($rc != -1 && ($rc >> 8) == 30) { + print "mock failed with rc=30 (package manager); retrying once\n"; + $rc = system($cmd); + } + if ($rc != 0) { + my $exit = $rc == -1 ? 255 : ($rc >> 8); + die "Command failed (rc=$exit): $cmd\n"; + } +} + sub run_capture_rc { my ($cmd, $log_file) = @_; my $full = "$cmd > " . sh_quote($log_file) . " 2>&1"; diff --git a/mockbuild-perl-packages.pl b/mockbuild-perl-packages.pl index 1ea27d7..2869aa0 100644 --- a/mockbuild-perl-packages.pl +++ b/mockbuild-perl-packages.pl @@ -514,7 +514,7 @@ sub build_package { my $srpm_result = "$pkg_run_dir/srpm"; make_path($srpm_result); - run( + run_mock( "mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --buildsrpm --spec " . sh_quote($spec) . " --sources " . sh_quote($source_dir) . @@ -539,7 +539,7 @@ sub build_package { $additional_opt .= " --additional-package " . sh_quote($_) for @need_rpms; } - run( + run_mock( "mock -r " . sh_quote($det_mock_cfg) . $mock_uniqueext_opt . " --rebuild " . sh_quote($srpm_path) . $additional_opt . " --define " . sh_quote("use_source_date_epoch_as_buildtime 1") . @@ -784,6 +784,22 @@ sub capture { return $out; } +# mock exits 30 when its package manager failed (chroot init, build deps), which against public +# mirrors is most often a transient download error (stale mirror metadata): retry such a run once. +sub run_mock { + my ($cmd) = @_; + print "+ $cmd\n"; + my $rc = system($cmd); + if ($rc != -1 && ($rc >> 8) == 30) { + print "mock failed with rc=30 (package manager); retrying once\n"; + $rc = system($cmd); + } + if ($rc != 0) { + my $exit = $rc == -1 ? 255 : ($rc >> 8); + die "Command failed (rc=$exit): $cmd\n"; + } +} + sub run_capture_rc { my ($cmd, $log_file) = @_; my $full = "$cmd > " . sh_quote($log_file) . " 2>&1";