From 411da1539eb890ae896cfbf1f1db58a7440674ad Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 13 Aug 2026 06:29:42 -0300 Subject: [PATCH] fix(xcat-dep): scrub the shared genesis mock chroot before each build The xCAT-genesis-base build runs buildrpms.pl without a per-run --mock-uniqueext, so its mock chroot (xCAT-genesis-base-) is shared across CD runs. mock only scrubs a chroot on a SUCCESSFUL build, so a killed or failFast-interrupted prior run leaves the chroot stunted (missing /bin/sh), and mock REUSES that corpse on the next run, which then dies with FileNotFoundError: '/bin/sh' during genesis -- failing an otherwise-healthy build until an operator manually scrubs the chroot. Scrub the genesis chroot before building it: a lock-safe, best-effort 'mock --scrub=chroot --scrub=bootstrap' (skipped if a concurrent build holds the lock, a no-op on the first run before the config exists). Any corpse from an interrupted run is dropped and mock recreates the chroot fresh from the cached root, so an interrupted build can no longer poison the next one. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- mockbuild-all.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mockbuild-all.pl b/mockbuild-all.pl index e7a0ddd..a0cbd41 100755 --- a/mockbuild-all.pl +++ b/mockbuild-all.pl @@ -520,7 +520,15 @@ if (!$skip_build) { # buildrpms.pl's rpmdev-setuptree only runs during env setup, not per build, so create the # rpmbuild tree ourselves for this per-target HOME (else $HOME/rpmbuild/SOURCES is missing). my $mktree = join(' ', map { sh_quote("$genesis_home/rpmbuild/$_") } qw(SOURCES SPECS BUILD BUILDROOT RPMS SRPMS)); - my $cmd = "mkdir -p $mktree && HOME=" . sh_quote($genesis_home) . ' ' . join(' ', + # The genesis chroot (xCAT-genesis-base-) is SHARED across runs -- buildrpms.pl builds it + # without a per-run --mock-uniqueext. mock's post-build scrub only runs on SUCCESS, so a killed + # or failFast-interrupted prior run leaves the chroot stunted (missing /bin/sh), and mock REUSES + # the corpse on the next run -> "FileNotFoundError: '/bin/sh'". Scrub it FIRST (lock-safe -- mock + # refuses if a concurrent build holds it -- and best-effort: a no-op on the first run before the + # config exists) so mock recreates the chroot fresh from the cached root (fast, no re-bootstrap). + my $genesis_scrub = "{ mock -r " . sh_quote("xCAT-genesis-base-$target") + . " --scrub=chroot --scrub=bootstrap >/dev/null 2>&1 || true; }"; + my $cmd = "mkdir -p $mktree && $genesis_scrub && HOME=" . sh_quote($genesis_home) . ' ' . join(' ', 'perl', sh_quote("$xcat_src/buildrpms.pl"), '--package', 'xCAT-genesis-base', '--target', sh_quote($target),