docs/cookbook/container: don't delete *.out and *.code during build.

If mkdocs is running in parallel, it can get upset if one of these
files exists when it lists the directory, but doesn't exist when it
goes to generate the output.  Fundamentally this is a problem in mkdocs
more than in our code, but we might as well avoid it.
This commit is contained in:
Avery Pennarun 2019-02-02 23:54:27 -05:00
commit 6fbda9a7b3
3 changed files with 9 additions and 8 deletions

View file

@ -1,7 +1,7 @@
./need.sh python kvm busybox
redo-ifchange "$2.initrd" memcalc.py
rm -f "$3.out" "$3.code"
rm -f "$1.out" "$1.code"
# Linux only allows an initrd of size < 50% of RAM,
# so set a RAM amount based on the initrd size.
@ -16,18 +16,17 @@ kvm \
-no-reboot \
-display none \
-chardev stdio,mux=on,id=char0 \
-chardev file,id=char1,path="$3.out" \
-chardev file,id=char2,path="$3.code" \
-chardev file,id=char1,path="$1.out" \
-chardev file,id=char2,path="$1.code" \
-serial chardev:char0 \
-serial chardev:char1 \
-serial chardev:char2 >&2
read rv <$3.code || true
read rv <$1.code || true
[ -z "$rv" ] && exit 99
if [ "$rv" -eq 0 ]; then
sed -e 's/\r//g' "$3.out" >$3
sed -e 's/\r//g' "$1.out" >$3
echo "ok." >&2
else
echo "kvm program returned error: $rv" >&2
fi
rm -f "$3.out" "$3.code"
exit "$rv"