Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jun 2010 18:18:31 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r209210 - head/tools/tools/nanobsd
Message-ID:  <201006151818.o5FIIVTU056573@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Jun 15 18:18:31 2010
New Revision: 209210
URL: http://svn.freebsd.org/changeset/base/209210

Log:
  Allow population of /cfg and /data.  Begin the move to making all
  slice creation overrideable too, but there's a few problems doing that
  for the duplicated partitions (s1 and s2), so just comment that it
  needs work.
  
  MFC after:	3 days

Modified:
  head/tools/tools/nanobsd/nanobsd.sh

Modified: head/tools/tools/nanobsd/nanobsd.sh
==============================================================================
--- head/tools/tools/nanobsd/nanobsd.sh	Tue Jun 15 18:16:45 2010	(r209209)
+++ head/tools/tools/nanobsd/nanobsd.sh	Tue Jun 15 18:18:31 2010	(r209210)
@@ -357,6 +357,30 @@ prune_usr() (
 		done
 )
 
+populate_slice ( ) (
+	local dev dir mnt
+	dev=$1
+	dir=$2
+	mnt=$3
+	test -z $2 && dir=/var/empty
+	test -d $d || dir=/var/empty
+	echo "Creating ${dev} with ${dir} (mounting on ${mnt})"
+	newfs ${NANO_NEWFS} ${dev}
+	mount ${dev} ${mnt}
+	cd ${dir}
+	find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${mnt}
+	df -i ${mnt}
+	umount ${mnt}
+)
+
+populate_cfg_slice ( ) (
+	populate_slice "$1" "$2" "$3"
+)
+
+populate_data_slice ( ) (
+	populate_slice "$1" "$2" "$3"
+)
+
 create_i386_diskimage ( ) (
 	pprint 2 "build diskimage"
 	pprint 3 "log: ${NANO_OBJ}/_.di"
@@ -456,6 +480,7 @@ create_i386_diskimage ( ) (
 	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}
@@ -480,13 +505,11 @@ create_i386_diskimage ( ) (
 	fi
 	
 	# Create Config slice
-	newfs ${NANO_NEWFS} /dev/${MD}s3
-	# XXX: fill from where ?
+	populate_cfg_slice /dev/${MD}s3 "${NANO_CFGDIR}" ${MNT}
 
 	# Create Data slice, if any.
 	if [ $NANO_DATASIZE -ne 0 ] ; then
-		newfs ${NANO_NEWFS} /dev/${MD}s4
-		# XXX: fill from where ?
+		populate_data_slice /dev/${MD}s4 "${NANO_DATADIR}" ${MNT}
 	fi
 
 	if [ "${NANO_MD_BACKING}" = "swap" ] ; then



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006151818.o5FIIVTU056573>