Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167651630
D58949.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
25 KB
Referenced Files
None
Subscribers
None
D58949.diff
View Options
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -53,10 +53,10 @@
# 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.
+# directory located in Files
#NANO_CUST_FILES_MTREE=""
-# Use the time of the last commit as a timestamp when doing a NO_PRIV build.
+# Use the time of the last commit as a timestamp when doing a NO_PRIV build
NANO_TIMESTAMP=$(git log -1 --format=%ct || true)
# Object tree directory
@@ -71,7 +71,7 @@
NANO_MAKE="make"
NANO_NCPU=$(sysctl -n hw.ncpu)
-# The default name for any image we create.
+# The default name for any image we create
NANO_IMGNAME="_.disk.full"
NANO_IMG1NAME="_.disk.image"
@@ -81,7 +81,7 @@
# Options to put in make.conf during installworld only
CONF_INSTALL=' '
-# Options to put in make.conf during both build- & installworld.
+# Options to put in make.conf during both build- & installworld
CONF_WORLD='
WITHOUT_DEBUG_FILES=true
WITHOUT_LIB32=true
@@ -93,16 +93,16 @@
NANO_KERNEL=GENERIC
# Kernel modules to install. If empty, no modules are installed.
-# Use "default" to install all built modules.
+# Use "default" to install all built modules
NANO_MODULES=
-# Early customize commands.
+# Early customize commands
NANO_EARLY_CUSTOMIZE=""
-# Customize commands.
+# Customize commands
NANO_CUSTOMIZE=""
-# Late customize commands.
+# Late customize commands
NANO_LATE_CUSTOMIZE=""
# Newfs parameters to use
@@ -122,15 +122,15 @@
# 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.
+# 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.
+# Size of configuration file system in 512 bytes sectors.
+# Cannot be zero
NANO_CONFSIZE=2048
-# Size of data file system in 512 bytes sectors
+# Size of data file system in 512 bytes sectors.
# If zero: no partition configured.
# If negative: max size possible
NANO_DATASIZE=0
@@ -183,11 +183,10 @@
# 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`
+# to the arch of the current machine
+NANO_ARCH=$(uname -p)
-# CPUTYPE defaults to "" which is the default when CPUTYPE isn't
-# defined.
+# CPUTYPE defaults to "" which is the default when CPUTYPE isn't defined
NANO_CPUTYPE=""
# Directory to populate /cfg from
@@ -217,7 +216,7 @@
# 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.
+# right for paths with spaces in them
make_export() {
# Similar to export_var, except puts the data out to stdout
local var=$1
@@ -238,7 +237,7 @@
# Extra environment variables for kernel builds
nano_make_kernel_env() {
- if [ -f "${NANO_KERNEL}" ] ; then
+ if [ -f "${NANO_KERNEL}" ]; then
KERNCONFDIR="$(realpath $(dirname ${NANO_KERNEL}))"
KERNCONF="$(basename ${NANO_KERNEL})"
make_export KERNCONFDIR
@@ -256,25 +255,24 @@
}
#
-# Create empty files in the target tree, and record the fact. All paths
-# are relative to NANO_WORLDDIR.
+# Create empty files in the target tree, and record the fact.
+# All paths are relative to NANO_WORLDDIR
#
tgt_touch() (
cd "${NANO_WORLDDIR}"
for i; do
touch $i
if [ -n "$NANO_METALOG" ]; then
- echo "./${i} type=file" \
- "uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" \
- "mode=0644" >> "${NANO_METALOG}"
+ printf "./%s type=file uname=%s gname=%s mode=0644\n" \
+ "$i" "$NANO_DEF_UNAME" "$NANO_DEF_GNAME" >> "$NANO_METALOG"
fi
done
)
#
-# Convert a directory into a symlink. Takes three arguments, the current
+# Convert a directory into a symlink. Takes three arguments, the current
# directory, what it should become a symlink to, and optionally, the mode.
-# The directory is removed and a symlink is created. If we're doing
+# 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() (
@@ -286,9 +284,9 @@
rm -xrf "$dir"
ln -sf "$symlink" "$dir"
if [ -n "$NANO_METALOG" ]; then
- echo "./${dir} type=link" \
- "uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" \
- "mode=${mode} link=${symlink}" >> ${NANO_METALOG}
+ printf "./%s type=link uname=%s gname=%s mode=%s link=%s\n" \
+ "$dir" "$NANO_DEF_UNAME" "$NANO_DEF_GNAME" "$mode" \
+ "$symlink" >> "$NANO_METALOG"
fi
)
@@ -321,8 +319,7 @@
current="$1"
new="$2"
- for f in ${NANO_WORLDDIR}/etc/fstab ${NANO_WORLDDIR}/conf/base/etc/fstab
- do
+ for f in ${NANO_WORLDDIR}/etc/fstab ${NANO_WORLDDIR}/conf/base/etc/fstab; do
sed -i "" "s=${NANO_DRIVE}${current}=${NANO_DRIVE}${new}=g" "${f}"
done
}
@@ -340,7 +337,7 @@
clean_build() {
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}/
rm -xr ${MAKEOBJDIRPREFIX}/
fi
@@ -388,7 +385,7 @@
# 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.
+ # file to override this behavior. Just set NANO_MODULES=default
set -o xtrace
cd "${NANO_SRC}"
${NANO_PMAKE} buildkernel
@@ -398,7 +395,7 @@
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
+ if ! rm -xrf ${NANO_OBJ}/ > /dev/null 2>&1; then
chflags -R noschg ${NANO_OBJ}
rm -xr ${NANO_OBJ}/
fi
@@ -406,7 +403,7 @@
printenv > ${NANO_LOG}/_.env
else
pprint 2 "Clean and create world directory (${NANO_WORLDDIR})"
- if ! rm -xrf "${NANO_WORLDDIR}/" > /dev/null 2>&1 ; then
+ if ! rm -xrf "${NANO_WORLDDIR}/" > /dev/null 2>&1; then
chflags -R noschg "${NANO_WORLDDIR}"
rm -xrf "${NANO_WORLDDIR}/"
fi
@@ -453,7 +450,7 @@
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.
+ # so they can spam it
cp /dev/null "${NANO_WORLDDIR}"/etc/make.conf
) > ${NANO_LOG}/_.etc 2>&1
}
@@ -495,16 +492,15 @@
}
#
-# Run the requested set of early customization scripts, run before
-# buildworld.
+# Run the requested set of early customization scripts,
+# run before buildworld
#
run_early_customize() {
pprint 2 "run early customize scripts"
- for c in $NANO_EARLY_CUSTOMIZE
- do
+ for c in $NANO_EARLY_CUSTOMIZE; do
pprint 2 "early customize \"$c\""
pprint 3 "log: ${NANO_LOG}/_.early_cust.$c"
- pprint 4 "`type $c`"
+ pprint 4 "$(type $c)"
{ t=$(set -o | awk '$1 == "xtrace" && $2 == "off" { print "set +o xtrace"}');
set -o xtrace ;
$c ;
@@ -516,16 +512,15 @@
#
# 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.
+# and tweaked them in the standard way
#
run_customize() {
pprint 2 "run customize scripts"
- for c in $NANO_CUSTOMIZE
- do
+ for c in $NANO_CUSTOMIZE; do
pprint 2 "customize \"$c\""
pprint 3 "log: ${NANO_LOG}/_.cust.$c"
- pprint 4 "`type $c`"
+ pprint 4 "$(type $c)"
( set -o xtrace ; $c ) > ${NANO_LOG}/_.cust.$c 2>&1
done
}
@@ -536,21 +531,20 @@
#
run_late_customize() {
pprint 2 "run late customize scripts"
- for c in $NANO_LATE_CUSTOMIZE
- do
+ for c in $NANO_LATE_CUSTOMIZE; do
pprint 2 "late customize \"$c\""
pprint 3 "log: ${NANO_LOG}/_.late_cust.$c"
- pprint 4 "`type $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
+# 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.
+# have been recording their actions. It's not anticipated that
+# a user's cfg file would override this
#
fixup_before_diskimage() {
# Run the deduplication script that takes the metalog journal and
@@ -560,7 +554,7 @@
# 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.
+ # 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
@@ -579,8 +573,8 @@
# 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
+ # 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
@@ -592,21 +586,20 @@
# 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.
+ # the symlink not being here causes problems. It never hurts
+ # to have the symlink in error though
tgt_dir2symlink usr/local/etc ../../etc/local 0755
- for d in var etc
- do
- # link /$d under /conf
+ 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.
+ # the files in /$d will be hidden by the mount
tgt_dir conf/base/$d conf/default/$d
find $d -print | cpio ${CPIO_SYMLINK} -dumpl conf/base/
if [ -n "$NANO_METALOG" ]; then
grep "^.\/${d}\/" "${NANO_METALOG}" |
sed -e "s=^./${d}=./conf/base/${d}=g" |
- sort | uniq >> "${NANO_METALOG}.conf"
+ sort -u >> "${NANO_METALOG}.conf"
fi
done
@@ -620,7 +613,7 @@
tgt_touch conf/base/etc/md_size
tgt_touch conf/base/var/md_size
- # pick up config files from the special partition
+ # Pick up config files from the special partition
echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount
tgt_touch conf/default/etc/remount
@@ -677,7 +670,7 @@
fi
[ -n "${NANO_NOPRIV_BUILD}" ] && chmod 444 etc/defaults/rc.conf
- # save config file for scripts
+ # Save config file for scripts
echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
tgt_touch etc/nanobsd.conf
@@ -739,7 +732,8 @@
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}
+ find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' |
+ cpio ${CPIO_SYMLINK} -dumpv ${mnt}
fi
df -i ${mnt}
nano_umount ${mnt}
@@ -756,7 +750,7 @@
echo "Creating ${fs}"
- # Use the directory provided, otherwise create an empty one temporarily.
+ # Use the directory provided, otherwise create an empty one temporarily
if [ -n "${dir}" ] && [ -d "${dir}" ]; then
echo "Populating ${lbl} from ${dir}"
else
@@ -768,7 +762,7 @@
if [ -d "${dir}" ]; then
# If there is no metalog, create one using the default
- # NANO_DEF_UNAME and NANO_DEF_GNAME for all entries in the spec.
+ # NANO_DEF_UNAME and NANO_DEF_GNAME for all entries in the spec
if [ -z "${metalog}" ]; then
metalog="${NANO_METALOG}.${type}"
echo "/set type=dir uname=${NANO_DEF_UNAME}" \
@@ -814,7 +808,7 @@
#######################################################################
#
-# Optional convenience functions.
+# Optional convenience functions
#
#######################################################################
@@ -823,7 +817,7 @@
#
FlashDevice() {
- if [ -d ${NANO_TOOLS} ] ; then
+ if [ -d ${NANO_TOOLS} ]; then
. ${NANO_TOOLS}/FlashDevice.sub
else
. ${NANO_SRC}/${NANO_TOOLS}/FlashDevice.sub
@@ -848,11 +842,11 @@
# 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.
+# The generic-hdd device is preferred for flash devices larger than 1GB
#
UsbDevice() {
- local a1=`echo $1 | tr '[:upper:]' '[:lower:]'`
+ local a1=$(echo $1 | tr '[:upper:]' '[:lower:]')
case $a1 in
generic-fdd)
NANO_HEADS=64
@@ -881,7 +875,7 @@
# 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.
+ # Tell loader to use serial console early
echo "${NANO_BOOT2CFG}" > ${NANO_WORLDDIR}/boot.config
tgt_touch boot.config
}
@@ -899,7 +893,8 @@
cust_install_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
CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE}
@@ -916,7 +911,7 @@
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.
+ # 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}
@@ -924,7 +919,7 @@
echo "PKG_DBDIR: \"${NANO_PKG_META_BASE}/pkg\"" >> ${PKG_CONF}
fi
- # If the package directory doesn't exist, we're done.
+ # 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"
@@ -932,8 +927,8 @@
fi
# Find a pkg-* package
- for x in `find -s ${NANO_PACKAGE_DIR} -iname 'pkg-*'`; do
- _NANO_PKG_PACKAGE=`basename "$x"`
+ 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"
@@ -953,10 +948,10 @@
(
# Expand any glob characters in package list
cd "${NANO_PACKAGE_DIR}"
- _PKGS=`find ${NANO_PACKAGE_LIST} -not -name "${_NANO_PKG_PACKAGE}" -print | sort | uniq`
+ _PKGS=$(find ${NANO_PACKAGE_LIST} -not -name "${_NANO_PKG_PACKAGE}" -print | sort -u)
# Show todo
- todo=`echo "$_PKGS" | wc -l`
+ todo=$(echo "$_PKGS" | wc -l)
echo "=== TODO: $todo"
echo "$_PKGS"
echo "==="
@@ -978,7 +973,7 @@
#######################################################################
# Convenience function:
# Register all args as early customize function to run just before
-# build commences.
+# build commences
early_customize_cmd() {
NANO_EARLY_CUSTOMIZE="$NANO_EARLY_CUSTOMIZE $*"
@@ -986,7 +981,7 @@
#######################################################################
# Convenience function:
-# Register all args as customize function.
+# Register all args as customize function
customize_cmd() {
NANO_CUSTOMIZE="$NANO_CUSTOMIZE $*"
@@ -995,7 +990,7 @@
#######################################################################
# Convenience function:
# Register all args as late customize function to run just before
-# image creation.
+# image creation
late_customize_cmd() {
NANO_LATE_CUSTOMIZE="$NANO_LATE_CUSTOMIZE $*"
@@ -1011,8 +1006,9 @@
# Print $2 at level $1.
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
+ runtime=$(( $(date +%s) - NANO_STARTTIME ))
+ printf "%s %.${1}s %s\n" \
+ "$(date -u -r $runtime +%H:%M:%S)" "#####" "$2" 1>&3
fi
}
@@ -1046,13 +1042,13 @@
export_var() {
var=$1
- # Lookup value of the variable.
+ # 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.
+# Call this function to set defaults _after_ parsing options
set_defaults_and_export() {
: ${NANO_OBJ:=/usr/obj/nanobsd.${NANO_NAME}${NANO_LAYOUT:+.${NANO_LAYOUT}}}
: ${MAKEOBJDIRPREFIX:=${NANO_OBJ}}
@@ -1072,7 +1068,7 @@
# 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.
+ # 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
@@ -1080,7 +1076,7 @@
NANO_METALOG=${NANO_OBJ}/_.metalog
fi
- NANO_STARTTIME=`date +%s`
+ NANO_STARTTIME=$(date +%s)
: ${NANO_TIMESTAMP:=${NANO_STARTTIME}}
pprint 3 "Exporting NanoBSD variables"
export_var MAKEOBJDIRPREFIX
diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh
--- a/tools/tools/nanobsd/legacy.sh
+++ b/tools/tools/nanobsd/legacy.sh
@@ -27,16 +27,19 @@
#
#
-# Media geometry, only relevant if bios doesn't understand LBA.
+# Media geometry, only relevant if bios doesn't understand LBA
[ -n "$NANO_SECTS" ] || NANO_SECTS=63
[ -n "$NANO_HEADS" ] || NANO_HEADS=16
+#
# The first partition should start at offset 16,
-# because the first 16 sectors are reserved for metadata.
+# because the first 16 sectors are reserved for metadata
+#
METADATA_SECTS=16
+#######################################################################
# Functions and variable definitions used by the legacy nanobsd
-# image building system.
+# image building system
calculate_partitioning() {
echo $NANO_MEDIASIZE $NANO_IMAGES \
@@ -72,17 +75,17 @@
c = isl * cs;
# Second image partition (if any) also starts offset one
- # track to keep them identical.
+ # track to keep them identical
if ($2 > 1) {
print $3 + c, isl * cs - $3, 2
c += isl * cs;
}
- # Config partition starts at cylinder boundary.
+ # Config partition starts at cylinder boundary
print c, csl * cs, 3
c += csl * cs
- # Data partition (if any) starts at cylinder boundary.
+ # Data partition (if any) starts at cylinder boundary
if ($7 > 0) {
print c, dsl * cs, 4
} else if ($7 < 0 && $1 > c) {
@@ -106,7 +109,7 @@
mkdir -p ${MNT}
CODE_SIZE=$(awk '$3 == 1 {print $2}' "${NANO_LOG}/_.partitioning")
- if [ "${NANO_MD_BACKING}" = "swap" ] ; then
+ if [ "${NANO_MD_BACKING}" = "swap" ]; then
MD=$(mdconfig -a -t swap -s ${CODE_SIZE} -x ${NANO_SECTS} \
-y ${NANO_HEADS})
else
@@ -137,7 +140,7 @@
( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du
nano_umount ${MNT}
- if [ "${NANO_MD_BACKING}" = "swap" ] ; then
+ if [ "${NANO_MD_BACKING}" = "swap" ]; then
echo "Writing out ${NANO_IMG1NAME}..."
dd conv=sparse if=/dev/${MD} of=${IMG} bs=64k
fi
@@ -185,7 +188,7 @@
MNT=${NANO_OBJ}/_.mnt
mkdir -p ${MNT}
- if [ "${NANO_MD_BACKING}" = "swap" ] ; then
+ if [ "${NANO_MD_BACKING}" = "swap" ]; then
MD=$(mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} \
-y ${NANO_HEADS})
else
@@ -206,8 +209,8 @@
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.
+ # 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
@@ -226,7 +229,7 @@
echo "Writing code image..."
dd conv=sparse if=${NANO_DISKIMGDIR}/${NANO_IMG1NAME} of=/dev/${MD}${NANO_SLICE_ROOT} bs=64k
- if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
+ 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
@@ -237,7 +240,7 @@
done
nano_umount ${MNT}
# Override the label from the first partition so we
- # don't confuse glabel with duplicates.
+ # don't confuse glabel with duplicates
if [ -n "${NANO_LABEL}" ]; then
tunefs -L ${NANO_LABEL}"${NANO_ALTROOT}" /dev/${MD}${NANO_ALTROOT}
fi
@@ -246,17 +249,17 @@
# Create Config slice
populate_cfg_slice /dev/${MD}${NANO_SLICE_CFG} "${NANO_CFGDIR}" ${MNT} "${NANO_SLICE_CFG}"
- # Create Data slice, if any.
+ # 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
+ 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_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
@@ -299,8 +302,8 @@
diskimage="-p freebsd:=${NANO_DISKIMGDIR}/${NANO_IMG1NAME}:$(( NANO_SECTS * 512 ))"
- if [ "$NANO_IMAGES" -gt 1 ] ; then
- if [ "$NANO_INIT_IMG2" -gt 0 ] ; then
+ if [ "$NANO_IMAGES" -gt 1 ]; then
+ if [ "$NANO_INIT_IMG2" -gt 0 ]; then
echo "Duplicating to second image..."
tgt_switch_root_fstab "${NANO_SLICE_ROOT}" "${NANO_SLICE_ALTROOT}"
nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
@@ -328,14 +331,14 @@
"${NANO_SLICE_CFG}" "${CONF_SIZE}" "${NANO_METALOG_CFG}"
cfgimage="-p freebsd:=${NANO_OBJ}/_.cfg.part"
- # Create Data slice, if any.
+ # Create Data slice, if any
if [ -n "${NANO_SLICE_DATA}" ] &&
[ "${NANO_SLICE_CFG}" = "${NANO_SLICE_DATA}" ] &&
[ "${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 ] && [ -n "${NANO_SLICE_DATA}" ] ; then
+ if [ "${NANO_DATASIZE}" -ne 0 ] && [ -n "${NANO_SLICE_DATA}" ]; then
_populate_data_part "${NANO_OBJ}/_.data.part" "${NANO_DATADIR}" \
"${NANO_SLICE_DATA}" "${DATA_SIZE}" "${NANO_METALOG_DATA}"
dataimage="-p freebsd:=${NANO_OBJ}/_.data.part"
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh
--- a/tools/tools/nanobsd/nanobsd.sh
+++ b/tools/tools/nanobsd/nanobsd.sh
@@ -28,8 +28,8 @@
set -e
-nanobsd_sh=`realpath $0`
-topdir=`dirname ${nanobsd_sh}`
+nanobsd_sh=$(realpath $0)
+topdir=$(dirname ${nanobsd_sh})
. "${topdir}/defaults.sh"
#######################################################################
@@ -50,8 +50,8 @@
. "${topdir}/legacy.sh"
set +e
-args=`getopt BKXWbc:fhiIknpqUvw $*`
-if [ $? -ne 0 ] ; then
+args=$(getopt BKXWbc:fhiIknpqUvw $*)
+if [ $? -ne 0 ]; then
usage
exit 2
fi
@@ -96,7 +96,7 @@
-c)
# Make config file path available to the config file
# itself so that it can access additional files relative
- # to its own location.
+ # to its own location
NANO_CONFIG=$2
. "$2"
shift
@@ -149,7 +149,7 @@
esac
done
-if [ $# -gt 0 ] ; then
+if [ $# -gt 0 ]; then
echo "$0: Extraneous arguments supplied"
usage
fi
@@ -168,14 +168,14 @@
pprint 1 "NanoBSD image ${NANO_NAME} build starting"
-if $do_prep_image ; then
+if $do_prep_image; then
run_early_customize
else
pprint 2 "Skipping early customization for image prep (as instructed)"
fi
-if $do_world ; then
- if $do_clean ; then
+if $do_world; then
+ if $do_clean; then
clean_build
else
pprint 2 "Using existing build tree (as instructed)"
@@ -186,8 +186,8 @@
pprint 2 "Skipping buildworld (as instructed)"
fi
-if $do_kernel ; then
- if ! $do_world ; then
+if $do_kernel; then
+ if ! $do_world; then
make_conf_build
fi
build_kernel
@@ -204,19 +204,19 @@
pprint 2 "Skipping installworld (as instructed)"
fi
-if ${do_native_xtools} ; then
+if ${do_native_xtools}; then
native_xtools
fi
-if ${do_prep_image} ; then
+if ${do_prep_image}; then
setup_nanobsd_etc
fi
-if $do_installkernel ; then
+if $do_installkernel; then
install_kernel
else
pprint 2 "Skipping installkernel (as instructed)"
fi
-if $do_prep_image ; then
+if $do_prep_image; then
run_customize
setup_nanobsd
prune_usr
@@ -225,14 +225,14 @@
else
pprint 2 "Skipping image prep (as instructed)"
fi
-if $do_code ; then
+if $do_code; then
calculate_partitioning
if [ -z "${NANO_NOPRIV_BUILD}" ]; then
create_code_slice
else
_create_code_slice
fi
- if $do_image ; then
+ if $do_image; then
if [ -z "${NANO_NOPRIV_BUILD}" ]; then
create_diskimage
else
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 24, 1:00 PM (15 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37127977
Default Alt Text
D58949.diff (25 KB)
Attached To
Mode
D58949: nanobsd: Normalize style in common functions
Attached
Detach File
Event Timeline
Log In to Comment