-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Introduce prepare-integration make target
to prepare the VM filesystem for the tests. This target is suppused to be run like so: make prepare-integration integration but currently the filesystem it creates is not bootable for some reason. Signed-off-by: Dimitris Karakasilis <[email protected]>
- Loading branch information
1 parent
0ef7b8f
commit 451571e
Showing
4 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,48 @@ | ||
#!/bin/bash | ||
dd if=/dev/zero of=rootfs.raw bs=1G count=1 | ||
mkfs.ext4 rootfs.raw | ||
sudo losetup -fP rootfs.raw | ||
mkdir rootfs | ||
sudo mount /dev/loop0 rootfs | ||
sudo pacstrap rootfs base openssh | ||
|
||
# TODO: Move to a pre-built image? | ||
prepareDeps(){ | ||
pacman -Sy | ||
pacman -S --noconfirm sudo qemu-img arch-install-scripts linux dracut | ||
} | ||
|
||
cleanupPreviousRuns() { | ||
rm -rf "${OUTDIR}/rootfs" | ||
rm -rf "${OUTDIR}/rootfs.raw" | ||
} | ||
|
||
set -ex | ||
|
||
export WORKDIR=/workdir | ||
export OUTDIR=$WORKDIR/kernel | ||
|
||
prepareDeps | ||
cleanupPreviousRuns | ||
|
||
# Copy a kernel file too | ||
find /usr/lib/modules/ -name "vmlinuz" -type f -exec cp {} $OUTDIR/bzImage \; -quit | ||
|
||
dd if=/dev/zero of="${OUTDIR}/rootfs.raw" bs=1G count=1 | ||
mkfs.ext4 "${OUTDIR}/rootfs.raw" | ||
sudo losetup -fP "${OUTDIR}/rootfs.raw" | ||
mkdir "${OUTDIR}/rootfs" | ||
sudo mount /dev/loop0 "${OUTDIR}/rootfs" | ||
sudo pacstrap "${OUTDIR}/rootfs" base openssh | ||
|
||
echo "[Match] | ||
Name=enp0s3 | ||
[Network] | ||
DHCP=yes" | sudo tee rootfs/etc/systemd/network/20-wired.network | ||
DHCP=yes" | sudo tee "${OUTDIR}/rootfs/etc/systemd/network/20-wired.network" | ||
|
||
sudo sed -i '/^root/ { s/:x:/::/ }' rootfs/etc/passwd | ||
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' rootfs/etc/ssh/sshd_config | ||
sudo sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords yes/' rootfs/etc/ssh/sshd_config | ||
sudo sed -i '/^root/ { s/:x:/::/ }' "${OUTDIR}/rootfs/etc/passwd" | ||
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' "${OUTDIR}/rootfs/etc/ssh/sshd_config" | ||
sudo sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords yes/' "${OUTDIR}/rootfs/etc/ssh/sshd_config" | ||
|
||
sudo arch-chroot rootfs systemctl enable sshd systemd-networkd | ||
sudo rm rootfs/var/cache/pacman/pkg/* | ||
sudo umount rootfs | ||
sudo arch-chroot "${OUTDIR}/rootfs" systemctl enable sshd systemd-networkd | ||
sudo rm "${OUTDIR}"/rootfs/var/cache/pacman/pkg/* | ||
sudo umount "${OUTDIR}"/rootfs | ||
sudo losetup -d /dev/loop0 | ||
rm -r rootfs | ||
qemu-img create -o backing_file=rootfs.raw,backing_fmt=raw -f qcow2 rootfs.cow | ||
rm -r "${OUTDIR}"/rootfs | ||
qemu-img create -o backing_file=rootfs.raw,backing_fmt=raw -f qcow2 "${OUTDIR}"/rootfs.cow | ||
chmod 777 "${OUTDIR}"/rootfs.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters