diff --git a/release/amd64/make-memstick.sh b/release/amd64/make-memstick.sh index cbb80e971343..cec4b27b5b96 100755 --- a/release/amd64/make-memstick.sh +++ b/release/amd64/make-memstick.sh @@ -1,78 +1,79 @@ #!/bin/sh # # This script generates a "memstick image" (image that can be copied to a # USB memory stick) from a directory tree. Note that the script does not # clean up after itself very well for error conditions on purpose so the # problem can be diagnosed (full filesystem most likely but ...). # # Usage: make-memstick.sh # # set -e scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh if [ "$(uname -s)" = "FreeBSD" ]; then PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH fi if [ $# -ne 2 ]; then echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi MAKEFSARG=${1} if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ -e ${2} ]; then echo "won't overwrite ${2}" exit 1 fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${BASEBITSDIR}/etc/fstab echo 'root_rw_mount="NO"' > ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} echo "./etc/rc.conf.local type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi -makefs -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} +${MAKEFS} -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} rm ${BASEBITSDIR}/etc/fstab rm ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi # Make an ESP in a file. espfilename=$(mktemp /tmp/efiboot.XXXXXX) if [ -f "${BASEBITSDIR}/boot/loader_ia32.efi" ]; then make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi bootx64 \ ${BASEBITSDIR}/boot/loader_ia32.efi bootia32 else make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi fi -mkimg -s mbr \ +${MKIMG} -s mbr \ -b ${BASEBITSDIR}/boot/mbr \ -p efi:=${espfilename} \ - -p freebsd:-"mkimg -s bsd -b ${BASEBITSDIR}/boot/boot -p freebsd-ufs:=${2}.part" \ + -p freebsd:-"${MKIMG} -s bsd -b ${BASEBITSDIR}/boot/boot -p freebsd-ufs:=${2}.part" \ -a 2 \ -o ${2} rm ${espfilename} rm ${2}.part diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh index 245beb660c3f..8f7163e05261 100644 --- a/release/amd64/mkisoimages.sh +++ b/release/amd64/mkisoimages.sh @@ -1,134 +1,123 @@ #!/bin/sh # # Module: mkisoimages.sh # Author: Jordan K Hubbard # Date: 22 June 2001 # # # This script is used by release/Makefile to build the (optional) ISO images # for a FreeBSD release. It is considered architecture dependent since each # platform has a slightly unique way of making bootable CDs. This script # is also allowed to generate any number of images since that is more of # publishing decision than anything else. # # Usage: # # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] # # Where -b is passed if the ISO image should be made "bootable" by # whatever standards this architecture supports (may be unsupported), # image-label is the ISO image label, image-name is the filename of the # resulting ISO image, base-bits-dir contains the image contents and # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. set -e scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh -if [ -z $ETDUMP ]; then - ETDUMP=etdump -fi - -if [ -z $MAKEFS ]; then - MAKEFS=makefs -fi - -if [ -z $MKIMG ]; then - MKIMG=mkimg -fi - if [ "$1" = "-b" ]; then MAKEFSARG="$4" else MAKEFSARG="$3" fi if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ "$1" = "-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot" # Make EFI system partition. espfilename=$(mktemp /tmp/efiboot.XXXXXX) # ESP file size in KB. espsize="2048" if [ -f "${BASEBITSDIR}/boot/loader_ia32.efi" ]; then make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi bootx64 \ ${BASEBITSDIR}/boot/loader_ia32.efi bootia32 else make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi fi bootable="$bootable -o bootimage=i386;${espfilename} -o no-emul-boot -o platformid=efi" shift else bootable="" fi if [ $# -lt 3 ]; then echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" exit 1 fi LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift # MAKEFSARG extracted already shift publisher="The FreeBSD Project. https://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi $MAKEFS -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" rm -f "$BASEBITSDIR/etc/fstab" rm -f ${espfilename} if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi if [ "$bootable" != "" ]; then # Look for the EFI System Partition image we dropped in the ISO image. for entry in `$ETDUMP --format shell $NAME`; do eval $entry if [ "$et_platform" = "efi" ]; then espstart=`expr $et_lba \* 2048` espsize=`expr $et_sectors \* 512` espparam="-p efi::$espsize:$espstart" break fi done # Create a GPT image containing the partitions we need for hybrid boot. hybridfilename=$(mktemp /tmp/hybrid.img.XXXXXX) if [ "$(uname -s)" = "Linux" ]; then imgsize=`stat -c %s "$NAME"` else imgsize=`stat -f %z "$NAME"` fi $MKIMG -s gpt \ --capacity $imgsize \ -b "$BASEBITSDIR/boot/pmbr" \ -p freebsd-boot:="$BASEBITSDIR/boot/isoboot" \ $espparam \ -o $hybridfilename # Drop the PMBR, GPT, and boot code into the System Area of the ISO. dd if=$hybridfilename of="$NAME" bs=32k count=1 conv=notrunc rm -f $hybridfilename fi diff --git a/release/arm64/make-memstick.sh b/release/arm64/make-memstick.sh index 90ff98b394c7..0da59c29635b 100755 --- a/release/arm64/make-memstick.sh +++ b/release/arm64/make-memstick.sh @@ -1,71 +1,72 @@ #!/bin/sh # # This script generates a "memstick image" (image that can be copied to a # USB memory stick) from a directory tree. Note that the script does not # clean up after itself very well for error conditions on purpose so the # problem can be diagnosed (full filesystem most likely but ...). # # Usage: make-memstick.sh # # set -e if [ "$(uname -s)" = "FreeBSD" ]; then PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH fi scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh if [ $# -ne 2 ]; then echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi MAKEFSARG=${1} if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ -e ${2} ]; then echo "won't overwrite ${2}" exit 1 fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${BASEBITSDIR}/etc/fstab echo 'root_rw_mount="NO"' > ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} echo "./etc/rc.conf.local type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi -makefs -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} +${MAKEFS} -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} rm ${BASEBITSDIR}/etc/fstab rm ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi # Make an ESP in a file. espfilename=$(mktemp /tmp/efiboot.XXXXXX) make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi -mkimg -s gpt \ +${MKIMG} -s gpt \ -p efi:=${espfilename} \ -p freebsd-ufs:=${2}.part \ -o ${2} rm ${espfilename} rm ${2}.part diff --git a/release/arm64/mkisoimages.sh b/release/arm64/mkisoimages.sh index cb58178ed4b9..46b16f0ce08d 100644 --- a/release/arm64/mkisoimages.sh +++ b/release/arm64/mkisoimages.sh @@ -1,122 +1,111 @@ #!/bin/sh # # # This script is used by release/Makefile to build the (optional) ISO images # for a FreeBSD release. It is considered architecture dependent since each # platform has a slightly unique way of making bootable CDs. This script is # also allowed to generate any number of images since that is more of # publishing decision than anything else. # # Usage: # # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] # # Where -b is passed if the ISO image should be made "bootable" by # whatever standards this architecture supports (may be unsupported), # image-label is the ISO image label, image-name is the filename of the # resulting ISO image, base-bits-dir contains the image contents and # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. set -e scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh -if [ -z $ETDUMP ]; then - ETDUMP=etdump -fi - -if [ -z $MAKEFS ]; then - MAKEFS=makefs -fi - -if [ -z $MKIMG ]; then - MKIMG=mkimg -fi - if [ "$1" = "-b" ]; then MAKEFSARG="$4" else MAKEFSARG="$3" fi if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ "$1" = "-b" ]; then # Make an EFI system partition. espfilename=$(mktemp /tmp/efiboot.XXXXXX) # ESP file size in KB. espsize="2048" make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi bootable="-o bootimage=efi;${espfilename} -o no-emul-boot -o platformid=efi" shift else bootable="" fi if [ $# -lt 3 ]; then echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" exit 1 fi LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift # MAKEFSARG extracted already shift publisher="The FreeBSD Project. https://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi $MAKEFS -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" rm -f "$BASEBITSDIR/etc/fstab" rm -f ${espfilename} if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi if [ "$bootable" != "" ]; then # Look for the EFI System Partition image we dropped in the ISO image. for entry in `$ETDUMP --format shell $NAME`; do eval $entry # XXX: etdump(8) returns "default" for the initial entry if [ "$et_platform" = "default" ]; then espstart=`expr $et_lba \* 2048` espsize=`expr $et_sectors \* 512` espparam="-p efi::$espsize:$espstart" break fi done # Create a GPT image containing the EFI partition. efifilename=$(mktemp /tmp/efi.img.XXXXXX) if [ "$(uname -s)" = "Linux" ]; then imgsize=`stat -c %s "$NAME"` else imgsize=`stat -f %z "$NAME"` fi $MKIMG -s gpt \ --capacity $imgsize \ $espparam \ -o $efifilename # Drop the GPT into the System Area of the ISO. dd if=$efifilename of="$NAME" bs=32k count=1 conv=notrunc rm -f $efifilename fi diff --git a/release/i386/make-memstick.sh b/release/i386/make-memstick.sh index 7a20be20c026..ad2126b0a8f8 100755 --- a/release/i386/make-memstick.sh +++ b/release/i386/make-memstick.sh @@ -1,63 +1,66 @@ #!/bin/sh # # This script generates a "memstick image" (image that can be copied to a # USB memory stick) from a directory tree. Note that the script does not # clean up after itself very well for error conditions on purpose so the # problem can be diagnosed (full filesystem most likely but ...). # # Usage: make-memstick.sh # # set -e +scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr + if [ "$(uname -s)" = "FreeBSD" ]; then PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH fi if [ $# -ne 2 ]; then echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi MAKEFSARG=${1} if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ -e ${2} ]; then echo "won't overwrite ${2}" exit 1 fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${BASEBITSDIR}/etc/fstab echo 'root_rw_mount="NO"' > ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} echo "./etc/rc.conf.local type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi -makefs -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} +${MAKEFS} -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} rm ${BASEBITSDIR}/etc/fstab rm ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi -mkimg -s mbr \ +${MKIMG} -s mbr \ -b ${BASEBITSDIR}/boot/mbr \ - -p freebsd:-"mkimg -s bsd -b ${BASEBITSDIR}/boot/boot -p freebsd-ufs:=${2}.part" \ + -p freebsd:-"${MKIMG} -s bsd -b ${BASEBITSDIR}/boot/boot -p freebsd-ufs:=${2}.part" \ -o ${2} rm ${2}.part diff --git a/release/i386/mkisoimages.sh b/release/i386/mkisoimages.sh index 8f000aae3b17..1918b36eeb44 100644 --- a/release/i386/mkisoimages.sh +++ b/release/i386/mkisoimages.sh @@ -1,74 +1,77 @@ #!/bin/sh # # Module: mkisoimages.sh # Author: Jordan K Hubbard # Date: 22 June 2001 # # # This script is used by release/Makefile to build the (optional) ISO images # for a FreeBSD release. It is considered architecture dependent since each # platform has a slightly unique way of making bootable CDs. This script # is also allowed to generate any number of images since that is more of # publishing decision than anything else. # # Usage: # # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] # # Where -b is passed if the ISO image should be made "bootable" by # whatever standards this architecture supports (may be unsupported), # image-label is the ISO image label, image-name is the filename of the # resulting ISO image, base-bits-dir contains the image contents and # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. set -e +scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr + if [ "$1" = "-b" ]; then MAKEFSARG="$4" else MAKEFSARG="$3" fi if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ "$1" = "-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot" shift else bootable="" fi if [ $# -lt 3 ]; then echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" exit 1 fi LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift # MAKEFSARG extracted already shift publisher="The FreeBSD Project. https://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi -makefs -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" +${MAKEFS} -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" rm -f "$BASEBITSDIR/etc/fstab" if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi diff --git a/release/powerpc/mkisoimages.sh b/release/powerpc/mkisoimages.sh index ba7c32f87bee..9d83390f1a4e 100644 --- a/release/powerpc/mkisoimages.sh +++ b/release/powerpc/mkisoimages.sh @@ -1,118 +1,121 @@ #!/bin/sh # # Module: mkisoimages.sh # Author: Jordan K Hubbard # Date: 22 June 2001 # # # This script is used by release/Makefile to build the (optional) ISO images # for a FreeBSD release. It is considered architecture dependent since each # platform has a slightly unique way of making bootable CDs. This script # is also allowed to generate any number of images since that is more of # publishing decision than anything else. # # Usage: # # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] # # Where -b is passed if the ISO image should be made "bootable" by # whatever standards this architecture supports (may be unsupported), # image-label is the ISO image label, image-name is the filename of the # resulting ISO image, base-bits-dir contains the image contents and # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. set -e +scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr + if [ "$1" = "-b" ]; then MAKEFSARG="$4" else MAKEFSARG="$3" fi if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ "$1" = "-b" ]; then bootable=1 shift else bootable="" fi if [ $# -lt 3 ]; then echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" exit 1 fi LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift # MAKEFSARG extracted already shift if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} MAKEFSARG=${metalogfilename} fi if [ -n "$bootable" ]; then echo "Building bootable disc" BOOTBLOCK=$(mktemp /tmp/hfs-boot-block.XXXXXX) # Apple boot code uudecode -p "`dirname "$0"`/hfs-boot.bz2.uu" | bunzip2 > $BOOTBLOCK OFFSET=$(hd $BOOTBLOCK | grep 'Loader START' | cut -f 1 -d ' ') OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}') dd if="$BASEBITSDIR/boot/loader" of=$BOOTBLOCK seek=$OFFSET conv=notrunc bootable="-o bootimage=macppc;$BOOTBLOCK -o no-emul-boot" # pSeries/PAPR boot code mkdir -p "$BASEBITSDIR/ppc/chrp" cp "$BASEBITSDIR/boot/loader" "$BASEBITSDIR/ppc/chrp" cat > "$BASEBITSDIR/ppc/bootinfo.txt" << EOF FreeBSD Install FreeBSD boot &device;:,\ppc\chrp\loader EOF bootable="$bootable -o chrp-boot" if [ -n "${METALOG}" ]; then echo "./ppc type=dir uname=root gname=wheel mode=0755" >> ${metalogfilename} echo "./ppc/chrp type=dir uname=root gname=wheel mode=0755" >> ${metalogfilename} echo "./ppc/chrp/loader type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} echo "./ppc/bootinfo.txt type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} fi # Petitboot config for PS3/PowerNV echo FreeBSD Install=\'/boot/kernel/kernel vfs.root.mountfrom=cd9660:/dev/iso9660/$LABEL\' > "$BASEBITSDIR/etc/kboot.conf" if [ -n "${METALOG}" ]; then echo "./etc/kboot.conf type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} fi fi publisher="The FreeBSD Project. https://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" if [ -n "${METALOG}" ]; then echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} fi -makefs -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" +${MAKEFS} -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" rm -f "$BASEBITSDIR/etc/fstab" if [ n "$bootable" ]; then rm $BOOTBLOCK fi rm -rf "$BASEBITSDIR/ppc" if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi diff --git a/release/riscv/make-memstick.sh b/release/riscv/make-memstick.sh index 90ff98b394c7..0da59c29635b 100755 --- a/release/riscv/make-memstick.sh +++ b/release/riscv/make-memstick.sh @@ -1,71 +1,72 @@ #!/bin/sh # # This script generates a "memstick image" (image that can be copied to a # USB memory stick) from a directory tree. Note that the script does not # clean up after itself very well for error conditions on purpose so the # problem can be diagnosed (full filesystem most likely but ...). # # Usage: make-memstick.sh # # set -e if [ "$(uname -s)" = "FreeBSD" ]; then PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH fi scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh if [ $# -ne 2 ]; then echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi MAKEFSARG=${1} if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ -e ${2} ]; then echo "won't overwrite ${2}" exit 1 fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${BASEBITSDIR}/etc/fstab echo 'root_rw_mount="NO"' > ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} echo "./etc/rc.conf.local type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi -makefs -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} +${MAKEFS} -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG} rm ${BASEBITSDIR}/etc/fstab rm ${BASEBITSDIR}/etc/rc.conf.local if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi # Make an ESP in a file. espfilename=$(mktemp /tmp/efiboot.XXXXXX) make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi -mkimg -s gpt \ +${MKIMG} -s gpt \ -p efi:=${espfilename} \ -p freebsd-ufs:=${2}.part \ -o ${2} rm ${espfilename} rm ${2}.part diff --git a/release/riscv/mkisoimages.sh b/release/riscv/mkisoimages.sh index cb58178ed4b9..46b16f0ce08d 100644 --- a/release/riscv/mkisoimages.sh +++ b/release/riscv/mkisoimages.sh @@ -1,122 +1,111 @@ #!/bin/sh # # # This script is used by release/Makefile to build the (optional) ISO images # for a FreeBSD release. It is considered architecture dependent since each # platform has a slightly unique way of making bootable CDs. This script is # also allowed to generate any number of images since that is more of # publishing decision than anything else. # # Usage: # # mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] # # Where -b is passed if the ISO image should be made "bootable" by # whatever standards this architecture supports (may be unsupported), # image-label is the ISO image label, image-name is the filename of the # resulting ISO image, base-bits-dir contains the image contents and # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. set -e scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh -if [ -z $ETDUMP ]; then - ETDUMP=etdump -fi - -if [ -z $MAKEFS ]; then - MAKEFS=makefs -fi - -if [ -z $MKIMG ]; then - MKIMG=mkimg -fi - if [ "$1" = "-b" ]; then MAKEFSARG="$4" else MAKEFSARG="$3" fi if [ -f ${MAKEFSARG} ]; then BASEBITSDIR=`dirname ${MAKEFSARG}` METALOG=${MAKEFSARG} elif [ -d ${MAKEFSARG} ]; then BASEBITSDIR=${MAKEFSARG} METALOG= else echo "${MAKEFSARG} must exist" exit 1 fi if [ "$1" = "-b" ]; then # Make an EFI system partition. espfilename=$(mktemp /tmp/efiboot.XXXXXX) # ESP file size in KB. espsize="2048" make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi bootable="-o bootimage=efi;${espfilename} -o no-emul-boot -o platformid=efi" shift else bootable="" fi if [ $# -lt 3 ]; then echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]" exit 1 fi LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift NAME="$1"; shift # MAKEFSARG extracted already shift publisher="The FreeBSD Project. https://www.FreeBSD.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab" if [ -n "${METALOG}" ]; then metalogfilename=$(mktemp /tmp/metalog.XXXXXX) cat ${METALOG} > ${metalogfilename} echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename} MAKEFSARG=${metalogfilename} fi $MAKEFS -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" rm -f "$BASEBITSDIR/etc/fstab" rm -f ${espfilename} if [ -n "${METALOG}" ]; then rm ${metalogfilename} fi if [ "$bootable" != "" ]; then # Look for the EFI System Partition image we dropped in the ISO image. for entry in `$ETDUMP --format shell $NAME`; do eval $entry # XXX: etdump(8) returns "default" for the initial entry if [ "$et_platform" = "default" ]; then espstart=`expr $et_lba \* 2048` espsize=`expr $et_sectors \* 512` espparam="-p efi::$espsize:$espstart" break fi done # Create a GPT image containing the EFI partition. efifilename=$(mktemp /tmp/efi.img.XXXXXX) if [ "$(uname -s)" = "Linux" ]; then imgsize=`stat -c %s "$NAME"` else imgsize=`stat -f %z "$NAME"` fi $MKIMG -s gpt \ --capacity $imgsize \ $espparam \ -o $efifilename # Drop the GPT into the System Area of the ISO. dd if=$efifilename of="$NAME" bs=32k count=1 conv=notrunc rm -f $efifilename fi diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index ce0ea03c096c..eb816018e9d3 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -1,369 +1,370 @@ #!/bin/sh # # # # Common functions for virtual machine image build scripts. # scriptdir=$(dirname $(realpath $0)) +. ${scriptdir}/../scripts/tools.subr . ${scriptdir}/../../tools/boot/install-boot.sh export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" trap "cleanup" INT QUIT TRAP ABRT TERM # Platform-specific large-scale setup # Most platforms use GPT, so put that as default, then special cases PARTSCHEME=gpt ROOTLABEL="gpt" case "${TARGET}:${TARGET_ARCH}" in powerpc:powerpc*) PARTSCHEME=mbr ROOTLABEL="ufs" NOSWAP=yes # Can't label swap partition with MBR, so no swap ;; esac err() { printf "${@}\n" cleanup return 1 } cleanup() { if [ -c "${DESTDIR}/dev/null" ]; then umount_loop ${DESTDIR}/dev 2>/dev/null fi return 0 } metalog_add_data() { if [ -n "${NO_ROOT}" ]; then echo "$1 type=file uname=root gname=wheel mode=0644" >> \ ${DESTDIR}/METALOG fi } vm_create_base() { mkdir -p ${DESTDIR} return 0 } vm_copy_base() { # Defunct return 0 } vm_install_base() { # Installs the FreeBSD userland/kernel to the virtual machine disk. cd ${WORLDDIR} && \ make DESTDIR=${DESTDIR} ${INSTALLOPTS} \ installworld installkernel distribution || \ err "\n\nCannot install the base system to ${DESTDIR}." # Bootstrap etcupdate(8) database. mkdir -p ${DESTDIR}/var/db/etcupdate etcupdate extract -B \ -M "TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" \ -s ${WORLDDIR} -d ${DESTDIR}/var/db/etcupdate \ -L /dev/stdout ${NO_ROOT:+-N} if [ -n "${NO_ROOT}" ]; then # Reroot etcupdate's internal METALOG to the whole tree sed -n 's,^\.,./var/db/etcupdate/current,p' \ ${DESTDIR}/var/db/etcupdate/current/METALOG | \ env -i LC_COLLATE=C sort >> ${DESTDIR}/METALOG rm ${DESTDIR}/var/db/etcupdate/current/METALOG fi echo '# Custom /etc/fstab for FreeBSD VM images' \ > ${DESTDIR}/etc/fstab if [ "${VMFS}" != zfs ]; then echo "/dev/${ROOTLABEL}/rootfs / ${VMFS} rw 1 1" \ >> ${DESTDIR}/etc/fstab fi if [ -z "${NOSWAP}" ]; then echo '/dev/gpt/swapfs none swap sw 0 0' \ >> ${DESTDIR}/etc/fstab fi metalog_add_data ./etc/fstab local hostname hostname="$(echo $(uname -o) | tr '[:upper:]' '[:lower:]')" echo "hostname=\"${hostname}\"" >> ${DESTDIR}/etc/rc.conf metalog_add_data ./etc/rc.conf if [ "${VMFS}" = zfs ]; then echo "zfs_enable=\"YES\"" >> ${DESTDIR}/etc/rc.conf echo "zpool_reguid=\"zroot\"" >> ${DESTDIR}/etc/rc.conf echo "zpool_upgrade=\"zroot\"" >> ${DESTDIR}/etc/rc.conf echo "kern.geom.label.disk_ident.enable=0" >> ${DESTDIR}/boot/loader.conf echo "zfs_load=YES" >> ${DESTDIR}/boot/loader.conf metalog_add_data ./boot/loader.conf fi return 0 } vm_emulation_setup() { if [ -n "${WITHOUT_QEMU}" ]; then return 0 fi if [ -n "${QEMUSTATIC}" ]; then export EMULATOR=/qemu cp ${QEMUSTATIC} ${DESTDIR}/${EMULATOR} fi mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} ${EMULATOR} /usr/bin/newaliases chroot ${DESTDIR} ${EMULATOR} /bin/sh /etc/rc.d/ldconfig forcestart cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf return 0 } vm_extra_install_base() { # Prototype. When overridden, runs extra post-installworld commands # as needed, based on the target virtual machine image or cloud # provider image target. return 0 } vm_extra_enable_services() { if [ -n "${VM_RC_LIST}" ]; then for _rcvar in ${VM_RC_LIST}; do echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf done fi if [ -z "${VMCONFIG}" -o -c "${VMCONFIG}" ]; then echo 'ifconfig_DEFAULT="DHCP inet6 accept_rtadv"' >> \ ${DESTDIR}/etc/rc.conf # Expand the filesystem to fill the disk. echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf touch ${DESTDIR}/firstboot fi return 0 } vm_extra_install_packages() { if [ -n "${WITHOUT_QEMU}" ]; then return 0 fi if [ -z "${VM_EXTRA_PACKAGES}" ]; then return 0 fi chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg bootstrap -y for p in ${VM_EXTRA_PACKAGES}; do chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg install -y ${p} done return 0 } vm_extra_install_ports() { # Prototype. When overridden, installs additional ports within the # virtual machine environment. return 0 } vm_extra_pre_umount() { # Prototype. When overridden, performs additional tasks within the # virtual machine environment prior to unmounting the filesystem. return 0 } vm_emulation_cleanup() { if [ -n "${WITHOUT_QEMU}" ]; then return 0 fi if ! [ -z "${QEMUSTATIC}" ]; then rm -f ${DESTDIR}/${EMULATOR} fi rm -f ${DESTDIR}/etc/resolv.conf umount_loop ${DESTDIR}/dev return 0 } vm_extra_pkg_rmcache() { if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/local/sbin/pkg clean -y -a fi return 0 } buildfs() { local md tmppool case "${VMFS}" in ufs) - cd ${DESTDIR} && makefs ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \ + cd ${DESTDIR} && ${MAKEFS} ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \ ${VMBASE} .${NO_ROOT:+/METALOG} ;; zfs) - cd ${DESTDIR} && makefs -t zfs ${MAKEFSARGS} \ + cd ${DESTDIR} && ${MAKEFS} -t zfs ${MAKEFSARGS} \ -o poolname=zroot -o bootfs=zroot/ROOT/default -o rootpath=/ \ -o fs=zroot\;mountpoint=none \ -o fs=zroot/ROOT\;mountpoint=none \ -o fs=zroot/ROOT/default\;mountpoint=/\;canmount=noauto \ -o fs=zroot/home\;mountpoint=/home \ -o fs=zroot/tmp\;mountpoint=/tmp\;exec=on\;setuid=off \ -o fs=zroot/usr\;mountpoint=/usr\;canmount=off \ -o fs=zroot/usr/ports\;setuid=off \ -o fs=zroot/usr/src \ -o fs=zroot/usr/obj \ -o fs=zroot/var\;mountpoint=/var\;canmount=off \ -o fs=zroot/var/audit\;setuid=off\;exec=off \ -o fs=zroot/var/crash\;setuid=off\;exec=off \ -o fs=zroot/var/log\;setuid=off\;exec=off \ -o fs=zroot/var/mail\;atime=on \ -o fs=zroot/var/tmp\;setuid=off \ ${VMBASE} .${NO_ROOT:+/METALOG} ;; *) echo "Unexpected VMFS value '${VMFS}'" exit 1 ;; esac } umount_loop() { DIR=$1 i=0 sync while ! umount ${DIR}; do i=$(( $i + 1 )) if [ $i -ge 10 ]; then # This should never happen. But, it has happened. echo "Cannot umount(8) ${DIR}" echo "Something has gone horribly wrong." return 1 fi sleep 1 done return 0 } vm_create_disk() { local BOOTFILES BOOTPARTSOFFSET FSPARTTYPE X86GPTBOOTFILE if [ -z "${NOSWAP}" ]; then SWAPOPT="-p freebsd-swap/swapfs::${SWAPSIZE}" fi if [ -n "${VM_BOOTPARTSOFFSET}" ]; then BOOTPARTSOFFSET=":${VM_BOOTPARTSOFFSET}" fi if [ -n "${CONFIG_DRIVE}" ]; then CONFIG_DRIVE="-p freebsd/config-drive::${CONFIG_DRIVE_SIZE}" fi case "${VMFS}" in ufs) FSPARTTYPE=freebsd-ufs X86GPTBOOTFILE=i386/gptboot/gptboot ;; zfs) FSPARTTYPE=freebsd-zfs X86GPTBOOTFILE=i386/gptzfsboot/gptzfsboot ;; *) echo "Unexpected VMFS value '${VMFS}'" return 1 ;; esac echo "Creating image... Please wait." echo BOOTFILES="$(env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ WITH_UNIFIED_OBJDIR=yes \ make -C ${WORLDDIR}/stand -V .OBJDIR)" BOOTFILES="$(realpath ${BOOTFILES})" MAKEFSARGS="-s ${VMSIZE} -D" case "${TARGET}:${TARGET_ARCH}" in amd64:amd64 | i386:i386) ESP=yes BOOTPARTS="-b ${BOOTFILES}/i386/pmbr/pmbr \ -p freebsd-boot/bootfs:=${BOOTFILES}/${X86GPTBOOTFILE}${BOOTPARTSOFFSET}" ROOTFSPART="-p ${FSPARTTYPE}/rootfs:=${VMBASE}" MAKEFSARGS="$MAKEFSARGS -B little" ;; arm:armv7 | arm64:aarch64 | riscv:riscv64*) ESP=yes BOOTPARTS= ROOTFSPART="-p ${FSPARTTYPE}/rootfs:=${VMBASE}" MAKEFSARGS="$MAKEFSARGS -B little" ;; powerpc:powerpc*) ESP=no BOOTPARTS="-p prepboot:=${BOOTFILES}/powerpc/boot1.chrp/boot1.elf -a 1" ROOTFSPART="-p freebsd:=${VMBASE}" if [ ${TARGET_ARCH} = powerpc64le ]; then MAKEFSARGS="$MAKEFSARGS -B little" else MAKEFSARGS="$MAKEFSARGS -B big" fi ;; *) echo "vmimage.subr: unsupported target '${TARGET}:${TARGET_ARCH}'" >&2 exit 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/efiboot0:=${espfilename}" # Add this to fstab mkdir -p ${DESTDIR}/boot/efi echo "/dev/${ROOTLABEL}/efiboot0 /boot/efi msdosfs rw 2 2" \ >> ${DESTDIR}/etc/fstab fi echo "Building filesystem... Please wait." buildfs echo "Building final disk image... Please wait." - mkimg -s ${PARTSCHEME} -f ${VMFORMAT} \ + ${MKIMG} -s ${PARTSCHEME} -f ${VMFORMAT} \ ${BOOTPARTS} \ ${SWAPOPT} \ ${CONFIG_DRIVE} \ ${ROOTFSPART} \ -o ${VMIMAGE} echo "Disk image ${VMIMAGE} created." if [ ${ESP} = "yes" ]; then rm ${espfilename} fi return 0 } vm_extra_create_disk() { return 0 } touch_firstboot() { touch ${DESTDIR}/firstboot metalog_add_data ./firstboot }