Skip to content

Commit

Permalink
Hoist CR convenience function up from dhcpd config and use
Browse files Browse the repository at this point in the history
appropriately in nanobsd.sh. Also create CR0 for a errors allowed
version.
  • Loading branch information
bsdimp committed Apr 24, 2014
1 parent d27e241 commit 6180f4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
5 changes: 0 additions & 5 deletions tools/tools/nanobsd/dhcpd/common
Original file line number Diff line number Diff line change
Expand Up @@ -156,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 ()
{
Expand Down
32 changes: 19 additions & 13 deletions tools/tools/nanobsd/nanobsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ SRCCONF=${SRCCONF:=/dev/null}
#
#######################################################################

# 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
Expand Down Expand Up @@ -748,8 +760,7 @@ cust_pkg () (
# 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 env PKG_DBDIR='${NANO_PKG_META_BASE}'/pkg pkg_add -v -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}/${NANO_PKG_META_BASE}/pkg | wc -l`
Expand Down Expand Up @@ -795,9 +806,8 @@ cust_pkgng () (
)

#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;"
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
Expand All @@ -813,19 +823,15 @@ cust_pkgng () (
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'`
have=$(CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l)

# Attempt to install more packages
chroot ${NANO_WORLDDIR} sh -c \
'ls Pkg/*txz | xargs env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg add ' || true
CR0 'ls 'Pkg/*txz' | xargs env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg add'

# See what that got us
now=`chroot ${NANO_WORLDDIR} sh -c \
'env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l'`
now=$(CR 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'
CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info
echo "==="
if [ $now -eq $todo ] ; then
echo "DONE $now packages"
Expand Down

0 comments on commit 6180f4b

Please sign in to comment.