summaryrefslogtreecommitdiffstats
path: root/tools/tools
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2012-07-22 20:55:42 +0000
committerphk <phk@FreeBSD.org>2012-07-22 20:55:42 +0000
commite4dd41f3949ecccb9a44be2f867edef70a137c6b (patch)
treef0f9e4cc9be2f5900eb6aad531766c16d490f432 /tools/tools
parent3d22525e563013d0c86b0816e64ba8273c14dfc3 (diff)
downloadFreeBSD-src-e4dd41f3949ecccb9a44be2f867edef70a137c6b.zip
FreeBSD-src-e4dd41f3949ecccb9a44be2f867edef70a137c6b.tar.gz
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
Diffstat (limited to 'tools/tools')
-rw-r--r--tools/tools/sysbuild/sysbuild.sh48
1 files changed, 25 insertions, 23 deletions
diff --git a/tools/tools/sysbuild/sysbuild.sh b/tools/tools/sysbuild/sysbuild.sh
index dad5acb..dfca7c0 100644
--- a/tools/tools/sysbuild/sysbuild.sh
+++ b/tools/tools/sysbuild/sysbuild.sh
@@ -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"
OpenPOWER on IntegriCloud