Author: mhorne
Date: Fri Oct 30 18:16:10 2020
New Revision: 367175
URL: https://svnweb.freebsd.org/changeset/base/367175

Log:
  Slight refactor in vmimage.subr
  
  De-duplicate the invocation of mkimg(1). No functional change.
  
  Reviewed by:  gjb
  MFC after:    2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D26984

Modified:
  head/release/tools/vmimage.subr

Modified: head/release/tools/vmimage.subr
==============================================================================
--- head/release/tools/vmimage.subr     Fri Oct 30 17:05:36 2020        
(r367174)
+++ head/release/tools/vmimage.subr     Fri Oct 30 18:16:10 2020        
(r367175)
@@ -24,40 +24,46 @@ write_partition_layout() {
 
        case "${TARGET}:${TARGET_ARCH}" in
                amd64:amd64 | i386:i386)
-                       # Create an ESP
-                       espfilename=$(mktemp /tmp/efiboot.XXXXXX)
-                       make_esp_file ${espfilename} ${fat32min} 
${BOOTFILES}/efi/loader_lua/loader_lua.efi
-                       mkimg -s gpt -f ${VMFORMAT} \
-                               -b ${BOOTFILES}/i386/pmbr/pmbr \
-                               -p 
freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \
-                               -p efi:=${espfilename} \
-                               ${SWAPOPT} \
-                               -p freebsd-ufs/rootfs:=${VMBASE} \
-                               -o ${VMIMAGE}
-                       rm ${espfilename}
+                       ESP=yes
+                       SCHEME=gpt
+                       BOOTPARTS="-b ${BOOTFILES}/i386/pmbr/pmbr \
+                                  -p 
freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot"
+                       ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}"
                        ;;
                arm64:aarch64)
-                       # Create an ESP
-                       espfilename=$(mktemp /tmp/efiboot.XXXXXX)
-                       make_esp_file ${espfilename} ${fat32min} 
${BOOTFILES}/efi/loader_lua/loader_lua.efi
-                       mkimg -s mbr -f ${VMFORMAT} \
-                               -p efi:=${espfilename} \
-                               -p freebsd:=${VMBASE} \
-                               -o ${VMIMAGE}
-                       rm ${espfilename}
+                       ESP=yes
+                       SCHEME=mbr
+                       BOOTPARTS=
+                       ROOTFSPART="-p freebsd:=${VMBASE}"
                        ;;
                powerpc:powerpc*)
-                       mkimg -s apm -f ${VMFORMAT} \
-                               -p 
apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \
-                               ${SWAPOPT} \
-                               -p freebsd-ufs/rootfs:=${VMBASE} \
-                               -o ${VMIMAGE}
+                       ESP=no
+                       SCHEME=apm
+                       BOOTPARTS="-p 
apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs"
+                       ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}"
                        ;;
                *)
                        # ENOTSUPP
                        return 1
                        ;;
        esac
+
+       if [ ${ESP} = "yes" ]; then
+               # Create an ESP
+               espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+               make_esp_file ${espfilename} ${fat32min} 
${BOOTFILES}/efi/loader_lua/loader_lua.efi
+               BOOTPARTS="${BOOTPARTS} -p efi:=${espfilename}"
+       fi
+
+       mkimg -s ${SCHEME} -f ${VMFORMAT} \
+               ${BOOTPARTS} \
+               ${SWAPOPT} \
+               ${ROOTFSPART} \
+               -o ${VMIMAGE}
+
+       if [ ${ESP} = "yes" ]; then
+               rm ${espfilename}
+       fi
 
        return 0
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to