--- tools/tools/nanobsd/nanobsd.sh.orig 2010-12-03 22:22:24.000000000 -0700
+++ tools/tools/nanobsd/nanobsd.sh 2010-12-03 22:22:31.000000000 -0700
@@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/tools/tools/nanobsd/nanobsd.sh,v 1.51.2.4 2010/09/10 03:52:05 imp Exp $
+# $FreeBSD: src/tools/tools/nanobsd/nanobsd.sh,v 1.51.2.3.2.1 2010/06/14 02:09:06 kensmith Exp $
#
set -e
@@ -124,10 +124,6 @@
NANO_BOOT0CFG="-o packet -s 1 -m 3"
NANO_BOOTLOADER="boot/boot0sio"
-# boot2 flags/options
-# default force serial console
-NANO_BOOT2CFG="-h"
-
# Backing type of md(4) device
# Can be "file" or "swap"
NANO_MD_BACKING="file"
@@ -135,12 +131,15 @@
# Progress Print level
PPLEVEL=3
-#######################################################################
-# Architecture to build. Corresponds to TARGET_ARCH in a buildworld.
-# Unfortunately, there's no way to set TARGET at this time, and it
-# conflates the two, so architectures where TARGET != TARGET_ARCH do
-# not work. This defaults to the arch of the current machine.
+# Set NANO_LABEL to non-blank to form the basis for using /dev/ufs/label
+# in preference to /dev/${NANO_DRIVE}
+# Root partition will be ${NANO_LABEL}s{1,2}
+# /cfg partition will be ${NANO_LABEL}s3
+# /data partition will be ${NANO_LABEL}s4
+NANO_LABEL=""
+#######################################################################
+# Not a variable at this time
NANO_ARCH=`uname -p`
#######################################################################
@@ -361,16 +360,26 @@
done
)
+newfs_part ( ) (
+ local dev mnt lbl
+ dev=$1
+ mnt=$2
+ lbl=$3
+ echo newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev}
+ newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev}
+ mount -o async ${dev} ${mnt}
+)
+
populate_slice ( ) (
- local dev dir mnt
+ local dev dir mnt lbl
dev=$1
dir=$2
mnt=$3
+ lbl=$4
test -z $2 && dir=/var/empty
- test -d $d || dir=/var/empty
+ test -d $dir || dir=/var/empty
echo "Creating ${dev} with ${dir} (mounting on ${mnt})"
- newfs ${NANO_NEWFS} ${dev}
- mount ${dev} ${mnt}
+ newfs_part $dev $mnt $lbl
cd ${dir}
find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${mnt}
df -i ${mnt}
@@ -378,11 +387,11 @@
)
populate_cfg_slice ( ) (
- populate_slice "$1" "$2" "$3"
+ populate_slice "$1" "$2" "$3" "$4"
)
populate_data_slice ( ) (
- populate_slice "$1" "$2" "$3"
+ populate_slice "$1" "$2" "$3" "$4"
)
create_i386_diskimage ( ) (
@@ -467,8 +476,8 @@
-y ${NANO_HEADS}`
else
echo "Creating md backing file..."
- dd if=/dev/zero of=${IMG} bs=${NANO_SECTS}b \
- count=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}`
+ rm -f ${IMG}
+ dd if=/dev/zero of=${IMG} seek=${NANO_MEDIASIZE} count=0
MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \
-y ${NANO_HEADS}`
fi
@@ -484,13 +493,8 @@
bsdlabel ${MD}s1
# Create first image
- # XXX: should use populate_slice for easier override
- newfs ${NANO_NEWFS} /dev/${MD}s1a
- mount /dev/${MD}s1a ${MNT}
- df -i ${MNT}
- echo "Copying worlddir..."
- ( cd ${NANO_WORLDDIR} && find . -print | cpio -dump ${MNT} )
- df -i ${MNT}
+ populate_slice /dev/${MD}s1a ${NANO_WORLDDIR} ${MNT} "s1a"
+ mount -o async /dev/${MD}s1a ${MNT}
echo "Generating mtree..."
( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree
( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du
@@ -500,20 +504,23 @@
# Duplicate to second image (if present)
echo "Duplicating to second image..."
dd if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k
- mount /dev/${MD}s2a ${MNT}
+ mount -o async /dev/${MD}s2a ${MNT}
for f in ${MNT}/etc/fstab ${MNT}/conf/base/etc/fstab
do
sed -i "" "s=${NANO_DRIVE}s1=${NANO_DRIVE}s2=g" $f
done
umount ${MNT}
+ if [ ! -z ${NANO_LABEL} ]; then
+ tunefs -L ${NANO_LABEL}"s2a" /dev/${MD}s2a
+ fi
fi
# Create Config slice
- populate_cfg_slice /dev/${MD}s3 "${NANO_CFGDIR}" ${MNT}
+ populate_cfg_slice /dev/${MD}s3 "${NANO_CFGDIR}" ${MNT} "s3"
# Create Data slice, if any.
if [ $NANO_DATASIZE -ne 0 ] ; then
- populate_data_slice /dev/${MD}s4 "${NANO_DATADIR}" ${MNT}
+ populate_data_slice /dev/${MD}s4 "${NANO_DATADIR}" ${MNT} "s4"
fi
if [ "${NANO_MD_BACKING}" = "swap" ] ; then
@@ -612,7 +619,7 @@
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${NANO_WORLDDIR}/etc/ttys
# Tell loader to use serial console early.
- echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config
+ echo " -h" > ${NANO_WORLDDIR}/boot.config
)
#######################################################################
@@ -712,12 +719,12 @@
usage () {
(
- echo "Usage: $0 [-biknqvw] [-c config_file]"
+ echo "Usage: $0 [-bikqvw] [-c config_file]"
echo " -b suppress builds (both kernel and world)"
echo " -i suppress disk image build"
echo " -k suppress buildkernel"
echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc"
- echo " -q make output more quiet"
+ echo " -q make output more quite"
echo " -v make output more verbose"
echo " -w suppress buildworld"
echo " -c specify config file"
@@ -820,6 +827,11 @@
NANO_PMAKE="${NANO_PMAKE} -DNO_CLEAN"
fi
+# Override user's NANO_DRIVE if they specified a NANO_LABEL
+if [ ! -z "${NANO_LABEL}" ]; then
+ NANO_DRIVE=ufs/${NANO_LABEL}
+fi
+
export MAKEOBJDIRPREFIX
export NANO_ARCH
@@ -844,6 +856,7 @@
export NANO_WORLDDIR
export NANO_BOOT0CFG
export NANO_BOOTLOADER
+export NANO_LABEL
#######################################################################
# And then it is as simple as that...