From 06c8cd0ca94ec02a6b3d20d8231593a8db3821e7 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 19 Aug 2021 23:37:45 +0200 Subject: [PATCH] build/serial: rebuild UEFI on FreeBSD 13 The .efifat files have been deleted from the distribution so they need to be handrolled. That's alright, but then mkimg doesn't work on FreeBSD 13 because our STAGEDIR contains a ":" character. Sidestep the issue by using a relative path inside STAGEDIR, but also hoping that file names with ":" are not becoming second-class. This should be compatible with 21.7 builds although we likely do not need new images. While here also convert dvd image with others to be done later. --- build/common.sh | 20 ++++++++++++++++++++ build/dvd.sh | 19 ++++++------------- build/serial.sh | 19 ++++++++++++------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/build/common.sh b/build/common.sh index 9106762..ff8b0fe 100644 --- a/build/common.sh +++ b/build/common.sh @@ -1111,6 +1111,26 @@ EOF EOF } +setup_efiboot() +{ + local EFIFILE + + if [ ${PRODUCT_ARCH} = "amd64" ]; then + EFIFILE=bootx64 + elif [ ${PRODUCT_ARCH} = "aarch64" ]; then + EFIFILE=bootaa64 + else + echo ">>> Unsupported UEFI architecture: ${PRODUCT_ARCH}" >&2 + exit 1 + fi + + mkdir -p ${1}.d/EFI/LOADER + cp ${2} ${1}.d/EFI/LOADER/${EFIFILE}.efi + + makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \ + -o volume_label=EFISYS -s 33292k ${1} ${1}.d +} + setup_stage() { echo ">>> Setting up stage in ${1}" diff --git a/build/dvd.sh b/build/dvd.sh index 39b9aa4..f34fdc7 100644 --- a/build/dvd.sh +++ b/build/dvd.sh @@ -47,23 +47,14 @@ setup_mtree ${STAGEDIR}/work setup_entropy ${STAGEDIR}/work UEFIBOOT= -if [ ${PRODUCT_ARCH} = "amd64" -a -n "${PRODUCT_UEFI}" -a \ - -z "${PRODUCT_UEFI%%*"${SELF}"*}" ]; then - dd if=/dev/zero of=${STAGEDIR}/efiboot.img bs=4k count=200 - DEV=$(mdconfig -a -t vnode -f ${STAGEDIR}/efiboot.img) - newfs_msdos -F 12 -m 0xf8 /dev/${DEV} - mount -t msdosfs /dev/${DEV} ${STAGEDIR}/mnt - mkdir -p ${STAGEDIR}/mnt/efi/boot - cp ${STAGEDIR}/work/boot/loader.efi \ - ${STAGEDIR}/mnt/efi/boot/bootx64.efi - umount ${STAGEDIR}/mnt - mdconfig -d -u ${DEV} +if [ -n "${PRODUCT_UEFI}" -a -z "${PRODUCT_UEFI%%*"${SELF}"*}" ]; then UEFIBOOT="-o bootimage=i386;${STAGEDIR}/efiboot.img" UEFIBOOT="${UEFIBOOT} -o no-emul-boot -o platformid=efi" -fi -echo -n ">>> Building dvd image... " + setup_efiboot ${STAGEDIR}/efiboot.img \ + ${STAGEDIR}/work/boot/loader.efi +fi cat > ${STAGEDIR}/work/etc/fstab << EOF # Device Mountpoint FStype Options Dump Pass # @@ -71,6 +62,8 @@ cat > ${STAGEDIR}/work/etc/fstab << EOF tmpfs /tmp tmpfs rw,mode=01777 0 0 EOF +echo -n ">>> Building dvd image... " + makefs -t cd9660 \ -o 'bootimage=i386;'"${STAGEDIR}"'/work/boot/cdboot' -o no-emul-boot \ ${UEFIBOOT} -o label=${DVDLABEL} -o rockridge ${DVDIMAGE} ${STAGEDIR}/work diff --git a/build/serial.sh b/build/serial.sh index 60e00f7..6bf5f72 100644 --- a/build/serial.sh +++ b/build/serial.sh @@ -56,15 +56,20 @@ EOF makefs -B little -o label=${SERIALLABEL} -o version=2 \ ${STAGEDIR}/root.part ${STAGEDIR}/work -UEFIBOOT= GPTDUMMY= +UEFIBOOT= -if [ ${PRODUCT_ARCH} = "amd64" -a -n "${PRODUCT_UEFI}" -a \ - -z "${PRODUCT_UEFI%%*"${SELF}"*}" ]; then - UEFIBOOT="-p efi:=${STAGEDIR}/work/boot/boot1.efifat" +if [ "${PRODUCT_UEFI}" -a -z "${PRODUCT_UEFI%%*"${SELF}"*}" ]; then GPTDUMMY="-p freebsd-swap::512k" + UEFIBOOT="-p efi:=efiboot.img" + + setup_efiboot ${STAGEDIR}/efiboot.img \ + ${STAGEDIR}/work/boot/loader.efi fi -mkimg -s gpt -o ${SERIALIMG} -b ${STAGEDIR}/work/boot/pmbr ${UEFIBOOT} \ - -p freebsd-boot:=${STAGEDIR}/work/boot/gptboot ${GPTDUMMY} \ - -p freebsd-ufs:=${STAGEDIR}/root.part +echo -n ">>> Building serial image... " + +(cd ${STAGEDIR}; mkimg -s gpt -o ${SERIALIMG} -b work/boot/pmbr ${UEFIBOOT} \ + -p freebsd-boot:=work/boot/gptboot ${GPTDUMMY} -p freebsd-ufs:=root.part) + +echo "done"