From 1a9b1c367fa606c7850cfc876bf73a1e1129279a Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Mon, 28 Feb 2022 22:37:37 +0000 Subject: [PATCH] release: Add support for building on non-FreeBSD This requires two sets of changes. Firstly, for non-FreeBSD, we do not know where tools are in PATH (and it is likely that some are not in system directories and have been built as bootstrap tools during the build), so we should leave PATH alone and trust the user. Secondly, makefs needs a master.passwd for building images from a METALOG file, so pass the directory in the image tree to makefs's -N option in order to pick up a valid FreeBSD master.passwd; this is unnecessary on FreeBSD (except in the edge case of building an image that refers to users or groups not present in the host's database, which is unlikely but technically possible) but harmless so can be done unconditionally. Reviewed by: brooks, emaste, gjb Differential Revision: https://reviews.freebsd.org/D34001 --- release/amd64/make-memstick.sh | 8 +++++--- release/amd64/mkisoimages.sh | 2 +- release/arm64/make-memstick.sh | 8 +++++--- release/arm64/mkisoimages.sh | 2 +- release/i386/make-memstick.sh | 8 +++++--- release/i386/mkisoimages.sh | 2 +- release/powerpc/mkisoimages.sh | 2 +- release/riscv/make-memstick.sh | 8 +++++--- release/riscv/mkisoimages.sh | 2 +- 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/release/amd64/make-memstick.sh b/release/amd64/make-memstick.sh index 835dc126d61d..57902e559d10 100755 --- a/release/amd64/make-memstick.sh +++ b/release/amd64/make-memstick.sh @@ -15,8 +15,10 @@ set -e scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh -PATH=/bin:/usr/bin:/sbin:/usr/sbin -export PATH +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" @@ -50,7 +52,7 @@ if [ -n "${METALOG}" ]; then 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} +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 diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh index 90e6aed5e7ec..a90578c02ebd 100644 --- a/release/amd64/mkisoimages.sh +++ b/release/amd64/mkisoimages.sh @@ -91,7 +91,7 @@ if [ -n "${METALOG}" ]; then 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" "$@" +$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 diff --git a/release/arm64/make-memstick.sh b/release/arm64/make-memstick.sh index 0dd6dcfaf4dd..9fcc001fc6fd 100755 --- a/release/arm64/make-memstick.sh +++ b/release/arm64/make-memstick.sh @@ -12,8 +12,10 @@ set -e -PATH=/bin:/usr/bin:/sbin:/usr/sbin -export PATH +if [ "$(uname -s)" = "FreeBSD" ]; then + PATH=/bin:/usr/bin:/sbin:/usr/sbin + export PATH +fi scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh @@ -50,7 +52,7 @@ if [ -n "${METALOG}" ]; then 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} +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 diff --git a/release/arm64/mkisoimages.sh b/release/arm64/mkisoimages.sh index b90100286d4a..e7e56eef1cb6 100644 --- a/release/arm64/mkisoimages.sh +++ b/release/arm64/mkisoimages.sh @@ -85,7 +85,7 @@ if [ -n "${METALOG}" ]; then 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" "$@" +$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 diff --git a/release/i386/make-memstick.sh b/release/i386/make-memstick.sh index 715e4582a4ef..99f419fc0036 100755 --- a/release/i386/make-memstick.sh +++ b/release/i386/make-memstick.sh @@ -12,8 +12,10 @@ set -e -PATH=/bin:/usr/bin:/sbin:/usr/sbin -export PATH +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" @@ -47,7 +49,7 @@ if [ -n "${METALOG}" ]; then 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} +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 diff --git a/release/i386/mkisoimages.sh b/release/i386/mkisoimages.sh index a408fa7cddb2..6ee7f72212c9 100644 --- a/release/i386/mkisoimages.sh +++ b/release/i386/mkisoimages.sh @@ -68,7 +68,7 @@ if [ -n "${METALOG}" ]; then 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" "$@" +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} diff --git a/release/powerpc/mkisoimages.sh b/release/powerpc/mkisoimages.sh index 362604170fd1..0f13464567f1 100644 --- a/release/powerpc/mkisoimages.sh +++ b/release/powerpc/mkisoimages.sh @@ -107,7 +107,7 @@ 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" "$@" +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 /tmp/hfs-boot-block rm -rf "$BASEBITSDIR/ppc" diff --git a/release/riscv/make-memstick.sh b/release/riscv/make-memstick.sh index 0dd6dcfaf4dd..9fcc001fc6fd 100755 --- a/release/riscv/make-memstick.sh +++ b/release/riscv/make-memstick.sh @@ -12,8 +12,10 @@ set -e -PATH=/bin:/usr/bin:/sbin:/usr/sbin -export PATH +if [ "$(uname -s)" = "FreeBSD" ]; then + PATH=/bin:/usr/bin:/sbin:/usr/sbin + export PATH +fi scriptdir=$(dirname $(realpath $0)) . ${scriptdir}/../../tools/boot/install-boot.sh @@ -50,7 +52,7 @@ if [ -n "${METALOG}" ]; then 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} +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 diff --git a/release/riscv/mkisoimages.sh b/release/riscv/mkisoimages.sh index b90100286d4a..e7e56eef1cb6 100644 --- a/release/riscv/mkisoimages.sh +++ b/release/riscv/mkisoimages.sh @@ -85,7 +85,7 @@ if [ -n "${METALOG}" ]; then 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" "$@" +$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