: nply/foundationpkgs

commit fda27eb4b4108c856924fc4b0171ddff0c020fdd
parent f72dd3f58702ea40e12b4015befbb555d307155f
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 29 Oct 2026 23:37:35 +0530

Isolate abuild staging paths from minci's exported environment
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/build-apk.sh b/scripts/build-apk.sh
@@ -25,6 +25,8 @@ cp -R "$recipe_dir/." "$work/recipes/$repo/$pkg/"
 # Build in a fresh copy: no mutation of the checkout or reuse of stale APKs.
 (
 	cd "$work/recipes/$repo/$pkg"
+	# minci exports its own staging paths. Never let abuild clean those directories.
+	unset srcdir pkgdir subpkgdir tmpdir startdir builddir pkgbasedir workdir destdir
 	APKBUILD="$work/recipes/$repo/$pkg/$(basename "$recipe")" \
 		REPODEST="$work/packages" SRCDEST="${SRCDEST:-$work/sources}" "$abuild" -d
 )
diff --git a/tests/apk-backend.sh b/tests/apk-backend.sh
@@ -54,6 +54,10 @@ set -eu
 [ -n "$CBUILD" ] && [ "$CHOST" = x86_64-alpine-linux-musl ]
 [ -z "${FPKGS_TEST_EXPECT_CBUILD:-}" ] || [ "$CBUILD" = "$FPKGS_TEST_EXPECT_CBUILD" ]
 [ -n "$SRCDEST" ]
+for name in srcdir pkgdir subpkgdir tmpdir startdir builddir pkgbasedir workdir destdir; do
+	eval value=\${$name-}
+	[ -z "$value" ] || { echo "Inherited CI staging variable: $name" >&2; exit 1; }
+done
 touch generated-only-in-copy
 out=$REPODEST/noarch/x86_64
 mkdir -p "$out"

@@ -91,12 +95,16 @@ FPKGS_PACKAGES=not-selected sh "$cli" plan "$rev" >"$work/filter"
 [ ! -s "$work/filter" ]
 FPKGS_PACKAGES=fixture sh "$cli" plan "$rev" >"$work/filter"
 [ "$(wc -l <"$work/filter" | tr -d ' ')" -eq 1 ]
-sh "$cli" run "$rev" >"$work/run.log" 2>&1 || {
+mkdir -p "$work/minci-source" "$work/minci-pkg" "$work/minci-work"
+printf sentinel >"$work/minci-source/keep"
+srcdir="$work/minci-source" pkgdir="$work/minci-pkg" workdir="$work/minci-work" \
+	sh "$cli" run "$rev" >"$work/run.log" 2>&1 || {
 	cat "$work/run.log"
 	find "$FPKGS_WORK_ROOT/build" -name build.log -exec tail -n 100 {} \;
 	exit 1
 }
 [ ! -f noarch/fixture/generated-only-in-copy ]
+[ "$(cat "$work/minci-source/keep")" = sentinel ]
 sh "$cli" status fixture "$FPKGS_TARGETS" "$rev" >"$work/status"
 grep -q '^format=apk$' "$work/status"
 grep -q '/noarch/x86_64/fixture-1.0-r0.apk$' "$work/status"