Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jul 2012 20:55:42 +0000 (UTC)
From:      Poul-Henning Kamp <phk@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238704 - head/tools/tools/sysbuild
Message-ID:  <201207222055.q6MKtg46025588@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: phk
Date: Sun Jul 22 20:55:42 2012
New Revision: 238704
URL: http://svn.freebsd.org/changeset/base/238704

Log:
  Derive FREEBSD_PART from /etc/fstab, and make it full device name.
  
  Give suggestion for next steps when done.
  
  Inspired by patches from:	Flemming "F3" Jacobsen

Modified:
  head/tools/tools/sysbuild/sysbuild.sh

Modified: head/tools/tools/sysbuild/sysbuild.sh
==============================================================================
--- head/tools/tools/sysbuild/sysbuild.sh	Sun Jul 22 20:08:38 2012	(r238703)
+++ head/tools/tools/sysbuild/sysbuild.sh	Sun Jul 22 20:55:42 2012	(r238704)
@@ -31,7 +31,7 @@ set -e
 
 exec < /dev/null
 
-if [ `uname -m` = "i386" ] ; then
+if [ `uname -m` = "i386" -o `uname -m` = "amd64" ] ; then
 	TARGET_PART=`df / | sed '
 	1d
 	s/[    ].*//
@@ -41,25 +41,24 @@ if [ `uname -m` = "i386" ] ; then
 	s,s3a,s2a,
 	'`
 
-	# Where our build-bits are to be found
-	FREEBSD_PART=`echo $TARGET_PART | sed 's/s[12]a/s3/'`
-elif [ `uname -m` = "amd64" ] ; then
-	TARGET_PART=`df / | sed '
-	1d
-	s/[    ].*//
-	s,/dev/,,
-	s,s1a,s3a,
-	s,s2a,s1a,
-	s,s3a,s2a,
-	'`
-
-	# Where our build-bits are to be found
-	FREEBSD_PART=`echo $TARGET_PART | sed 's/s[12]a/s3/'`
+	FREEBSD_PART=`sed -n	\
+		-e 's/#.*//'	\
+		-e '/[ 	]\/freebsd[ 	]/!d'	\
+		-e 's/[ 	].*//p'	\
+		/etc/fstab`
+
+	# Calculate a suggested gpart command
+	TARGET_DISK=`expr ${TARGET_PART} : '\(.*\)s[12]a$' || true`
+	TARGET_SLICE=`expr ${TARGET_PART} : '.*s\([12]\)a$' || true`
+	GPART_SUGGESTION="gpart set -a active -i $TARGET_SLICE /dev/$TARGET_DISK"
+	unset TARGET_DISK TARGET_SLICE
 else
 	TARGET_PART=unknown
 	FREEBSD_PART=unknown
+	GPART_SUGGESTION=unknown
 fi
 
+
 # Relative to /freebsd
 PORTS_PATH=ports
 SRC_PATH=src
@@ -405,7 +404,7 @@ log_it Unmount everything
 	( cleanup )
 	umount /freebsd/distfiles || true
 	umount ${SBMNT}/freebsd/distfiles || true
-	umount /dev/${FREEBSD_PART} || true
+	umount ${FREEBSD_PART} || true
 	umount ${SBMNT}/freebsd || true
 	umount ${SBMNT}/dev || true
 	umount ${SBMNT} || true
@@ -414,7 +413,7 @@ log_it Unmount everything
 
 log_it Prepare running image
 mkdir -p /freebsd
-mount /dev/${FREEBSD_PART} /freebsd
+mount ${FREEBSD_PART} /freebsd
 
 #######################################################################
 
@@ -525,9 +524,9 @@ log_it Move filesystems
 if [ "x${REMOTEDISTFILES}" != "x" ] ; then
 	umount /freebsd/distfiles
 fi
-umount /dev/${FREEBSD_PART} || true
+umount ${FREEBSD_PART} || true
 mkdir -p ${SBMNT}/freebsd
-mount /dev/${FREEBSD_PART} ${SBMNT}/freebsd
+mount ${FREEBSD_PART} ${SBMNT}/freebsd
 if [ "x${REMOTEDISTFILES}" != "x" ] ; then
 	mount  ${REMOTEDISTFILES} ${SBMNT}/freebsd/distfiles
 fi
@@ -560,6 +559,10 @@ log_it before_ports
 	before_ports 
 )
 
+log_it fixing fstab
+sed "/[ 	]\/[ 	]/s;^[^ 	]*[ 	];/dev/${TARGET_PART}	;" \
+	/etc/fstab > ${SBMNT}/etc/fstab
+
 log_it build ports
 pwd
 cp $0 ${SBMNT}/root
@@ -573,10 +576,6 @@ else
 fi
 cp ${SBMNT}/tmp/_sb_log /tmp
 
-log_it fixing fstab
-sed "/[ 	]\/[ 	]/s;^[^ 	]*[ 	];/dev/${TARGET_PART}	;" \
-	/etc/fstab > ${SBMNT}/etc/fstab
-
 log_it create all mountpoints
 grep -v '^[ 	]*#' ${SBMNT}/etc/fstab | 
 while read a b c
@@ -615,3 +614,6 @@ cp ${SBMNT}/tmp/_sb_log /tmp
 log_it "Check these messages (if any):"
 grep '^Stop' ${SBMNT}/_* || true
 log_it DONE
+echo "Now you probably want to:"
+echo "    $GPART_SUGGESTION"
+echo "    shutdown -r now"



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