Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Nov 2013 11:06:18 +0000 (UTC)
From:      Michael Reifenberger <mr@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r258709 - head/tools/tools/nanobsd
Message-ID:  <201311281106.rASB6IT6099658@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mr
Date: Thu Nov 28 11:06:18 2013
New Revision: 258709
URL: http://svnweb.freebsd.org/changeset/base/258709

Log:
  Add package additions support for pkgng by adding a new function cust_pkgng():
  	first bootstrap the pkg package (must be contained in the Pkg/ dir)
  	then add the other packages

Modified:
  head/tools/tools/nanobsd/nanobsd.sh

Modified: head/tools/tools/nanobsd/nanobsd.sh
==============================================================================
--- head/tools/tools/nanobsd/nanobsd.sh	Thu Nov 28 10:28:28 2013	(r258708)
+++ head/tools/tools/nanobsd/nanobsd.sh	Thu Nov 28 11:06:18 2013	(r258709)
@@ -734,6 +734,77 @@ cust_pkg () (
 	rm -rf ${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
+	chroot ${NANO_WORLDDIR} sh -c \
+		"env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /Pkg/${_NANO_PKG_PACKAGE}"
+	chroot ${NANO_WORLDDIR} sh -c "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=`chroot ${NANO_WORLDDIR} sh -c \
+			'env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l'`
+
+		# Attempt to install more packages
+		# ...but no more than 200 at a time due to (XXX still the case?) pkg_add's internal
+		# limitations.
+		chroot ${NANO_WORLDDIR} sh -c \
+			'ls Pkg/*txz | xargs -n 200 env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg add ' || true
+
+		# See what that got us
+		now=`chroot ${NANO_WORLDDIR} sh -c \
+			'env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l'`
+		echo "=== NOW $now"
+		chroot ${NANO_WORLDDIR} sh -c \
+			'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 -rf ${NANO_WORLDDIR}/Pkg
+)
+
 #######################################################################
 # Convenience function:
 # 	Register all args as customize function.



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