From 45e025b4b0e7c5e519819c6f0396b825e4fa9d82 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sun, 21 Mar 2010 02:33:09 -0500 Subject: [PATCH] script/gencard: specify bootcode; else choose /boot/boot, or /boot/boot.blk if the former is a symlink --- script/gencard | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/script/gencard b/script/gencard index ee098f6..e1be88b 100755 --- a/script/gencard +++ b/script/gencard @@ -14,6 +14,7 @@ pebkac(){ echo " -c Config directory to embed into card image" echo " -o Card image filename to write (default card.img)" echo " -s Intended card size, in 512-byte sectors" + echo " -a Bootcode file to use (default /boot/boot)" echo " -h Hi!" exit 1 } @@ -51,6 +52,16 @@ compute_label(){ } # Defaults +bootcode="/boot/boot" + +# Since almost all of the boot process refers absolutely to /boot/... and +# cannot work when /boot is on its own filesystem, the bootcode in /boot/boot +# must be moved to make way for a 'boot -> .' symlink so that it works. +# Unfortunately, this breaks bsdlabel, which expects the bootcode to be in +# /boot/boot. bsdlabel will happily store whatever is in /boot/boot into the +# track, including the directory itself. >o.O< +[ ! -f "${bootcode}" -a -f "/boot/boot.blk" ] && bootcode="/boot/boot.blk" + boot_img="boot.img" root_img="root.img" conf_dir="conf" @@ -58,7 +69,7 @@ card_img="card.img" card_size=1000944 # Parse command line options -while getopts "b:r:c:o:s:h" opt +while getopts "b:r:c:o:s:a:h" opt do case "${opt}" in b) boot_img="${OPTARG}" ;; @@ -66,6 +77,7 @@ do c) conf_dir="${OPTARG}" ;; o) card_img="${OPTARG}" ;; s) card_size="${OPTARG}" ;; + a) bootcode="${OPTARG}" ;; h) pebkac ;; [?]) pebkac "Unrecognized option ${opt}" ;; esac @@ -76,6 +88,7 @@ shift $(( $OPTIND - 1 )) [ -f "${root_img}" ] || err "${root_img}: no such file or directory" [ -d "${conf_dir}" ] || err "${conf_dir}: not a directory" [ "${card_size}" -gt 0 ] || err "${card_size}: not a number " +[ -f "${bootcode}" ] || err "${bootcode}: not a regular file" log Card size: ${card_size} sectors rm -f "${card_img}" @@ -84,7 +97,7 @@ md=$(mdconfig -a -t vnode -f "${card_img}") mnt="$(mktemp -d /tmp/conf.XXXXXXXX)" trap "umount '${mnt}'; rm -Rf '${mnt}'; mdconfig -d -u '${md}'" exit hup int term kill -compute_label "${card_size}" "${boot_img}" "${root_img}" | bsdlabel -R -B "${md}" /dev/stdin +compute_label "${card_size}" "${boot_img}" "${root_img}" | bsdlabel -R -B -b "${bootcode}" "${md}" /dev/stdin log Applied label: bsdlabel "${md}" -- 2.42.0