Changeset View
Changeset View
Standalone View
Standalone View
release/tools/vmimage.subr
#!/bin/sh | #!/bin/sh | ||||
# | # | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# | # | ||||
# Common functions for virtual machine image build scripts. | # Common functions for virtual machine image build scripts. | ||||
# | # | ||||
scriptdir=$(dirname $(realpath $0)) | |||||
. ${scriptdir}/../../tools/boot/install-boot.sh | |||||
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" | export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" | ||||
trap "cleanup" INT QUIT TRAP ABRT TERM | trap "cleanup" INT QUIT TRAP ABRT TERM | ||||
write_partition_layout() { | write_partition_layout() { | ||||
if [ -z "${NOSWAP}" ]; then | if [ -z "${NOSWAP}" ]; then | ||||
SWAPOPT="-p freebsd-swap/swapfs::${SWAPSIZE}" | SWAPOPT="-p freebsd-swap/swapfs::${SWAPSIZE}" | ||||
fi | fi | ||||
BOOTFILES="$(env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ | BOOTFILES="$(env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ | ||||
WITH_UNIFIED_OBJDIR=yes \ | WITH_UNIFIED_OBJDIR=yes \ | ||||
make -C ${WORLDDIR}/stand -V .OBJDIR)" | make -C ${WORLDDIR}/stand -V .OBJDIR)" | ||||
BOOTFILES="$(realpath ${BOOTFILES})" | BOOTFILES="$(realpath ${BOOTFILES})" | ||||
case "${TARGET}:${TARGET_ARCH}" in | case "${TARGET}:${TARGET_ARCH}" in | ||||
amd64:amd64 | i386:i386) | amd64:amd64 | i386:i386) | ||||
mkimg -s gpt -f ${VMFORMAT} \ | mkimg -s gpt -f ${VMFORMAT} \ | ||||
-b ${BOOTFILES}/i386/pmbr/pmbr \ | -b ${BOOTFILES}/i386/pmbr/pmbr \ | ||||
-p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \ | -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \ | ||||
${SWAPOPT} \ | ${SWAPOPT} \ | ||||
-p freebsd-ufs/rootfs:=${VMBASE} \ | -p freebsd-ufs/rootfs:=${VMBASE} \ | ||||
-o ${VMIMAGE} | -o ${VMIMAGE} | ||||
;; | ;; | ||||
arm64:aarch64) | arm64:aarch64) | ||||
mkimg -s mbr -f ${VMFORMAT} \ | # Create an ESP (EFI System Partition) of 33292 KB (minimum FAT32 size) | ||||
imp: I'd think should do the ${espfilename} dance too, with the rm after... I'm not thrilled about… | |||||
Done Inline ActionsYeah, me neither. bcran: Yeah, me neither. | |||||
-p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \ | make_esp_file ${BOOTFILES}/efi/efiboot.img 33292 ${BOOTFILES}/efi/loader_lua/loader_lua.efi | ||||
impUnsubmitted Done Inline Actionswhere is VMBASE added? This just makes an esp, but doesn't seem to create the resulting image in VMIMAGE. imp: where is VMBASE added? This just makes an esp, but doesn't seem to create the resulting image… | |||||
bcranAuthorUnsubmitted Done Inline ActionsGood point - not sure how I removed the mkimg command. bcran: Good point - not sure how I removed the mkimg command. | |||||
-p freebsd:=${VMBASE} \ | |||||
-o ${VMIMAGE} | |||||
;; | ;; | ||||
powerpc:powerpc*) | powerpc:powerpc*) | ||||
mkimg -s apm -f ${VMFORMAT} \ | mkimg -s apm -f ${VMFORMAT} \ | ||||
-p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \ | -p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \ | ||||
${SWAPOPT} \ | ${SWAPOPT} \ | ||||
-p freebsd-ufs/rootfs:=${VMBASE} \ | -p freebsd-ufs/rootfs:=${VMBASE} \ | ||||
-o ${VMIMAGE} | -o ${VMIMAGE} | ||||
;; | ;; | ||||
*) | *) | ||||
# ENOTSUPP | # ENOTSUPP | ||||
return 1 | return 1 | ||||
;; | ;; | ||||
Done Inline Actionssince it's also used here nearly verbatim. imp: since it's also used here nearly verbatim.
| |||||
esac | esac | ||||
return 0 | return 0 | ||||
} | } | ||||
err() { | err() { | ||||
printf "${@}\n" | printf "${@}\n" | ||||
cleanup | cleanup | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |
I'd think should do the ${espfilename} dance too, with the rm after... I'm not thrilled about lua here, but I'm not sure what would be better given the context this script runs in.