1#!/bin/sh 2 3# Install loader, kernel, and enough of userland to boot in QEMU and echo 4# "Hello world." from init, as a very quick smoke test for CI. Uses QEMU's 5# virtual FAT filesystem to avoid the need to create a disk image. 6# 7# $FreeBSD$ 8 9set -e 10 11# Root directory for minimal FreeBSD installation. 12ROOTDIR=$(pwd)/fat-root 13 14# Create minimal directory structure. 15rm -f $ROOTDIR/efi/boot/BOOTx64.EFI 16for dir in dev bin efi/boot etc lib libexec sbin usr/libexec; do 17 mkdir -p $ROOTDIR/$dir 18done 19 20# Install kernel, loader and minimal userland. 21make -DNO_ROOT DESTDIR=$ROOTDIR \ 22 MODULES_OVERRIDE= \ 23 WITHOUT_DEBUG_FILES=yes \ 24 WITHOUT_KERNEL_SYMBOLS=yes \ 25 installkernel 26for dir in stand \ 27 lib/libc lib/libedit lib/ncurses \ 28 libexec/rtld-elf \ 29 bin/sh sbin/init sbin/shutdown; do 30 make -DNO_ROOT DESTDIR=$ROOTDIR INSTALL="install -U" \ 31 WITHOUT_MAN= \ 32 WITHOUT_PROFILE= \ 33 WITHOUT_TESTS= \ 34 WITHOUT_TOOLCHAIN= \ 35 -C $dir install 36done 37 38# Put loader in standard EFI location. 39mv $ROOTDIR/boot/loader.efi $ROOTDIR/efi/boot/BOOTx64.EFI 40 41# Configuration files. 42cat > $ROOTDIR/boot/loader.conf <<EOF 43vfs.root.mountfrom="msdosfs:/dev/ada0s1" 44autoboot_delay=-1 45boot_verbose=YES 46EOF 47cat > $ROOTDIR/etc/rc <<EOF 48#!/bin/sh 49 50echo "Hello world." 51/sbin/shutdown -p now 52EOF 53 54# Remove unnecessary files to keep FAT filesystem size down. 55rm -rf $ROOTDIR/METALOG $ROOTDIR/usr/lib 56 57# And, boot in QEMU. 58timeout 300 \ 59 qemu-system-x86_64 -m 256M -bios OVMF.fd \ 60 -serial stdio -vga none -nographic -monitor none \ 61 -snapshot -hda fat:$ROOTDIR 2>&1 | tee boot.log 62grep -q 'Hello world.' boot.log 63echo OK 64