diff --git a/tools/tools/nanobsd/dhcpd/common b/tools/tools/nanobsd/dhcpd/common --- a/tools/tools/nanobsd/dhcpd/common +++ b/tools/tools/nanobsd/dhcpd/common @@ -34,6 +34,8 @@ # NB: You want the other file +legacy + NANO_PMAKE="make -j $(sysctl -n hw.ncpu)" NANO_CFG_BASE=$(pwd) diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -71,6 +71,9 @@ echo "NANO_NAME not defined. Use foo.cfg instead." fi +# We define our own imaging plan, so instruct nanobsd not to define its own. +NANO_PLAN=embedded + NANO_SLICE_FAT_SIZE=32m NANO_SLICE_CFG_SIZE=32m diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh --- a/tools/tools/nanobsd/legacy.sh +++ b/tools/tools/nanobsd/legacy.sh @@ -34,7 +34,13 @@ # Functions and variable definitions used by the legacy nanobsd # image building system. -calculate_partitioning() { +NANO_PLAN=legacy + +# Note: we use the is_defined hack to catch most uses of function redefinition +# in config files. Older versions of FreeBSD defined these before configs were +# included, but now we define it after to allow different NANO_PLAN... + +is_defined calculate_partitioning || calculate_partitioning() { echo $NANO_MEDIASIZE $NANO_IMAGES \ $NANO_SECTS $NANO_HEADS \ $NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE | @@ -92,7 +98,7 @@ ' > ${NANO_LOG}/_.partitioning } -create_code_slice() { +is_defined create_code_slice || create_code_slice() { pprint 2 "build code slice" pprint 3 "log: ${NANO_OBJ}/_.cs" @@ -145,7 +151,7 @@ } -create_diskimage() { +is_defined create_diskimage || create_diskimage() { pprint 2 "build diskimage" pprint 3 "log: ${NANO_OBJ}/_.di" diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh --- a/tools/tools/nanobsd/nanobsd.sh +++ b/tools/tools/nanobsd/nanobsd.sh @@ -28,6 +28,18 @@ set -e +legacy() { + # Pull in legacy stuff on demand + . "${topdir}/legacy.sh" +} + +is_defined() { + case $(type $1 2>/dev/null) in + *function) return 0 ;; + *) return 1 ;; + esac +} + nanobsd_sh=`realpath $0` topdir=`dirname ${nanobsd_sh}` . "${topdir}/defaults.sh" @@ -45,9 +57,6 @@ do_native_xtools=false do_prep_image=true -# Pull in legacy stuff for now automatically -. "${topdir}/legacy.sh" - set +e args=`getopt BKXWbc:fhiIknpqvw $*` if [ $? -ne 0 ] ; then @@ -148,6 +157,10 @@ usage fi +# Transition hack -- If you get this warning, add 'legacy' to your nano config file +[ -n "$NANO_PLAN" ] || echo "Warning: no plan defined, assuming legacy config." +[ -n "$NANO_PLAN" ] || legacy + ####################################################################### # And then it is as simple as that... diff --git a/tools/tools/nanobsd/pcengines/common.conf b/tools/tools/nanobsd/pcengines/common.conf --- a/tools/tools/nanobsd/pcengines/common.conf +++ b/tools/tools/nanobsd/pcengines/common.conf @@ -1,6 +1,8 @@ # # +legacy + NANO_SRC=$(pwd) NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/pcengines} NANO_OBJ=${NANO_SRC}/../nanobsd-builds/${NANO_NAME}/obj diff --git a/tools/tools/nanobsd/rescue/common b/tools/tools/nanobsd/rescue/common --- a/tools/tools/nanobsd/rescue/common +++ b/tools/tools/nanobsd/rescue/common @@ -1,5 +1,7 @@ #!/bin/sh +legacy + #NANO_SRC=$(pwd) #NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/rescue} #NANO_OBJ=${NANO_SRC}/../nanobsd-builds/${NANO_NAME}/obj