summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2014-11-16 01:29:18 +0000
committerimp <imp@FreeBSD.org>2014-11-16 01:29:18 +0000
commitb24fe3677d8be4f965991d5170dff07d7a0614d1 (patch)
tree5bbc4941a078bcc375aa500e4a779cb9698267a7
parent131ee6d96ee7de1bb7a9ece242f292368670ab2d (diff)
downloadFreeBSD-src-b24fe3677d8be4f965991d5170dff07d7a0614d1.zip
FreeBSD-src-b24fe3677d8be4f965991d5170dff07d7a0614d1.tar.gz
MFC from the last few months:
Note: didn't merge r274331 removing gif/faith on purpose. r268246 | mr | use mkimg and build into separate directories r269355 | imp | Fix typo in example script r269362 | imp | use rm -x on 10 and newer r269363 | imp | NANO_OBJ shouldn't end with '/' r269423 | imp | -K to suppress installkernel r269424 | imp | sort usage r269425 | imp | sort switch r269983 | imp | only install bootloader if it exists r269984 | imp | create_diskimage since it never was $ARCH dependent r270162 | imp | Add support for -X which instales cross native tools
-rw-r--r--tools/tools/nanobsd/dhcpd/README2
-rw-r--r--tools/tools/nanobsd/dhcpd/common5
-rw-r--r--tools/tools/nanobsd/nanobsd.sh100
-rw-r--r--tools/tools/nanobsd/rescue/R3214
-rw-r--r--tools/tools/nanobsd/rescue/R6414
-rwxr-xr-xtools/tools/nanobsd/rescue/build.sh24
-rw-r--r--tools/tools/nanobsd/rescue/common17
-rwxr-xr-xtools/tools/nanobsd/rescue/merge.sh26
-rw-r--r--tools/tools/nanobsd/rescue/rescue_amd64.conf2
-rw-r--r--tools/tools/nanobsd/rescue/rescue_i386.conf2
10 files changed, 148 insertions, 58 deletions
diff --git a/tools/tools/nanobsd/dhcpd/README b/tools/tools/nanobsd/dhcpd/README
index 8d9960c..35bc66e 100644
--- a/tools/tools/nanobsd/dhcpd/README
+++ b/tools/tools/nanobsd/dhcpd/README
@@ -9,6 +9,6 @@ and DHCPd.
This is a work in progress. Generally, to build this you should
cd tools/tools/nanobsd/dhcpd
- sudo sh ../nandobsd.sh -C os-base
+ sudo sh ../nanobsd.sh -C os-base
but do be careful if things are interrupted. There may still be
bugs lurking that cause your entire FreeBSD tree to disappear.
diff --git a/tools/tools/nanobsd/dhcpd/common b/tools/tools/nanobsd/dhcpd/common
index 412c1a1..2658a84 100644
--- a/tools/tools/nanobsd/dhcpd/common
+++ b/tools/tools/nanobsd/dhcpd/common
@@ -261,11 +261,6 @@ die()
exit 1
}
-create_amd64_diskimage()
-{
- create_i386_diskimage "$*"
-}
-
# Automatically include the packaging port here so it is always first so it
# builds the port and adds the package so we can add other packages.
add_port ports-mgmt/pkg
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh
index 600d112..437085a 100644
--- a/tools/tools/nanobsd/nanobsd.sh
+++ b/tools/tools/nanobsd/nanobsd.sh
@@ -178,6 +178,15 @@ SRCCONF=${SRCCONF:=/dev/null}
#
#######################################################################
+# rm doesn't know -x prior to FreeBSD 10, so cope with a variety of build
+# hosts for now.
+nano_rm ( ) {
+ case $(uname -r) in
+ 7*|8*|9*) rm $* ;;
+ *) rm -x $* ;;
+ esac
+}
+
# run in the world chroot, errors fatal
CR()
{
@@ -200,9 +209,9 @@ nano_cleanup ( ) (
clean_build ( ) (
pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})"
- if ! rm -xrf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then
+ if ! nano_rm -rf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then
chflags -R noschg ${MAKEOBJDIRPREFIX}/
- rm -xr ${MAKEOBJDIRPREFIX}/
+ nano_rm -r ${MAKEOBJDIRPREFIX}/
fi
mkdir -p ${MAKEOBJDIRPREFIX}
printenv > ${MAKEOBJDIRPREFIX}/_.env
@@ -256,17 +265,17 @@ build_kernel ( ) (
clean_world ( ) (
if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then
pprint 2 "Clean and create object directory (${NANO_OBJ})"
- if ! rm -rxf ${NANO_OBJ}/ > /dev/null 2>&1 ; then
+ if ! nano_rm -rf ${NANO_OBJ}/ > /dev/null 2>&1 ; then
chflags -R noschg ${NANO_OBJ}
- rm -xr ${NANO_OBJ}/
+ nano_rm -r ${NANO_OBJ}/
fi
mkdir -p ${NANO_OBJ} ${NANO_WORLDDIR}
printenv > ${NANO_OBJ}/_.env
else
pprint 2 "Clean and create world directory (${NANO_WORLDDIR})"
- if ! rm -rxf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then
+ if ! nano_rm -rf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then
chflags -R noschg ${NANO_WORLDDIR}
- rm -rxf ${NANO_WORLDDIR}/
+ nano_rm -rf ${NANO_WORLDDIR}/
fi
mkdir -p ${NANO_WORLDDIR}
fi
@@ -338,6 +347,18 @@ install_kernel ( ) (
) > ${NANO_OBJ}/_.ik 2>&1
)
+native_xtools ( ) (
+ print 2 "Installing the optimized native build tools for cross env"
+ pprint 3 "log: ${NANO_OBJ}/_.native_xtools"
+
+ cd ${NANO_SRC}
+ env TARGET_ARCH=${NANO_ARCH} \
+ ${NANO_MAKE} SRCCONF=${SRCCONF} \
+ __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} native-xtools \
+ DESTDIR=${NANO_WORLDDIR} \
+ > ${NANO_OBJ}/_.native_xtools 2>&1
+)
+
run_customize() (
pprint 2 "run customize scripts"
@@ -378,7 +399,7 @@ setup_nanobsd ( ) (
cd usr/local/etc
find . -print | cpio -dumpl ../../../etc/local
cd ..
- rm -rf etc
+ nano_rm -rf etc
ln -s ../../etc/local etc
)
fi
@@ -400,7 +421,7 @@ setup_nanobsd ( ) (
echo "mount -o ro /dev/${NANO_DRIVE}s3" > conf/default/etc/remount
# Put /tmp on the /var ramdisk (could be symlink already)
- test -d tmp && rmdir tmp || rm -f tmp
+ test -d tmp && rmdir tmp || nano_rm -f tmp
ln -s var/tmp tmp
) > ${NANO_OBJ}/_.dl 2>&1
@@ -478,7 +499,7 @@ populate_data_slice ( ) (
populate_slice "$1" "$2" "$3" "$4"
)
-create_i386_diskimage ( ) (
+create_diskimage ( ) (
pprint 2 "build diskimage"
pprint 3 "log: ${NANO_OBJ}/_.di"
@@ -560,7 +581,7 @@ create_i386_diskimage ( ) (
-y ${NANO_HEADS}`
else
echo "Creating md backing file..."
- rm -f ${IMG}
+ nano_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}`
@@ -572,8 +593,14 @@ create_i386_diskimage ( ) (
fdisk ${MD}
# XXX: params
# XXX: pick up cached boot* files, they may not be in image anymore.
- boot0cfg -B -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOT0CFG} ${MD}
- bsdlabel -w -B -b ${NANO_WORLDDIR}/boot/boot ${MD}s1
+ if [ -f ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ]; then
+ boot0cfg -B -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOT0CFG} ${MD}
+ fi
+ if [ -f ${NANO_WORLDDIR}/boot/boot ]; then
+ bsdlabel -w -B -b ${NANO_WORLDDIR}/boot/boot ${MD}s1
+ else
+ bsdlabel -w ${MD}s1
+ fi
bsdlabel ${MD}s1
# Create first image
@@ -634,11 +661,6 @@ create_i386_diskimage ( ) (
) > ${NANO_OBJ}/_.di 2>&1
)
-# i386 and amd64 are identical for disk images
-create_amd64_diskimage ( ) (
- create_i386_diskimage
-)
-
last_orders () (
# Redefine this function with any last orders you may have
# after the build completed, for instance to copy the finished
@@ -785,7 +807,7 @@ cust_pkg () (
exit 2
fi
done
- rm -rxf ${NANO_WORLDDIR}/Pkg
+ nano_rm -rf ${NANO_WORLDDIR}/Pkg
)
cust_pkgng () (
@@ -820,7 +842,7 @@ cust_pkgng () (
echo "FAILED: pkg bootstrapping faied"
exit 2
fi
- rm -f ${NANO_WORLDDIR}/Pkg/pkg-*
+ nano_rm -f ${NANO_WORLDDIR}/Pkg/pkg-*
# Count & report how many we have to install
todo=`ls ${NANO_WORLDDIR}/Pkg | /usr/bin/wc -l`
@@ -849,7 +871,7 @@ cust_pkgng () (
exit 2
fi
done
- rm -rxf ${NANO_WORLDDIR}/Pkg
+ nano_rm -rf ${NANO_WORLDDIR}/Pkg
)
#######################################################################
@@ -886,8 +908,10 @@ pprint() (
usage () {
(
- echo "Usage: $0 [-bfiknqvw] [-c config_file]"
+ echo "Usage: $0 [-bfiKknqvw] [-c config_file]"
+ echo " -K suppress installkernel"
echo " -b suppress builds (both kernel and world)"
+ echo " -c specify config file"
echo " -f suppress code slice extraction"
echo " -i suppress disk image build"
echo " -k suppress buildkernel"
@@ -895,7 +919,6 @@ usage () {
echo " -q make output more quiet"
echo " -v make output more verbose"
echo " -w suppress buildworld"
- echo " -c specify config file"
) 1>&2
exit 2
}
@@ -905,12 +928,14 @@ usage () {
do_clean=true
do_kernel=true
+do_installkernel=true
do_world=true
do_image=true
do_copyout_partition=true
+do_native_xtools=false
set +e
-args=`getopt bc:fhiknqvw $*`
+args=`getopt KXbc:fhiknqvw $*`
if [ $? -ne 0 ] ; then
usage
exit 2
@@ -922,12 +947,16 @@ for i
do
case "$i"
in
- -b)
- do_world=false
- do_kernel=false
+ -K)
+ do_installkernel=false
shift
;;
- -k)
+ -X)
+ do_native_xtools=true
+ shift
+ ;;
+ -b)
+ do_world=false
do_kernel=false
shift
;;
@@ -951,6 +980,10 @@ do
do_image=false
shift
;;
+ -k)
+ do_kernel=false
+ shift
+ ;;
-n)
do_clean=false
shift
@@ -983,7 +1016,7 @@ trap nano_cleanup EXIT
#######################################################################
# Setup and Export Internal variables
#
-test -n "${NANO_OBJ}" || NANO_OBJ=/usr/obj/nanobsd.${NANO_NAME}/
+test -n "${NANO_OBJ}" || NANO_OBJ=/usr/obj/nanobsd.${NANO_NAME}
test -n "${MAKEOBJDIRPREFIX}" || MAKEOBJDIRPREFIX=${NANO_OBJ}
test -n "${NANO_DISKIMGDIR}" || NANO_DISKIMGDIR=${NANO_OBJ}
@@ -1073,15 +1106,22 @@ clean_world
make_conf_install
install_world
install_etc
+if $do_native_xtools ; then
+ native_xtools
+fi
setup_nanobsd_etc
-install_kernel
+if $do_installkernel ; then
+ install_kernel
+else
+ pprint 2 "Skipping installkernel (as instructed)"
+fi
run_customize
setup_nanobsd
prune_usr
run_late_customize
if $do_image ; then
- create_${NANO_ARCH}_diskimage
+ create_diskimage
else
pprint 2 "Skipping image build (as instructed)"
fi
diff --git a/tools/tools/nanobsd/rescue/R32 b/tools/tools/nanobsd/rescue/R32
new file mode 100644
index 0000000..3c15ebe
--- /dev/null
+++ b/tools/tools/nanobsd/rescue/R32
@@ -0,0 +1,14 @@
+#
+# R32 -- Generic kernel configuration file with modifications for rescue.
+#
+# $FreeBSD$
+
+include GENERIC
+
+ident R32
+
+nooptions INVARIANTS
+nooptions INVARIANT_SUPPORT
+nooptions WITNESS
+nooptions WITNESS_SKIPSPIN
+nooptions MALLOC_DEBUG_MAXZONES
diff --git a/tools/tools/nanobsd/rescue/R64 b/tools/tools/nanobsd/rescue/R64
new file mode 100644
index 0000000..17900e2
--- /dev/null
+++ b/tools/tools/nanobsd/rescue/R64
@@ -0,0 +1,14 @@
+#
+# R64 -- Generic kernel configuration file with modifications for rescue.
+#
+# $FreeBSD$
+
+include GENERIC
+
+ident R64
+
+nooptions INVARIANTS
+nooptions INVARIANT_SUPPORT
+nooptions WITNESS
+nooptions WITNESS_SKIPSPIN
+nooptions MALLOC_DEBUG_MAXZONES
diff --git a/tools/tools/nanobsd/rescue/build.sh b/tools/tools/nanobsd/rescue/build.sh
index 525b7ba..4c109ff 100755
--- a/tools/tools/nanobsd/rescue/build.sh
+++ b/tools/tools/nanobsd/rescue/build.sh
@@ -3,6 +3,8 @@
# $FreeBSD$
#
+today=`date '+%Y%m%d'`
+
if [ -z "${1}" -o \! -f "${1}" ]; then
echo "Usage: $0 cfg_file [-bhiknw]"
echo "-i : skip image build"
@@ -15,4 +17,26 @@ fi
CFG="${1}"
shift;
+if [ \! -d /usr/obj/Rescue ]; then
+ mkdir -p /usr/obj/Rescue
+fi
+
sh ../nanobsd.sh $* -c ${CFG}
+
+F32="/usr/obj/Rescue/rescue_${today}_x32"
+D32="/usr/obj/nanobsd.rescue_i386"
+if [ -f "${D32}/_.disk.full" ]; then
+ mv "${D32}/_.disk.full" "${F32}.img"
+fi
+if [ -f "${D32}/_.disk.iso" ]; then
+ mv "${D32}/_.disk.iso" "${F32}.iso"
+fi
+
+F64="/usr/obj/Rescue/rescue_${today}_x64"
+D64="/usr/obj/nanobsd.rescue_amd64"
+if [ -f "${D64}/_.disk.full" ]; then
+ mv "${D64}/_.disk.full" "${F64}.img"
+fi
+if [ -f "${D64}/_.disk.iso" ]; then
+ mv "${D64}/_.disk.iso" "${F64}.iso"
+fi
diff --git a/tools/tools/nanobsd/rescue/common b/tools/tools/nanobsd/rescue/common
index d78a1ca..3fd06c8 100644
--- a/tools/tools/nanobsd/rescue/common
+++ b/tools/tools/nanobsd/rescue/common
@@ -3,7 +3,7 @@
#
NANO_TOOLS=`pwd`
NANO_PACKAGE_DIR=`pwd`/Pkg
-NANO_RAM_TMPVARSIZE=20480
+NANO_RAM_TMPVARSIZE=40960
NANO_PMAKE="make -j 8"
NANO_LABEL="rescue"
NANO_RAM_TMPVARSIZE=40960
@@ -68,6 +68,7 @@ cust_etc_cfg () (
echo "#ifconfig_fxp0=\"AUTO\"" >> etc/rc.conf
echo "#sshd_enable=\"YES\"" >> etc/rc.conf
echo "/dev/ufs/${NANO_LABEL}s1a / ufs ro,noatime 0 0" > etc/fstab
+ echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> etc/fstab
echo "tmpfs /boot/zfs tmpfs rw,size=1048576,mode=777 0 0" >> etc/fstab
echo "ports:/usr/ports /usr/ports nfs rw,noauto,noatime,bg,soft,intr,nfsv3 0 0" >> etc/fstab
# echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab
@@ -100,16 +101,8 @@ last_orders () (
touch conf/default/etc/.keepme
touch conf/default/var/.keepme
cd ..
- mkisofs -quiet -r -J -no-emul-boot \
- -V ${NANO_LABEL} \
- -b boot/cdboot -o _.disk.iso _.w/
+ makefs -t cd9660 -o rockridge \
+ -o label="${NANO_LABEL}" -o publisher="RMX" \
+ -o bootimage="i386;_.w/boot/cdboot" -o no-emul-boot _.disk.iso _.w/
)
)
-
-#create_i386_diskimage () {
-# #currently not used
-#}
-
-#create_amd64_diskimage () {
-# create_i386_diskimage
-#}
diff --git a/tools/tools/nanobsd/rescue/merge.sh b/tools/tools/nanobsd/rescue/merge.sh
index 6761c94..afb6637 100755
--- a/tools/tools/nanobsd/rescue/merge.sh
+++ b/tools/tools/nanobsd/rescue/merge.sh
@@ -1,18 +1,28 @@
#!/bin/sh
# $FreeBSD$
-D1="/usr/obj/nanobsd.rescue_i386"
-D2="/usr/obj/nanobsd.rescue_amd64"
+today=`date '+%Y%m%d'`
-MD=`mdconfig -a -t vnode -f ${D1}/_.disk.full`
+I32="/usr/obj/Rescue/rescue_${today}_x32.img"
+I64="/usr/obj/Rescue/rescue_${today}_x64.img"
+IAL="/usr/obj/Rescue/rescue_${today}_xal.img"
+D64="/usr/obj/nanobsd.rescue_amd64"
+MNT="/usr/obj/Rescue/_mnt"
-dd if=${D2}/_.disk.image of=/dev/${MD}s2 bs=128k
+if [ \! -d "$MNT" ]; then
+ mkdir "$MNT"
+fi
+
+dd if=${I32} of=${IAL} bs=128k
+MD=`mdconfig -a -t vnode -f ${IAL}`
+
+dd if=${D64}/_.disk.image of=/dev/${MD}s2 bs=128k
tunefs -L rescues2a /dev/${MD}s2a
-mount /dev/${MD}s2a ${D1}/_.mnt
+mount /dev/${MD}s2a ${MNT}
-sed -i "" -e 's/rescues1/rescues2/' ${D1}/_.mnt/conf/base/etc/fstab
-sed -i "" -e 's/rescues1/rescues2/' ${D1}/_.mnt/etc/fstab
+sed -i "" -e 's/rescues1/rescues2/' ${MNT}/conf/base/etc/fstab
+sed -i "" -e 's/rescues1/rescues2/' ${MNT}/etc/fstab
-umount ${D1}/_.mnt
+umount ${MNT}
mdconfig -d -u ${MD}
diff --git a/tools/tools/nanobsd/rescue/rescue_amd64.conf b/tools/tools/nanobsd/rescue/rescue_amd64.conf
index 8a183ee..a82325f 100644
--- a/tools/tools/nanobsd/rescue/rescue_amd64.conf
+++ b/tools/tools/nanobsd/rescue/rescue_amd64.conf
@@ -1,7 +1,7 @@
#
# $FreeBSD$
#
-NANO_KERNEL=GENERIC
+NANO_KERNEL=R64
NANO_ARCH=amd64
TARGET_ARCH=amd64; export TARGET_ARCH
#TARGET_CPUTYPE=amd64; export TARGET_CPUTYPE
diff --git a/tools/tools/nanobsd/rescue/rescue_i386.conf b/tools/tools/nanobsd/rescue/rescue_i386.conf
index 5e91453..97b51d4 100644
--- a/tools/tools/nanobsd/rescue/rescue_i386.conf
+++ b/tools/tools/nanobsd/rescue/rescue_i386.conf
@@ -1,7 +1,7 @@
#
# $FreeBSD$
#
-NANO_KERNEL=GENERIC
+NANO_KERNEL=R32
NANO_ARCH=i386
TARGET_ARCH=i386; export TARGET_ARCH
#TARGET_CPUTYPE=i386; export TARGET_CPUTYPE
OpenPOWER on IntegriCloud