Seems that there is a delay before the disk can be used when using newer QEMU versions (e.g. on Debian trixie). We get errors like these: sfdisk: cannot open /dev/nbd0: Inappropriate ioctl for device or mount: /srv/strongswan-testing/build/loop: special device /dev/nbd0p1 does not exist. A sleep before the next command seems to help. Also see [1]. [1] https://gitlab.com/qemu-project/qemu/-/issues/1413
51 lines
1.4 KiB
Bash
Executable File
51 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
DIR="$(dirname `readlink -f $0`)/.."
|
|
. $DIR/testing.conf
|
|
. $DIR/scripts/function.sh
|
|
|
|
[ `id -u` -eq 0 ] || die "You must be root to run $0"
|
|
[ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
|
|
[ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
|
|
running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
|
|
|
|
SRCUID=${SUDO_UID:-$(id -u)}
|
|
SRCGID=${SUDO_GID:-$(id -g)}
|
|
|
|
check_commands blockdev qemu-img qemu-nbd bindfs
|
|
|
|
load_qemu_nbd
|
|
|
|
mkdir -p $LOOPDIR
|
|
mkdir -p $IMGDIR
|
|
|
|
log_action "Connecting root image to NBD device $NBDEV"
|
|
execute "qemu-nbd -c $NBDEV $ROOTIMG"
|
|
do_on_exit qemu-nbd -d $NBDEV
|
|
# wait for disk to become ready with newer QEMU versions
|
|
sleep 1
|
|
blockdev --rereadpt $NBDEV
|
|
|
|
log_action "Mounting $NBDPARTITION to $LOOPDIR"
|
|
execute "mount $NBDPARTITION $LOOPDIR"
|
|
do_on_exit umount $LOOPDIR
|
|
|
|
log_action "Mounting proc filesystem to $LOOPDIR/proc"
|
|
execute "mount -t proc none $LOOPDIR/proc"
|
|
do_on_exit umount $LOOPDIR/proc
|
|
|
|
mkdir -p $LOOPDIR/root/testing
|
|
log_action "Mounting ${DIR} as /root/testing"
|
|
execute "bindfs -u $SRCUID -g $SRCGID --create-for-user=$SRCUID --create-for-group=$SRCGID ${DIR} $LOOPDIR/root/testing"
|
|
do_on_exit umount $LOOPDIR/root/testing
|
|
|
|
log_action "Building certificates"
|
|
execute_chroot "/root/testing/scripts/build-certs-chroot"
|
|
|
|
# rebuild the guest images to generate the CRLs on winnetou
|
|
if [ -z "$2" ]; then
|
|
# cleanup before mounting guest images
|
|
on_exit
|
|
$DIR/scripts/build-guestimages
|
|
fi
|