3 # Copyright (c) 2005 Poul-Henning Kamp.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #######################################################################
34 # Setup default values for all controlling variables.
35 # These values can be overridden from the config file(s)
37 #######################################################################
39 # Name of this NanoBSD build. (Used to construct workdir names)
42 # Source tree directory
45 # Where nanobsd additional files live under the source tree
46 NANO_TOOLS=tools/tools/nanobsd
48 # Where cust_pkgng() finds packages to install
49 NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
52 # where package metadata gets placed
53 NANO_PKG_META_BASE=/var/db
55 # Path to mtree file to apply to anything copied by cust_install_files().
56 # If you specify this, the mtree file *must* have an entry for every file and
57 # directory located in Files.
58 #NANO_CUST_FILES_MTREE=""
60 # Object tree directory
61 # default is subdir of /usr/obj
64 # The directory to put the final images
65 # default is ${NANO_OBJ}
68 # Make & parallel Make
70 NANO_NCPU=$(sysctl -n hw.ncpu)
71 NANO_PMAKE="make -j $NANO_NCPU"
73 # The default name for any image we create.
74 NANO_IMGNAME="_.disk.full"
75 NANO_IMG1NAME="_.disk.image"
77 # Options to put in make.conf during buildworld only
80 # Options to put in make.conf during installworld only
83 # Options to put in make.conf during both build- & installworld.
86 # Kernel config file to use
89 # Kernel modules to install. If empty, no modules are installed.
90 # Use "default" to install all built modules.
93 # Early customize commands.
94 NANO_EARLY_CUSTOMIZE=""
99 # Late customize commands.
100 NANO_LATE_CUSTOMIZE=""
102 # Newfs parameters to use
103 NANO_NEWFS="-b 4096 -f 512 -i 8192 -U"
105 # The drive name of the media at runtime
108 # Target media size in 512 bytes sectors
109 NANO_MEDIASIZE=2000000
111 # Number of code images on media (1 or 2)
114 # 0 -> Leave second image all zeroes so it compresses better.
115 # 1 -> Initialize second image with a copy of the first
118 # Size of code file system in 512 bytes sectors
119 # If zero, size will be as large as possible.
122 # Size of configuration file system in 512 bytes sectors
126 # Size of data file system in 512 bytes sectors
127 # If zero: no partition configured.
128 # If negative: max size possible
131 # Size of the /etc ramdisk in 512 bytes sectors
132 NANO_RAM_ETCSIZE=10240
134 # Size of the /tmp+/var ramdisk in 512 bytes sectors
135 NANO_RAM_TMPVARSIZE=10240
137 # boot0 flags/options and configuration
138 NANO_BOOT0CFG="-o packet -s 1 -m 3"
139 NANO_BOOTLOADER="boot/boot0sio"
141 # boot2 flags/options
142 # default force serial console
143 NANO_BOOT2CFG="-h -S115200"
145 # Backing type of md(4) device
146 # Can be "file" or "swap"
147 NANO_MD_BACKING="file"
149 # for swap type md(4) backing, write out the mbr only
150 NANO_IMAGE_MBRONLY=true
152 # Progress Print level
155 # Set NANO_LABEL to non-blank to form the basis for using /dev/ufs/label
156 # in preference to /dev/${NANO_DRIVE}
157 # Root partition will be ${NANO_LABEL}s{1,2}
158 # /cfg partition will be ${NANO_LABEL}s3
159 # /data partition will be ${NANO_LABEL}s4
162 NANO_SLICE_ALTROOT=s2
165 NANO_PARTITION_ROOT=a
166 NANO_PARTITION_ALTROOT=a
170 # Default ownwership for nopriv build
174 #######################################################################
175 # Architecture to build. Corresponds to TARGET_ARCH in a buildworld.
176 # Unfortunately, there's no way to set TARGET at this time, and it
177 # conflates the two, so architectures where TARGET != TARGET_ARCH and
178 # TARGET can't be guessed from TARGET_ARCH do not work. This defaults
179 # to the arch of the current machine.
182 # CPUTYPE defaults to "" which is the default when CPUTYPE isn't
186 # Directory to populate /cfg from
189 # Directory to populate /data from
192 # We don't need SRCCONF or SRC_ENV_CONF. NanoBSD puts everything we
193 # need for the build in files included with __MAKE_CONF. Override in your
194 # config file if you really must. We set them unconditionally here, though
195 # in case they are stray in the build environment
197 SRC_ENV_CONF=/dev/null
199 #######################################################################
201 # The functions which do the real work.
202 # Can be overridden from the config file(s)
204 #######################################################################
206 # Export values into the shell. Must use { } instead of ( ) like
207 # other functions to avoid a subshell.
208 # We set __MAKE_CONF as a global since it is easier to get quoting
209 # right for paths with spaces in them.
211 # Similar to export_var, except puts the data out to stdout
214 echo "Setting variable: $var=\"$val\""
218 nano_make_build_env ( ) {
219 __MAKE_CONF="${NANO_MAKE_CONF_BUILD}"
220 make_export __MAKE_CONF
223 nano_make_install_env ( ) {
224 __MAKE_CONF="${NANO_MAKE_CONF_INSTALL}"
225 make_export __MAKE_CONF
228 # Extra environment variables for kernel builds
229 nano_make_kernel_env ( ) {
230 if [ -f "${NANO_KERNEL}" ] ; then
231 KERNCONFDIR="$(realpath $(dirname ${NANO_KERNEL}))"
232 KERNCONF="$(basename ${NANO_KERNEL})"
233 make_export KERNCONFDIR
236 export KERNCONF="${NANO_KERNEL}"
241 nano_global_make_env ( ) (
242 # global settings for the make.conf file, if set
243 [ -z "${NANO_ARCH}" ] || echo TARGET_ARCH="${NANO_ARCH}"
244 [ -z "${NANO_CPUTYPE}" ] || echo TARGET_CPUTYPE="${NANO_CPUTYPE}"
247 # rm doesn't know -x prior to FreeBSD 10, so cope with a variety of build
248 # hosts for now. This will go away when support in the base goes away.
252 7*|8*|9*) command rm $* ;;
253 *) command rm -x $* ;;
258 # Create empty files in the target tree, and record the fact. All paths
259 # are relative to NANO_WORLDDIR.
262 cd "${NANO_WORLDDIR}"
265 echo "./${i} type=file" >> ${NANO_METALOG}
270 # Convert a directory into a symlink. Takes two arguments, the
271 # current directory and what it should become a symlink to. The
272 # directory is removed and a symlink is created. If we're doing
273 # a nopriv build, then append this fact to the metalog
275 tgt_dir2symlink ( ) (
279 cd "${NANO_WORLDDIR}"
281 ln -s "$symlink" "$dir"
282 if [ -n "$NANO_METALOG" ]; then
283 echo "./${dir} type=link mode=0777 link=${symlink}" >> ${NANO_METALOG}
287 # run in the world chroot, errors fatal
289 chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*"
292 # run in the world chroot, errors not fatal
294 chroot "${NANO_WORLDDIR}" /bin/sh -c "$*" || true
298 pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})"
300 if ! rm -rf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then
301 chflags -R noschg ${MAKEOBJDIRPREFIX}/
302 rm -r ${MAKEOBJDIRPREFIX}/
306 make_conf_build ( ) (
307 pprint 2 "Construct build make.conf ($NANO_MAKE_CONF_BUILD)"
309 mkdir -p ${MAKEOBJDIRPREFIX}
310 printenv > ${MAKEOBJDIRPREFIX}/_.env
312 # Make sure we get all the global settings that NanoBSD wants
313 # in addition to the user's global settings
318 ) > ${NANO_MAKE_CONF_BUILD}
322 pprint 2 "run buildworld"
323 pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw"
329 ${NANO_PMAKE} buildworld
330 ) > ${MAKEOBJDIRPREFIX}/_.bw 2>&1
334 pprint 2 "build kernel ($NANO_KERNEL)"
335 pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bk"
341 # Note: We intentionally build all modules, not only the ones in
342 # NANO_MODULES so the built world can be reused by multiple images.
343 # Although MODULES_OVERRIDE can be defined in the kernel config
344 # file to override this behavior. Just set NANO_MODULES=default.
347 ${NANO_PMAKE} buildkernel
348 ) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1
352 if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then
353 pprint 2 "Clean and create object directory (${NANO_OBJ})"
354 if ! rm -rf ${NANO_OBJ}/ > /dev/null 2>&1 ; then
355 chflags -R noschg ${NANO_OBJ}
358 mkdir -p "${NANO_OBJ}" "${NANO_WORLDDIR}"
359 printenv > ${NANO_LOG}/_.env
361 pprint 2 "Clean and create world directory (${NANO_WORLDDIR})"
362 if ! rm -rf "${NANO_WORLDDIR}/" > /dev/null 2>&1 ; then
363 chflags -R noschg "${NANO_WORLDDIR}"
364 rm -rf "${NANO_WORLDDIR}/"
366 mkdir -p "${NANO_WORLDDIR}"
370 make_conf_install ( ) (
371 pprint 2 "Construct install make.conf ($NANO_MAKE_CONF_INSTALL)"
373 # Make sure we get all the global settings that NanoBSD wants
374 # in addition to the user's global settings
378 echo "${CONF_INSTALL}"
379 if [ -n "${NANO_NOPRIV_BUILD}" ]; then
381 echo METALOG=${NANO_METALOG}
383 ) > ${NANO_MAKE_CONF_INSTALL}
387 pprint 2 "installworld"
388 pprint 3 "log: ${NANO_LOG}/_.iw"
391 nano_make_install_env
394 ${NANO_MAKE} installworld DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes
395 chflags -R noschg "${NANO_WORLDDIR}"
396 ) > ${NANO_LOG}/_.iw 2>&1
400 pprint 2 "install /etc"
401 pprint 3 "log: ${NANO_LOG}/_.etc"
404 nano_make_install_env
407 ${NANO_MAKE} distribution DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes
408 # make.conf doesn't get created by default, but some ports need it
409 # so they can spam it.
410 cp /dev/null "${NANO_WORLDDIR}"/etc/make.conf
411 ) > ${NANO_LOG}/_.etc 2>&1
415 pprint 2 "install kernel ($NANO_KERNEL)"
416 pprint 3 "log: ${NANO_LOG}/_.ik"
420 nano_make_install_env
423 if [ "${NANO_MODULES}" != "default" ]; then
424 MODULES_OVERRIDE="${NANO_MODULES}"
425 make_export MODULES_OVERRIDE
430 ${NANO_MAKE} installkernel DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes
432 ) > ${NANO_LOG}/_.ik 2>&1
436 print 2 "Installing the optimized native build tools for cross env"
437 pprint 3 "log: ${NANO_LOG}/_.native_xtools"
441 nano_make_install_env
444 ${NANO_MAKE} native-xtools
445 ${NANO_MAKE} native-xtools-install DESTDIR="${NANO_WORLDDIR}"
447 ) > ${NANO_LOG}/_.native_xtools 2>&1
451 # Run the requested set of early customization scripts, run before
454 run_early_customize ( ) {
455 pprint 2 "run early customize scripts"
456 for c in $NANO_EARLY_CUSTOMIZE
458 pprint 2 "early customize \"$c\""
459 pprint 3 "log: ${NANO_LOG}/_.early_cust.$c"
461 { set -x ; $c ; set +x ; } >${NANO_LOG}/_.early_cust.$c 2>&1
466 # Run the requested set of customization scripts, run after we've
467 # done an installworld, installed the etc files, installed the kernel
468 # and tweaked them in the standard way.
472 pprint 2 "run customize scripts"
473 for c in $NANO_CUSTOMIZE
475 pprint 2 "customize \"$c\""
476 pprint 3 "log: ${NANO_LOG}/_.cust.$c"
478 ( set -x ; $c ) > ${NANO_LOG}/_.cust.$c 2>&1
483 # Run any last-minute customization commands after we've had a chance to
484 # setup nanobsd, prune empty dirs from /usr, etc
486 run_late_customize ( ) (
487 pprint 2 "run late customize scripts"
488 for c in $NANO_LATE_CUSTOMIZE
490 pprint 2 "late customize \"$c\""
491 pprint 3 "log: ${NANO_LOG}/_.late_cust.$c"
493 ( set -x ; $c ) > ${NANO_LOG}/_.late_cust.$c 2>&1
498 # Hook called after we run all the late customize commands, but
499 # before we invoke the disk imager. The nopriv build uses it to
500 # read in the meta log, apply the changes other parts of nanobsd
501 # have been recording their actions. It's not anticipated that
502 # a user's cfg file would override this.
504 fixup_before_diskimage ( ) (
505 # Run the deduplication script that takes the matalog journal and
506 # combines multiple entries for the same file (see source for
507 # details). We take the extra step of removing the size keywords. This
508 # script, and many of the user scripts, copies, appeneds and otherwise
509 # modifies files in the build, changing their sizes. These actions are
510 # impossible to trap, so go ahead remove the size= keyword. For this
511 # narrow use, it doesn't buy us any protection and just gets in the way.
512 # The dedup tool's output must be sorted due to limitations in awk.
513 if [ -n "${NANO_METALOG}" ]; then
514 pprint 2 "Fixing metalog"
515 cp ${NANO_METALOG} ${NANO_METALOG}.pre
516 echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" > ${NANO_METALOG}
517 cat ${NANO_METALOG}.pre | ${NANO_TOOLS}/mtree-dedup.awk | \
518 sed -e 's/ size=[0-9][0-9]*//' | sort >> ${NANO_METALOG}
523 pprint 2 "configure nanobsd setup"
524 pprint 3 "log: ${NANO_LOG}/_.dl"
527 cd "${NANO_WORLDDIR}"
529 # Move /usr/local/etc to /etc/local so that the /cfg stuff
530 # can stomp on it. Otherwise packages like ipsec-tools which
531 # have hardcoded paths under ${prefix}/etc are not tweakable.
532 if [ -d usr/local/etc ] ; then
535 find . -print | cpio -dumpl ../../../etc/local
541 # Always setup the usr/local/etc -> etc/local symlink.
542 # usr/local/etc gets created by packages, but if no packages
543 # are installed by this point, but are later in the process,
544 # the symlink not being here causes problems. It never hurts
545 # to have the symlink in error though.
546 ln -s ../../etc/local usr/local/etc
550 # link /$d under /conf
551 # we use hard links so we have them both places.
552 # the files in /$d will be hidden by the mount.
553 mkdir -p conf/base/$d conf/default/$d
554 find $d -print | cpio -dumpl conf/base/
557 echo "$NANO_RAM_ETCSIZE" > conf/base/etc/md_size
558 echo "$NANO_RAM_TMPVARSIZE" > conf/base/var/md_size
560 # pick up config files from the special partition
561 echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount
563 # Put /tmp on the /var ramdisk (could be symlink already)
564 tgt_dir2symlink tmp var/tmp
566 ) > ${NANO_LOG}/_.dl 2>&1
569 setup_nanobsd_etc ( ) (
570 pprint 2 "configure nanobsd /etc"
573 cd "${NANO_WORLDDIR}"
575 # create diskless marker file
578 [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 666 etc/defaults/rc.conf
580 # Make root filesystem R/O by default
581 echo "root_rw_mount=NO" >> etc/defaults/rc.conf
582 # Disable entropy file, since / is read-only /var/db/entropy should be enough?
583 echo "entropy_file=NO" >> etc/defaults/rc.conf
585 [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf
587 # save config file for scripts
588 echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
590 echo "/dev/${NANO_DRIVE}${NANO_ROOT} / ufs ro 1 1" > etc/fstab
591 echo "/dev/${NANO_DRIVE}${NANO_SLICE_CFG} /cfg ufs rw,noauto 2 2" >> etc/fstab
594 # Create directory for eventual /usr/local/etc contents
600 # Remove all empty directories in /usr
601 find "${NANO_WORLDDIR}"/usr -type d -depth -print |
604 rmdir $d > /dev/null 2>&1 || true
613 echo newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev}
614 newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev}
615 mount -o async ${dev} ${mnt}
618 # Convenient spot to work around any umount issues that your build environment
619 # hits by overriding this method.
625 local dev dir mnt lbl
630 echo "Creating ${dev} (mounting on ${mnt})"
631 newfs_part ${dev} ${mnt} ${lbl}
632 if [ -n "${dir}" -a -d "${dir}" ]; then
633 echo "Populating ${lbl} from ${dir}"
635 find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio -dumpv ${mnt}
641 populate_cfg_slice ( ) (
642 populate_slice "$1" "$2" "$3" "$4"
645 populate_data_slice ( ) (
646 populate_slice "$1" "$2" "$3" "$4"
650 # Redefine this function with any last orders you may have
651 # after the build completed, for instance to copy the finished
652 # image to a more convenient place:
653 # cp ${NANO_DISKIMGDIR}/${NANO_IMG1NAME} /home/ftp/pub/nanobsd.disk
657 #######################################################################
659 # Optional convenience functions.
661 #######################################################################
663 #######################################################################
664 # Common Flash device geometries
668 if [ -d ${NANO_TOOLS} ] ; then
669 . ${NANO_TOOLS}/FlashDevice.sub
671 . ${NANO_SRC}/${NANO_TOOLS}/FlashDevice.sub
673 sub_FlashDevice $1 $2
676 #######################################################################
677 # USB device geometries
680 # UsbDevice Generic 1000 # a generic flash key sold as having 1GB
682 # This function will set NANO_MEDIASIZE, NANO_HEADS and NANO_SECTS for you.
684 # Note that the capacity of a flash key is usually advertised in MB or
685 # GB, *not* MiB/GiB. As such, the precise number of cylinders available
686 # for C/H/S geometry may vary depending on the actual flash geometry.
688 # The following generic device layouts are understood:
689 # generic An alias for generic-hdd.
690 # generic-hdd 255H 63S/T xxxxC with no MBR restrictions.
691 # generic-fdd 64H 32S/T xxxxC with no MBR restrictions.
693 # The generic-hdd device is preferred for flash devices larger than 1GB.
697 a1=`echo $1 | tr '[:upper:]' '[:lower:]'`
702 NANO_MEDIASIZE=$(( $2 * 1000 * 1000 / 512 ))
707 NANO_MEDIASIZE=$(( $2 * 1000 * 1000 / 512 ))
710 echo "Unknown USB flash device"
716 #######################################################################
717 # Setup serial console
719 cust_comconsole ( ) (
720 # Enable getty on console
721 sed -i "" -e /tty[du]0/s/off/on/ ${NANO_WORLDDIR}/etc/ttys
723 # Disable getty on syscons devices
724 sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${NANO_WORLDDIR}/etc/ttys
726 # Tell loader to use serial console early.
727 echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config
730 #######################################################################
731 # Allow root login via ssh
733 cust_allow_ssh_root ( ) (
734 sed -i "" -e '/PermitRootLogin/s/.*/PermitRootLogin yes/' \
735 ${NANO_WORLDDIR}/etc/ssh/sshd_config
738 #######################################################################
739 # Install the stuff under ./Files
741 cust_install_files ( ) (
742 cd "${NANO_TOOLS}/Files"
743 find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio -Ldumpv ${NANO_WORLDDIR}
745 if [ -n "${NANO_CUST_FILES_MTREE}" -a -f ${NANO_CUST_FILES_MTREE} ]; then
746 CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE}
750 #######################################################################
751 # Install packages from ${NANO_PACKAGE_DIR}
754 mkdir -p ${NANO_WORLDDIR}/usr/local/etc
755 local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf"
756 local PKGCMD="env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=${NANO_PKG_META_BASE}/pkg SIGNATURE_TYPE=none /usr/sbin/pkg"
758 # Ensure pkg.conf points pkg to where the package meta data lives.
760 if grep -Eiq '^PKG_DBDIR:.*' ${PKG_CONF}; then
761 sed -i -e "\|^PKG_DBDIR:.*|Is||PKG_DBDIR: "\"${NANO_PKG_META_BASE}/pkg\""|" ${PKG_CONF}
763 echo "PKG_DBDIR: \"${NANO_PKG_META_BASE}/pkg\"" >> ${PKG_CONF}
766 # If the package directory doesn't exist, we're done.
767 if [ ! -d ${NANO_PACKAGE_DIR} ]; then
768 echo "DONE 0 packages"
772 # Find a pkg-* package
773 for x in `find -s ${NANO_PACKAGE_DIR} -iname 'pkg-*'`; do
774 _NANO_PKG_PACKAGE=`basename "$x"`
776 if [ -z "${_NANO_PKG_PACKAGE}" -o ! -f "${NANO_PACKAGE_DIR}/${_NANO_PKG_PACKAGE}" ]; then
777 echo "FAILED: need a pkg/ package for bootstrapping"
781 # Mount packages into chroot
782 mkdir -p ${NANO_WORLDDIR}/_.p
783 mount -t nullfs -o noatime -o ro ${NANO_PACKAGE_DIR} ${NANO_WORLDDIR}/_.p
784 mount -t devfs devfs ${NANO_WORLDDIR}/dev
786 trap "umount ${NANO_WORLDDIR}/dev; umount ${NANO_WORLDDIR}/_.p ; rm -rf ${NANO_WORLDDIR}/_.p" 1 2 15 EXIT
788 # Install pkg-* package
789 CR "${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}"
792 # Expand any glob characters in pacakge list
793 cd "${NANO_PACKAGE_DIR}"
794 _PKGS=`find ${NANO_PACKAGE_LIST} -not -name "${_NANO_PKG_PACKAGE}" -print | sort | uniq`
797 todo=`echo "$_PKGS" | wc -l`
798 echo "=== TODO: $todo"
803 for _PKG in $_PKGS; do
804 CR "${PKGCMD} add /_.p/${_PKG}"
811 umount ${NANO_WORLDDIR}/dev
812 umount ${NANO_WORLDDIR}/_.p
813 rm -rf ${NANO_WORLDDIR}/_.p
816 #######################################################################
817 # Convenience function:
818 # Register all args as early customize function to run just before
821 early_customize_cmd ( ) {
822 NANO_EARLY_CUSTOMIZE="$NANO_EARLY_CUSTOMIZE $*"
825 #######################################################################
826 # Convenience function:
827 # Register all args as customize function.
830 NANO_CUSTOMIZE="$NANO_CUSTOMIZE $*"
833 #######################################################################
834 # Convenience function:
835 # Register all args as late customize function to run just before
838 late_customize_cmd ( ) {
839 NANO_LATE_CUSTOMIZE="$NANO_LATE_CUSTOMIZE $*"
842 #######################################################################
844 # All set up to go...
846 #######################################################################
849 # Print $2 at level $1.
851 if [ "$1" -le $PPLEVEL ]; then
852 runtime=$(( `date +%s` - $NANO_STARTTIME ))
853 printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3
859 echo "Usage: $0 [-bfhiKknqvwX] [-c config_file]"
860 echo " -b suppress builds (both kernel and world)"
861 echo " -c specify config file"
862 echo " -f suppress code slice extraction (implies -i)"
863 echo " -h print this help summary page"
864 echo " -i suppress disk image build"
865 echo " -K suppress installkernel"
866 echo " -k suppress buildkernel"
867 echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc"
868 echo " -q make output more quiet"
869 echo " -v make output more verbose"
870 echo " -w suppress buildworld"
871 echo " -X make native-xtools"
876 #######################################################################
877 # Setup and Export Internal variables
880 export_var ( ) { # Don't wawnt a subshell
882 # Lookup value of the variable.
884 pprint 3 "Setting variable: $var=\"$val\""
888 # Call this function to set defaults _after_ parsing options.
889 # dont want a subshell otherwise variable setting is thrown away.
890 set_defaults_and_export ( ) {
891 : ${NANO_OBJ:=/usr/obj/nanobsd.${NANO_NAME}}
892 : ${MAKEOBJDIRPREFIX:=${NANO_OBJ}}
893 : ${NANO_DISKIMGDIR:=${NANO_OBJ}}
894 : ${NANO_WORLDDIR:=${NANO_OBJ}/_.w}
895 : ${NANO_LOG:=${NANO_OBJ}}
896 NANO_MAKE_CONF_BUILD=${MAKEOBJDIRPREFIX}/make.conf.build
897 NANO_MAKE_CONF_INSTALL=${NANO_OBJ}/make.conf.install
899 # Override user's NANO_DRIVE if they specified a NANO_LABEL
900 [ -n "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true
902 # Set a default NANO_TOOLS to NANO_SRC/NANO_TOOLS if it exists.
903 [ ! -d "${NANO_TOOLS}" ] && [ -d "${NANO_SRC}/${NANO_TOOLS}" ] && \
904 NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}" || true
906 [ -n "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ] && \
907 NANO_METALOG=${NANO_OBJ}/_.metalog || true
909 NANO_STARTTIME=`date +%s`
910 pprint 3 "Exporting NanoBSD variables"
911 export_var MAKEOBJDIRPREFIX
913 export_var NANO_CODESIZE
914 export_var NANO_CONFSIZE
915 export_var NANO_CUSTOMIZE
916 export_var NANO_DATASIZE
917 export_var NANO_DRIVE
918 export_var NANO_HEADS
919 export_var NANO_IMAGES
920 export_var NANO_IMGNAME
921 export_var NANO_IMG1NAME
923 export_var NANO_MAKE_CONF_BUILD
924 export_var NANO_MAKE_CONF_INSTALL
925 export_var NANO_MEDIASIZE
928 export_var NANO_NEWFS
930 export_var NANO_PMAKE
931 export_var NANO_SECTS
933 export_var NANO_TOOLS
934 export_var NANO_WORLDDIR
935 export_var NANO_BOOT0CFG
936 export_var NANO_BOOTLOADER
937 export_var NANO_LABEL
938 export_var NANO_MODULES
939 export_var NANO_NOPRIV_BUILD
940 export_var NANO_METALOG
943 export_var SRC_ENV_CONF