diff options
author | mr <mr@FreeBSD.org> | 2013-11-28 11:06:18 +0000 |
---|---|---|
committer | mr <mr@FreeBSD.org> | 2013-11-28 11:06:18 +0000 |
commit | 4425f4524efe3fe0ba4db6c363aab68aca6aa108 (patch) | |
tree | 146c83a9cffab2c0a909d9d4e09771590018a0c4 /tools | |
parent | c9cfc8e3226ba615d3221cb9c74e66d69b9c70c5 (diff) | |
download | FreeBSD-src-4425f4524efe3fe0ba4db6c363aab68aca6aa108.zip FreeBSD-src-4425f4524efe3fe0ba4db6c363aab68aca6aa108.tar.gz |
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
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/nanobsd/nanobsd.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh index 01b602c..f8bd2cd 100644 --- a/tools/tools/nanobsd/nanobsd.sh +++ b/tools/tools/nanobsd/nanobsd.sh @@ -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. |