nanobsd: minor formatting cleanup

- Reformat function definitions

POSIX states that compound commands, i.e., ones that use `(..)` or
`{ .. } `, are permissible as function definitions, however, many shell
syntax validators do not acknowledge the former format.

Switch to the latter format so more naive editors, like the vim syntax
highlighter, better parse the syntax of the file.

Moreover, replacing `(..)` with `{..}` replaces several subshells with
their non-subshell equivalents. Given that `set -e` is used liberally
and `exit` is not used in the calling code when `set -e` is not
enforced, there is no net loss by making this change.

- Clean trailing whitespace.
- Reindent some related comments to match the indentation of the
  previous line.
- Add shebangs to the tops of files to help syntax colorizers and file
  identifiers understand that the files are in shell syntax.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D52596
This commit is contained in:
Enji Cooper
2025-09-17 11:06:43 -07:00
parent a37825313f
commit c99bb5747f
4 changed files with 130 additions and 132 deletions
+80 -82
View File
@@ -209,30 +209,29 @@ SRC_ENV_CONF=/dev/null
# #
####################################################################### #######################################################################
# Export values into the shell. Must use { } instead of ( ) like # Export values into the shell.
# other functions to avoid a subshell.
# We set __MAKE_CONF as a global since it is easier to get quoting # We set __MAKE_CONF as a global since it is easier to get quoting
# right for paths with spaces in them. # right for paths with spaces in them.
make_export ( ) { make_export() {
# Similar to export_var, except puts the data out to stdout # Similar to export_var, except puts the data out to stdout
var=$1 local var=$1
eval val=\$$var eval val=\$$var
echo "Setting variable: $var=\"$val\"" echo "Setting variable: $var=\"$val\""
export $1 export $1
} }
nano_make_build_env ( ) { nano_make_build_env() {
__MAKE_CONF="${NANO_MAKE_CONF_BUILD}" __MAKE_CONF="${NANO_MAKE_CONF_BUILD}"
make_export __MAKE_CONF make_export __MAKE_CONF
} }
nano_make_install_env ( ) { nano_make_install_env() {
__MAKE_CONF="${NANO_MAKE_CONF_INSTALL}" __MAKE_CONF="${NANO_MAKE_CONF_INSTALL}"
make_export __MAKE_CONF make_export __MAKE_CONF
} }
# Extra environment variables for kernel builds # Extra environment variables for kernel builds
nano_make_kernel_env ( ) { nano_make_kernel_env() {
if [ -f "${NANO_KERNEL}" ] ; then if [ -f "${NANO_KERNEL}" ] ; then
KERNCONFDIR="$(realpath $(dirname ${NANO_KERNEL}))" KERNCONFDIR="$(realpath $(dirname ${NANO_KERNEL}))"
KERNCONF="$(basename ${NANO_KERNEL})" KERNCONF="$(basename ${NANO_KERNEL})"
@@ -244,23 +243,23 @@ nano_make_kernel_env ( ) {
fi fi
} }
nano_global_make_env ( ) ( nano_global_make_env() {
# global settings for the make.conf file, if set # global settings for the make.conf file, if set
[ -z "${NANO_ARCH}" ] || echo TARGET_ARCH="${NANO_ARCH}" [ -z "${NANO_ARCH}" ] || echo TARGET_ARCH="${NANO_ARCH}"
[ -z "${NANO_CPUTYPE}" ] || echo TARGET_CPUTYPE="${NANO_CPUTYPE}" [ -z "${NANO_CPUTYPE}" ] || echo TARGET_CPUTYPE="${NANO_CPUTYPE}"
) }
# #
# Create empty files in the target tree, and record the fact. All paths # Create empty files in the target tree, and record the fact. All paths
# are relative to NANO_WORLDDIR. # are relative to NANO_WORLDDIR.
# #
tgt_touch ( ) ( tgt_touch() {
cd "${NANO_WORLDDIR}" cd "${NANO_WORLDDIR}"
for i; do for i; do
touch $i touch $i
echo "./${i} type=file" >> ${NANO_METALOG} echo "./${i} type=file" >> ${NANO_METALOG}
done done
) }
# #
# Convert a directory into a symlink. Takes two arguments, the # Convert a directory into a symlink. Takes two arguments, the
@@ -268,9 +267,9 @@ tgt_touch ( ) (
# directory is removed and a symlink is created. If we're doing # directory is removed and a symlink is created. If we're doing
# a nopriv build, then append this fact to the metalog # a nopriv build, then append this fact to the metalog
# #
tgt_dir2symlink ( ) ( tgt_dir2symlink() {
dir=$1 local dir=$1
symlink=$2 local symlink=$2
cd "${NANO_WORLDDIR}" cd "${NANO_WORLDDIR}"
rm -xrf "$dir" rm -xrf "$dir"
@@ -278,28 +277,28 @@ tgt_dir2symlink ( ) (
if [ -n "$NANO_METALOG" ]; then if [ -n "$NANO_METALOG" ]; then
echo "./${dir} type=link mode=0777 link=${symlink}" >> ${NANO_METALOG} echo "./${dir} type=link mode=0777 link=${symlink}" >> ${NANO_METALOG}
fi fi
) }
# run in the world chroot, errors fatal # run in the world chroot, errors fatal
CR ( ) { CR() {
chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*" chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*"
} }
# run in the world chroot, errors not fatal # run in the world chroot, errors not fatal
CR0 ( ) { CR0() {
chroot "${NANO_WORLDDIR}" /bin/sh -c "$*" || true chroot "${NANO_WORLDDIR}" /bin/sh -c "$*" || true
} }
clean_build ( ) ( clean_build() {
pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})" pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})"
if ! rm -xrf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then if ! rm -xrf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then
chflags -R noschg ${MAKEOBJDIRPREFIX}/ chflags -R noschg ${MAKEOBJDIRPREFIX}/
rm -xr ${MAKEOBJDIRPREFIX}/ rm -xr ${MAKEOBJDIRPREFIX}/
fi fi
) }
make_conf_build ( ) ( make_conf_build() {
pprint 2 "Construct build make.conf ($NANO_MAKE_CONF_BUILD)" pprint 2 "Construct build make.conf ($NANO_MAKE_CONF_BUILD)"
mkdir -p ${MAKEOBJDIRPREFIX} mkdir -p ${MAKEOBJDIRPREFIX}
@@ -312,9 +311,9 @@ make_conf_build ( ) (
echo "${CONF_WORLD}" echo "${CONF_WORLD}"
echo "${CONF_BUILD}" echo "${CONF_BUILD}"
) > ${NANO_MAKE_CONF_BUILD} ) > ${NANO_MAKE_CONF_BUILD}
) }
build_world ( ) ( build_world() {
pprint 2 "run buildworld" pprint 2 "run buildworld"
pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw" pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bw"
@@ -324,9 +323,9 @@ build_world ( ) (
cd "${NANO_SRC}" cd "${NANO_SRC}"
${NANO_PMAKE} buildworld ${NANO_PMAKE} buildworld
) > ${MAKEOBJDIRPREFIX}/_.bw 2>&1 ) > ${MAKEOBJDIRPREFIX}/_.bw 2>&1
) }
build_kernel ( ) ( build_kernel() {
pprint 2 "build kernel ($NANO_KERNEL)" pprint 2 "build kernel ($NANO_KERNEL)"
pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bk" pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.bk"
@@ -342,9 +341,9 @@ build_kernel ( ) (
cd "${NANO_SRC}" cd "${NANO_SRC}"
${NANO_PMAKE} buildkernel ${NANO_PMAKE} buildkernel
) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1 ) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1
) }
clean_world ( ) ( clean_world() {
if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then
pprint 2 "Clean and create object directory (${NANO_OBJ})" pprint 2 "Clean and create object directory (${NANO_OBJ})"
if ! rm -xrf ${NANO_OBJ}/ > /dev/null 2>&1 ; then if ! rm -xrf ${NANO_OBJ}/ > /dev/null 2>&1 ; then
@@ -361,9 +360,9 @@ clean_world ( ) (
fi fi
mkdir -p "${NANO_WORLDDIR}" mkdir -p "${NANO_WORLDDIR}"
fi fi
) }
make_conf_install ( ) ( make_conf_install() {
pprint 2 "Construct install make.conf ($NANO_MAKE_CONF_INSTALL)" pprint 2 "Construct install make.conf ($NANO_MAKE_CONF_INSTALL)"
# Make sure we get all the global settings that NanoBSD wants # Make sure we get all the global settings that NanoBSD wants
@@ -377,9 +376,9 @@ make_conf_install ( ) (
echo METALOG=${NANO_METALOG} echo METALOG=${NANO_METALOG}
fi fi
) > ${NANO_MAKE_CONF_INSTALL} ) > ${NANO_MAKE_CONF_INSTALL}
) }
install_world ( ) ( install_world() {
pprint 2 "installworld" pprint 2 "installworld"
pprint 3 "log: ${NANO_LOG}/_.iw" pprint 3 "log: ${NANO_LOG}/_.iw"
@@ -390,9 +389,9 @@ install_world ( ) (
${NANO_MAKE} installworld DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes ${NANO_MAKE} installworld DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes
chflags -R noschg "${NANO_WORLDDIR}" chflags -R noschg "${NANO_WORLDDIR}"
) > ${NANO_LOG}/_.iw 2>&1 ) > ${NANO_LOG}/_.iw 2>&1
) }
install_etc ( ) ( install_etc() {
pprint 2 "install /etc" pprint 2 "install /etc"
pprint 3 "log: ${NANO_LOG}/_.etc" pprint 3 "log: ${NANO_LOG}/_.etc"
@@ -405,9 +404,9 @@ install_etc ( ) (
# so they can spam it. # so they can spam it.
cp /dev/null "${NANO_WORLDDIR}"/etc/make.conf cp /dev/null "${NANO_WORLDDIR}"/etc/make.conf
) > ${NANO_LOG}/_.etc 2>&1 ) > ${NANO_LOG}/_.etc 2>&1
) }
install_kernel ( ) ( install_kernel() {
pprint 2 "install kernel ($NANO_KERNEL)" pprint 2 "install kernel ($NANO_KERNEL)"
pprint 3 "log: ${NANO_LOG}/_.ik" pprint 3 "log: ${NANO_LOG}/_.ik"
@@ -426,9 +425,9 @@ install_kernel ( ) (
${NANO_MAKE} installkernel DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes ${NANO_MAKE} installkernel DESTDIR="${NANO_WORLDDIR}" DB_FROM_SRC=yes
) > ${NANO_LOG}/_.ik 2>&1 ) > ${NANO_LOG}/_.ik 2>&1
) }
native_xtools ( ) ( native_xtools() {
pprint 2 "Installing the optimized native build tools for cross env" pprint 2 "Installing the optimized native build tools for cross env"
pprint 3 "log: ${NANO_LOG}/_.native_xtools" pprint 3 "log: ${NANO_LOG}/_.native_xtools"
@@ -441,13 +440,13 @@ native_xtools ( ) (
${NANO_MAKE} native-xtools-install DESTDIR="${NANO_WORLDDIR}" ${NANO_MAKE} native-xtools-install DESTDIR="${NANO_WORLDDIR}"
) > ${NANO_LOG}/_.native_xtools 2>&1 ) > ${NANO_LOG}/_.native_xtools 2>&1
) }
# #
# Run the requested set of early customization scripts, run before # Run the requested set of early customization scripts, run before
# buildworld. # buildworld.
# #
run_early_customize ( ) { run_early_customize() {
pprint 2 "run early customize scripts" pprint 2 "run early customize scripts"
for c in $NANO_EARLY_CUSTOMIZE for c in $NANO_EARLY_CUSTOMIZE
do do
@@ -467,7 +466,7 @@ run_early_customize ( ) {
# done an installworld, installed the etc files, installed the kernel # done an installworld, installed the etc files, installed the kernel
# and tweaked them in the standard way. # and tweaked them in the standard way.
# #
run_customize ( ) ( run_customize() {
pprint 2 "run customize scripts" pprint 2 "run customize scripts"
for c in $NANO_CUSTOMIZE for c in $NANO_CUSTOMIZE
@@ -477,13 +476,13 @@ run_customize ( ) (
pprint 4 "`type $c`" pprint 4 "`type $c`"
( set -o xtrace ; $c ) > ${NANO_LOG}/_.cust.$c 2>&1 ( set -o xtrace ; $c ) > ${NANO_LOG}/_.cust.$c 2>&1
done done
) }
# #
# Run any last-minute customization commands after we've had a chance to # Run any last-minute customization commands after we've had a chance to
# setup nanobsd, prune empty dirs from /usr, etc # setup nanobsd, prune empty dirs from /usr, etc
# #
run_late_customize ( ) ( run_late_customize() {
pprint 2 "run late customize scripts" pprint 2 "run late customize scripts"
for c in $NANO_LATE_CUSTOMIZE for c in $NANO_LATE_CUSTOMIZE
do do
@@ -492,7 +491,7 @@ run_late_customize ( ) (
pprint 4 "`type $c`" pprint 4 "`type $c`"
( set -o xtrace ; $c ) > ${NANO_LOG}/_.late_cust.$c 2>&1 ( set -o xtrace ; $c ) > ${NANO_LOG}/_.late_cust.$c 2>&1
done done
) }
# #
# Hook called after we run all the late customize commands, but # Hook called after we run all the late customize commands, but
@@ -501,7 +500,7 @@ run_late_customize ( ) (
# have been recording their actions. It's not anticipated that # have been recording their actions. It's not anticipated that
# a user's cfg file would override this. # a user's cfg file would override this.
# #
fixup_before_diskimage ( ) ( fixup_before_diskimage() {
# Run the deduplication script that takes the metalog journal and # Run the deduplication script that takes the metalog journal and
# combines multiple entries for the same file (see source for # combines multiple entries for the same file (see source for
# details). We take the extra step of removing the size keywords. This # details). We take the extra step of removing the size keywords. This
@@ -517,9 +516,9 @@ fixup_before_diskimage ( ) (
cat ${NANO_METALOG}.pre | ${NANO_TOOLS}/mtree-dedup.awk | \ cat ${NANO_METALOG}.pre | ${NANO_TOOLS}/mtree-dedup.awk | \
sed -e 's/ size=[0-9][0-9]*//' | sort >> ${NANO_METALOG} sed -e 's/ size=[0-9][0-9]*//' | sort >> ${NANO_METALOG}
fi fi
) }
setup_nanobsd ( ) ( setup_nanobsd() {
pprint 2 "configure nanobsd setup" pprint 2 "configure nanobsd setup"
pprint 3 "log: ${NANO_LOG}/_.dl" pprint 3 "log: ${NANO_LOG}/_.dl"
@@ -564,9 +563,9 @@ setup_nanobsd ( ) (
tgt_dir2symlink tmp var/tmp tgt_dir2symlink tmp var/tmp
) > ${NANO_LOG}/_.dl 2>&1 ) > ${NANO_LOG}/_.dl 2>&1
) }
setup_nanobsd_etc ( ) ( setup_nanobsd_etc() {
pprint 2 "configure nanobsd /etc" pprint 2 "configure nanobsd /etc"
( (
@@ -623,18 +622,18 @@ EOF
# Create directory for eventual /usr/local/etc contents # Create directory for eventual /usr/local/etc contents
mkdir -p etc/local mkdir -p etc/local
) )
) }
prune_usr ( ) ( prune_usr() {
# Remove all empty directories in /usr # Remove all empty directories in /usr
find "${NANO_WORLDDIR}"/usr -type d -depth -print | find "${NANO_WORLDDIR}"/usr -type d -depth -print |
while read d while read d
do do
rmdir $d > /dev/null 2>&1 || true rmdir $d > /dev/null 2>&1 || true
done done
) }
newfs_part ( ) ( newfs_part() {
local dev mnt lbl local dev mnt lbl
dev=$1 dev=$1
mnt=$2 mnt=$2
@@ -642,15 +641,15 @@ newfs_part ( ) (
echo newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev} echo newfs ${NANO_NEWFS} ${NANO_LABEL:+-L${NANO_LABEL}${lbl}} ${dev}
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} mount -o async ${dev} ${mnt}
) }
# Convenient spot to work around any umount issues that your build environment # Convenient spot to work around any umount issues that your build environment
# hits by overriding this method. # hits by overriding this method.
nano_umount ( ) ( nano_umount() {
umount ${1} umount ${1}
) }
populate_slice ( ) ( populate_slice() {
local dev dir mnt lbl local dev dir mnt lbl
dev=$1 dev=$1
dir=$2 dir=$2
@@ -665,23 +664,23 @@ populate_slice ( ) (
fi fi
df -i ${mnt} df -i ${mnt}
nano_umount ${mnt} nano_umount ${mnt}
) }
populate_cfg_slice ( ) ( populate_cfg_slice() {
populate_slice "$1" "$2" "$3" "$4" populate_slice "$1" "$2" "$3" "$4"
) }
populate_data_slice ( ) ( populate_data_slice() {
populate_slice "$1" "$2" "$3" "$4" populate_slice "$1" "$2" "$3" "$4"
) }
last_orders ( ) ( last_orders() {
# Redefine this function with any last orders you may have # Redefine this function with any last orders you may have
# after the build completed, for instance to copy the finished # after the build completed, for instance to copy the finished
# image to a more convenient place: # image to a more convenient place:
# cp ${NANO_DISKIMGDIR}/${NANO_IMG1NAME} /home/ftp/pub/nanobsd.disk # cp ${NANO_DISKIMGDIR}/${NANO_IMG1NAME} /home/ftp/pub/nanobsd.disk
true true
) }
####################################################################### #######################################################################
# #
@@ -693,7 +692,7 @@ last_orders ( ) (
# Common Flash device geometries # Common Flash device geometries
# #
FlashDevice ( ) { FlashDevice() {
if [ -d ${NANO_TOOLS} ] ; then if [ -d ${NANO_TOOLS} ] ; then
. ${NANO_TOOLS}/FlashDevice.sub . ${NANO_TOOLS}/FlashDevice.sub
else else
@@ -722,8 +721,8 @@ FlashDevice ( ) {
# The generic-hdd device is preferred for flash devices larger than 1GB. # The generic-hdd device is preferred for flash devices larger than 1GB.
# #
UsbDevice ( ) { UsbDevice() {
a1=`echo $1 | tr '[:upper:]' '[:lower:]'` local a1=`echo $1 | tr '[:upper:]' '[:lower:]'`
case $a1 in case $a1 in
generic-fdd) generic-fdd)
NANO_HEADS=64 NANO_HEADS=64
@@ -745,7 +744,7 @@ UsbDevice ( ) {
####################################################################### #######################################################################
# Setup serial console # Setup serial console
cust_comconsole ( ) ( cust_comconsole() {
# Enable getty on console # Enable getty on console
sed -i "" -e '/^tty[du]0/s/off/onifconsole/' ${NANO_WORLDDIR}/etc/ttys sed -i "" -e '/^tty[du]0/s/off/onifconsole/' ${NANO_WORLDDIR}/etc/ttys
@@ -754,32 +753,32 @@ cust_comconsole ( ) (
# Tell loader to use serial console early. # Tell loader to use serial console early.
echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config
) }
####################################################################### #######################################################################
# Allow root login via ssh # Allow root login via ssh
cust_allow_ssh_root ( ) ( cust_allow_ssh_root() {
sed -i "" -E 's/^#?PermitRootLogin.*/PermitRootLogin yes/' \ sed -i "" -E 's/^#?PermitRootLogin.*/PermitRootLogin yes/' \
${NANO_WORLDDIR}/etc/ssh/sshd_config ${NANO_WORLDDIR}/etc/ssh/sshd_config
) }
####################################################################### #######################################################################
# Install the stuff under ./Files # Install the stuff under ./Files
cust_install_files ( ) ( cust_install_files() {
cd "${NANO_TOOLS}/Files" cd "${NANO_TOOLS}/Files"
find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio ${CPIO_SYMLINK} -Ldumpv ${NANO_WORLDDIR} 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 if [ -n "${NANO_CUST_FILES_MTREE}" -a -f ${NANO_CUST_FILES_MTREE} ]; then
CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE} CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE}
fi fi
) }
####################################################################### #######################################################################
# Install packages from ${NANO_PACKAGE_DIR} # Install packages from ${NANO_PACKAGE_DIR}
cust_pkgng ( ) ( cust_pkgng() {
mkdir -p ${NANO_WORLDDIR}/usr/local/etc mkdir -p ${NANO_WORLDDIR}/usr/local/etc
local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf" 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" local PKGCMD="env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=${NANO_PKG_META_BASE}/pkg SIGNATURE_TYPE=none /usr/sbin/pkg"
@@ -841,14 +840,14 @@ cust_pkgng ( ) (
umount ${NANO_WORLDDIR}/dev umount ${NANO_WORLDDIR}/dev
umount ${NANO_WORLDDIR}/_.p umount ${NANO_WORLDDIR}/_.p
rm -xrf ${NANO_WORLDDIR}/_.p rm -xrf ${NANO_WORLDDIR}/_.p
) }
####################################################################### #######################################################################
# Convenience function: # Convenience function:
# Register all args as early customize function to run just before # Register all args as early customize function to run just before
# build commences. # build commences.
early_customize_cmd ( ) { early_customize_cmd() {
NANO_EARLY_CUSTOMIZE="$NANO_EARLY_CUSTOMIZE $*" NANO_EARLY_CUSTOMIZE="$NANO_EARLY_CUSTOMIZE $*"
} }
@@ -856,7 +855,7 @@ early_customize_cmd ( ) {
# Convenience function: # Convenience function:
# Register all args as customize function. # Register all args as customize function.
customize_cmd ( ) { customize_cmd() {
NANO_CUSTOMIZE="$NANO_CUSTOMIZE $*" NANO_CUSTOMIZE="$NANO_CUSTOMIZE $*"
} }
@@ -865,7 +864,7 @@ customize_cmd ( ) {
# Register all args as late customize function to run just before # Register all args as late customize function to run just before
# image creation. # image creation.
late_customize_cmd ( ) { late_customize_cmd() {
NANO_LATE_CUSTOMIZE="$NANO_LATE_CUSTOMIZE $*" NANO_LATE_CUSTOMIZE="$NANO_LATE_CUSTOMIZE $*"
} }
@@ -877,14 +876,14 @@ late_customize_cmd ( ) {
# Progress Print # Progress Print
# Print $2 at level $1. # Print $2 at level $1.
pprint ( ) ( pprint() {
if [ "$1" -le $PPLEVEL ]; then if [ "$1" -le $PPLEVEL ]; then
runtime=$(( `date +%s` - $NANO_STARTTIME )) runtime=$(( `date +%s` - $NANO_STARTTIME ))
printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3 printf "%s %.${1}s %s\n" "`date -u -r $runtime +%H:%M:%S`" "#####" "$2" 1>&3
fi fi
) }
usage ( ) { usage() {
( (
echo "Usage: $0 [-BbfhIiKknpqvWwX] [-c config_file]" echo "Usage: $0 [-BbfhIiKknpqvWwX] [-c config_file]"
echo " -B suppress installs (both kernel and world)" echo " -B suppress installs (both kernel and world)"
@@ -911,7 +910,7 @@ usage ( ) {
# Setup and Export Internal variables # Setup and Export Internal variables
# #
export_var ( ) { # Don't want a subshell export_var() {
var=$1 var=$1
# Lookup value of the variable. # Lookup value of the variable.
eval val=\$$var eval val=\$$var
@@ -920,8 +919,7 @@ export_var ( ) { # Don't want a subshell
} }
# Call this function to set defaults _after_ parsing options. # 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}}} : ${NANO_OBJ:=/usr/obj/nanobsd.${NANO_NAME}${NANO_LAYOUT:+.${NANO_LAYOUT}}}
: ${MAKEOBJDIRPREFIX:=${NANO_OBJ}} : ${MAKEOBJDIRPREFIX:=${NANO_OBJ}}
: ${NANO_DISKIMGDIR:=${NANO_OBJ}} : ${NANO_DISKIMGDIR:=${NANO_OBJ}}
+28 -28
View File
@@ -1,4 +1,4 @@
#!/bin/sh
#- #-
# Copyright (c) 2015 M. Warner Losh <imp@FreeBSD.org> # Copyright (c) 2015 M. Warner Losh <imp@FreeBSD.org>
# Copyright (c) 2010-2011 iXsystems, Inc. # Copyright (c) 2010-2011 iXsystems, Inc.
@@ -113,18 +113,18 @@ NANO_FAT_DIR=${NANO_LOG}/_.fat
customize_cmd cust_allow_ssh_root customize_cmd cust_allow_ssh_root
add_etc_make_conf ( ) ( add_etc_make_conf() {
touch ${NANO_WORLDDIR}/etc/make.conf touch ${NANO_WORLDDIR}/etc/make.conf
) }
customize_cmd add_etc_make_conf customize_cmd add_etc_make_conf
cust_install_machine_files ( ) ( cust_install_machine_files() {
echo "cd ${NANO_CFG_BASE}/Files" echo "cd ${NANO_CFG_BASE}/Files"
cd ${NANO_CFG_BASE}/Files cd ${NANO_CFG_BASE}/Files
find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${NANO_WORLDDIR} find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${NANO_WORLDDIR}
) }
customize_cmd cust_install_files customize_cmd cust_install_files
customize_cmd cust_install_machine_files customize_cmd cust_install_machine_files
CONF_BUILD=" CONF_BUILD="
LOCAL_XTOOL_DIRS=usr.bin/mkimg LOCAL_XTOOL_DIRS=usr.bin/mkimg
@@ -173,13 +173,13 @@ NANO_PACKAGE_ONLY=1
# Creates images for all the formats that use MBR / GPT # Creates images for all the formats that use MBR / GPT
# split later if the #ifdef soup gets too bad. # split later if the #ifdef soup gets too bad.
create_diskimage_gpt ( ) ( create_diskimage_gpt() {
pprint 2 "build diskimage gpt ${NANO_NAME}" pprint 2 "build diskimage gpt ${NANO_NAME}"
create_diskimage_mbr $* create_diskimage_mbr $*
) }
create_diskimage_mbr ( ) ( create_diskimage_mbr() {
local fmt local fmt
@@ -314,7 +314,7 @@ create_diskimage_mbr ( ) (
rm -f ${out}.xz rm -f ${out}.xz
xz -9 --keep ${out} xz -9 --keep ${out}
) > ${NANO_LOG}/_.di 2>&1 ) > ${NANO_LOG}/_.di 2>&1
) }
die( ) { die( ) {
echo "$*" echo "$*"
@@ -373,7 +373,7 @@ $var=$val"
fi fi
done done
typical_embedded ( ) ( typical_embedded() {
# Need to create rc.conf before we copy over /etc to /conf/base/etc # Need to create rc.conf before we copy over /etc to /conf/base/etc
# so now's a good time. # so now's a good time.
@@ -388,10 +388,10 @@ typical_embedded ( ) (
# Make sure that firstboot scripts run so growfs works. # Make sure that firstboot scripts run so growfs works.
# Note: still some issues remvoing this XXX # Note: still some issues remvoing this XXX
touch ${NANO_WORLDDIR}/firstboot touch ${NANO_WORLDDIR}/firstboot
) }
customize_cmd typical_embedded customize_cmd typical_embedded
fix_pkg ( ) ( fix_pkg() {
chdir ${NANO_WORLDDIR} chdir ${NANO_WORLDDIR}
mkdir -p pkg mkdir -p pkg
mkdir -p pkg/db mkdir -p pkg/db
@@ -410,20 +410,20 @@ fix_pkg ( ) (
echo "./pkg/db 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" echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755"
) >> ${NANO_METALOG} ) >> ${NANO_METALOG}
) }
customize_cmd fix_pkg customize_cmd fix_pkg
save_build ( ) ( save_build() {
VERSION_FILE=${NANO_WORLDDIR}/etc/version VERSION_FILE=${NANO_WORLDDIR}/etc/version
if [ "${SVNREVISION}" = "${REVISION}" ]; then if [ "${SVNREVISION}" = "${REVISION}" ]; then
echo "${NANO_NAME}" > "${VERSION_FILE}" echo "${NANO_NAME}" > "${VERSION_FILE}"
else else
echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}" echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}"
fi fi
) }
customize_cmd save_build customize_cmd save_build
shrink_md_fbsize ( ) ( shrink_md_fbsize() {
# We have a lot of little files on our memory disks. Let's decrease # 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 # 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 -- # halves our space requirement by ~50% on /etc and /var on 8.x --
@@ -431,12 +431,12 @@ shrink_md_fbsize ( ) (
# are 4 times larger). # are 4 times larger).
sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \ sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \
${NANO_WORLDDIR}/etc/rc.initdiskless ${NANO_WORLDDIR}/etc/rc.initdiskless
) }
customize_cmd shrink_md_fbsize customize_cmd shrink_md_fbsize
customize_cmd cust_comconsole customize_cmd cust_comconsole
dos_boot_part ( ) ( dos_boot_part() {
local d=/usr/local/share/u-boot/${NANO_BOOT_PKG} local d=/usr/local/share/u-boot/${NANO_BOOT_PKG}
local f=${NANO_FAT_DIR} local f=${NANO_FAT_DIR}
@@ -453,7 +453,7 @@ dos_boot_part ( ) (
# Now we need to copy over dtb files from the build. # Now we need to copy over dtb files from the build.
cp ${NANO_WORLDDIR}/boot/dtb/*.dtb . cp ${NANO_WORLDDIR}/boot/dtb/*.dtb .
) }
if [ -n "$NANO_BOOT_PKG" ]; then if [ -n "$NANO_BOOT_PKG" ]; then
d=/usr/local/share/u-boot/${NANO_BOOT_PKG} d=/usr/local/share/u-boot/${NANO_BOOT_PKG}
@@ -468,7 +468,7 @@ if [ -n "$NANO_BOOT_PKG" ]; then
customize_cmd dos_boot_part customize_cmd dos_boot_part
fi fi
product_custom ( ) ( product_custom() {
# not quite ready to tweak these in nopriv build # not quite ready to tweak these in nopriv build
if [ -z ${NANO_NOPRIV_BUILD} ]; then if [ -z ${NANO_NOPRIV_BUILD} ]; then
# Last second tweaks -- generally not needed # Last second tweaks -- generally not needed
@@ -480,7 +480,7 @@ product_custom ( ) (
chown root:wheel ${NANO_WORLDDIR}/ chown root:wheel ${NANO_WORLDDIR}/
chown root:wheel ${NANO_WORLDDIR}/usr chown root:wheel ${NANO_WORLDDIR}/usr
fi fi
) }
late_customize_cmd product_custom late_customize_cmd product_custom
# #
@@ -615,19 +615,19 @@ esac
NANO_SLICE_DATA= # Not included NANO_SLICE_DATA= # Not included
# These don't make any sense to this strategy, so stub them out. # 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. # 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 # Each major disk scheme has its own routine. Generally
# this is for mbr, gpt, etc. These are generally are widely # this is for mbr, gpt, etc. These are generally are widely
# shared, but some specialized formats won't be shared. # shared, but some specialized formats won't be shared.
create_diskimage ( ) ( create_diskimage() {
eval create_diskimage_${NANO_DISK_SCHEME} eval create_diskimage_${NANO_DISK_SCHEME}
) }
# Set the path to the same path we use for buldworld to use latest mkimg # 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_TARGET=$(cd ${NANO_SRC}; ${NANO_MAKE} TARGET_ARCH=${NANO_ARCH} -V _TARGET)
+6 -6
View File
@@ -34,7 +34,7 @@
# Functions and variable definitions used by the legacy nanobsd # Functions and variable definitions used by the legacy nanobsd
# image building system. # image building system.
calculate_partitioning ( ) ( calculate_partitioning() {
echo $NANO_MEDIASIZE $NANO_IMAGES \ echo $NANO_MEDIASIZE $NANO_IMAGES \
$NANO_SECTS $NANO_HEADS \ $NANO_SECTS $NANO_HEADS \
$NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE | $NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE |
@@ -90,9 +90,9 @@ calculate_partitioning ( ) (
} }
} }
' > ${NANO_LOG}/_.partitioning ' > ${NANO_LOG}/_.partitioning
) }
create_code_slice ( ) ( create_code_slice() {
pprint 2 "build code slice" pprint 2 "build code slice"
pprint 3 "log: ${NANO_OBJ}/_.cs" pprint 3 "log: ${NANO_OBJ}/_.cs"
@@ -142,10 +142,10 @@ create_code_slice ( ) (
trap - 1 2 15 EXIT trap - 1 2 15 EXIT
) > ${NANO_OBJ}/_.cs 2>&1 ) > ${NANO_OBJ}/_.cs 2>&1
) }
create_diskimage ( ) ( create_diskimage() {
pprint 2 "build diskimage" pprint 2 "build diskimage"
pprint 3 "log: ${NANO_OBJ}/_.di" pprint 3 "log: ${NANO_OBJ}/_.di"
@@ -243,4 +243,4 @@ create_diskimage ( ) (
trap - 1 2 15 EXIT trap - 1 2 15 EXIT
) > ${NANO_LOG}/_.di 2>&1 ) > ${NANO_LOG}/_.di 2>&1
) }
+16 -16
View File
@@ -1,5 +1,5 @@
# #!/bin/sh
#
#NANO_SRC=$(pwd) #NANO_SRC=$(pwd)
#NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/rescue} #NANO_SRC=${NANO_SRC%/tools/tools/nanobsd/rescue}
#NANO_OBJ=${NANO_SRC}/../nanobsd-builds/${NANO_NAME}/obj #NANO_OBJ=${NANO_SRC}/../nanobsd-builds/${NANO_NAME}/obj
@@ -24,12 +24,12 @@ NANO_MD_BACKING=file
# Options to put in make.conf during buildworld only # Options to put in make.conf during buildworld only
CONF_BUILD=' CONF_BUILD='
' '
# Options to put in make.conf during installworld only # Options to put in make.conf during installworld only
CONF_INSTALL=' CONF_INSTALL='
' '
# Options to put in make.conf during both build- & installworld. # Options to put in make.conf during both build- & installworld.
CONF_WORLD=' CONF_WORLD='
CFLAGS=-O -pipe CFLAGS=-O -pipe
# We do not need these for rescue # We do not need these for rescue
WITHOUT_TESTS=true WITHOUT_TESTS=true
WITHOUT_DEBUG_FILES=true WITHOUT_DEBUG_FILES=true
@@ -71,9 +71,9 @@ customize_cmd cust_install_files
#customize_cmd cust_pkgng #customize_cmd cust_pkgng
cust_etc_cfg () ( cust_etc_cfg() {
cd ${NANO_WORLDDIR} cd ${NANO_WORLDDIR}
# mkdir -pv scratch # mkdir -pv scratch
echo "hostname=\"rescue\"" > etc/rc.conf echo "hostname=\"rescue\"" > etc/rc.conf
echo "font8x14=\"iso15-8x14\"" >> etc/rc.conf echo "font8x14=\"iso15-8x14\"" >> etc/rc.conf
echo "font8x16=\"iso15-8x16\"" >> etc/rc.conf echo "font8x16=\"iso15-8x16\"" >> etc/rc.conf
@@ -85,12 +85,12 @@ cust_etc_cfg () (
echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> 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 "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 "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 /usr/sbin/pwd_mkdb -d etc etc/master.passwd
) }
customize_cmd cust_etc_cfg customize_cmd cust_etc_cfg
setup_nanobsd_etc ( ) ( setup_nanobsd_etc() {
pprint 2 "configure nanobsd /etc" pprint 2 "configure nanobsd /etc"
( (
cd ${NANO_WORLDDIR} cd ${NANO_WORLDDIR}
@@ -102,8 +102,8 @@ setup_nanobsd_etc ( ) (
echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
mkdir -p cfg mkdir -p cfg
) )
) }
last_orders () ( last_orders() {
pprint 2 "last orders" pprint 2 "last orders"
( (
cd ${NANO_WORLDDIR} cd ${NANO_WORLDDIR}
@@ -112,7 +112,7 @@ last_orders () (
echo "/dev/iso9660/${BIGLABEL} / cd9660 ro,noatime 0 0" > etc/fstab 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 "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 "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 rm -f conf/default/etc/remount
touch conf/default/etc/.keepme touch conf/default/etc/.keepme
touch conf/default/var/.keepme touch conf/default/var/.keepme
@@ -125,4 +125,4 @@ last_orders () (
-o label="${BIGLABEL}" -o publisher="RMX" \ -o label="${BIGLABEL}" -o publisher="RMX" \
-o bootimage="i386;_.w/boot/cdboot" -o no-emul-boot _.disk.iso _.w/ -o bootimage="i386;_.w/boot/cdboot" -o no-emul-boot _.disk.iso _.w/
) )
) }