diff --git a/tools/boot/rootgen.sh b/tools/boot/rootgen.sh index f087afa5ad49..06e8a1ec8245 100755 --- a/tools/boot/rootgen.sh +++ b/tools/boot/rootgen.sh @@ -1,833 +1,791 @@ #!/bin/sh # $FreeBSD$ passphrase=passphrase iterations=50000 # The smallest FAT32 filesystem is 33292 KB espsize=33292 # # Builds all the bat-shit crazy combinations we support booting from, # at least for amd64. It assume you have a ~sane kernel in /boot/kernel # and copies that into the ~150MB root images we create (we create the du # size of the kernel + 20MB). # # Sad panda sez: this runs as root, but could be any user if someone # creates userland geli. # # This assumes an external program install-boot.sh which will install # the appropriate boot files in the appropriate locations. # # Assumes you've already rebuilt... maybe bad? Also maybe bad: the env # vars should likely be conditionally set to allow better automation. # . $(dirname $0)/install-boot.sh cpsys() { src=$1 dst=$2 # Copy kernel + boot loader (cd $src ; tar cf - .) | (cd $dst; tar xf -) } ufs_fstab() { dir=$1 cat > ${dir}/etc/fstab < ${dst}/boot/loader.conf.local <> ${mntpt}/boot/loader.conf <> ${mntpt}/boot/loader.conf <> ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf <> ${mntpt}/boot/loader.conf <> ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf < $sh chmod 755 $sh # https://wiki.freebsd.org/arm64/QEMU also has # -device virtio-net-device,netdev=net0 # -netdev user,id=net0 } log_for() { dir=$(dirname $1) fn=$(basename $1 .sh) echo $dir/$fn.log } # Amd64 qemu qemu_amd64_legacy() { img=$1 sh=$2 log=$(log_for $2) echo "echo -n $(basename $sh .sh):' '" > $sh echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh chmod 755 $sh } qemu_amd64_uefi() { img=$1 sh=$2 log=$(log_for $2) echo "echo -n $(basename $sh .sh):' '" > $sh echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh chmod 755 $sh } qemu_amd64_both() { img=$1 sh=$2 log=$(log_for $2) echo "echo -n $(basename $sh .sh):' '" > $sh echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh echo "echo -n $(basename $sh .sh):' '" >> $sh echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee -a $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh chmod 755 $sh } # arm # nothing listed? # i386 qemu_i386_legacy() { img=$1 sh=$2 echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh chmod 755 $sh } # Not yet supported qemu_i386_uefi() { img=$1 sh=$2 echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" > $sh chmod 755 $sh } # Needs UEFI to be supported qemu_i386_both() { img=$1 sh=$2 echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" >> $sh chmod 755 $sh } make_one_image() { local arch=${1?} local geli=${2?} local scheme=${3?} local fs=${4?} local bios=${5?} # Create sparse file and mount newly created filesystem(s) on it img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh echo "$sh" >> ${IMGDIR}/all.sh echo date >> ${IMGDIR}/all.sh echo "vvvvvvvvvvvvvv Creating $img vvvvvvvvvvvvvvv" rm -f ${img}* eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios} eval qemu_${arch}_${bios} ${img} ${sh} [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}* echo "^^^^^^^^^^^^^^ Created $img ^^^^^^^^^^^^^^^" } # Powerpc -- doesn't work but maybe it would enough for testing -- needs details # powerpc64 # qemu-system-ppc64 -drive file=/path/to/disk.img,format=raw # Misc variables SRCTOP=$(make -v SRCTOP) cd ${SRCTOP}/stand OBJDIR=$(make -v .OBJDIR) IMGDIR=${OBJDIR}/boot-images mkdir -p ${IMGDIR} MNTPT=$(mktemp -d /tmp/stand-test.XXXXXX) # Setup the installed tree... DESTDIR=${OBJDIR}/boot-tree rm -rf ${DESTDIR} mkdir -p ${DESTDIR}/boot/defaults mkdir -p ${DESTDIR}/boot/kernel cp /boot/kernel/kernel ${DESTDIR}/boot/kernel echo -h -D -S115200 > ${DESTDIR}/boot.config cat > ${DESTDIR}/boot/loader.conf < ${DESTDIR}/etc/rc < ${IMGDIR}/all.sh chmod +x ${IMGDIR}/all.sh if [ $# -eq 5 ]; then make_one_image $* echo ${IMGDIR}/all.sh exit fi # OK. Let the games begin for arch in amd64; do for geli in nogeli; do # geli for scheme in gpt mbr; do - for fs in ufs ; do # zfs + for fs in ufs zfs; do for bios in legacy uefi both; do make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} done done done done done + # We should also do a cd image for amd64 here echo ${IMGDIR}/all.sh rmdir ${MNTPT} exit 0 # Notes for the future for arch in i386; do for geli in nogeli geli; do for scheme in gpt mbr; do for fs in ufs zfs; do for bios in legacy; do + # The legacy boot is shared with amd64 so those routines could + # likely be used here. make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} done done done done done + # We should also do a cd image for i386 here for arch in arm aarch64; do + geli=nogeli # I don't think geli boot works / is supported on arm for scheme in gpt mbr; do - fs=ufs - bios=efi + for fs in ufs zfs; do + bios=efi # Note: arm has some uboot support with ufs, what to do? make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} + done done done -for arch in powerpc powerpc64; do - for scheme in ppc-wtf; do - fs=ufs +# It's not clear that the nested looping paradigm is best for powerpc +# due to its diversity. +for arch in powerpc powerpc64 powerpc64le; do + geli=nogeli + for scheme in apm gpt; do + fs=ufs # zfs + gpt might be supported? for bios in ofw uboot chrp; do make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} done done done for arch in riscv; do geli=nogeli - fs=ufs + fs=ufs # Generic ZFS booting support with efi? scheme=gpt bios=efi make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} done