path: root/release/amd64/make-memstick.sh
diff options
authorJessica Clarke <jrtc27@FreeBSD.org>2022-02-28 22:37:03 +0000
committerJessica Clarke <jrtc27@FreeBSD.org>2022-02-28 22:37:03 +0000
commit13cb004130d2b62f79fe421eaf4a7973efd6a505 (patch)
tree507066d9a6dfbe8539884037aff87a972d09c3a4 /release/amd64/make-memstick.sh
parent045c8f526484cb3b97f5fd693987f4376fa43c5f (diff)
release: Support -DNO_ROOT image building
This requires a bunch of METALOG mangling to include the files we inject into the tree. The mkisoimages.sh and make-memstick.sh scripts are now called with the current directory inside the tree so that the relative paths in the METALOG match up with the current directory. The scripts do not require this when not using a METALOG, but for simplicity we always do so. The Makefile mangles the real METALOG created from the install, as those files are shared across all uses of the tree, but the shell scripts create a temporary copy of the METALOG that they mangle as their tree modifications are specific to that image. We also need to pass -D to makefs to turn any duplicate METALOG entry errors into warnings, as we have many (harmless) instances of those. Whilst dvd1.iso should work, the !NOPKG code will need more work to support this. All media will also lack mergemaster and etcupdate trees, since more work is needed to add -DNO_ROOT modes to them. Users of install media built this way will have to manually bootstrap them. Reviewed by: brooks, gjb Differential Revision: https://reviews.freebsd.org/D33999
Diffstat (limited to 'release/amd64/make-memstick.sh')
1 files changed, 30 insertions, 12 deletions
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
@@ -5,7 +5,7 @@
# 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 <directory tree> <image filename>
+# Usage: make-memstick.sh <directory tree or manifest> <image filename>
# $FreeBSD$
@@ -19,12 +19,20 @@ 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
-if [ ! -d ${1} ]; then
- echo "${1} must be a directory"
+if [ -f ${MAKEFSARG} ]; then
+elif [ -d ${MAKEFSARG} ]; then
+ echo "${MAKEFSARG} must exist"
exit 1
@@ -33,20 +41,30 @@ if [ -e ${2} ]; then
exit 1
-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}
+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}
# 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}