Menu

[r10367]: / branches / feedback / patches / freebsd-nanobsd.patch  Maximize  Restore  History

Download this file

138 lines (127 with data), 4.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
--- 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...
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.