aboutsummaryrefslogtreecommitdiff
path: root/release/amd64/make-memstick.sh
diff options
context:
space:
mode:
Diffstat (limited to 'release/amd64/make-memstick.sh')
-rwxr-xr-xrelease/amd64/make-memstick.sh49
1 files changed, 34 insertions, 15 deletions
diff --git a/release/amd64/make-memstick.sh b/release/amd64/make-memstick.sh
index c0e405c3a976..4c51d7d65af4 100755
--- a/release/amd64/make-memstick.sh
+++ b/release/amd64/make-memstick.sh
@@ -5,9 +5,8 @@
# 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$
#
set -e
@@ -15,16 +14,26 @@ 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 /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
@@ -33,20 +42,30 @@ if [ -e ${2} ]; then
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 -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} ${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}