From 8bc351e9712d79724966d0fdc6337cb28ea770ae Mon Sep 17 00:00:00 2001 From: Zvonko Kaiser Date: Tue, 14 Jul 2026 19:32:57 +0000 Subject: [PATCH] build(qemu): use mktemp -d and trap for safe clone directory Replace rm -rf qemu + clone-into-relative-path with mktemp -d so the build never touches a pre-existing qemu/ directory in the bind-mounted host working directory. The trap ensures cleanup on any exit path. Assisted-by: Claude Sonnet 4.6 Signed-off-by: Zvonko Kaiser --- tools/packaging/static-build/qemu/build-qemu.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/packaging/static-build/qemu/build-qemu.sh b/tools/packaging/static-build/qemu/build-qemu.sh index 865e346ee6..d08d21f04f 100755 --- a/tools/packaging/static-build/qemu/build-qemu.sh +++ b/tools/packaging/static-build/qemu/build-qemu.sh @@ -26,11 +26,10 @@ HYPERVISOR_NAME="${HYPERVISOR_NAME:-}" PREFIX="${PREFIX:-}" PKGVERSION=${PKGVERSION:-} -# This script always runs inside a dedicated build container (see -# static-build/qemu/Dockerfile), so rm -rf of a relative path is safe. -rm -rf qemu -git clone --depth=1 "${QEMU_REPO}" qemu -pushd qemu +workdir="$(mktemp -d)" +trap 'rm -rf "${workdir}"' EXIT +git clone --depth=1 "${QEMU_REPO}" "${workdir}/qemu" +pushd "${workdir}/qemu" git fetch --depth=1 origin "${QEMU_VERSION_NUM}" git checkout FETCH_HEAD scripts/git-submodule.sh update meson capstone