fix: Mount proc and sys AFTER the first stage of debootstrap.

This commit is contained in:
Mingyang Li
2026-05-30 10:08:22 -07:00
parent ee779d6be7
commit 2b4eea9fc6

View File

@@ -141,16 +141,21 @@ brainux:
exit 1; \
fi
mkdir -p brainux
sudo mkdir -p brainux/proc brainux/sys
sudo mount -t proc none $(shell pwd)/brainux/proc
sudo mount --rbind /sys $(shell pwd)/brainux/sys
@if [ "$(CI)" = "true" ]; then \
echo "I'm in CI and debootstrap without cache."; \
sudo debootstrap --arch=$(ROOTFS_CROSS) --foreign trixie brainux/; \
else \
sudo debootstrap --arch=$(ROOTFS_CROSS) --foreign trixie brainux/ http://localhost:65432/debian/; \
fi
# Mount proc and sys to allow debootstrap to run the second stage in the chroot.
# Keep the mounting commands AFTER the first stage of debootstrap, because
# debootstrap's cleanup code/trap tries to clean up the target directory
# (`rm -rf /work/brainux/proc`) and fails because proc virtual files can't be removed.
sudo mkdir -p brainux/proc brainux/sys
sudo mount -t proc none $(shell pwd)/brainux/proc
sudo mount --rbind /sys $(shell pwd)/brainux/sys
sudo cp /usr/bin/qemu-arm-static brainux/usr/bin/
sudo cp ./os-brainux/setup_brainux.sh brainux/
sudo ./os-brainux/override-pre.sh ./os-brainux/override ./brainux