diff --git a/release/Makefile b/release/Makefile index 646b9f8738d2..db9cc6b22cbe 100644 --- a/release/Makefile +++ b/release/Makefile @@ -1,290 +1,331 @@ # $FreeBSD$ # # Makefile for building releases and release media. # # User-driven targets: # cdrom: Builds release CD-ROM media (disc1.iso) # dvdrom: Builds release DVD-ROM media (dvd1.iso) # memstick: Builds memory stick image (memstick.img) # mini-memstick: Builds minimal memory stick image (mini-memstick.img) # ftp: Sets up FTP distribution area (ftp) # release: Invokes real-release, vm-release, and cloudware-release targets # real-release: Build all media and FTP distribution area # vm-release: Build all virtual machine image targets # cloudware-release: Build all cloud hosting provider targets # install: Invokes the release-install and vm-install targets # release-install: Copies all release installation media into ${DESTDIR} # vm-install: Copies all virtual machine images into ${DESTDIR} # # Variables affecting the build process: # WORLDDIR: location of src tree -- must have built world and default kernel # (by default, the directory above this one) # PORTSDIR: location of ports tree to distribute (default: /usr/ports) # XTRADIR: xtra-bits-dir argument for /mkisoimages.sh # NOPKG: if set, do not distribute third-party packages # NOPORTS: if set, do not distribute ports tree # NOSRC: if set, do not distribute source tree # WITH_DVD: if set, generate dvd1.iso # WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1) # (uncompressed images are not removed) # WITH_VMIMAGES: if set, build virtual machine images with the release # WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images # with xz(1) (extremely time consuming) # WITH_CLOUDWARE: if set, build cloud hosting disk images with the release # TARGET/TARGET_ARCH: architecture of built release # WORLDDIR?= ${.CURDIR}/.. PORTSDIR?= /usr/ports .if !defined(TARGET) || empty(TARGET) TARGET= ${MACHINE} .endif .if !defined(TARGET_ARCH) || empty(TARGET_ARCH) .if ${TARGET} == ${MACHINE} TARGET_ARCH= ${MACHINE_ARCH} .else TARGET_ARCH= ${TARGET} .endif .endif IMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} DISTDIR= dist # Define OSRELEASE by using newvers.sh .if !defined(OSRELEASE) || empty(OSRELEASE) .for _V in TYPE BRANCH REVISION ${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V} .endfor .for _V in ${TARGET_ARCH} .if !empty(TARGET:M${_V}) OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET} VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET} .else OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH} VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH} .endif .endfor .endif .if !defined(VOLUME_LABEL) || empty(VOLUME_LABEL) VOLUME_LABEL= FreeBSD_Install .endif .if !exists(${PORTSDIR}) NOPORTS= true .endif EXTRA_PACKAGES= .if !defined(NOPORTS) EXTRA_PACKAGES+= ports.txz .endif .if !defined(NOSRC) EXTRA_PACKAGES+= src.txz .endif RELEASE_TARGETS= ftp IMAGES= .if exists(${.CURDIR}/${TARGET}/mkisoimages.sh) RELEASE_TARGETS+= cdrom IMAGES+= disc1.iso bootonly.iso . if defined(WITH_DVD) && !empty(WITH_DVD) RELEASE_TARGETS+= dvdrom IMAGES+= dvd1.iso . endif .endif .if exists(${.CURDIR}/${TARGET}/make-memstick.sh) RELEASE_TARGETS+= memstick.img RELEASE_TARGETS+= mini-memstick.img IMAGES+= memstick.img IMAGES+= mini-memstick.img .endif CLEANFILES= packagesystem *.txz MANIFEST release ${IMAGES} .if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) . for I in ${IMAGES} CLEANFILES+= ${I}.xz . endfor .endif .if defined(WITH_DVD) && !empty(WITH_DVD) CLEANFILES+= pkg-stage .endif CLEANDIRS= dist ftp disc1 bootonly dvd beforeclean: chflags -R noschg . .include clean: beforeclean base.txz: mkdir -p ${DISTDIR} cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR} +# TODO: Add NO_ROOT mode to mm-tree.sh and etcupdate +.if !defined(NO_ROOT) # Set up mergemaster root database sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \ "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} ${.MAKE.JOBS:D-j${.MAKE.JOBS}}" \ -D "${.OBJDIR}/${DISTDIR}/base" etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" +.endif # Package all components cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR} mv ${DISTDIR}/*.txz . kernel.txz: mkdir -p ${DISTDIR} cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR} mv ${DISTDIR}/kernel*.txz . src.txz: mkdir -p ${DISTDIR}/usr ln -fs ${WORLDDIR} ${DISTDIR}/usr/src cd ${DISTDIR} && tar cLvf - --exclude .svn --exclude .zfs \ --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \ ${XZ_CMD} > ${.OBJDIR}/src.txz ports.txz: mkdir -p ${DISTDIR}/usr ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports cd ${DISTDIR} && tar cLvf - \ --exclude .git --exclude .svn \ --exclude usr/ports/distfiles --exclude usr/ports/packages \ --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ ${XZ_CMD} > ${.OBJDIR}/ports.txz disc1: packagesystem # Install system mkdir -p ${.TARGET} cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \ MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \ MK_TOOLCHAIN=no MK_PROFILE=no \ MK_RESCUE=no MK_DICT=no \ MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \ -DDB_FROM_SRC # Copy distfiles mkdir -p ${.TARGET}/usr/freebsd-dist for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done +.if defined(NO_ROOT) + echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG + for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \ + do echo "./usr/freebsd-dist/$${dist} type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG; \ + done +.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf cp ${.CURDIR}/rc.local ${.TARGET}/etc +.if defined(NO_ROOT) + echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG + echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG +.endif touch ${.TARGET} bootonly: packagesystem # Install system mkdir -p ${.TARGET} cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \ MK_GAMES=no \ MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \ MK_TOOLCHAIN=no MK_PROFILE=no \ MK_RESCUE=no MK_DICT=no \ MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \ -DDB_FROM_SRC # Copy manifest only (no distfiles) to get checksums mkdir -p ${.TARGET}/usr/freebsd-dist cp MANIFEST ${.TARGET}/usr/freebsd-dist +.if defined(NO_ROOT) + echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG + echo "./usr/freebsd-dist/MANIFEST type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG +.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf cp ${.CURDIR}/rc.local ${.TARGET}/etc +.if defined(NO_ROOT) + echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG + echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG +.endif dvd: packagesystem # Install system mkdir -p ${.TARGET} cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \ MK_TESTS=no MK_DEBUG_FILES=no \ -DDB_FROM_SRC # Copy distfiles mkdir -p ${.TARGET}/usr/freebsd-dist for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done +.if defined(NO_ROOT) + echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG + for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \ + do echo "./usr/freebsd-dist/$${dist} type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG; \ + done +.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf cp ${.CURDIR}/rc.local ${.TARGET}/etc +.if defined(NO_ROOT) + echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG + echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG + echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG +.endif touch ${.TARGET} release.iso: disc1.iso disc1.iso: disc1 - sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1 ${XTRADIR} + cd disc1 && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} dvd1.iso: dvd pkg-stage - sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd ${XTRADIR} + cd dvd && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} bootonly.iso: bootonly - sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly ${XTRADIR} + cd bootonly && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} memstick: memstick.img memstick.img: disc1 - sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET} + cd disc1 && sh ${.CURDIR}/${TARGET}/make-memstick.sh .${NO_ROOT:D/METALOG} ../${.TARGET} mini-memstick: mini-memstick.img mini-memstick.img: bootonly - sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET} + cd bootonly && sh ${.CURDIR}/${TARGET}/make-memstick.sh .${NO_ROOT:D/METALOG} ../${.TARGET} packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES} sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST touch ${.TARGET} pkg-stage: +# TODO: Support for -DNO_ROOT .if !defined(NOPKG) || empty(NOPKG) env PORTSDIR=${PORTSDIR} REPOS_DIR=${.CURDIR}/pkg_repos/ \ sh ${.CURDIR}/scripts/pkg-stage.sh mkdir -p ${.OBJDIR}/dvd/packages/repos/ cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \ ${.OBJDIR}/dvd/packages/repos/ .endif touch ${.TARGET} cdrom: disc1.iso bootonly.iso dvdrom: dvd1.iso ftp: packagesystem rm -rf ftp mkdir -p ftp cp *.txz MANIFEST ftp release: real-release vm-release cloudware-release ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} release-done true release-done: touch release real-release: ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} install: release-install vm-install release-install: .if defined(DESTDIR) && !empty(DESTDIR) mkdir -p ${DESTDIR} .endif cp -a ftp ${DESTDIR}/ .if !empty(IMAGES) .for I in ${IMAGES} cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} . if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) ${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I} . endif .endfor cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512 cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 .endif .include "${.CURDIR}/Makefile.inc1" .include "${.CURDIR}/Makefile.vm" diff --git a/release/amd64/make-memstick.sh b/release/amd64/make-memstick.sh index c0e405c3a976..835dc126d61d 100755 --- a/release/amd64/make-memstick.sh +++ b/release/amd64/make-memstick.sh @@ -1,54 +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 +# Usage: make-memstick.sh # # $FreeBSD$ # set -e scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH if [ $# -ne 2 ]; then - echo "make-memstick.sh /path/to/directory /path/to/image/file" + echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi -if [ ! -d ${1} ]; then - echo "${1} must be a directory" +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' > ${1}/etc/fstab -echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local -makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1} -rm ${1}/etc/fstab -rm ${1}/etc/rc.conf.local +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 -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} ${1}/boot/loader.efi +make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi mkimg -s mbr \ - -b ${1}/boot/mbr \ + -b ${BASEBITSDIR}/boot/mbr \ -p efi:=${espfilename} \ - -p freebsd:-"mkimg -s bsd -b ${1}/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 7f79ddc800e9..90e6aed5e7ec 100644 --- a/release/amd64/mkisoimages.sh +++ b/release/amd64/mkisoimages.sh @@ -1,100 +1,126 @@ #!/bin/sh # # Module: mkisoimages.sh # Author: Jordan K Hubbard # Date: 22 June 2001 # # $FreeBSD$ # # 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}/../../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 - BASEBITSDIR="$4" + 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" make_esp_file ${espfilename} ${espsize} ${BASEBITSDIR}/boot/loader.efi bootable="$bootable -o bootimage=i386;${espfilename} -o no-emul-boot -o platformid=efi" shift else - BASEBITSDIR="$3" 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" -$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" +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 -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) imgsize=`stat -f %z "$NAME"` $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 0cde77b018b8..0dd6dcfaf4dd 100755 --- a/release/arm64/make-memstick.sh +++ b/release/arm64/make-memstick.sh @@ -1,52 +1,70 @@ #!/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 +# Usage: make-memstick.sh # # $FreeBSD$ # set -e PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh if [ $# -ne 2 ]; then - echo "make-memstick.sh /path/to/directory /path/to/image/file" + echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi -if [ ! -d ${1} ]; then - echo "${1} must be a directory" +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' > ${1}/etc/fstab -echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local -makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1} -rm ${1}/etc/fstab -rm ${1}/etc/rc.conf.local +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 -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} ${1}/boot/loader.efi +make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi 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 8d260883c294..b90100286d4a 100644 --- a/release/arm64/mkisoimages.sh +++ b/release/arm64/mkisoimages.sh @@ -1,94 +1,119 @@ #!/bin/sh # # $FreeBSD$ # # 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}/../../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 - BASEBITSDIR="$4" + 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 - BASEBITSDIR="$3" 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" -$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" +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 -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) imgsize=`stat -f %z "$NAME"` $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 6774e86ae550..715e4582a4ef 100755 --- a/release/i386/make-memstick.sh +++ b/release/i386/make-memstick.sh @@ -1,44 +1,62 @@ #!/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 +# Usage: make-memstick.sh # # $FreeBSD$ # set -e PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH if [ $# -ne 2 ]; then - echo "make-memstick.sh /path/to/directory /path/to/image/file" + echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi -if [ ! -d ${1} ]; then - echo "${1} must be a directory" +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' > ${1}/etc/fstab -echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local -makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1} -rm ${1}/etc/fstab -rm ${1}/etc/rc.conf.local +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 -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 \ - -b ${1}/boot/mbr \ - -p freebsd:-"mkimg -s bsd -b ${1}/boot/boot -p freebsd-ufs:=${2}.part" \ + -b ${BASEBITSDIR}/boot/mbr \ + -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 b9eb893edeef..a408fa7cddb2 100644 --- a/release/i386/mkisoimages.sh +++ b/release/i386/mkisoimages.sh @@ -1,47 +1,75 @@ #!/bin/sh # # Module: mkisoimages.sh # Author: Jordan K Hubbard # Date: 22 June 2001 # # $FreeBSD$ # # 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 +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;$4/boot/cdboot -o no-emul-boot" + 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" > "$1/etc/fstab" -makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" -rm -f "$1/etc/fstab" +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 -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 2d5ea76ca7a2..362604170fd1 100644 --- a/release/powerpc/mkisoimages.sh +++ b/release/powerpc/mkisoimages.sh @@ -1,76 +1,116 @@ #!/bin/sh # # Module: mkisoimages.sh # Author: Jordan K Hubbard # Date: 22 June 2001 # # $FreeBSD$ # # 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 +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" # Apple boot code uudecode -o /tmp/hfs-boot-block.bz2 "`dirname "$0"`/hfs-boot.bz2.uu" bzip2 -d /tmp/hfs-boot-block.bz2 OFFSET=$(hd /tmp/hfs-boot-block | grep 'Loader START' | cut -f 1 -d ' ') OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}') - dd if="$1/boot/loader" of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc + dd if="$BASEBITSDIR/boot/loader" of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc bootable="-o bootimage=macppc;/tmp/hfs-boot-block -o no-emul-boot" # pSeries/PAPR boot code - mkdir -p "$1/ppc/chrp" - cp "$1/boot/loader" "$1/ppc/chrp" - cat > "$1/ppc/bootinfo.txt" << EOF + 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\' > "$1/etc/kboot.conf" + 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" > "$1/etc/fstab" -makefs -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" -rm -f "$1/etc/fstab" +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 -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@" +rm -f "$BASEBITSDIR/etc/fstab" rm -f /tmp/hfs-boot-block -rm -rf "$1/ppc" +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 0cde77b018b8..0dd6dcfaf4dd 100755 --- a/release/riscv/make-memstick.sh +++ b/release/riscv/make-memstick.sh @@ -1,52 +1,70 @@ #!/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 +# Usage: make-memstick.sh # # $FreeBSD$ # set -e PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh if [ $# -ne 2 ]; then - echo "make-memstick.sh /path/to/directory /path/to/image/file" + echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file" exit 1 fi -if [ ! -d ${1} ]; then - echo "${1} must be a directory" +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' > ${1}/etc/fstab -echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local -makefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1} -rm ${1}/etc/fstab -rm ${1}/etc/rc.conf.local +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 -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} ${1}/boot/loader.efi +make_esp_file ${espfilename} ${fat32min} ${BASEBITSDIR}/boot/loader.efi 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 8d260883c294..b90100286d4a 100644 --- a/release/riscv/mkisoimages.sh +++ b/release/riscv/mkisoimages.sh @@ -1,94 +1,119 @@ #!/bin/sh # # $FreeBSD$ # # 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}/../../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 - BASEBITSDIR="$4" + 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 - BASEBITSDIR="$3" 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" -$MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$@" +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 -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) imgsize=`stat -f %z "$NAME"` $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