diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh index 4c4323c4bd87..4f0cc2fa99bd 100755 --- a/tools/tools/nanobsd/defaults.sh +++ b/tools/tools/nanobsd/defaults.sh @@ -1,982 +1,980 @@ #!/bin/sh # # Copyright (c) 2005 Poul-Henning Kamp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # set -e ####################################################################### # # Setup default values for all controlling variables. # These values can be overridden from the config file(s) # ####################################################################### # Name of this NanoBSD build. (Used to construct workdir names) NANO_NAME=full # Source tree directory NANO_SRC=/usr/src # Where nanobsd additional files live under the source tree NANO_TOOLS=tools/tools/nanobsd # Where cust_pkgng() finds packages to install NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg NANO_PACKAGE_LIST="*" # where package metadata gets placed NANO_PKG_META_BASE=/var/db # Path to mtree file to apply to anything copied by cust_install_files(). # If you specify this, the mtree file *must* have an entry for every file and # directory located in Files. #NANO_CUST_FILES_MTREE="" # Object tree directory # default is subdir of /usr/obj #NANO_OBJ="" # The directory to put the final images # default is ${NANO_OBJ} #NANO_DISKIMGDIR="" # Make & parallel Make NANO_MAKE="make" NANO_NCPU=$(sysctl -n hw.ncpu) # The default name for any image we create. NANO_IMGNAME="_.disk.full" NANO_IMG1NAME="_.disk.image" # Options to put in make.conf during buildworld only CONF_BUILD=' ' # Options to put in make.conf during installworld only CONF_INSTALL=' ' # Options to put in make.conf during both build- & installworld. CONF_WORLD=' WITHOUT_DEBUG_FILES=true WITHOUT_LIB32=true WITHOUT_KERNEL_SYMBOLS=true WITHOUT_TESTS=true ' # Kernel config file to use NANO_KERNEL=GENERIC # Kernel modules to install. If empty, no modules are installed. # Use "default" to install all built modules. NANO_MODULES= # Early customize commands. NANO_EARLY_CUSTOMIZE="" # Customize commands. NANO_CUSTOMIZE="" # Late customize commands. NANO_LATE_CUSTOMIZE="" # Newfs parameters to use NANO_NEWFS="-b 4096 -f 512 -i 8192 -U" # The drive name of the media at runtime NANO_DRIVE=ada0 # Target media size in 512 bytes sectors NANO_MEDIASIZE=4000000 # Number of code images on media (1 or 2) NANO_IMAGES=2 # 0 -> Leave second image all zeroes so it compresses better. # 1 -> Initialize second image with a copy of the first NANO_INIT_IMG2=1 # Size of code file system in 512 bytes sectors # If zero, size will be as large as possible. NANO_CODESIZE=0 # Size of configuration file system in 512 bytes sectors # Cannot be zero. NANO_CONFSIZE=2048 # Size of data file system in 512 bytes sectors # If zero: no partition configured. # If negative: max size possible NANO_DATASIZE=0 # Size of the /etc ramdisk in 512 bytes sectors NANO_RAM_ETCSIZE=10240 # Size of the /tmp+/var ramdisk in 512 bytes sectors NANO_RAM_TMPVARSIZE=10240 # boot0 flags/options and configuration NANO_BOOT0CFG="-o packet -s 1 -m 3" NANO_BOOTLOADER="boot/boot0sio" # boot2 flags/options # default force serial console NANO_BOOT2CFG="-h -S115200" # Backing type of md(4) device # Can be "file" or "swap" NANO_MD_BACKING="file" # for swap type md(4) backing, write out the mbr only NANO_IMAGE_MBRONLY=true # Progress Print level PPLEVEL=3 # Set NANO_LABEL to non-blank to form the basis for using /dev/ufs/label # in preference to /dev/${NANO_DRIVE} # Root partition will be ${NANO_LABEL}s{1,2} # /cfg partition will be ${NANO_LABEL}s3 # /data partition will be ${NANO_LABEL}s4 NANO_LABEL="" NANO_SLICE_ROOT=s1 NANO_SLICE_ALTROOT=s2 NANO_SLICE_CFG=s3 NANO_SLICE_DATA=s4 NANO_PARTITION_ROOT=a NANO_PARTITION_ALTROOT=a NANO_ROOT=s1a NANO_ALTROOT=s2a # Default ownwership for nopriv build NANO_DEF_UNAME=root NANO_DEF_GNAME=wheel ####################################################################### # Architecture to build. Corresponds to TARGET_ARCH in a buildworld. # Unfortunately, there's no way to set TARGET at this time, and it # conflates the two, so architectures where TARGET != TARGET_ARCH and # TARGET can't be guessed from TARGET_ARCH do not work. This defaults # to the arch of the current machine. NANO_ARCH=`uname -p` # CPUTYPE defaults to "" which is the default when CPUTYPE isn't # defined. NANO_CPUTYPE="" # Directory to populate /cfg from NANO_CFGDIR="" # Directory to populate /data from NANO_DATADIR="" # We don't need SRCCONF or SRC_ENV_CONF. NanoBSD puts everything we # need for the build in files included with __MAKE_CONF. Override in your # config file if you really must. We set them unconditionally here, though # in case they are stray in the build environment SRCCONF=/dev/null SRC_ENV_CONF=/dev/null # Comment this out if /usr/obj is a symlink # CPIO_SYMLINK=--insecure ####################################################################### # # The functions which do the real work. # Can be overridden from the config file(s) # ####################################################################### -# Export values into the shell. Must use { } instead of ( ) like -# other functions to avoid a subshell. +# Export values into the shell. # We set __MAKE_CONF as a global since it is easier to get quoting # right for paths with spaces in them. -make_export ( ) { +make_export() { # Similar to export_var, except puts the data out to stdout - var=$1 + local var=$1 eval val=\$$var echo "Setting variable: $var=\"$val\"" export $1 } -nano_make_build_env ( ) { +nano_make_build_env() { __MAKE_CONF="${NANO_MAKE_CONF_BUILD}" make_export __MAKE_CONF } -nano_make_install_env ( ) { +nano_make_install_env() { __MAKE_CONF="${NANO_MAKE_CONF_INSTALL}" make_export __MAKE_CONF } # Extra environment variables for kernel builds -nano_make_kernel_env ( ) { +nano_make_kernel_env() { if [ -f "${NANO_KERNEL}" ] ; then KERNCONFDIR="$(realpath $(dirname ${NANO_KERNEL}))" KERNCONF="$(basename ${NANO_KERNEL})" make_export KERNCONFDIR make_export KERNCONF else export KERNCONF="${NANO_KERNEL}" make_export KERNCONF fi } -nano_global_make_env ( ) ( +nano_global_make_env() { # global settings for the make.conf file, if set [ -z "${NANO_ARCH}" ] || echo TARGET_ARCH="${NANO_ARCH}" [ -z "${NANO_CPUTYPE}" ] || echo TARGET_CPUTYPE="${NANO_CPUTYPE}" -) +} # # Create empty files in the target tree, and record the fact. All paths # are relative to NANO_WORLDDIR. # -tgt_touch ( ) ( +tgt_touch() { cd "${NANO_WORLDDIR}" for i; do touch $i echo "./${i} type=file" >> ${NANO_METALOG} done -) +} # # Convert a directory into a symlink. Takes two arguments, the # current directory and what it should become a symlink to. The # directory is removed and a symlink is created. If we're doing # a nopriv build, then append this fact to the metalog # -tgt_dir2symlink ( ) ( - dir=$1 - symlink=$2 +tgt_dir2symlink() { + local dir=$1 + local symlink=$2 cd "${NANO_WORLDDIR}" rm -xrf "$dir" ln -s "$symlink" "$dir" if [ -n "$NANO_METALOG" ]; then echo "./${dir} type=link mode=0777 link=${symlink}" >> ${NANO_METALOG} fi -) +} # run in the world chroot, errors fatal -CR ( ) { +CR() { chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*" } # run in the world chroot, errors not fatal -CR0 ( ) { +CR0() { chroot "${NANO_WORLDDIR}" /bin/sh -c "$*" || true } -clean_build ( ) ( +clean_build() { pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})" if ! rm -xrf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then chflags -R noschg ${MAKEOBJDIRPREFIX}/ rm -xr ${MAKEOBJDIRPREFIX}/ fi -) +} -make_conf_build ( ) ( +make_conf_build() { pprint 2 "Construct build make.conf ($NANO_MAKE_CONF_BUILD)" mkdir -p ${MAKEOBJDIRPREFIX} printenv > ${MAKEOBJDIRPREFIX}/_.env # Make sure we get all the global settings that NanoBSD wants # in addition to the user's global settings ( nano_global_make_env echo "${CONF_WORLD}" echo "${CONF_BUILD}" ) > ${NANO_MAKE_CONF_BUILD} -) +} -build_world ( ) ( +build_world() { pprint 2 "run buildworld" pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw" ( nano_make_build_env set -o xtrace cd "${NANO_SRC}" ${NANO_PMAKE} buildworld ) > ${MAKEOBJDIRPREFIX}/_.bw 2>&1 -) +} -build_kernel ( ) ( +build_kernel() { pprint 2 "build kernel ($NANO_KERNEL)" pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bk" ( nano_make_build_env nano_make_kernel_env # Note: We intentionally build all modules, not only the ones in # NANO_MODULES so the built world can be reused by multiple images. # Although MODULES_OVERRIDE can be defined in the kernel config # file to override this behavior. Just set NANO_MODULES=default. set -o xtrace cd "${NANO_SRC}" ${NANO_PMAKE} buildkernel ) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1 -) +} -clean_world ( ) ( +clean_world() { if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then pprint 2 "Clean and create object directory (${NANO_OBJ})" if ! rm -xrf ${NANO_OBJ}/ > /dev/null 2>&1 ; then chflags -R noschg ${NANO_OBJ} rm -xr ${NANO_OBJ}/ fi mkdir -p "${NANO_OBJ}" "${NANO_WORLDDIR}" printenv > ${NANO_LOG}/_.env else pprint 2 "Clean and create world directory (${NANO_WORLDDIR})" if ! rm -xrf "${NANO_WORLDDIR}/" > /dev/null 2>&1 ; then chflags -R noschg "${NANO_WORLDDIR}" rm -xrf "${NANO_WORLDDIR}/" fi mkdir -p "${NANO_WORLDDIR}" fi -) +} -make_conf_install ( ) ( +make_conf_install() { pprint 2 "Construct install make.conf ($NANO_MAKE_CONF_INSTALL)" # Make sure we get all the global settings that NanoBSD wants # in addition to the user's global settings ( nano_global_make_env echo "${CONF_WORLD}" echo "${CONF_INSTALL}" if [ -n "${NANO_NOPRIV_BUILD}" ]; then echo NO_ROOT=t echo METALOG=${NANO_METALOG} fi ) > ${NANO_MAKE_CONF_INSTALL} -) +} -install_world ( ) ( +install_world() { pprint 2 "installworld" pprint 3 "log: ${NANO_LOG}/_.iw" ( nano_make_install_env set -o xtrace cd "${NANO_SRC}" ${NANO_MAKE} installworld DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes chflags -R noschg "${NANO_WORLDDIR}" ) > ${NANO_LOG}/_.iw 2>&1 -) +} -install_etc ( ) ( +install_etc() { pprint 2 "install /etc" pprint 3 "log: ${NANO_LOG}/_.etc" ( nano_make_install_env set -o xtrace cd "${NANO_SRC}" ${NANO_MAKE} distribution DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes # make.conf doesn't get created by default, but some ports need it # so they can spam it. cp /dev/null "${NANO_WORLDDIR}"/etc/make.conf ) > ${NANO_LOG}/_.etc 2>&1 -) +} -install_kernel ( ) ( +install_kernel() { pprint 2 "install kernel ($NANO_KERNEL)" pprint 3 "log: ${NANO_LOG}/_.ik" ( nano_make_install_env nano_make_kernel_env if [ "${NANO_MODULES}" != "default" ]; then MODULES_OVERRIDE="${NANO_MODULES}" make_export MODULES_OVERRIDE fi set -o xtrace cd "${NANO_SRC}" ${NANO_MAKE} installkernel DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes ) > ${NANO_LOG}/_.ik 2>&1 -) +} -native_xtools ( ) ( +native_xtools() { pprint 2 "Installing the optimized native build tools for cross env" pprint 3 "log: ${NANO_LOG}/_.native_xtools" ( nano_make_install_env set -o xtrace cd "${NANO_SRC}" ${NANO_MAKE} native-xtools ${NANO_MAKE} native-xtools-install DESTDIR="${NANO_WORLDDIR}" ) > ${NANO_LOG}/_.native_xtools 2>&1 -) +} # # Run the requested set of early customization scripts, run before # buildworld. # -run_early_customize ( ) { +run_early_customize() { pprint 2 "run early customize scripts" for c in $NANO_EARLY_CUSTOMIZE do pprint 2 "early customize \"$c\"" pprint 3 "log: ${NANO_LOG}/_.early_cust.$c" pprint 4 "`type $c`" { t=$(set -o | awk '$1 == "xtrace" && $2 == "off" { print "set +o xtrace"}'); set -o xtrace ; $c ; eval $t } >${NANO_LOG}/_.early_cust.$c 2>&1 done } # # Run the requested set of customization scripts, run after we've # done an installworld, installed the etc files, installed the kernel # and tweaked them in the standard way. # -run_customize ( ) ( +run_customize() { pprint 2 "run customize scripts" for c in $NANO_CUSTOMIZE do pprint 2 "customize \"$c\"" pprint 3 "log: ${NANO_LOG}/_.cust.$c" pprint 4 "`type $c`" ( set -o xtrace ; $c ) > ${NANO_LOG}/_.cust.$c 2>&1 done -) +} # # Run any last-minute customization commands after we've had a chance to # setup nanobsd, prune empty dirs from /usr, etc # -run_late_customize ( ) ( +run_late_customize() { pprint 2 "run late customize scripts" for c in $NANO_LATE_CUSTOMIZE do pprint 2 "late customize \"$c\"" pprint 3 "log: ${NANO_LOG}/_.late_cust.$c" pprint 4 "`type $c`" ( set -o xtrace ; $c ) > ${NANO_LOG}/_.late_cust.$c 2>&1 done -) +} # # Hook called after we run all the late customize commands, but # before we invoke the disk imager. The nopriv build uses it to # read in the meta log, apply the changes other parts of nanobsd # have been recording their actions. It's not anticipated that # a user's cfg file would override this. # -fixup_before_diskimage ( ) ( +fixup_before_diskimage() { # Run the deduplication script that takes the metalog journal and # combines multiple entries for the same file (see source for # details). We take the extra step of removing the size keywords. This # script, and many of the user scripts, copies, appends and otherwise # modifies files in the build, changing their sizes. These actions are # impossible to trap, so go ahead remove the size= keyword. For this # narrow use, it doesn't buy us any protection and just gets in the way. # The dedup tool's output must be sorted due to limitations in awk. if [ -n "${NANO_METALOG}" ]; then pprint 2 "Fixing metalog" cp ${NANO_METALOG} ${NANO_METALOG}.pre echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" > ${NANO_METALOG} cat ${NANO_METALOG}.pre | ${NANO_TOOLS}/mtree-dedup.awk | \ sed -e 's/ size=[0-9][0-9]*//' | sort >> ${NANO_METALOG} fi -) +} -setup_nanobsd ( ) ( +setup_nanobsd() { pprint 2 "configure nanobsd setup" pprint 3 "log: ${NANO_LOG}/_.dl" ( cd "${NANO_WORLDDIR}" # Move /usr/local/etc to /etc/local so that the /cfg stuff # can stomp on it. Otherwise packages like ipsec-tools which # have hardcoded paths under ${prefix}/etc are not tweakable. if [ -d usr/local/etc ] ; then ( cd usr/local/etc find . -print | cpio ${CPIO_SYMLINK} -dumpl ../../../etc/local cd .. rm -xrf etc ) fi # Always setup the usr/local/etc -> etc/local symlink. # usr/local/etc gets created by packages, but if no packages # are installed by this point, but are later in the process, # the symlink not being here causes problems. It never hurts # to have the symlink in error though. ln -sf ../../etc/local usr/local/etc for d in var etc do # link /$d under /conf # we use hard links so we have them both places. # the files in /$d will be hidden by the mount. mkdir -p conf/base/$d conf/default/$d find $d -print | cpio ${CPIO_SYMLINK} -dumpl conf/base/ done echo "$NANO_RAM_ETCSIZE" > conf/base/etc/md_size echo "$NANO_RAM_TMPVARSIZE" > conf/base/var/md_size # pick up config files from the special partition echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount # Put /tmp on the /var ramdisk (could be symlink already) tgt_dir2symlink tmp var/tmp ) > ${NANO_LOG}/_.dl 2>&1 -) +} -setup_nanobsd_etc ( ) ( +setup_nanobsd_etc() { pprint 2 "configure nanobsd /etc" ( cd "${NANO_WORLDDIR}" # create diskless marker file touch etc/diskless [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 666 boot/defaults/loader.conf { echo echo '### NanoBSD configuration ##################################' echo 'hostuuid_load="NO"' echo 'entropy_cache_load="NO" # Disable loading cached entropy at boot time.' echo 'kern.random.initial_seeding.disable_bypass_warnings="1" # Do not log a warning' echo " # if the 'bypass_before_seeding' knob is enabled" echo " # and a request is submitted prior to initial" echo " # seeding." } >> boot/defaults/loader.conf [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 boot/defaults/loader.conf [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 666 etc/defaults/rc.conf if ! ed -s etc/defaults/rc.conf <<\EOF /^### Define source_rc_confs, the mechanism used by \/etc\/rc\.\* ##$/i ### NanoBSD options ######################################## ############################################################## kldxref_enable="NO" # Disable building linker.hints files with kldxref(8). root_rw_mount="NO" # Inhibit remounting root read-write. entropy_boot_file="NO" # Disable very early (used at early boot time) # entropy caching through reboots. entropy_file="NO" # Disable late (used when going multi-user) # entropy through reboots. entropy_dir="NO" # Disable caching entropy via cron. ############################################################## . w q EOF then echo "Regular expression pattern not found" exit 2 fi [ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf # save config file for scripts echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf echo "/dev/${NANO_DRIVE}${NANO_ROOT} / ufs ro 1 1" > etc/fstab echo "/dev/${NANO_DRIVE}${NANO_SLICE_CFG} /cfg ufs rw,noauto 2 2" >> etc/fstab mkdir -p cfg # Create directory for eventual /usr/local/etc contents mkdir -p etc/local ) -) +} -prune_usr ( ) ( +prune_usr() { # Remove all empty directories in /usr find "${NANO_WORLDDIR}"/usr -type d -depth -print | while read d do rmdir $d > /dev/null 2>&1 || true done -) +} -newfs_part ( ) ( +newfs_part() { local dev mnt lbl dev=$1 mnt=$2 lbl=$3 echo newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev} newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev} mount -o async ${dev} ${mnt} -) +} # Convenient spot to work around any umount issues that your build environment # hits by overriding this method. -nano_umount ( ) ( +nano_umount() { umount ${1} -) +} -populate_slice ( ) ( +populate_slice() { local dev dir mnt lbl dev=$1 dir=$2 mnt=$3 lbl=$4 echo "Creating ${dev} (mounting on ${mnt})" newfs_part ${dev} ${mnt} ${lbl} if [ -n "${dir}" -a -d "${dir}" ]; then echo "Populating ${lbl} from ${dir}" cd "${dir}" find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio ${CPIO_SYMLINK} -dumpv ${mnt} fi df -i ${mnt} nano_umount ${mnt} -) +} -populate_cfg_slice ( ) ( +populate_cfg_slice() { populate_slice "$1" "$2" "$3" "$4" -) +} -populate_data_slice ( ) ( +populate_data_slice() { populate_slice "$1" "$2" "$3" "$4" -) +} -last_orders ( ) ( +last_orders() { # Redefine this function with any last orders you may have # after the build completed, for instance to copy the finished # image to a more convenient place: # cp ${NANO_DISKIMGDIR}/${NANO_IMG1NAME} /home/ftp/pub/nanobsd.disk true -) +} ####################################################################### # # Optional convenience functions. # ####################################################################### ####################################################################### # Common Flash device geometries # -FlashDevice ( ) { +FlashDevice() { if [ -d ${NANO_TOOLS} ] ; then . ${NANO_TOOLS}/FlashDevice.sub else . ${NANO_SRC}/${NANO_TOOLS}/FlashDevice.sub fi sub_FlashDevice $1 $2 } ####################################################################### # USB device geometries # # Usage: # UsbDevice Generic 1000 # a generic flash key sold as having 1GB # # This function will set NANO_MEDIASIZE, NANO_HEADS and NANO_SECTS for you. # # Note that the capacity of a flash key is usually advertised in MB or # GB, *not* MiB/GiB. As such, the precise number of cylinders available # for C/H/S geometry may vary depending on the actual flash geometry. # # The following generic device layouts are understood: # generic An alias for generic-hdd. # generic-hdd 255H 63S/T xxxxC with no MBR restrictions. # generic-fdd 64H 32S/T xxxxC with no MBR restrictions. # # The generic-hdd device is preferred for flash devices larger than 1GB. # -UsbDevice ( ) { - a1=`echo $1 | tr '[:upper:]' '[:lower:]'` +UsbDevice() { + local a1=`echo $1 | tr '[:upper:]' '[:lower:]'` case $a1 in generic-fdd) NANO_HEADS=64 NANO_SECTS=32 NANO_MEDIASIZE=$(( $2 * 1000 * 1000 / 512 )) ;; generic|generic-hdd) NANO_HEADS=255 NANO_SECTS=63 NANO_MEDIASIZE=$(( $2 * 1000 * 1000 / 512 )) ;; *) echo "Unknown USB flash device" exit 2 ;; esac } ####################################################################### # Setup serial console -cust_comconsole ( ) ( +cust_comconsole() { # Enable getty on console sed -i "" -e '/^tty[du]0/s/off/onifconsole/' ${NANO_WORLDDIR}/etc/ttys # Disable getty on syscons or vt devices sed -i "" -E '/^ttyv[0-8]/s/\ton(ifexists)?/\toff/' ${NANO_WORLDDIR}/etc/ttys # Tell loader to use serial console early. echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config -) +} ####################################################################### # Allow root login via ssh -cust_allow_ssh_root ( ) ( +cust_allow_ssh_root() { sed -i "" -E 's/^#?PermitRootLogin.*/PermitRootLogin yes/' \ ${NANO_WORLDDIR}/etc/ssh/sshd_config -) +} ####################################################################### # Install the stuff under ./Files -cust_install_files ( ) ( +cust_install_files() { cd "${NANO_TOOLS}/Files" find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio ${CPIO_SYMLINK} -Ldumpv ${NANO_WORLDDIR} if [ -n "${NANO_CUST_FILES_MTREE}" -a -f ${NANO_CUST_FILES_MTREE} ]; then CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE} fi -) +} ####################################################################### # Install packages from ${NANO_PACKAGE_DIR} -cust_pkgng ( ) ( +cust_pkgng() { mkdir -p ${NANO_WORLDDIR}/usr/local/etc local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf" local PKGCMD="env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=${NANO_PKG_META_BASE}/pkg SIGNATURE_TYPE=none /usr/sbin/pkg" # Ensure pkg.conf points pkg to where the package meta data lives. touch ${PKG_CONF} if grep -Eiq '^PKG_DBDIR:.*' ${PKG_CONF}; then sed -i -e "\|^PKG_DBDIR:.*|Is||PKG_DBDIR: "\"${NANO_PKG_META_BASE}/pkg\""|" ${PKG_CONF} else echo "PKG_DBDIR: \"${NANO_PKG_META_BASE}/pkg\"" >> ${PKG_CONF} fi # If the package directory doesn't exist, we're done. NANO_PACKAGE_DIR="$(realpath $NANO_PACKAGE_DIR)" 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 # Mount packages into chroot mkdir -p ${NANO_WORLDDIR}/_.p mount -t nullfs -o noatime -o ro ${NANO_PACKAGE_DIR} ${NANO_WORLDDIR}/_.p mount -t devfs devfs ${NANO_WORLDDIR}/dev trap "umount ${NANO_WORLDDIR}/dev; umount ${NANO_WORLDDIR}/_.p ; rm -xrf ${NANO_WORLDDIR}/_.p" 1 2 15 EXIT # Install pkg-* package CR "${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}" ( # Expand any glob characters in package list cd "${NANO_PACKAGE_DIR}" _PKGS=`find ${NANO_PACKAGE_LIST} -not -name "${_NANO_PKG_PACKAGE}" -print | sort | uniq` # Show todo todo=`echo "$_PKGS" | wc -l` echo "=== TODO: $todo" echo "$_PKGS" echo "===" # Install packages for _PKG in $_PKGS; do CR "${PKGCMD} add /_.p/${_PKG}" done ) CR0 "${PKGCMD} info" trap - 1 2 15 EXIT umount ${NANO_WORLDDIR}/dev umount ${NANO_WORLDDIR}/_.p rm -xrf ${NANO_WORLDDIR}/_.p -) +} ####################################################################### # Convenience function: # Register all args as early customize function to run just before # build commences. -early_customize_cmd ( ) { +early_customize_cmd() { NANO_EARLY_CUSTOMIZE="$NANO_EARLY_CUSTOMIZE $*" } ####################################################################### # Convenience function: # Register all args as customize function. -customize_cmd ( ) { +customize_cmd() { NANO_CUSTOMIZE="$NANO_CUSTOMIZE $*" } ####################################################################### # Convenience function: # Register all args as late customize function to run just before # image creation. -late_customize_cmd ( ) { +late_customize_cmd() { NANO_LATE_CUSTOMIZE="$NANO_LATE_CUSTOMIZE $*" } ####################################################################### # # All set up to go... # ####################################################################### # Progress Print # Print $2 at level $1. -pprint ( ) ( +pprint() { if [ "$1" -le $PPLEVEL ]; then runtime=$(( `date +%s` - $NANO_STARTTIME )) printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3 fi -) +} -usage ( ) { +usage() { ( echo "Usage: $0 [-BbfhIiKknpqvWwX] [-c config_file]" echo " -B suppress installs (both kernel and world)" echo " -b suppress builds (both kernel and world)" echo " -c specify config file" echo " -f suppress code slice extraction (implies -i)" echo " -h print this help summary page" echo " -I build disk image from existing build/install" echo " -i suppress disk image build" echo " -K suppress installkernel" echo " -k suppress buildkernel" echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc" echo " -p suppress preparing the image" echo " -q make output more quiet" echo " -v make output more verbose" echo " -W suppress installworld" echo " -w suppress buildworld" echo " -X make native-xtools" ) 1>&2 exit 2 } ####################################################################### # Setup and Export Internal variables # -export_var ( ) { # Don't want a subshell +export_var() { var=$1 # Lookup value of the variable. eval val=\$$var pprint 3 "Setting variable: $var=\"$val\"" export $1 } # Call this function to set defaults _after_ parsing options. -# don't want a subshell otherwise variable setting is thrown away. -set_defaults_and_export ( ) { +set_defaults_and_export() { : ${NANO_OBJ:=/usr/obj/nanobsd.${NANO_NAME}${NANO_LAYOUT:+.${NANO_LAYOUT}}} : ${MAKEOBJDIRPREFIX:=${NANO_OBJ}} : ${NANO_DISKIMGDIR:=${NANO_OBJ}} : ${NANO_WORLDDIR:=${NANO_OBJ}/_.w} : ${NANO_LOG:=${NANO_OBJ}} : ${NANO_PMAKE:="${NANO_MAKE} -j ${NANO_NCPU}"} if ! $do_clean; then NANO_PMAKE="${NANO_PMAKE} -DNO_CLEAN" fi NANO_MAKE_CONF_BUILD=${MAKEOBJDIRPREFIX}/make.conf.build NANO_MAKE_CONF_INSTALL=${NANO_OBJ}/make.conf.install # Override user's NANO_DRIVE if they specified a NANO_LABEL [ -n "${NANO_LABEL}" ] && NANO_DRIVE="ufs/${NANO_LABEL}" || true # Set a default NANO_TOOLS to NANO_SRC/NANO_TOOLS if it exists. [ ! -d "${NANO_TOOLS}" ] && [ -d "${NANO_SRC}/${NANO_TOOLS}" ] && \ NANO_TOOLS="${NANO_SRC}/${NANO_TOOLS}" || true [ -n "${NANO_NOPRIV_BUILD}" ] && [ -z "${NANO_METALOG}" ] && \ NANO_METALOG=${NANO_OBJ}/_.metalog || true NANO_STARTTIME=`date +%s` pprint 3 "Exporting NanoBSD variables" export_var MAKEOBJDIRPREFIX export_var NANO_ARCH export_var NANO_CODESIZE export_var NANO_CONFSIZE export_var NANO_CUSTOMIZE export_var NANO_DATASIZE export_var NANO_DRIVE export_var NANO_HEADS export_var NANO_IMAGES export_var NANO_IMGNAME export_var NANO_IMG1NAME export_var NANO_MAKE export_var NANO_MAKE_CONF_BUILD export_var NANO_MAKE_CONF_INSTALL export_var NANO_MEDIASIZE export_var NANO_NAME export_var NANO_NCPU export_var NANO_NEWFS export_var NANO_OBJ export_var NANO_PMAKE export_var NANO_SECTS export_var NANO_SRC export_var NANO_TOOLS export_var NANO_WORLDDIR export_var NANO_BOOT0CFG export_var NANO_BOOTLOADER export_var NANO_LABEL export_var NANO_MODULES export_var NANO_NOPRIV_BUILD export_var NANO_METALOG export_var NANO_LOG export_var SRCCONF export_var SRC_ENV_CONF } diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common index 4aecd3602f6f..132ca9e2ba5b 100644 --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -1,635 +1,635 @@ - +#!/bin/sh #- # Copyright (c) 2015 M. Warner Losh # Copyright (c) 2010-2011 iXsystems, Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL iXsystems, Inc OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # This file is heavily derived from both Sam Leffler's Avilia config, # as well as the BSDRP project's config file. Neither of these have # an explicit copyright/license statement, but are implicitly BSDL. This # example has been taken from the FreeNAS project (an early version) and # simplified to meet the needs of the example. # # NB: You want the other file as the command line arg :) # Missing in base: # o mkimg setting active partition # o mkimg starting at arbitrary offset (needed for A10, et al) # o mtools still needed because we have no makefs -t msdos # o nanobsd doesn't record changes to WORLDTEMP in customization # scripts yet, so we have kludge to pick up all files # o easy way for pkg to grab files from other repos and put that # data on the image # o Need to have some way to create / resize the s4 slice to do ping # pong bouncing between s3 and s4 for an arbitrary image. we can resize # one slice, not two # o hints in the uboot ports for how to create the image # # Missing here # o documentation for how to run the qemu images # o msdos mtools fallback # o special boot for !x86 !arm platforms # o qemu image for aarch64 # o qemu image for armv7 # o easy support for different image / vm formats # o need to promote much of this to nanobsd.sh and friends # o uses old kludge to build image w/o ownership being right # for many files. Should move to mtree-dedup.awk. # o support for EFI images # o support for GPT partitioning # # Long Term # o common tooling for creating images for odd-ball platforms # o support for boot loaders other than uboot in the image # or via special instructions # o no pony support; sadly, you cannot have a pony # if [ -z $NANO_NAME ]; then echo "NANO_NAME not defined. Use foo.cfg instead." fi NANO_SLICE_FAT_SIZE=32m NANO_SLICE_CFG_SIZE=32m NANO_BOOT2CFG="-h -S115200" NANO_RAM_ETCSIZE=8192 NANO_RAM_TMPVARSIZE=8192 NANO_IMAGES=2 NANO_PMAKE="make -j $(sysctl -n hw.ncpu)" NANO_CFG_BASE=$(pwd) NANO_CFG_BASE=$(realpath ${NANO_CFG_BASE}/..) NANO_SRC=$(realpath ${NANO_CFG_BASE}/../../..) #### XXX share obj if [ -z ${NANO_CPUTYPE} ]; then NANO_OBJ=${NANO_SRC}/../embedded/obj else # Alas, I can't set OBJTREE to ${MACHINE}.${MACHINE_ARCH}.${CPUTYPE} # so this will have to do until I can. NANO_OBJ=${NANO_SRC}/../embedded/obj.${NANO_CPUTYPE} fi NANO_LOG=${NANO_OBJ}/../${NANO_NAME} NANO_DISKIMGDIR=${NANO_OBJ}/../images NANO_WORLDDIR=${NANO_LOG}/_.w NANO_INIT_IMG2=0 NANO_NOPRIV_BUILD=t unset MAKEOBJDIRPREFIX mkdir -p ${NANO_OBJ} NANO_OBJ=$(realpath ${NANO_OBJ}) mkdir -p ${NANO_LOG} NANO_LOG=$(realpath ${NANO_LOG}) mkdir -p ${NANO_WORLDDIR} NANO_WORLDDIR=$(realpath ${NANO_WORLDDIR}) mkdir -p ${NANO_DISKIMGDIR} NANO_DISKIMGDIR=$(realpath ${NANO_DISKIMGDIR}) NANO_FAT_DIR=${NANO_LOG}/_.fat customize_cmd cust_allow_ssh_root -add_etc_make_conf ( ) ( +add_etc_make_conf() { touch ${NANO_WORLDDIR}/etc/make.conf -) +} customize_cmd add_etc_make_conf -cust_install_machine_files ( ) ( +cust_install_machine_files() { echo "cd ${NANO_CFG_BASE}/Files" cd ${NANO_CFG_BASE}/Files find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${NANO_WORLDDIR} -) +} customize_cmd cust_install_files -customize_cmd cust_install_machine_files +customize_cmd cust_install_machine_files CONF_BUILD=" LOCAL_XTOOL_DIRS=usr.bin/mkimg WITHOUT_ACPI=true WITHOUT_AUDIT=true WITHOUT_BLUETOOTH=true WITHOUT_CALENDAR=true WITHOUT_DICT=true WITHOUT_EXAMPLES=true WITHOUT_GAMES=true WITHOUT_HTML=true WITHOUT_IPFILTER=true WITHOUT_LLVM_COV=true WITHOUT_LOCALES=true WITHOUT_LPR=true WITHOUT_MAN=true WITHOUT_NETCAT=true WITHOUT_NIS=true WITHOUT_NLS=true WITHOUT_NS_CACHING=true WITHOUT_PROFILE=true WITHOUT_SENDMAIL=true WITHOUT_SHAREDOCS=true WITHOUT_SYSCONS=true WITHOUT_LIB32=true WITHOUT_TESTS=true WITHOUT_DEBUG_FILES=t WITHOUT_KERNEL_SYMBOLS=t " CONF_INSTALL="$CONF_BUILD INSTALL_NODEBUG=t NOPORTDOCS=t NO_INSTALL_MANPAGES=t " # The following would help... # WITHOUT_TOOLCHAIN=true can't build ports # WITHOUT_INSTALLLIB=true libgcc.a # # from the build PKG_ONLY_MAKE_CONF=" WITHOUT_TOOLCHAIN=true WITHOUT_INSTALLLIB=true " NANO_PACKAGE_ONLY=1 # Creates images for all the formats that use MBR / GPT # split later if the #ifdef soup gets too bad. -create_diskimage_gpt ( ) ( +create_diskimage_gpt() { pprint 2 "build diskimage gpt ${NANO_NAME}" create_diskimage_mbr $* -) +} -create_diskimage_mbr ( ) ( +create_diskimage_mbr() { local fmt [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}" pprint 2 "build diskimage ${NANO_NAME}" pprint 3 "log: ${NANO_LOG}/_.di" pprint 3 "image in: ${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt}" ( local extra i sz fmt fmtarg bootmbr bootbsd skiparg set -o xtrace # Tell mtools not to be too picky export MTOOLS_SKIP_CHECK=1 [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}" [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}" bootmbr=${NANO_BOOT_MBR:+-b ${NANO_BOOT_MBR}} bootbsd=${NANO_BOOT_BSD:+-b ${NANO_BOOT_BSD}} skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}} for i in s1 s2 s3 s4 p1 p2 p3 p4 p5 empty; do rm -fr ${NANO_LOG}/_.${i}* done # Populate the FAT partition, if needed if [ -n "${NANO_SLICE_FAT}" ]; then echo Creating MSDOS partition for kernel newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \ ${NANO_LOG}/_.${NANO_SLICE_FAT} if [ -d ${NANO_FAT_DIR} ]; then # Need to copy files from ${NANO_FATDIR} with mtools, or use # makefs -t msdos once that's supported mcopy -s -i ${NANO_LOG}/_.${NANO_SLICE_FAT} ${NANO_FAT_DIR}/* :: fi fi # Populate the Powerpc boot image, if needed if [ "${NANO_LAYOUT}" = powerpc64-ibm ]; then dd if=${NANO_WORLDDIR}/boot/boot1.elf of=${NANO_LOG}/_.s1 bs=800k count=1 conv=sync fi # Populate the / partition, and place it into a slice with a # bsd label [ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}" sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}} eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_LOG}/_.${NANO_ROOT}" \ "${NANO_WORLDDIR}" case ${NANO_DISK_SCHEME} in mbr) mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_LOG}/_.${NANO_ROOT} \ -o ${NANO_LOG}/_.${NANO_SLICE_ROOT} eval $NANO_SLICE_CFG=freebsd eval $NANO_SLICE_ROOT=freebsd ;; gpt) eval $NANO_SLICE_CFG=freebsd-ufs eval $NANO_SLICE_ROOT=freebsd-ufs ;; esac # Populate the /cfg partition, empty if none given if [ -z "${NANO_CFGDIR}" ]; then echo "Faking cfg dir, it's empty" NANO_CFGDIR=${NANO_LOG}/_.empty mkdir -p ${NANO_CFGDIR} fi # XXX -F cfg-mtree eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \ "${NANO_LOG}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}" # data slice not supported since we need the part for FAT for # booting # Now shuffle all the slices together into the proper layout if [ -n "$NANO_SLICE_FAT" ]; then eval $NANO_SLICE_FAT=fat16b fi out=${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt} # below depends on https://reviews.freebsd.org/D4403 not yet in the tree # but there's problems: it marks all partitions as active, so you have to # boot off partition 3 or 2 by hand if you're playing around with this WIP case ${NANO_LAYOUT} in std-embedded) mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \ -p ${s2}:=${NANO_LOG}/_.s2 \ -p ${s3}:=${NANO_LOG}/_.s3 \ -o ${out} ;; std-x86) # s3 is cfg, s1 is /, s2 is other / (s2 is created in first boot script) mkimg -a 1 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \ -p- \ -p ${s3}:=${NANO_LOG}/_.s3 \ -o ${out} ;; std-uefi) # s1 is boot, s2 is cfg, s3 is /, not sure how to make that # boot (marked as active) with mkimg yet mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr \ -p efi:=${NANO_WORLDDIR}/boot/efiboot.img \ -p ${s2}:=${NANO_LOG}/_.s2 \ -p ${s3}:=${NANO_LOG}/_.s3 \ -o ${out} ;; std-uefi-bios) # p1 is boot for uefi, p2 is boot for gpt, p3 is cfg, p4 is / # and p5 is alt-root (after resize) mkimg -a 2 ${fmtarg} ${bootmbr} -s gpt \ -p efi/efiboot0:=${NANO_WORLDDIR}/boot/efiboot.img \ -p freebsd-boot:=${NANO_WORLDDIR}/boot/gptboot \ -p ${p3}/cfg:=${NANO_LOG}/_.p3 \ -p ${p4}:=${NANO_LOG}/_.p4 \ -o ${out} ;; powerpc64-ibm) # A lie to make the boot loader work, it boots the first BSD partition # it finds, regardless of the active flag. s2=fat16b # boot image is on a special partition, ala std-embedded, but that # partition isn't FAT with special files, but a copy of the boot # loader itself. mkimg -a 1 ${fmtarg} -s mbr -p prepboot:=${NANO_LOG}/_.s1 \ -p ${s2}:=${NANO_LOG}/_.s2 \ -p ${s3}:=${NANO_LOG}/_.s3a \ -o ${out} ;; esac rm -f ${out}.xz xz -9 --keep ${out} ) > ${NANO_LOG}/_.di 2>&1 -) +} die( ) { echo "$*" exit 1 } # Automatically include the packaging port here so it is always first so it # builds the port and adds the package so we can add other packages. #XXX Doesn't work for cross build, so punting until I can integreate qemu-static #XXX or poudriere, both of which require priv'd execution. Or qemu-system, #XXX which is super, super slow. #add_port ports-mgmt/pkg #add_port security/sudo #add_port ftp/curl rp=$(realpath ${NANO_OBJ}/) __a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'` if [ -n "$__a" ]; then echo "unmounting $__a" umount $__a fi if [ "$DEBUG" = 1 ]; then DEBUG_BUILD=" DEBUG_FLAGS= -g " else DEBUG_INSTALL=" INSTALL_NODEBUG= t " fi CONF_INSTALL="$CONF_BUILD ${DEBUG_BUILD} " CONF_INSTALL="$CONF_INSTALL ${DEBUG_INSTALL} " if [ "${NANO_PACKAGE_ONLY}" -eq 1 ]; then CONF_INSTALL="${CONF_INSTALL} ${PKG_ONLY_MAKE_CONF} " echo "Automatically building a thin image with packages" else echo "Automatically building a * * F A T * * image so we can build ports" fi VARS="MASTER_SITE_BACKUP MASTER_SITE_OVERRIDE PACKAGEROOT PACKAGESITE" for var in $VARS; do val=$(eval echo "\$$var") if [ -n "$val" ]; then CONF_INSTALL="${CONF_INSTALL} $var=$val" fi done -typical_embedded ( ) ( +typical_embedded() { # Need to create rc.conf before we copy over /etc to /conf/base/etc # so now's a good time. local rc=${NANO_WORLDDIR}/etc/rc.conf echo "hostname=nanobsd-${NANO_NAME}" > $rc echo "growfs_enable=YES" >> $rc echo "growfs_type=nanobsd-pingpong" >> $rc echo "ntpdate_enable=YES" >> $rc echo "ifconfig_DEFAULT=DHCP" >> $rc echo "ntpdate_hosts='0.freebsd.pool.ntp.org 1.freebsd.pool.ntp.org'" >> $rc # Make sure that firstboot scripts run so growfs works. # Note: still some issues remvoing this XXX touch ${NANO_WORLDDIR}/firstboot -) +} customize_cmd typical_embedded -fix_pkg ( ) ( +fix_pkg() { chdir ${NANO_WORLDDIR} mkdir -p pkg mkdir -p pkg/db mkdir -p pkg/cache mkdir -p pkg/tmp # Needed for pkg bootstrap mkdir -p usr/local/etc # Will get moved to local/etc ( echo 'PKG_DBDIR = "/pkg/db"' echo 'PKG_CACHEDIR = "/pkg/cache"' echo 'DEFAULT_ALWAYS_YES = "yes"' echo 'ASSUME_ALWAYS_YES = "yes"' ) >> usr/local/etc/pkg.conf [ -z ${NANO_NOPRIV_BUILD} ] || ( echo "./pkg type=dir uname=root gname=wheel mode=0755" echo "./pkg/cache type=dir uname=root gname=wheel mode=0755" echo "./pkg/db type=dir uname=root gname=wheel mode=0755" echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755" ) >> ${NANO_METALOG} -) +} customize_cmd fix_pkg -save_build ( ) ( +save_build() { VERSION_FILE=${NANO_WORLDDIR}/etc/version if [ "${SVNREVISION}" = "${REVISION}" ]; then echo "${NANO_NAME}" > "${VERSION_FILE}" else echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}" fi -) +} customize_cmd save_build -shrink_md_fbsize ( ) ( +shrink_md_fbsize() { # We have a lot of little files on our memory disks. Let's decrease # the block and frag size to fit more little files on them (this # halves our space requirement by ~50% on /etc and /var on 8.x -- # and gives us more back on 9.x as the default block and frag size # are 4 times larger). sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \ ${NANO_WORLDDIR}/etc/rc.initdiskless -) +} customize_cmd shrink_md_fbsize customize_cmd cust_comconsole -dos_boot_part ( ) ( +dos_boot_part() { local d=/usr/local/share/u-boot/${NANO_BOOT_PKG} local f=${NANO_FAT_DIR} # For now, just copy all the files. However, for iMX6 and Allwinner, # we'll need to put a special boot block at a fixed location # on the disk as well. rm -rf $f mkdir $f chdir $f cp ${d}/* . # We have to touch the saveenv file touch uEnv.txt # Now we need to copy over dtb files from the build. cp ${NANO_WORLDDIR}/boot/dtb/*.dtb . -) +} if [ -n "$NANO_BOOT_PKG" ]; then d=/usr/local/share/u-boot/${NANO_BOOT_PKG} if [ ! -d ${d} ]; then echo ${NANO_BOOT_PKG} not installed. Sadly, it must be. exit 1 fi if [ ! -x /usr/local/bin/mcopy ]; then echo mtools not installed. Sadly, we gotta have it. exit 1 fi customize_cmd dos_boot_part fi -product_custom ( ) ( +product_custom() { # not quite ready to tweak these in nopriv build if [ -z ${NANO_NOPRIV_BUILD} ]; then # Last second tweaks -- generally not needed chown -R root:wheel ${NANO_WORLDDIR}/root chmod 0755 ${NANO_WORLDDIR}/root/* chmod 0755 ${NANO_WORLDDIR}/* chown -R root:wheel ${NANO_WORLDDIR}/etc chown -R root:wheel ${NANO_WORLDDIR}/boot chown root:wheel ${NANO_WORLDDIR}/ chown root:wheel ${NANO_WORLDDIR}/usr fi -) +} late_customize_cmd product_custom # # Convenience routines to bring up many settings for standard environments # # # For each architecture, we have a standard set of settings to the extent # it makes sense. For architectures that don't have a standard environment # cfg files need to either define a lot of settings, provide their own disk # imaging, or set which of the variants we support. No subshells, since we # set global variables # std_aarch64 ( ) { } std_amd64 ( ) { std_i386 } std_armv7 ( ) { } std_i386 ( ) { # Default values, if not overridden in .cfg file : ${NANO_KERNEL:=GENERIC} : ${NANO_DRIVE:=ada0} : ${NANO_LAYOUT:=std-x86} : ${NANO_BOOT_MBR:=${NANO_WORLDDIR}/boot/boot0sio} : ${NANO_BOOT_BSD:=${NANO_WORLDDIR}/boot/boot} } std_powerpc ( ) { NANO_ENDIAN=big } std_powerpc64 ( ) { NANO_LAYOUT=powerpc64-ibm NANO_ENDIAN=big } # # QEMU settings for the standard environments # qemu_env ( ) { NANO_DISKIMAGE_FORMAT=qcow2 } # other standard environments will go here eval std_${NANO_ARCH} # Slice 1: FAT for ROM loading bootstrap # Slice 2: Config partition # Slice 3: FreeBSD partition (sized exactly) # Slice 4: FreeBSD partition (empty) # on first boot, we resize slice 3 & 4 to be 1/2 of what's # left over on the SD card after slice 1 and 2 are taken # off the top. We also resize the 'a' partition on first boot # to the size of the partition for the ping/pong upgrade. # This feature needs support in the rc.d bootup script. # # Ideally, we'd not put BSD labels on the MBR disks. # However, we can't boot off raw MBR disks. First, # boot2 defaults to 'a' partition, and freaks out # unless you tell it to use 'c'. But even if we # hack that, then /boot/loader wants to load off # of 'c' partition. If you fix that, then we'll # try to mount root, but sanity checks prevent # slices from working. # : ${NANO_ENDIAN:=little} # make -V something to figure it out? : ${NANO_LAYOUT:=std-embedded} : ${NANO_MAKEFS_UFS:=makefs -t ffs -B ${NANO_ENDIAN}} : ${NANO_DISK_SCHEME:=mbr} # No others really supported ATM (well, gpt) case ${NANO_LAYOUT} in std-embedded) NANO_SLICE_FAT=s1 NANO_SLICE_CFG=s2 NANO_SLICE_ROOT=s3 NANO_SLICE_ALTROOT=s4 NANO_ROOT=${NANO_SLICE_ROOT}a NANO_ALTROOT=${NANO_SLICE_ALTROOT}a ;; std-x86) NANO_SLICE_CFG=s3 NANO_SLICE_ROOT=s1 NANO_SLICE_ALTROOT=s2 NANO_ROOT=${NANO_SLICE_ROOT}a NANO_ALTROOT=${NANO_SLICE_ALTROOT}a ;; powerpc64-ibm) NANO_SLICE_PPCBOOT=s1 NANO_SLICE_CFG=s2 NANO_SLICE_ROOT=s3 NANO_SLICE_ALTROOT=s4 NANO_ROOT=${NANO_SLICE_ROOT}a NANO_ALTROOT=${NANO_SLICE_ALTROOT}a ;; powerpc64-apple) echo Not yet exit 1 ;; std-uefi) NANO_SLICE_UEFI=s1 NANO_SLICE_CFG=s2 NANO_SLICE_ROOT=s3 NANO_SLICE_ALTROOT=s4 NANO_ROOT=${NANO_SLICE_ROOT} NANO_ALTROOT=${NANO_SLICE_ALTROOT} ;; std-uefi-bios) NANO_DISK_SCHEME=gpt NANO_SLICE_UEFI=p1 NANO_SLICE_BOOT=p2 NANO_SLICE_CFG=p3 NANO_SLICE_ROOT=p4 NANO_SLICE_ALTROOT=p5 NANO_ROOT=${NANO_SLICE_ROOT} NANO_ALTROOT=${NANO_SLICE_ALTROOT} ;; *) echo Unknown Layout ${NANO_LAYOUT} exit 1 ;; esac NANO_SLICE_DATA= # Not included # These don't make any sense to this strategy, so stub them out. -calculate_partitioning ( ) ( -) +calculate_partitioning() { +} # These don't make any sense to this strategy, so stub them out. -create_code_slice ( ) ( -) +create_code_slice() { +} # Each major disk scheme has its own routine. Generally # this is for mbr, gpt, etc. These are generally are widely # shared, but some specialized formats won't be shared. -create_diskimage ( ) ( +create_diskimage() { eval create_diskimage_${NANO_DISK_SCHEME} -) +} # Set the path to the same path we use for buldworld to use latest mkimg NANO_TARGET=$(cd ${NANO_SRC}; ${NANO_MAKE} TARGET_ARCH=${NANO_ARCH} -V _TARGET) NANO_TMPPATH=$(cd ${NANO_SRC}; ${NANO_MAKE} MK_AUTO_OBJ=no TARGET=${NANO_TARGET} TARGET_ARCH=${NANO_ARCH} -f Makefile.inc1 buildenv -V TMPPATH) export PATH="${NANO_TMPPATH}:${PATH}" diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh index 2f689212263e..cbe56d6f560c 100644 --- a/tools/tools/nanobsd/legacy.sh +++ b/tools/tools/nanobsd/legacy.sh @@ -1,246 +1,246 @@ #!/bin/sh # # Copyright (c) 2005 Poul-Henning Kamp All rights reserved. # Copyright (c) 2016 M. Warner Losh # # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Media geometry, only relevant if bios doesn't understand LBA. [ -n "$NANO_SECTS" ] || NANO_SECTS=63 [ -n "$NANO_HEADS" ] || NANO_HEADS=16 # Functions and variable definitions used by the legacy nanobsd # image building system. -calculate_partitioning ( ) ( +calculate_partitioning() { echo $NANO_MEDIASIZE $NANO_IMAGES \ $NANO_SECTS $NANO_HEADS \ $NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE | awk ' { # size of cylinder in sectors cs = $3 * $4 # number of full cylinders on media cyl = int ($1 / cs) if ($7 > 0) { # size of data partition in full cylinders dsl = int (($7 + cs - 1) / cs) } else { dsl = 0; } # size of config partition in full cylinders csl = int (($6 + cs - 1) / cs) # size of image partition(s) in full cylinders if ($5 == 0) { isl = int ((cyl - dsl - csl) / $2) } else { isl = int (($5 + cs - 1) / cs) } # First image partition start at second track print $3, isl * cs - $3, 1 c = isl * cs; # Second image partition (if any) also starts offset one # track to keep them identical. if ($2 > 1) { print $3 + c, isl * cs - $3, 2 c += isl * cs; } # Config partition starts at cylinder boundary. print c, csl * cs, 3 c += csl * cs # Data partition (if any) starts at cylinder boundary. if ($7 > 0) { print c, dsl * cs, 4 } else if ($7 < 0 && $1 > c) { print c, $1 - c, 4 } else if ($1 < c) { print "Disk space overcommitted by", \ c - $1, "sectors" > "/dev/stderr" exit 2 } } ' > ${NANO_LOG}/_.partitioning -) +} -create_code_slice ( ) ( +create_code_slice() { pprint 2 "build code slice" pprint 3 "log: ${NANO_OBJ}/_.cs" ( IMG=${NANO_DISKIMGDIR}/_.disk.image MNT=${NANO_OBJ}/_.mnt mkdir -p ${MNT} CODE_SIZE=`head -n 1 ${NANO_LOG}/_.partitioning | awk '{ print $2 }'` if [ "${NANO_MD_BACKING}" = "swap" ] ; then MD=`mdconfig -a -t swap -s ${CODE_SIZE} -x ${NANO_SECTS} \ -y ${NANO_HEADS}` else echo "Creating md backing file..." rm -f ${IMG} dd if=/dev/zero of=${IMG} seek=${CODE_SIZE} count=0 MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \ -y ${NANO_HEADS}` fi trap "echo 'Running exit trap code' ; df -i ${MNT} ; umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT gpart create -s bsd "${MD}" gpart add -t freebsd-ufs -b 16 "${MD}" if [ -f ${NANO_WORLDDIR}/boot/boot ]; then echo "Making bootable partition" gpart bootcode -b ${NANO_WORLDDIR}/boot/boot ${MD} else echo "Partition will not be bootable" fi gpart list ${MD} # Create first image populate_slice /dev/${MD}${NANO_PARTITION_ROOT} ${NANO_WORLDDIR} ${MNT} "${NANO_ROOT}" mount /dev/${MD}a ${MNT} echo "Generating mtree..." ( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree ( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du nano_umount ${MNT} if [ "${NANO_MD_BACKING}" = "swap" ] ; then echo "Writing out _.disk.image..." dd conv=sparse if=/dev/${MD} of=${NANO_DISKIMGDIR}/_.disk.image bs=64k fi mdconfig -d -u $MD trap - 1 2 15 EXIT ) > ${NANO_OBJ}/_.cs 2>&1 -) +} -create_diskimage ( ) ( +create_diskimage() { pprint 2 "build diskimage" pprint 3 "log: ${NANO_OBJ}/_.di" ( IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME} MNT=${NANO_OBJ}/_.mnt mkdir -p ${MNT} if [ "${NANO_MD_BACKING}" = "swap" ] ; then MD=`mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} \ -y ${NANO_HEADS}` else echo "Creating md backing file..." rm -f ${IMG} dd if=/dev/zero of=${IMG} seek=${NANO_MEDIASIZE} count=0 MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \ -y ${NANO_HEADS}` fi awk ' BEGIN { # Create MBR partition table print "gpart create -s mbr $1" } { # Make partition print "gpart add -t freebsd -b ", $1, " -s ", $2, " -i ", $3, " $1" } END { # Force slice 1 to be marked active. This is necessary # for booting the image from a USB device to work. print "gpart set -a active -i 1 $1" } ' ${NANO_LOG}/_.partitioning > ${NANO_OBJ}/_.gpart trap "echo 'Running exit trap code' ; df -i ${MNT} ; nano_umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT sh ${NANO_OBJ}/_.gpart ${MD} gpart show ${MD} # XXX: params # XXX: pick up cached boot* files, they may not be in image anymore. if [ -f ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ]; then gpart bootcode -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOTFLAGS} ${MD} fi echo "Writing code image..." dd conv=sparse if=${NANO_DISKIMGDIR}/_.disk.image of=/dev/${MD}${NANO_SLICE_ROOT} bs=64k if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then # Duplicate to second image (if present) echo "Duplicating to second image..." dd conv=sparse if=/dev/${MD}${NANO_SLICE_ROOT} of=/dev/${MD}${NANO_SLICE_ALTROOT} bs=64k mount /dev/${MD}${NANO_ALTROOT} ${MNT} for f in ${MNT}/etc/fstab ${MNT}/conf/base/etc/fstab do sed -i "" "s=${NANO_DRIVE}${NANO_SLICE_ROOT}=${NANO_DRIVE}${NANO_SLICE_ALTROOT}=g" $f done nano_umount ${MNT} # Override the label from the first partition so we # don't confuse glabel with duplicates. if [ -n "${NANO_LABEL}" ]; then tunefs -L ${NANO_LABEL}"${NANO_ALTROOT}" /dev/${MD}${NANO_ALTROOT} fi fi # Create Config slice populate_cfg_slice /dev/${MD}${NANO_SLICE_CFG} "${NANO_CFGDIR}" ${MNT} "${NANO_SLICE_CFG}" # Create Data slice, if any. if [ -n "$NANO_SLICE_DATA" -a "$NANO_SLICE_CFG" = "$NANO_SLICE_DATA" -a \ "$NANO_DATASIZE" -ne 0 ]; then pprint 2 "NANO_SLICE_DATA is the same as NANO_SLICE_CFG, fix." exit 2 fi if [ $NANO_DATASIZE -ne 0 -a -n "$NANO_SLICE_DATA" ] ; then populate_data_slice /dev/${MD}${NANO_SLICE_DATA} "${NANO_DATADIR}" ${MNT} "${NANO_SLICE_DATA}" fi if [ "${NANO_MD_BACKING}" = "swap" ] ; then if [ ${NANO_IMAGE_MBRONLY} ]; then echo "Writing out _.disk.mbr..." dd if=/dev/${MD} of=${NANO_DISKIMGDIR}/_.disk.mbr bs=512 count=1 else echo "Writing out ${NANO_IMGNAME}..." dd if=/dev/${MD} of=${IMG} bs=64k fi echo "Writing out ${NANO_IMGNAME}..." dd conv=sparse if=/dev/${MD} of=${IMG} bs=64k fi mdconfig -d -u $MD trap - 1 2 15 EXIT ) > ${NANO_LOG}/_.di 2>&1 -) +} diff --git a/tools/tools/nanobsd/rescue/common b/tools/tools/nanobsd/rescue/common index 15bf10f5e67d..a145a1ded32a 100644 --- a/tools/tools/nanobsd/rescue/common +++ b/tools/tools/nanobsd/rescue/common @@ -1,128 +1,128 @@ -# -# +#!/bin/sh + #NANO_SRC=$(pwd) #NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/rescue} #NANO_OBJ=${NANO_SRC}/../nanobsd-builds/${NANO_NAME}/obj NANO_TOOLS=`pwd` NANO_PACKAGE_DIR=`pwd`/Pkg NANO_RAM_TMPVARSIZE=40960 NANO_PMAKE="make -j 8" NANO_LABEL="rescue" NANO_RAM_TMPVARSIZE=40960 NANO_MEDIASIZE="6000000" NANO_SECTS="63" NANO_HEADS="16" NANO_IMAGES="2" NANO_INIT_IMG2="0" NANO_BOOT0CFG="-o packet,update,nosetdrv -s 1 -m 3" NANO_DRIVE=da0 #NANO_MODULES= NANO_BOOTLOADER="boot/boot0" NANO_BOOT2CFG="" NANO_MD_BACKING=file # Options to put in make.conf during buildworld only CONF_BUILD=' ' -# Options to put in make.conf during installworld only +# Options to put in make.conf during installworld only CONF_INSTALL=' ' -# Options to put in make.conf during both build- & installworld. -CONF_WORLD=' -CFLAGS=-O -pipe +# Options to put in make.conf during both build- & installworld. +CONF_WORLD=' +CFLAGS=-O -pipe # We do not need these for rescue WITHOUT_TESTS=true WITHOUT_DEBUG_FILES=true WITHOUT_KERNEL_SYMBOLS=true WITHOUT_CLANG_FULL=true WITH_CLANG_EXTRAS=true WITHOUT_LIB32=true ' # Functions toLower() { echo $1 | tr "[:upper:]" "[:lower:]" } toUpper() { echo $1 | tr "[:lower:]" "[:upper:]" } #customize_cmd cust_comconsole customize_cmd cust_allow_ssh_root customize_cmd cust_install_files #cust_ld32_cfg () ( # cd ${NANO_WORLDDIR}/libexec # if [ \! -f ld-elf32.so.1 ]; then # ln -s ld-elf.so.1 ld-elf32.so.1 # fi #) #customize_cmd cust_ld32_cfg # #cust_boot_cfg () ( # cd ${NANO_WORLDDIR} # echo "-S115200 -h" > boot.config # echo "console=\"comconsole\"" > boot/loader.conf # echo "comconsole_speed=\"115200\"" >> boot/loader.conf # echo "hint.acpi.0.disabled=\"1\"" >> boot/loader.conf #) #customize_cmd cust_boot_cfg #customize_cmd cust_pkgng -cust_etc_cfg () ( - cd ${NANO_WORLDDIR} -# mkdir -pv scratch +cust_etc_cfg() { + cd ${NANO_WORLDDIR} + # mkdir -pv scratch echo "hostname=\"rescue\"" > etc/rc.conf echo "font8x14=\"iso15-8x14\"" >> etc/rc.conf echo "font8x16=\"iso15-8x16\"" >> etc/rc.conf echo "font8x8=\"iso15-8x8\"" >> etc/rc.conf echo "keymap=\"german.iso\"" >> etc/rc.conf echo "#ifconfig_fxp0=\"AUTO\"" >> etc/rc.conf echo "#sshd_enable=\"YES\"" >> etc/rc.conf echo "/dev/ufs/${NANO_LABEL}s1a / ufs ro,noatime 0 0" > etc/fstab echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> etc/fstab echo "tmpfs /boot/zfs tmpfs rw,size=1048576,mode=777 0 0" >> etc/fstab echo "ports:/usr/ports /usr/ports nfs rw,noauto,noatime,bg,soft,intr,nfsv3 0 0" >> etc/fstab -# echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab + # echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab /usr/sbin/pwd_mkdb -d etc etc/master.passwd -) +} customize_cmd cust_etc_cfg -setup_nanobsd_etc ( ) ( +setup_nanobsd_etc() { pprint 2 "configure nanobsd /etc" ( cd ${NANO_WORLDDIR} # create diskless marker file touch etc/diskless # Make root filesystem R/O by default echo "root_rw_mount=NO" >> etc/defaults/rc.conf # save config file for scripts echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf mkdir -p cfg ) -) -last_orders () ( +} +last_orders() { pprint 2 "last orders" ( cd ${NANO_WORLDDIR} #makefs converts labels to uppercase anyways BIGLABEL=`toUpper "${NANO_LABEL}"` echo "/dev/iso9660/${BIGLABEL} / cd9660 ro,noatime 0 0" > etc/fstab echo "tmpfs /boot/zfs tmpfs rw,size=1048576,mode=777 0 0" >> etc/fstab echo "ports:/usr/ports /usr/ports nfs rw,noauto,noatime,bg,soft,intr,nfsv3 0 0" >> etc/fstab -# echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab + # echo "/dev/ad1s1a /scratch ufs rw,noauto,noatime 0 0" >> etc/fstab rm -f conf/default/etc/remount touch conf/default/etc/.keepme touch conf/default/var/.keepme mkdir bootpool mkdir mnt/a mkdir mnt/b mkdir mnt/c cd .. makefs -t cd9660 -o rockridge \ -o label="${BIGLABEL}" -o publisher="RMX" \ -o bootimage="i386;_.w/boot/cdboot" -o no-emul-boot _.disk.iso _.w/ ) -) +}