Replace hardcoded /mnt with ${SBMNT} which defaults to /mnt.sysbuild

Submitted by:	Flemming "F3" Jacobsen
This commit is contained in:
Poul-Henning Kamp 2012-07-22 19:32:27 +00:00
parent 70a8f993c0
commit 1ec04b6d45

View File

@ -97,6 +97,8 @@ PORTS_OPTS="BATCH=YES MAKE_IDEA=YES A4=yes"
CONFIGFILES='
'
SBMNT="/mnt.sysbuild"
cleanup() (
)
@ -387,6 +389,8 @@ fi
T0=`date +%s`
echo $T0 $T0 > /tmp/_sb_log
[ ! -d ${SBMNT} ] && mkdir -p ${SBMNT}
if $do_prefetch ; then
rm -rf /tmp/sysbuild/ports
mkdir -p /tmp/sysbuild/ports
@ -400,11 +404,11 @@ log_it Unmount everything
(
( cleanup )
umount /freebsd/distfiles || true
umount /mnt/freebsd/distfiles || true
umount ${SBMNT}/freebsd/distfiles || true
umount /dev/${FREEBSD_PART} || true
umount /mnt/freebsd || true
umount /mnt/dev || true
umount /mnt || true
umount ${SBMNT}/freebsd || true
umount ${SBMNT}/dev || true
umount ${SBMNT} || true
umount /dev/${TARGET_PART} || true
) # > /dev/null 2>&1
@ -461,9 +465,9 @@ export PORTS_OPTS
log_it Prepare destination partition
newfs -O2 -U /dev/${TARGET_PART} > /dev/null
mount /dev/${TARGET_PART} /mnt
mkdir -p /mnt/dev
mount -t devfs devfs /mnt/dev
mount /dev/${TARGET_PART} ${SBMNT}
mkdir -p ${SBMNT}/dev
mount -t devfs devfs ${SBMNT}/dev
if [ "x${REMOTEDISTFILES}" != "x" ] ; then
rm -rf /freebsd/${PORTS_PATH}/distfiles
@ -473,16 +477,16 @@ if [ "x${REMOTEDISTFILES}" != "x" ] ; then
fi
log_it copy ports config files
(cd / ; find var/db/ports -print | cpio -dumpv /mnt > /dev/null 2>&1)
(cd / ; find var/db/ports -print | cpio -dumpv ${SBMNT} > /dev/null 2>&1)
log_it "Start prefetch of ports distfiles"
ports_prefetch /mnt &
ports_prefetch ${SBMNT} &
if $do_world ; then
(
cd /usr/src
log_it "Buildworld"
make ${JARG} -s buildworld ${SRCCONF} > /mnt/_.bw 2>&1
make ${JARG} -s buildworld ${SRCCONF} > ${SBMNT}/_.bw 2>&1
)
fi
@ -490,30 +494,30 @@ if $do_kernel ; then
(
cd /usr/src
log_it "Buildkernel"
make ${JARG} -s buildkernel KERNCONF=$KERNCONF > /mnt/_.bk 2>&1
make ${JARG} -s buildkernel KERNCONF=$KERNCONF > ${SBMNT}/_.bk 2>&1
)
fi
log_it Installworld
(cd /usr/src && make ${JARG} installworld DESTDIR=/mnt ${SRCCONF} ) \
> /mnt/_.iw 2>&1
(cd /usr/src && make ${JARG} installworld DESTDIR=${SBMNT} ${SRCCONF} ) \
> ${SBMNT}/_.iw 2>&1
log_it distribution
(cd /usr/src/etc && make -m /usr/src/share/mk distribution DESTDIR=/mnt ${SRCCONF} ) \
> /mnt/_.dist 2>&1
(cd /usr/src/etc && make -m /usr/src/share/mk distribution DESTDIR=${SBMNT} ${SRCCONF} ) \
> ${SBMNT}/_.dist 2>&1
log_it Installkernel
(cd /usr/src && make ${JARG} installkernel DESTDIR=/mnt KERNCONF=$KERNCONF ) \
> /mnt/_.ik 2>&1
(cd /usr/src && make ${JARG} installkernel DESTDIR=${SBMNT} KERNCONF=$KERNCONF ) \
> ${SBMNT}/_.ik 2>&1
if [ "x${OBJ_PATH}" != "x" ] ; then
rmdir /mnt/usr/obj
ln -s /freebsd/${OBJ_PATH} /mnt/usr/obj
rmdir ${SBMNT}/usr/obj
ln -s /freebsd/${OBJ_PATH} ${SBMNT}/usr/obj
fi
log_it Wait for ports prefetch
log_it "(Tail /mnt/_.prefetch for progress)"
log_it "(Tail ${SBMNT}/_.prefetch for progress)"
wait
log_it Move filesystems
@ -522,34 +526,34 @@ if [ "x${REMOTEDISTFILES}" != "x" ] ; then
umount /freebsd/distfiles
fi
umount /dev/${FREEBSD_PART} || true
mkdir -p /mnt/freebsd
mount /dev/${FREEBSD_PART} /mnt/freebsd
mkdir -p ${SBMNT}/freebsd
mount /dev/${FREEBSD_PART} ${SBMNT}/freebsd
if [ "x${REMOTEDISTFILES}" != "x" ] ; then
mount ${REMOTEDISTFILES} /mnt/freebsd/distfiles
mount ${REMOTEDISTFILES} ${SBMNT}/freebsd/distfiles
fi
rm -rf /mnt/usr/ports || true
ln -s /freebsd/${PORTS_PATH} /mnt/usr/ports
rm -rf ${SBMNT}/usr/ports || true
ln -s /freebsd/${PORTS_PATH} ${SBMNT}/usr/ports
rm -rf /mnt/usr/src || true
ln -s /freebsd/${SRC_PATH} /mnt/usr/src
rm -rf ${SBMNT}/usr/src || true
ln -s /freebsd/${SRC_PATH} ${SBMNT}/usr/src
log_it Build and install ports
# Make sure fetching will work in the chroot
if [ -f /etc/resolv.conf ] ; then
log_it copy resolv.conf
cp /etc/resolv.conf /mnt/etc
chflags schg /mnt/etc/resolv.conf
cp /etc/resolv.conf ${SBMNT}/etc
chflags schg ${SBMNT}/etc/resolv.conf
fi
if [ -f /etc/localtime ] ; then
log_it copy localtime
cp /etc/localtime /mnt/etc
cp /etc/localtime ${SBMNT}/etc
fi
log_it ldconfig in chroot
chroot /mnt sh /etc/rc.d/ldconfig start
chroot ${SBMNT} sh /etc/rc.d/ldconfig start
log_it before_ports
(
@ -558,56 +562,56 @@ log_it before_ports
log_it build ports
pwd
cp $0 /mnt/root
cp /tmp/_sb_log /mnt/tmp
cp $0 ${SBMNT}/root
cp /tmp/_sb_log ${SBMNT}/tmp
b=`basename $0`
if [ "x$c_arg" != "x" ] ; then
cp $c_arg /mnt/root
chroot /mnt sh /root/$0 -c /root/`basename $c_arg` $use_pkg chroot_script
cp $c_arg ${SBMNT}/root
chroot ${SBMNT} sh /root/$0 -c /root/`basename $c_arg` $use_pkg chroot_script
else
chroot /mnt sh /root/$0 $use_pkg chroot_script
chroot ${SBMNT} sh /root/$0 $use_pkg chroot_script
fi
cp /mnt/tmp/_sb_log /tmp
cp ${SBMNT}/tmp/_sb_log /tmp
log_it fixing fstab
sed "/[ ]\/[ ]/s;^[^ ]*[ ];/dev/${TARGET_PART} ;" \
/etc/fstab > /mnt/etc/fstab
/etc/fstab > ${SBMNT}/etc/fstab
log_it create all mountpoints
grep -v '^[ ]*#' /mnt/etc/fstab |
grep -v '^[ ]*#' ${SBMNT}/etc/fstab |
while read a b c
do
mkdir -p /mnt/$b
mkdir -p ${SBMNT}/$b
done
if [ "x$SERCONS" != "xfalse" ] ; then
log_it serial console
echo " -h" > /mnt/boot.config
sed -i "" -e /ttyd0/s/off/on/ /mnt/etc/ttys
sed -i "" -e /ttyu0/s/off/on/ /mnt/etc/ttys
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' /mnt/etc/ttys
echo " -h" > ${SBMNT}/boot.config
sed -i "" -e /ttyd0/s/off/on/ ${SBMNT}/etc/ttys
sed -i "" -e /ttyu0/s/off/on/ ${SBMNT}/etc/ttys
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${SBMNT}/etc/ttys
fi
log_it move dist config files "(expect warnings)"
(
cd /mnt
cd ${SBMNT}
mkdir root/configfiles_dist
find ${CONFIGFILES} -print | cpio -dumpv root/configfiles_dist
)
log_it copy live config files
(cd / && find ${CONFIGFILES} -print | cpio -dumpv /mnt)
(cd / && find ${CONFIGFILES} -print | cpio -dumpv ${SBMNT})
log_it final_root
( final_root )
log_it final_chroot
cp /tmp/_sb_log /mnt/tmp
cp /tmp/_sb_log ${SBMNT}/tmp
if [ "x$c_arg" != "x" ] ; then
chroot /mnt sh /root/$0 -c /root/`basename $c_arg` final_chroot
chroot ${SBMNT} sh /root/$0 -c /root/`basename $c_arg` final_chroot
else
chroot /mnt sh /root/$0 final_chroot
chroot ${SBMNT} sh /root/$0 final_chroot
fi
cp /mnt/tmp/_sb_log /tmp
cp ${SBMNT}/tmp/_sb_log /tmp
log_it "Check these messages (if any):"
grep '^Stop' /mnt/_* || true
grep '^Stop' ${SBMNT}/_* || true
log_it DONE