--- tools/tools/nanobsd/nanobsd.sh.orig 2010-09-09 21:52:05.000000000 -0600
+++ tools/tools/nanobsd/nanobsd.sh 2010-12-08 15:23:28.000000000 -0700
@@ -135,12 +135,18 @@
# Progress Print level
PPLEVEL=3
+# 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=""
+
#######################################################################
# 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.
-
NANO_ARCH=`uname -p`
#######################################################################
@@ -385,6 +391,40 @@
populate_slice "$1" "$2" "$3"
)
+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 lbl
+ dev=$1
+ dir=$2
+ mnt=$3
+ lbl=$4
+ test -z $2 && dir=/var/empty
+ test -d $dir || dir=/var/empty
+ echo "Creating ${dev} with ${dir} (mounting on ${mnt})"
+ newfs_part $dev $mnt $lbl
+ cd ${dir}
+ find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${mnt}
+ df -i ${mnt}
+ umount ${mnt}
+)
+
+populate_cfg_slice ( ) (
+ populate_slice "$1" "$2" "$3" "$4"
+)
+
+populate_data_slice ( ) (
+ populate_slice "$1" "$2" "$3" "$4"
+)
+
create_i386_diskimage ( ) (
pprint 2 "build diskimage"
pprint 3 "log: ${NANO_OBJ}/_.di"
@@ -467,8 +507,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 +524,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 +535,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
@@ -820,6 +858,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 +887,7 @@
export NANO_WORLDDIR
export NANO_BOOT0CFG
export NANO_BOOTLOADER
+export NANO_LABEL
#######################################################################
# And then it is as simple as that...