aboutsummaryrefslogtreecommitdiff
path: root/release/riscv
diff options
context:
space:
mode:
Diffstat (limited to 'release/riscv')
-rwxr-xr-xrelease/riscv/make-memstick.sh44
-rw-r--r--release/riscv/mkisoimages.sh38
2 files changed, 64 insertions, 18 deletions
diff --git a/release/riscv/make-memstick.sh b/release/riscv/make-memstick.sh
index 0cde77b018b8..9fcc001fc6fd 100755
--- a/release/riscv/make-memstick.sh
+++ b/release/riscv/make-memstick.sh
@@ -5,26 +5,36 @@
# 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
-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
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,15 +43,25 @@ 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 gpt \
-p efi:=${espfilename} \
diff --git a/release/riscv/mkisoimages.sh b/release/riscv/mkisoimages.sh
index 5556336840cd..e7e56eef1cb6 100644
--- a/release/riscv/mkisoimages.sh
+++ b/release/riscv/mkisoimages.sh
@@ -37,8 +37,23 @@ if [ -z $MKIMG ]; then
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.
@@ -49,7 +64,6 @@ if [ "$1" = "-b" ]; then
shift
else
- BASEBITSDIR="$3"
bootable=""
fi
@@ -60,12 +74,23 @@ 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 -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.
@@ -81,13 +106,14 @@ if [ "$bootable" != "" ]; then
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 efi.img
+ -o $efifilename
# Drop the GPT into the System Area of the ISO.
- dd if=efi.img of="$NAME" bs=32k count=1 conv=notrunc
- rm -f efi.img
+ dd if=$efifilename of="$NAME" bs=32k count=1 conv=notrunc
+ rm -f $efifilename
fi