Changeset 10407 in hybrid for branches/releng-9.0/nanobsd/cfg


Ignore:
Timestamp:
Apr 9, 2012, 10:34:31 AM (13 years ago)
Author:
rick
Message:

Nice hack to publish the /var/db/pkg into /usr/local/var/db/pkg. Allowing it to store on permanent location.

Related-To: nodefactory#109

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/cfg/nanobsd.wleiden

    r10385 r10407  
    258258
    259259
     260# pkgdb should live on persistent storage only
     261cust_alternate_pkg_db () (
     262        mkdir -p ${NANO_WORLDDIR}/usr/local/var/db/pkg ${NANO_WORLDDIR}/usr/local/tmp
     263        touch ${NANO_WORLDDIR}/usr/local/tmp/.hack-to-avoid-pruning-directory
     264        # sh profile
     265        ( echo 'PKG_DBDIR=/usr/local/var/db/pkg; export PKG_DBDIR'; \
     266        echo 'PKG_TMPDIR=/usr/local/tmp; export PKG_TMPDIR' ) >> ${NANO_WORLDDIR}/etc/profile
     267        # csh profile
     268        ( echo 'setenv PKG_DBDIR /usr/local/var/db/pkg'; \
     269        echo 'setenv PKG_TMPDIR /usr/local/tmp' ) >> ${NANO_WORLDDIR}/etc/csh.cshrc
     270)
     271
     272# Directly stolen from /usr/src/tools/tools/nanobsd/nanobsd.sh, and make sure
     273# to source /etc/profile in chroot to get PKG_* included, for alternate installs
     274cust_pkg () (
     275
     276        # If the package directory doesn't exist, we're done.
     277        if [ ! -d ${NANO_PACKAGE_DIR} ]; then
     278                echo "DONE 0 packages"
     279                return 0
     280        fi
     281
     282        # Copy packages into chroot
     283        mkdir -p ${NANO_WORLDDIR}/Pkg
     284        (
     285                cd ${NANO_PACKAGE_DIR}
     286                find ${NANO_PACKAGE_LIST} -print |
     287                    cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
     288        )
     289
     290        # Count & report how many we have to install
     291        todo=`ls ${NANO_WORLDDIR}/Pkg | wc -l`
     292        echo "=== TODO: $todo"
     293        ls ${NANO_WORLDDIR}/Pkg
     294        echo "==="
     295        NANO_PKG_DBDIR=${NANO_WORLDDIR}/`chroot ${NANO_WORLDDIR} sh -c '. /etc/profile; echo ${PKG_DBDIR:-/var/db/pkg}'`
     296        while true
     297        do
     298                # Record how many we have now
     299                have=`ls ${NANO_PKG_DBDIR} | wc -l`
     300
     301                # Attempt to install more packages
     302                # ...but no more than 200 at a time due to pkg_add's internal
     303                # limitations.
     304                chroot ${NANO_WORLDDIR} sh -c \
     305                        '. /etc/profile; ls Pkg/*tbz | xargs -n 200 pkg_add -F' || true
     306
     307                # See what that got us
     308                now=`ls ${NANO_PKG_DBDIR} | wc -l`
     309                echo "=== NOW $now"
     310                ls ${NANO_PKG_DBDIR}
     311                echo "==="
     312
     313
     314                if [ $now -eq $todo ] ; then
     315                        echo "DONE $now packages"
     316                        break
     317                elif [ $now -eq $have ] ; then
     318                        echo "FAILED: Nothing happened on this pass"
     319                        exit 2
     320                fi
     321        done
     322        rm -rf ${NANO_WORLDDIR}/Pkg
     323)
     324
    260325
    261326# Prune no needed directories of image
     
    325390# XXX: Determine size before installing all find of additions to see how much
    326391# base we are actually using ## du -h -d 0
     392customize_cmd cust_alternate_pkg_db
    327393customize_cmd cust_pkg
    328394customize_cmd cust_install_files
Note: See TracChangeset for help on using the changeset viewer.