I tried attaching strace to debootstrap instead, this showed it forking off a child process at the end, waiting on it, and getting a WEXITSTATUS of 1. run-debootstrap is out of the picture.
I'm pretty sure the problem is in the exit_function, this explains why set -x makes it look like it exits zero. But somehow it's failing. Actually, I suspect the exit_function gets run twice, once by the main debootstrap but before that, by its child process, which is started by the new call to second_stage_install. This causes things like umount /target/dev/pts to fail, and also I've noticed that after its exit, /target/proc is still mounted. Aj and I did some more poking at it; I tried a modification he suggested, changing this: eval $(eval echo \${EXIT_THING_$n}) 2>/dev/null || true To this: eval \${EXIT_THING_$n} 2>/dev/null || true This didn't change anything I could see. I've attached a strace of debootstrap with that change (and with set -x so you can kinda see what shell stuff it's doing). Adding a hash in front of that line does avoid the problem.. -- see shy jo
log.gz
Description: Binary data
signature.asc
Description: Digital signature