Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Nov 2014 01:29:19 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r274561 - in stable/10/tools/tools/nanobsd: . dhcpd rescue
Message-ID:  <201411160129.sAG1TJsC053053@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sun Nov 16 01:29:18 2014
New Revision: 274561
URL: https://svnweb.freebsd.org/changeset/base/274561

Log:
  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

Added:
  stable/10/tools/tools/nanobsd/rescue/R32
     - copied unchanged from r268246, head/tools/tools/nanobsd/rescue/R32
  stable/10/tools/tools/nanobsd/rescue/R64
     - copied unchanged from r268246, head/tools/tools/nanobsd/rescue/R64
Modified:
  stable/10/tools/tools/nanobsd/dhcpd/README
  stable/10/tools/tools/nanobsd/dhcpd/common
  stable/10/tools/tools/nanobsd/nanobsd.sh
  stable/10/tools/tools/nanobsd/rescue/build.sh
  stable/10/tools/tools/nanobsd/rescue/common
  stable/10/tools/tools/nanobsd/rescue/merge.sh
  stable/10/tools/tools/nanobsd/rescue/rescue_amd64.conf
  stable/10/tools/tools/nanobsd/rescue/rescue_i386.conf
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tools/tools/nanobsd/dhcpd/README
==============================================================================
--- stable/10/tools/tools/nanobsd/dhcpd/README	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/dhcpd/README	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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.

Modified: stable/10/tools/tools/nanobsd/dhcpd/common
==============================================================================
--- stable/10/tools/tools/nanobsd/dhcpd/common	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/dhcpd/common	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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

Modified: stable/10/tools/tools/nanobsd/nanobsd.sh
==============================================================================
--- stable/10/tools/tools/nanobsd/nanobsd.sh	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/nanobsd.sh	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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

Copied: stable/10/tools/tools/nanobsd/rescue/R32 (from r268246, head/tools/tools/nanobsd/rescue/R32)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/tools/tools/nanobsd/rescue/R32	Sun Nov 16 01:29:18 2014	(r274561, copy of r268246, head/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

Copied: stable/10/tools/tools/nanobsd/rescue/R64 (from r268246, head/tools/tools/nanobsd/rescue/R64)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/tools/tools/nanobsd/rescue/R64	Sun Nov 16 01:29:18 2014	(r274561, copy of r268246, head/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

Modified: stable/10/tools/tools/nanobsd/rescue/build.sh
==============================================================================
--- stable/10/tools/tools/nanobsd/rescue/build.sh	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/rescue/build.sh	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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

Modified: stable/10/tools/tools/nanobsd/rescue/common
==============================================================================
--- stable/10/tools/tools/nanobsd/rescue/common	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/rescue/common	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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
-#}

Modified: stable/10/tools/tools/nanobsd/rescue/merge.sh
==============================================================================
--- stable/10/tools/tools/nanobsd/rescue/merge.sh	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/rescue/merge.sh	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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"
+
+if [ \! -d "$MNT" ]; then
+  mkdir "$MNT"
+fi
 
-dd if=${D2}/_.disk.image of=/dev/${MD}s2 bs=128k
+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}

Modified: stable/10/tools/tools/nanobsd/rescue/rescue_amd64.conf
==============================================================================
--- stable/10/tools/tools/nanobsd/rescue/rescue_amd64.conf	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/rescue/rescue_amd64.conf	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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

Modified: stable/10/tools/tools/nanobsd/rescue/rescue_i386.conf
==============================================================================
--- stable/10/tools/tools/nanobsd/rescue/rescue_i386.conf	Sun Nov 16 01:18:41 2014	(r274560)
+++ stable/10/tools/tools/nanobsd/rescue/rescue_i386.conf	Sun Nov 16 01:29:18 2014	(r274561)
@@ -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



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