Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 May 2014 00:31: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: r265166 - in stable/10/tools/tools/nanobsd: . Files/root dhcpd gateworks pcengines
Message-ID:  <201405010031.s410VJQd039117@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Thu May  1 00:31:19 2014
New Revision: 265166
URL: http://svnweb.freebsd.org/changeset/base/265166

Log:
  MFC: r258705,r258709,r263140,r263184,r263185,r263186,r263187,r263188,
  r263189,r263190,r263192,r263193,r263287,r263288,r263890,r264281,
  r264655,r264656,r264856,r264857,r264858,r264859,r264860,r264861,
  r264891,r264892,r264909
  
  Catch up on all the referenced changes in -current, in brief:
  
  r258705 | n_hibma | Use NANO_PMAKE for build, but not install
  r258709 | mr | pkgng goo + bootstrap
  r263140 | glebius | Axe IPX.
  r263184 | imp | Fix build with spaces in names.
  r263185 | imp | Make pcengines config files compile again.
  r263186 | imp | Use UFS2 by default, but allow fallback to UFS1
  r263187 | imp | Print an error message when we exit out early.
  r263188 | imp | Sometimes only copy MBR when backing via swap
  r263189 | imp | Update save_cfg
  r263190 | imp | Be more explicit about setting SRCCONF to /dev/null
  r263192 | imp | Rely on default UFS type
  r263193 | imp | Remove TARGET_BIG_ENDIAN. It's no longer relevant.
  r263287 | bdrewery | pkg(8) has no limits
  r263288 | bdrewery | Remove comment meant for removal in r263287
  r263890 | imp | Up default media size to 1GB.
  r264281 | imp | Ignore .hg and .git files
  r264655 | imp | rm -x for safety
  r264656 | imp | new example: dhcpd derived from FreeNAS/BSDRP
  r264856 | imp | Override the parallel make target to use all CPUs.
  r264857 | imp | No need for true here, remove it.
  r264858 | imp | NANO_PKG_META_BASE
  r264859 | imp | stylize umount hack
  r264860 | imp | switch dhcpd to pkg(8).
  r264861 | imp | CR and CR0 added from dhcpd
  r264891 | imp | Try to alwaays use () for functions
  r264892 | imp | bash whines about r264857, revert
  r264909 | imp | Move back to {} for functions that need global effects

Added:
  stable/10/tools/tools/nanobsd/dhcpd/
     - copied from r264688, head/tools/tools/nanobsd/dhcpd/
Modified:
  stable/10/tools/tools/nanobsd/Files/root/save_cfg
  stable/10/tools/tools/nanobsd/dhcpd/common
  stable/10/tools/tools/nanobsd/dhcpd/os-base
  stable/10/tools/tools/nanobsd/gateworks/common
  stable/10/tools/tools/nanobsd/nanobsd.sh
  stable/10/tools/tools/nanobsd/pcengines/ALIX_DSK
  stable/10/tools/tools/nanobsd/pcengines/common.conf
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tools/tools/nanobsd/Files/root/save_cfg
==============================================================================
--- stable/10/tools/tools/nanobsd/Files/root/save_cfg	Thu May  1 00:12:24 2014	(r265165)
+++ stable/10/tools/tools/nanobsd/Files/root/save_cfg	Thu May  1 00:31:19 2014	(r265166)
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2006 Mathieu Arnold
+# Copyright (c) 2010 Alex Bakhtin
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -32,11 +33,86 @@ set -e
 trap "umount /cfg" 1 2 15 EXIT
 mount /cfg
 (
+cd /etc
+for filename in "$@" `find * -type f`
+do
+	if [ ! -f /cfg/$filename -a ! -f /cfg/.ignore/$filename ]
+	then
+
+		#
+		# If file doesn't exist in /cfg and file is not in the 'ignore' list
+		# then check if this file is exactly the same as original file
+		# in nanobsd image
+		#
+		if ! cmp -s /etc/$filename /conf/base/etc/$filename 
+		then
+			file_path=`echo "$filename" | sed 's/\/[^/]*$//'`
+			if [ $file_path != $filename ]
+			then
+				if [ ! -d /etc/$file_path ]
+				then
+					# should never go here unless we have some errors in
+					# sed script extracting file path
+					echo "Error: Path /etc/$file_path is not directory."
+					exit 1;
+				fi
+			fi
+
+			#
+			# Ask user - how should we handle this file.
+			# Add to cfg (y/n/i)?
+			#	y) -> save this file in /cfg
+			#	n) -> do not save this file in /cfg for current script invocation ONLY
+			#	i) -> add file to ignore list (/cfg/.ignore hiereachy) and never save
+			#	      try to add this file to /cfg.
+			#
+			# touch is ised to add files to /cfg to keep the script flow straight and easy
+			#
+			read -p "New file /etc/$filename found. Add to /cfg (y/n/i)? " key
+			case "$key" in
+			[yY])
+				if [ $file_path != $filename ]
+				then
+					mkdir -vp /cfg/$file_path
+				fi
+				touch /cfg/$filename && echo "File /etc/$filename added to /cfg."
+				;;
+			[iI])
+				mkdir -vp /cfg/.ignore
+				if [ $file_path != $filename ]
+				then
+					mkdir -vp /cfg/.ignore/$file_path
+				fi
+				touch /cfg/.ignore/$filename && echo "File /etc/$filename added to ignore list."
+				;;
+			esac
+		fi
+	fi
+done
+
+#
+# Actually check all files in /cfg and save if necessary
+#
 cd /cfg
-for i in "$@" `find * -type f`
+for filename in "$@" `find * -type f`
 do
-        cmp -s /etc/$i /cfg/$i || cp -pfv /etc/$i /cfg/$i
+	if [ -f /etc/$filename ]
+	then
+        	cmp -s /etc/$filename /cfg/$filename || cp -pfv /etc/$filename /cfg/$filename
+	else
+
+		#
+		# Give user an option to remove file from /cfg if this file is removed from /etc
+		#
+		read -p "File /cfg/$filename not found in /etc. Remove from /cfg (y/n)? " key
+		case "$key" in
+		[yY])
+			rm /cfg/$filename && echo "File /cfg/$filename removed"
+			;;
+		esac
+	fi
 done
+
 )
 umount /cfg
 trap 1 2 15 EXIT

Modified: stable/10/tools/tools/nanobsd/dhcpd/common
==============================================================================
--- head/tools/tools/nanobsd/dhcpd/common	Sun Apr 20 06:46:04 2014	(r264688)
+++ stable/10/tools/tools/nanobsd/dhcpd/common	Thu May  1 00:31:19 2014	(r265166)
@@ -33,7 +33,9 @@
 # simplified to meet the needs of the example.
 #
 
-NANO_PMAKE="make"					# NB: disable -j 3
+# NB: You want the other file
+
+NANO_PMAKE="make -j $(sysctl -n hw.ncpu)"
 
 NANO_CFG_BASE=$(pwd)
 NANO_CFG_BASE=${NANO_CFG_BASE%/dhcpd}
@@ -42,7 +44,8 @@ NANO_SRC=${NANO_SRC%/tools/tools/nanobsd
 NANO_OBJ=${NANO_SRC}/../dhcpd/obj
 # Where cust_pkg() finds packages to install
 #XXX: Is this the right place?
-NANO_PORTS=${NANO_SRC}/../ports
+#NANO_PORTS=$(realpath ${NANO_SRC}/../ports)
+NANO_PORTS=/usr/ports
 NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
 NANO_DATADIR=${NANO_OBJ}/_.data
 NANO_DATASIZE=40960
@@ -153,11 +156,6 @@ WITHOUT_RCS=true
 
 NANO_PACKAGE_ONLY=1
 
-CR()
-{
-	chroot ${NANO_WORLDDIR} /bin/sh -exc "$*"
-}
-
 # install a package from a pre-built binary
 do_add_pkg ()
 {
@@ -171,7 +169,7 @@ do_add_pkg ()
 	    ${NANO_WORLDDIR}/usr/ports/packages
 	mount -t nullfs -o noatime ${NANO_OBJ}/ports/distfiles \
 	    ${NANO_WORLDDIR}/usr/ports/distfiles
-	CR "cd /usr/ports/packages/All;pkg_add -F $1.tbz"
+	CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /usr/ports/packages/All/$1.txz
 	umount ${NANO_WORLDDIR}/usr/ports/distfiles
 	umount ${NANO_WORLDDIR}/usr/ports/packages
 	rmdir ${NANO_WORLDDIR}/usr/ports/packages
@@ -204,12 +202,16 @@ do_add_port ()
 	mount -t devfs devfs ${NANO_WORLDDIR}/dev
 	mkdir -p ${NANO_WORLDDIR}/usr/workdir
 	cp /etc/resolv.conf ${NANO_WORLDDIR}/etc/resolv.conf
+	# OK, a little inefficient, but likely not enough to worry about.
+	CR ldconfig /lib /usr/lib /usr/local/lib
+	CR ldconfig -R
+	CR ldconfig -r
 # Improvement: Don't know why package-recursive don't works here
 	CR "env UNAME_p=${NANO_ARCH} TARGET=${NANO_ARCH} \
-	    TARGET_ARCH=${NANO_ARCH} make \
+	    TARGET_ARCH=${NANO_ARCH} PORTSDIR=${NANO_PORTS} make \
 	    __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
 	    WRKDIRPREFIX=/usr/workdir -C /usr/ports/$port_path \
-	    package BATCH=yes $* clean FORCE_PKG_REGISTER=t"
+	    package-recursive BATCH=yes $* clean FORCE_PKG_REGISTER=t"
 	rm ${NANO_WORLDDIR}/etc/resolv.conf
 	rm -rf ${NANO_WORLDDIR}/usr/obj
 	rm -rf ${NANO_WORLDDIR}/usr/workdir
@@ -226,15 +228,14 @@ do_add_port ()
 add_port () {
     local port_path=$1
     local port=`echo $1 | sed -e 's/\//_/'`
-    export PORTSDIR=${NANO_PORTS}
     shift
     # Check if package allready exist
     # Need to:
     # 1. check ARCH of this package!
     # 2. Add a trap
     cd ${NANO_PORTS}/${port_path}
-    PKG_NAME=`make ${PKGNAME_HACK} PORTSDIR=${NANO_PORTS} __MAKE_CONF=${NANO_MAKE_CONF_BUILD} package-name` 
-    if [ -f ${NANO_OBJ}/ports/packages/All/${PKG_NAME}.tbz ]; then
+    PKG_NAME=`env PORTSDIR=${NANO_PORTS} make __MAKE_CONF=${NANO_MAKE_CONF_BUILD} package-name` 
+    if [ -f ${NANO_OBJ}/ports/packages/All/${PKG_NAME}.txz ]; then
 	# Pkg file found: Generate add_pkg_NAME function
 	eval "
 	    add_pkg_${port} () {
@@ -265,6 +266,10 @@ 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
+
 rp=$(realpath ${NANO_OBJ}/)
 __a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'`
 if [ -n "$__a" ]; then

Modified: stable/10/tools/tools/nanobsd/dhcpd/os-base
==============================================================================
--- head/tools/tools/nanobsd/dhcpd/os-base	Sun Apr 20 06:46:04 2014	(r264688)
+++ stable/10/tools/tools/nanobsd/dhcpd/os-base	Thu May  1 00:31:19 2014	(r265166)
@@ -108,28 +108,6 @@ save_build ( )
 }
 customize_cmd save_build
 
-# Move the $world/data to the /data partion
-move_data()
-{
-	db=${NANO_WORLDDIR}/data
-	rm -rf ${NANO_DATADIR}
-	mkdir -p ${NANO_DATADIR}
-	( cd ${db} ; find . | cpio -R root:wheel -dumpv ${NANO_DATADIR} )
-	rm -rf ${db}
-}
-customize_cmd move_data
-
-add_data_to_fstab ( )
-{
-	(
-	cd ${NANO_WORLDDIR}
-	echo "/dev/${NANO_DRIVE}s4 /data ufs rw,noatime 2 2" >> etc/fstab
-	mkdir -p data
-	)
-	
-}
-customize_cmd add_data_to_fstab
-
 remove_patch_divots ( )
 {
 	find ${NANO_WORLDDIR} -name \*.orig -or -name \*.rej -delete
@@ -168,7 +146,7 @@ customize_cmd unmute_console_logging
 
 fi
 
-freenas_custom()
+product_custom()
 {
 	gzip -v9 ${NANO_WORLDDIR}/boot/kernel/kernel
 
@@ -199,29 +177,10 @@ freenas_custom()
 	# magic.mgc is just a speed optimization.  Kill it for 1.7MB
 	rm -f ${NANO_WORLDDIR}/usr/share/misc/magic.mgc
 
-	# strip binaries (saves spaces on non-debug images).
-	if [ "${DEBUG}" != 1 ]; then
-		pprint 4 "Stripping binaries and libraries"
-		for dir in $(find ${NANO_WORLDDIR}/usr/local -name '*bin' -or -name 'libexec' -maxdepth 3); do
-			for f in $(find $dir -type f); do
-				if ! dontstrip "$f"
-				then
-					strip 2>/dev/null $f || :
-				fi
-			done
-		done
-		# .so's are the only thing that need to be stripped. The rest
-		# should remain untouched.
-		for f in $(find ${NANO_WORLDDIR}/usr/local/lib -name '*.so' -or -name '*.so.*' -maxdepth 3); do
-				strip 2>/dev/null $f || :
-		done
-	fi
-
 	# Last second tweaks
 	chown -R root:wheel ${NANO_WORLDDIR}/root
 	chmod 0755 ${NANO_WORLDDIR}/root/*
 	chmod 0755 ${NANO_WORLDDIR}/*
-	chmod 0440 ${NANO_WORLDDIR}/usr/local/etc/sudoers
 	chown -R root:wheel ${NANO_WORLDDIR}/etc
 	chown -R root:wheel ${NANO_WORLDDIR}/boot
 	chown root:wheel ${NANO_WORLDDIR}/
@@ -229,16 +188,7 @@ freenas_custom()
 	find ${NANO_WORLDDIR} -type f -name "*~" -delete
 	find ${NANO_WORLDDIR}/usr/local -type f -name "*.po" -delete
 	find ${NANO_WORLDDIR} -type f -name "*.service" -delete
-	mkdir ${NANO_WORLDDIR}/data/zfs
-	ln -s -f /usr/local/bin/bash ${NANO_WORLDDIR}/bin/bash
-	ln -s -f /data/zfs/zpool.cache ${NANO_WORLDDIR}/boot/zfs/zpool.cache
-
-	# This is wrong.  Needs a way to tell kernel how to find the mount utility
-	# instead.
-	mv ${NANO_WORLDDIR}/sbin/mount_ntfs ${NANO_WORLDDIR}/sbin/mount_ntfs-kern
-	ln -s -f /usr/local/bin/ntfs-3g ${NANO_WORLDDIR}/sbin/mount_ntfs
-
 }
-late_customize_cmd freenas_custom
+late_customize_cmd product_custom
 
 fi # [ $PACKAGE_PREP_BUILD = 1 ]

Modified: stable/10/tools/tools/nanobsd/gateworks/common
==============================================================================
--- stable/10/tools/tools/nanobsd/gateworks/common	Thu May  1 00:12:24 2014	(r265165)
+++ stable/10/tools/tools/nanobsd/gateworks/common	Thu May  1 00:31:19 2014	(r265166)
@@ -125,7 +125,6 @@ WITHOUT_HTML=true
 WITHOUT_INET6=true
 WITHOUT_INFO=true
 WITHOUT_IPFILTER=true
-WITHOUT_IPX=true
 WITHOUT_KERBEROS=true
 WITHOUT_LOCALES=true
 WITHOUT_LPR=true

Modified: stable/10/tools/tools/nanobsd/nanobsd.sh
==============================================================================
--- stable/10/tools/tools/nanobsd/nanobsd.sh	Thu May  1 00:12:24 2014	(r265165)
+++ stable/10/tools/tools/nanobsd/nanobsd.sh	Thu May  1 00:31:19 2014	(r265166)
@@ -49,6 +49,9 @@ NANO_TOOLS=tools/tools/nanobsd
 NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
 NANO_PACKAGE_LIST="*"
 
+# where package metadata gets placed
+NANO_PKG_META_BASE=/var/db
+
 # Object tree directory
 # default is subdir of /usr/obj
 #NANO_OBJ=""
@@ -57,7 +60,8 @@ NANO_PACKAGE_LIST="*"
 # default is ${NANO_OBJ}
 #NANO_DISKIMGDIR=""
 
-# Parallel Make
+# Make & parallel Make
+NANO_MAKE="make"
 NANO_PMAKE="make -j 3"
 
 # The default name for any image we create.
@@ -85,13 +89,13 @@ NANO_CUSTOMIZE=""
 NANO_LATE_CUSTOMIZE=""
 
 # Newfs paramters to use
-NANO_NEWFS="-b 4096 -f 512 -i 8192 -O1 -U"
+NANO_NEWFS="-b 4096 -f 512 -i 8192 -U"
 
 # The drive name of the media at runtime
 NANO_DRIVE=ad0
 
 # Target media size in 512 bytes sectors
-NANO_MEDIASIZE=1500000
+NANO_MEDIASIZE=2000000
 
 # Number of code images on media (1 or 2)
 NANO_IMAGES=2
@@ -135,6 +139,9 @@ NANO_BOOT2CFG="-h"
 # Can be "file" or "swap"
 NANO_MD_BACKING="file"
 
+# for swap type md(4) backing, write out the mbr only
+NANO_IMAGE_MBRONLY=true
+
 # Progress Print level
 PPLEVEL=3
 
@@ -159,6 +166,10 @@ NANO_CFGDIR=""
 # Directory to populate /data from
 NANO_DATADIR=""
 
+# src.conf to use when building the image. Defaults to /dev/null for the sake
+# of determinism.
+SRCCONF=${SRCCONF:=/dev/null}
+ 
 #######################################################################
 #
 # The functions which do the real work.
@@ -166,12 +177,31 @@ NANO_DATADIR=""
 #
 #######################################################################
 
+# run in the world chroot, errors fatal
+CR()
+{
+	chroot ${NANO_WORLDDIR} /bin/sh -exc "$*"
+}
+
+# run in the world chroot, errors not fatal
+CR0()
+{
+	chroot ${NANO_WORLDDIR} /bin/sh -c "$*" || true
+}
+
+nano_cleanup ( ) (
+	if [ $? -ne 0 ]; then
+		echo "Error encountered.  Check for errors in last log file." 1>&2
+	fi
+	exit $?
+)
+
 clean_build ( ) (
 	pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})"
 
-	if ! rm -rf ${MAKEOBJDIRPREFIX} > /dev/null 2>&1 ; then
-		chflags -R noschg ${MAKEOBJDIRPREFIX}
-		rm -r ${MAKEOBJDIRPREFIX}
+	if ! rm -xrf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then
+		chflags -R noschg ${MAKEOBJDIRPREFIX}/
+		rm -xr ${MAKEOBJDIRPREFIX}/
 	fi
 	mkdir -p ${MAKEOBJDIRPREFIX}
 	printenv > ${MAKEOBJDIRPREFIX}/_.env
@@ -182,7 +212,6 @@ make_conf_build ( ) (
 
 	echo "${CONF_WORLD}" > ${NANO_MAKE_CONF_BUILD}
 	echo "${CONF_BUILD}" >> ${NANO_MAKE_CONF_BUILD}
-	echo "SRCCONF=/dev/null" >> ${NANO_MAKE_CONF_BUILD}
 )
 
 build_world ( ) (
@@ -191,17 +220,20 @@ build_world ( ) (
 
 	cd ${NANO_SRC}
 	env TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} \
+		SRCCONF=${SRCCONF} \
 		__MAKE_CONF=${NANO_MAKE_CONF_BUILD} buildworld \
 		> ${MAKEOBJDIRPREFIX}/_.bw 2>&1
 )
 
 build_kernel ( ) (
+	local extra
+
 	pprint 2 "build kernel ($NANO_KERNEL)"
 	pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bk"
 
 	(
 	if [ -f ${NANO_KERNEL} ] ; then
-		kernconfdir=$(realpath $(dirname ${NANO_KERNEL}))
+		extra="KERNCONFDIR=$(realpath $(dirname ${NANO_KERNEL}))"
 		kernconf=$(basename ${NANO_KERNEL})
 	else
 		kernconf=${NANO_KERNEL}
@@ -211,12 +243,11 @@ build_kernel ( ) (
 	# unset these just in case to avoid compiler complaints
 	# when cross-building
 	unset TARGET_CPUTYPE
-	unset TARGET_BIG_ENDIAN
 	# Note: We intentionally build all modules, not only the ones in
 	# NANO_MODULES so the built world can be reused by multiple images.
 	env TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} buildkernel \
-		__MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
-		${kernconfdir:+"KERNCONFDIR="}${kernconfdir} \
+		SRCCONF=${SRCCONF} \
+		${extra} __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
 		KERNCONF=${kernconf}
 	) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1
 )
@@ -224,17 +255,17 @@ build_kernel ( ) (
 clean_world ( ) (
 	if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then
 		pprint 2 "Clean and create object directory (${NANO_OBJ})"
-		if ! rm -rf ${NANO_OBJ} > /dev/null 2>&1 ; then
+		if ! rm -rxf ${NANO_OBJ}/ > /dev/null 2>&1 ; then
 			chflags -R noschg ${NANO_OBJ}
-			rm -r ${NANO_OBJ}
+			rm -xr ${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 -rf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then
+		if ! rm -rxf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then
 			chflags -R noschg ${NANO_WORLDDIR}
-			rm -rf ${NANO_WORLDDIR}
+			rm -rxf ${NANO_WORLDDIR}/
 		fi
 		mkdir -p ${NANO_WORLDDIR}
 	fi
@@ -245,7 +276,6 @@ make_conf_install ( ) (
 
 	echo "${CONF_WORLD}" > ${NANO_MAKE_CONF_INSTALL}
 	echo "${CONF_INSTALL}" >> ${NANO_MAKE_CONF_INSTALL}
-	echo "SRCCONF=/dev/null" >> ${NANO_MAKE_CONF_INSTALL}
 )
 
 install_world ( ) (
@@ -254,7 +284,8 @@ install_world ( ) (
 
 	cd ${NANO_SRC}
 	env TARGET_ARCH=${NANO_ARCH} \
-	${NANO_PMAKE} __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} installworld \
+	${NANO_MAKE} SRCCONF=${SRCCONF} \
+		__MAKE_CONF=${NANO_MAKE_CONF_INSTALL} installworld \
 		DESTDIR=${NANO_WORLDDIR} \
 		> ${NANO_OBJ}/_.iw 2>&1
 	chflags -R noschg ${NANO_WORLDDIR}
@@ -267,7 +298,8 @@ install_etc ( ) (
 
 	cd ${NANO_SRC}
 	env TARGET_ARCH=${NANO_ARCH} \
-	${NANO_PMAKE} __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} distribution \
+	${NANO_MAKE} SRCCONF=${SRCCONF} \
+		__MAKE_CONF=${NANO_MAKE_CONF_INSTALL} distribution \
 		DESTDIR=${NANO_WORLDDIR} \
 		> ${NANO_OBJ}/_.etc 2>&1
 	# make.conf doesn't get created by default, but some ports need it
@@ -276,22 +308,24 @@ install_etc ( ) (
 )
 
 install_kernel ( ) (
+	local extra
+
 	pprint 2 "install kernel ($NANO_KERNEL)"
 	pprint 3 "log: ${NANO_OBJ}/_.ik"
 
 	(
 	if [ -f ${NANO_KERNEL} ] ; then
-		kernconfdir=$(realpath $(dirname ${NANO_KERNEL}))
+		extra="KERNCONFDIR=$(realpath $(dirname ${NANO_KERNEL}))"
 		kernconf=$(basename ${NANO_KERNEL})
 	else
 		kernconf=${NANO_KERNEL}
 	fi
 
 	cd ${NANO_SRC}
-	env TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} installkernel \
+	env TARGET_ARCH=${NANO_ARCH} ${NANO_MAKE} installkernel \
 		DESTDIR=${NANO_WORLDDIR} \
-		__MAKE_CONF=${NANO_MAKE_CONF_INSTALL} \
-		${kernconfdir:+"KERNCONFDIR="}${kernconfdir} \
+		SRCCONF=${SRCCONF} \
+		${extra} __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} \
 		KERNCONF=${kernconf} \
 		MODULES_OVERRIDE="${NANO_MODULES}"
 	) > ${NANO_OBJ}/_.ik 2>&1
@@ -406,6 +440,12 @@ newfs_part ( ) (
 	mount -o async ${dev} ${mnt}
 )
 
+# Convenient spot to work around any umount issues that your build environment
+# hits by overriding this method.
+nano_umount () (
+	umount ${1}
+)
+
 populate_slice ( ) (
 	local dev dir mnt lbl
 	dev=$1
@@ -417,10 +457,10 @@ populate_slice ( ) (
 	if [ -n "${dir}" -a -d "${dir}" ]; then
 		echo "Populating ${lbl} from ${dir}"
 		cd ${dir}
-		find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${mnt}
+		find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${mnt}
 	fi
 	df -i ${mnt}
-	umount ${mnt}
+	nano_umount ${mnt}
 )
 
 populate_cfg_slice ( ) (
@@ -519,7 +559,7 @@ create_i386_diskimage ( ) (
 			-y ${NANO_HEADS}`
 	fi
 
-	trap "echo 'Running exit trap code' ; df -i ${MNT} ; umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT
+	trap "echo 'Running exit trap code' ; df -i ${MNT} ; nano_umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT
 
 	fdisk -i -f ${NANO_OBJ}/_.fdisk ${MD}
 	fdisk ${MD}
@@ -535,7 +575,7 @@ create_i386_diskimage ( ) (
 	echo "Generating mtree..."
 	( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree
 	( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du
-	umount ${MNT}
+	nano_umount ${MNT}
 
 	if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
 		# Duplicate to second image (if present)
@@ -546,7 +586,7 @@ create_i386_diskimage ( ) (
 		do
 			sed -i "" "s=${NANO_DRIVE}s1=${NANO_DRIVE}s2=g" $f
 		done
-		umount ${MNT}
+		nano_umount ${MNT}
 		# Override the label from the first partition so we
 		# don't confuse glabel with duplicates.
 		if [ ! -z ${NANO_LABEL} ]; then
@@ -563,6 +603,14 @@ create_i386_diskimage ( ) (
 	fi
 
 	if [ "${NANO_MD_BACKING}" = "swap" ] ; then
+		if [ ${NANO_IMAGE_MBRONLY} ]; then
+			echo "Writing out _.disk.mbr..."
+			dd if=/dev/${MD} of=${NANO_DISKIMGDIR}/_.disk.mbr bs=512 count=1
+		else
+			echo "Writing out ${NANO_IMGNAME}..."
+			dd if=/dev/${MD} of=${IMG} bs=64k
+		fi
+
 		echo "Writing out ${NANO_IMGNAME}..."
 		dd conv=sparse if=/dev/${MD} of=${IMG} bs=64k
 	fi
@@ -573,7 +621,8 @@ create_i386_diskimage ( ) (
 	fi
 	mdconfig -d -u $MD
 
-	trap - 1 2 15 EXIT
+	trap - 1 2 15
+	trap nano_cleanup EXIT
 
 	) > ${NANO_OBJ}/_.di 2>&1
 )
@@ -677,7 +726,7 @@ cust_allow_ssh_root () (
 
 cust_install_files () (
 	cd ${NANO_TOOLS}/Files
-	find . -print | grep -Ev '/(CVS|\.svn)' | cpio -Ldumpv ${NANO_WORLDDIR}
+	find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -Ldumpv ${NANO_WORLDDIR}
 )
 
 #######################################################################
@@ -692,7 +741,7 @@ cust_pkg () (
 	fi
 
 	# Copy packages into chroot
-	mkdir -p ${NANO_WORLDDIR}/Pkg
+	mkdir -p ${NANO_WORLDDIR}/Pkg ${NANO_WORLDDIR}/${NANO_PKG_META_BASE}/pkg
 	(
 		cd ${NANO_PACKAGE_DIR}
 		find ${NANO_PACKAGE_LIST} -print |
@@ -707,18 +756,17 @@ cust_pkg () (
 	while true
 	do
 		# Record how many we have now
-		have=`ls ${NANO_WORLDDIR}/var/db/pkg | wc -l`
+		have=`ls ${NANO_WORLDDIR}/${NANO_PKG_META_BASE}/pkg | wc -l`
 
 		# Attempt to install more packages
 		# ...but no more than 200 at a time due to pkg_add's internal
 		# limitations.
-		chroot ${NANO_WORLDDIR} sh -c \
-			'ls Pkg/*tbz | xargs -n 200 pkg_add -F' || true
+		CR0 'ls Pkg/*tbz | xargs -n 200 env PKG_DBDIR='${NANO_PKG_META_BASE}'/pkg pkg_add -v -F'
 
 		# See what that got us
-		now=`ls ${NANO_WORLDDIR}/var/db/pkg | wc -l`
+		now=`ls ${NANO_WORLDDIR}/${NANO_PKG_META_BASE}/pkg | wc -l`
 		echo "=== NOW $now"
-		ls ${NANO_WORLDDIR}/var/db/pkg
+		ls ${NANO_WORLDDIR}/${NANO_PKG_META_BASE}/pkg
 		echo "==="
 
 
@@ -730,7 +778,71 @@ cust_pkg () (
 			exit 2
 		fi
 	done
-	rm -rf ${NANO_WORLDDIR}/Pkg
+	rm -rxf ${NANO_WORLDDIR}/Pkg
+)
+
+cust_pkgng () (
+
+	# If the package directory doesn't exist, we're done.
+	if [ ! -d ${NANO_PACKAGE_DIR} ]; then
+		echo "DONE 0 packages"
+		return 0
+	fi
+
+	# Find a pkg-* package
+	for x in `find -s ${NANO_PACKAGE_DIR} -iname 'pkg-*'`; do
+		_NANO_PKG_PACKAGE=`basename "$x"`
+	done
+	if [ -z "${_NANO_PKG_PACKAGE}" -o ! -f "${NANO_PACKAGE_DIR}/${_NANO_PKG_PACKAGE}" ]; then
+		echo "FAILED: need a pkg/ package for bootstrapping"
+		exit 2
+	fi
+
+	# Copy packages into chroot
+	mkdir -p ${NANO_WORLDDIR}/Pkg
+	(
+		cd ${NANO_PACKAGE_DIR}
+		find ${NANO_PACKAGE_LIST} -print |
+		cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
+	)
+
+	#Bootstrap pkg
+	CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /Pkg/${_NANO_PKG_PACKAGE}
+	CR pkg -N >/dev/null 2>&1
+	if [ "$?" -ne "0" ]; then
+		echo "FAILED: pkg bootstrapping faied"
+		exit 2
+	fi
+	rm -f ${NANO_WORLDDIR}/Pkg/pkg-*
+
+	# Count & report how many we have to install
+	todo=`ls ${NANO_WORLDDIR}/Pkg | /usr/bin/wc -l`
+	todo=$(expr $todo + 1) # add one for pkg since it is installed already
+	echo "=== TODO: $todo"
+	ls ${NANO_WORLDDIR}/Pkg
+	echo "==="
+	while true
+	do
+		# Record how many we have now
+ 		have=$(CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l)
+
+		# Attempt to install more packages
+		CR0 'ls 'Pkg/*txz' | xargs env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg add'
+
+		# See what that got us
+ 		now=$(CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l)
+		echo "=== NOW $now"
+		CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info
+		echo "==="
+		if [ $now -eq $todo ] ; then
+			echo "DONE $now packages"
+			break
+		elif [ $now -eq $have ] ; then
+			echo "FAILED: Nothing happened on this pass"
+			exit 2
+		fi
+	done
+	rm -rxf ${NANO_WORLDDIR}/Pkg
 )
 
 #######################################################################
@@ -758,12 +870,12 @@ late_customize_cmd () {
 
 # Progress Print
 #	Print $2 at level $1.
-pprint() {
+pprint() (
     if [ "$1" -le $PPLEVEL ]; then
 	runtime=$(( `date +%s` - $NANO_STARTTIME ))
 	printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3
     fi
-}
+)
 
 usage () {
 	(
@@ -855,6 +967,8 @@ if [ $# -gt 0 ] ; then
 	usage
 fi
 
+trap nano_cleanup EXIT
+
 #######################################################################
 # Setup and Export Internal variables
 #
@@ -878,6 +992,7 @@ fi
 if $do_clean ; then
 	true
 else
+	NANO_MAKE="${NANO_MAKE} -DNO_CLEAN"
 	NANO_PMAKE="${NANO_PMAKE} -DNO_CLEAN"
 fi
 
@@ -897,6 +1012,7 @@ export NANO_DRIVE
 export NANO_HEADS
 export NANO_IMAGES
 export NANO_IMGNAME
+export NANO_MAKE
 export NANO_MAKE_CONF_BUILD
 export NANO_MAKE_CONF_INSTALL
 export NANO_MEDIASIZE

Modified: stable/10/tools/tools/nanobsd/pcengines/ALIX_DSK
==============================================================================
--- stable/10/tools/tools/nanobsd/pcengines/ALIX_DSK	Thu May  1 00:12:24 2014	(r265165)
+++ stable/10/tools/tools/nanobsd/pcengines/ALIX_DSK	Thu May  1 00:31:19 2014	(r265166)
@@ -23,6 +23,9 @@ options 	PSEUDOFS		
 options 	GEOM_PART_GPT		
 options 	GEOM_LABEL		
 options 	COMPAT_43TTY		
+options 	COMPAT_FREEBSD4		# Compatible with FreeBSD4
+options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
+options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
 options 	COMPAT_FREEBSD7		
 options 	SCSI_DELAY=5000		
 options 	SYSVSHM			
@@ -32,12 +35,11 @@ options 	P1003_1B_SEMAPHORES	
 options 	_KPOSIX_PRIORITY_SCHEDULING 
 options 	PRINTF_BUFR_SIZE=128	
 device		apic			
+device		cpufreq
+device		acpi
 device		pci
 device		fdc
 device		ata
-device		atadisk		
-device		atapicd		
-device		atapist		
 options 	ATA_STATIC_ID	
 device		scbus		
 device		da		

Modified: stable/10/tools/tools/nanobsd/pcengines/common.conf
==============================================================================
--- stable/10/tools/tools/nanobsd/pcengines/common.conf	Thu May  1 00:12:24 2014	(r265165)
+++ stable/10/tools/tools/nanobsd/pcengines/common.conf	Thu May  1 00:31:19 2014	(r265166)
@@ -2,8 +2,11 @@
 # $FreeBSD$
 #
 
-NANO_TOOLS=`pwd`
-NANO_PACKAGE_DIR=`pwd`/Pkg
+NANO_SRC=$(pwd)
+NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/pcengines}
+NANO_OBJ=${NANO_SRC}/../${NANO_NAME}/obj
+NANO_TOOLS=$(pwd)
+NANO_PACKAGE_DIR=$(pwd)/Pkg
 #NANO_RAM_TMPVARSIZE=20480
 #NANO_RAM_TMPVARSIZE=30720
 NANO_RAM_TMPVARSIZE=40960



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