#!/usr/bin/env bash set -e # # This script creates a bootable image and should at some point in the future # be replaced by the proper NetBSD infrastructure. # : ${ARCH=i386} : ${OBJ=../obj.${ARCH}} : ${TOOLCHAIN_TRIPLET=i586-elf32-minix-} : ${BUILDSH=build.sh} : ${SETS="minix-base minix-comp minix-games minix-man minix-tests tests"} : ${IMG=minix_x86.img} if [ ! -f ${BUILDSH} ] then echo "Please invoke me from the root source dir, where ${BUILDSH} is." exit 1 fi # we create a disk image of about 2 gig's # for alignment reasons, prefer sizes which are multiples of 4096 bytes : ${BOOTXX_SECS=32} : ${ROOT_SIZE=$(( 128*(2**20) - ${BOOTXX_SECS} * 512 ))} : ${HOME_SIZE=$(( 128*(2**20) ))} : ${USR_SIZE=$(( 1792*(2**20) ))} : ${EFI_SIZE=$(( 0 ))} # set up disk creation environment . releasetools/image.defaults . releasetools/image.functions echo "Building work directory..." build_workdir "$SETS" echo "Adding extra files..." workdir_add_hdd_files # add kernels add_link_spec "boot/minix_latest" "minix_default" extra.kernel workdir_add_kernel minix_default workdir_add_kernel minix/$RELEASE_VERSION # add boot.cfg cat >${ROOT_DIR}/boot.cfg < ${OBJ}/efi.img EFI_START=$((${HOME_START} + ${_HOME_SIZE})) echo " * EFI" ${CROSS_TOOLS}/nbmakefs -t msdos -s ${EFI_SIZE} -o "F=32,c=1" ${OBJ}/efi.img ${EFI_DIR} dd if=${OBJ}/efi.img >> ${IMG} ${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE}* 81:${_USR_SIZE} 81:${_HOME_SIZE} EF:1+ else ${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE}* 81:${_USR_SIZE} 81:${_HOME_SIZE} fi ${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr/mdec/bootxx_minixfs3 echo "" echo "Disk image at `pwd`/${IMG}" echo "" echo "To boot this image on kvm using the bootloader:" echo "qemu-system-i386 --enable-kvm -m 256 -hda `pwd`/${IMG}" echo "" echo "To boot this image on kvm:" echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256M -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}" echo "To boot this image on kvm with EFI (tianocore OVMF):" echo "qemu-system-i386 -L . -bios OVMF-i32.fd -m 256M -drive file=minix_x86.img,if=ide,format=raw"