make_mirror.sh,run_qemu.sh: use temporary directory for temporary files instead of the current working directory
This commit is contained in:
parent
8cbc9e9a00
commit
0cc9e3b44a
2 changed files with 24 additions and 20 deletions
|
@ -163,11 +163,12 @@ mkdir -p "$cachedir"
|
||||||
# Write tarfile via redirection because in the Debian package autopkgtest
|
# Write tarfile via redirection because in the Debian package autopkgtest
|
||||||
# ./mmdebstrap is a suid binary and we do not want the tarfile being owned
|
# ./mmdebstrap is a suid binary and we do not want the tarfile being owned
|
||||||
# by root.
|
# by root.
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
./mmdebstrap --variant=apt --architectures=amd64,armhf --mode=unshare \
|
./mmdebstrap --variant=apt --architectures=amd64,armhf --mode=unshare \
|
||||||
--include=linux-image-amd64,systemd-sysv,perl,arch-test,fakechroot,fakeroot,mount,uidmap,proot,qemu-user-static,binfmt-support,qemu-user,dpkg-dev,mini-httpd,libdevel-cover-perl,debootstrap,libfakechroot:armhf,libfakeroot:armhf \
|
--include=linux-image-amd64,systemd-sysv,perl,arch-test,fakechroot,fakeroot,mount,uidmap,proot,qemu-user-static,binfmt-support,qemu-user,dpkg-dev,mini-httpd,libdevel-cover-perl,debootstrap,libfakechroot:armhf,libfakeroot:armhf \
|
||||||
unstable > debian-unstable.tar
|
unstable > "$tmpdir/debian-unstable.tar"
|
||||||
|
|
||||||
cat << END > extlinux.conf
|
cat << END > "$tmpdir/extlinux.conf"
|
||||||
default linux
|
default linux
|
||||||
timeout 0
|
timeout 0
|
||||||
|
|
||||||
|
@ -176,7 +177,7 @@ kernel /vmlinuz
|
||||||
append initrd=/initrd.img root=/dev/sda1 rw console=ttyS0,115200
|
append initrd=/initrd.img root=/dev/sda1 rw console=ttyS0,115200
|
||||||
serial 0 115200
|
serial 0 115200
|
||||||
END
|
END
|
||||||
cat << END > mmdebstrap.service
|
cat << END > "$tmpdir/mmdebstrap.service"
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=mmdebstrap worker script
|
Description=mmdebstrap worker script
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ END
|
||||||
# filesystem that doesn't support ownership information at all and a umask that
|
# filesystem that doesn't support ownership information at all and a umask that
|
||||||
# gives read/write access to everybody.
|
# gives read/write access to everybody.
|
||||||
# https://github.com/pjcj/Devel--Cover/issues/223
|
# https://github.com/pjcj/Devel--Cover/issues/223
|
||||||
cat << 'END' > worker.sh
|
cat << 'END' > "$tmpdir/worker.sh"
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mount -t 9p -o trans=virtio,access=any mmdebstrap /mnt
|
mount -t 9p -o trans=virtio,access=any mmdebstrap /mnt
|
||||||
(
|
(
|
||||||
|
@ -215,33 +216,34 @@ mount -t 9p -o trans=virtio,access=any mmdebstrap /mnt
|
||||||
umount /mnt
|
umount /mnt
|
||||||
systemctl poweroff
|
systemctl poweroff
|
||||||
END
|
END
|
||||||
chmod +x worker.sh
|
chmod +x "$tmpdir/worker.sh"
|
||||||
cat << 'END' > mini-httpd
|
cat << 'END' > "$tmpdir/mini-httpd"
|
||||||
START=1
|
START=1
|
||||||
DAEMON_OPTS="-h 127.0.0.1 -p 80 -u nobody -dd /mnt -i /var/run/mini-httpd.pid -T UTF-8"
|
DAEMON_OPTS="-h 127.0.0.1 -p 80 -u nobody -dd /mnt -i /var/run/mini-httpd.pid -T UTF-8"
|
||||||
END
|
END
|
||||||
cat << 'END' > hosts
|
cat << 'END' > "$tmpdir/hosts"
|
||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
END
|
END
|
||||||
#libguestfs-test-tool
|
#libguestfs-test-tool
|
||||||
#export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
|
#export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
|
||||||
guestfish -N debian-unstable.img=disk:2G -- \
|
guestfish -N "$tmpdir/debian-unstable.img"=disk:2G -- \
|
||||||
part-disk /dev/sda mbr : \
|
part-disk /dev/sda mbr : \
|
||||||
part-set-bootable /dev/sda 1 true : \
|
part-set-bootable /dev/sda 1 true : \
|
||||||
mkfs ext2 /dev/sda1 : \
|
mkfs ext2 /dev/sda1 : \
|
||||||
mount /dev/sda1 / : \
|
mount /dev/sda1 / : \
|
||||||
tar-in debian-unstable.tar / : \
|
tar-in "$tmpdir/debian-unstable.tar" / : \
|
||||||
extlinux / : \
|
extlinux / : \
|
||||||
copy-in extlinux.conf / : \
|
copy-in "$tmpdir/extlinux.conf" / : \
|
||||||
mkdir-p /etc/systemd/system/multi-user.target.wants : \
|
mkdir-p /etc/systemd/system/multi-user.target.wants : \
|
||||||
ln-s ../mmdebstrap.service /etc/systemd/system/multi-user.target.wants/mmdebstrap.service : \
|
ln-s ../mmdebstrap.service /etc/systemd/system/multi-user.target.wants/mmdebstrap.service : \
|
||||||
copy-in mmdebstrap.service /etc/systemd/system/ : \
|
copy-in "$tmpdir/mmdebstrap.service" /etc/systemd/system/ : \
|
||||||
copy-in worker.sh / : \
|
copy-in "$tmpdir/worker.sh" / : \
|
||||||
copy-in mini-httpd /etc/default : \
|
copy-in "$tmpdir/mini-httpd" /etc/default : \
|
||||||
copy-in hosts /etc/ :
|
copy-in "$tmpdir/hosts" /etc/ :
|
||||||
rm extlinux.conf worker.sh mini-httpd hosts debian-unstable.tar mmdebstrap.service
|
rm "$tmpdir/extlinux.conf" "$tmpdir/worker.sh" "$tmpdir/mini-httpd" "$tmpdir/hosts" "$tmpdir/debian-unstable.tar" "$tmpdir/mmdebstrap.service"
|
||||||
qemu-img convert -O qcow2 debian-unstable.img "$cachedir/debian-unstable.qcow"
|
qemu-img convert -O qcow2 "$tmpdir/debian-unstable.img" "$cachedir/debian-unstable.qcow"
|
||||||
rm debian-unstable.img
|
rm "$tmpdir/debian-unstable.img"
|
||||||
|
rmdir "$tmpdir"
|
||||||
|
|
||||||
mirror="http://127.0.0.1/debian"
|
mirror="http://127.0.0.1/debian"
|
||||||
SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' "$mirrordir/dists/unstable/Release")" +%s)
|
SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' "$mirrordir/dists/unstable/Release")" +%s)
|
||||||
|
|
|
@ -3,19 +3,21 @@
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cachedir="./shared/cache"
|
cachedir="./shared/cache"
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
|
||||||
# the path to debian-unstable.qcow must be absolute or otherwise qemu will
|
# the path to debian-unstable.qcow must be absolute or otherwise qemu will
|
||||||
# look for the path relative to debian-unstable-overlay.qcow
|
# look for the path relative to debian-unstable-overlay.qcow
|
||||||
qemu-img create -f qcow2 -b "$(realpath $cachedir)/debian-unstable.qcow" debian-unstable-overlay.qcow
|
qemu-img create -f qcow2 -b "$(realpath $cachedir)/debian-unstable.qcow" "$tmpdir/debian-unstable-overlay.qcow"
|
||||||
qemu-system-x86_64 -enable-kvm -m 512M -nographic \
|
qemu-system-x86_64 -enable-kvm -m 512M -nographic \
|
||||||
-monitor unix:/tmp/monitor,server,nowait \
|
-monitor unix:/tmp/monitor,server,nowait \
|
||||||
-serial unix:/tmp/ttyS0,server,nowait \
|
-serial unix:/tmp/ttyS0,server,nowait \
|
||||||
-serial unix:/tmp/ttyS1,server,nowait \
|
-serial unix:/tmp/ttyS1,server,nowait \
|
||||||
-virtfs local,id=mmdebstrap,path="$(pwd)/shared",security_model=none,mount_tag=mmdebstrap \
|
-virtfs local,id=mmdebstrap,path="$(pwd)/shared",security_model=none,mount_tag=mmdebstrap \
|
||||||
-drive file=debian-unstable-overlay.qcow,cache=unsafe,index=0
|
-drive file="$tmpdir/debian-unstable-overlay.qcow",cache=unsafe,index=0
|
||||||
head --lines=-1 shared/result.txt
|
head --lines=-1 shared/result.txt
|
||||||
if [ "$(tail --lines=1 shared/result.txt)" -ne 0 ]; then
|
if [ "$(tail --lines=1 shared/result.txt)" -ne 0 ]; then
|
||||||
echo "test.sh failed"
|
echo "test.sh failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm debian-unstable-overlay.qcow shared/result.txt
|
rm "$tmpdir/debian-unstable-overlay.qcow" shared/result.txt
|
||||||
|
rmdir "$tmpdir"
|
||||||
|
|
Loading…
Reference in a new issue