Page MenuHomeFreeBSD

D58965.id184562.diff
No OneTemporary

D58965.id184562.diff

diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
old mode 100755
new mode 100644
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -167,13 +167,6 @@
# 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
-
# EFI System Partition size in bytes
NANO_EFI_BOOTPART_SIZE="260Mi"
@@ -1455,21 +1448,6 @@
done
}
-#
-# Create a new UFS filesystem on a block device with an optional label,
-# and mount it async
-# Input: $1 = device, $2 = mount point, $3 = label suffix
-#
-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}
-}
-
#
# Run makefs to create a UFS filesystem image from a source directory
# using a metalog spec and timestamp
@@ -1501,29 +1479,6 @@
umount ${1}
}
-#
-# Populate a partition from a source directory on a given device
-# Input: $1 = device, $2 = source dir (optional), $3 = mount point,
-# $4 = label suffix
-#
-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}
-}
-
#
# Create a UFS filesystem image from a directory
# Input: $1 = type (cfg/data), $2 = output image path, $3 = source dir,
@@ -1572,15 +1527,6 @@
fi
}
-#
-# Thin wrapper around populate_part for creating
-# the configuration partition image file
-# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
-#
-populate_cfg_slice() {
- populate_slice "$1" "$2" "$3" "$4"
-}
-
#
# Thin wrapper around populate_part for creating
# the configuration partition image file
@@ -1591,14 +1537,6 @@
populate_part "cfg" "$1" "$2" "$3" "$4" "$5"
}
-#
-# Thin wrapper around populate_slice for the data partition
-# Input: $1 = device, $2 = source dir, $3 = mount point, $4 = label
-#
-populate_data_slice() {
- populate_slice "$1" "$2" "$3" "$4"
-}
-
#
# Thin wrapper around populate_part for creating the data partition image file
# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
@@ -1631,68 +1569,6 @@
exit 2
}
-#######################################################################
-# Common Flash device geometries
-#
-
-#
-# Source FlashDevice.sub and call sub_FlashDevice to set NANO_MEDIASIZE
-# and geometry vars for a named flash device
-# Input: $1 = flash device name, $2 = size variant
-#
-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.
-#
-
-#
-# Set NANO_HEADS, NANO_SECTS, and NANO_MEDIASIZE for a USB device based
-# on type (generic-fdd/generic-hdd) and advertised MB capacity
-# Input: $1 = device type string, $2 = size in MB
-#
-UsbDevice() {
- local a1=$(echo $1 | tr '[:upper:]' '[:lower:]')
- case $a1 in
- generic-fdd)
- NANO_HEADS=64
- NANO_SECTS=32
- NANO_MEDIASIZE="${2}m"
- ;;
- generic|generic-hdd)
- NANO_HEADS=255
- NANO_SECTS=63
- NANO_MEDIASIZE="${2}m"
- ;;
- *)
- err "Unknown USB flash device"
- ;;
- esac
-}
-
#
# Convert a human-readable size string with a suffix into bytes.
# Inspired by NetBSD's strsuftoll(3), humanize_number(3), and
@@ -1749,6 +1625,9 @@
printf "%s" "$(printf 'scale=0; %s\n' "$result" | tr 'x' '*' | bc)"
}
+#######################################################################
+# Setup serial console
+
#######################################################################
# Allow root login via ssh
@@ -1928,7 +1807,7 @@
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 " -f suppress code partition 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"
diff --git a/tools/tools/nanobsd/gpt.sh b/tools/tools/nanobsd/gpt.sh
--- a/tools/tools/nanobsd/gpt.sh
+++ b/tools/tools/nanobsd/gpt.sh
@@ -27,7 +27,7 @@
set -e
-NANO_PLAN=gpt
+NANO_PLAN=default
#
# Space-separated list of boot types; options: BIOS, UEFI (case-insensitive).
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
@@ -69,6 +69,13 @@
#
METADATA_SECTS=16
+# 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
+
# Newfs parameters to use
NANO_NEWFS="-b 4096 -f 512 -i 8192 -U"
@@ -97,10 +104,133 @@
NANO_BOOT0CFG="-o packet -s 1 -m 3"
NANO_BOOTLOADER="boot/boot0sio"
+# Size of the /tmp+/var ramdisk in 512 bytes sectors
+NANO_RAM_TMPVARSIZE=10240
+
#######################################################################
# Functions and variable definitions used by the legacy nanobsd
# image building system.
+#######################################################################
+# Common Flash device geometries
+#
+
+#
+# Source FlashDevice.sub and call sub_FlashDevice to set NANO_MEDIASIZE
+# and geometry vars for a named flash device
+# Input: $1 = flash device name, $2 = size variant
+#
+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
+#
+
+#
+# Set NANO_HEADS, NANO_SECTS, and NANO_MEDIASIZE for a USB device based
+# on type (generic-fdd/generic-hdd) and advertised MB capacity
+# Input: $1 = device type string, $2 = size in MB
+#
+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 ))
+ ;;
+ *)
+ err "Unknown USB flash device"
+ ;;
+ esac
+}
+
+#
+# Create a new UFS filesystem on a block device with an optional label,
+# and mount it async
+# Input: $1 = device, $2 = mount point, $3 = label suffix
+#
+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}
+}
+
+#
+# Populate a slice from a source directory on a given device
+# Input: $1 = device, $2 = source dir (optional), $3 = mount point,
+# $4 = label suffix
+#
+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}
+}
+
+#
+# Thin wrapper around populate_slice for the configuration slice
+# Input: $1 = device, $2 = source dir, $3 = mount point, $4 = label
+#
+populate_cfg_slice() {
+ populate_slice "$1" "$2" "$3" "$4"
+}
+
+#
+# Thin wrapper around populate_slice for the data slice
+# Input: $1 = device, $2 = source dir, $3 = mount point, $4 = label
+#
+populate_data_slice() {
+ populate_slice "$1" "$2" "$3" "$4"
+}
+
+# Note: we use the is_defined hack to catch most uses of function redefinition
+# in config files. Older versions of FreeBSD defined these before configs were
+# included, but now we define it after to allow different NANO_PLAN...
+
#
# Calculate MBR partition layout (start offset, size, index)
# from media/image/code/conf/data sizes
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
@@ -33,8 +33,8 @@
. "${topdir}/legacy.sh"
}
-gpt() {
- # Pull in gpt stuff on demand
+default() {
+ # Pull in default stuff on demand
. "${topdir}/gpt.sh"
}

File Metadata

Mime Type
text/plain
Expires
Sat, Aug 22, 8:30 PM (17 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37046027
Default Alt Text
D58965.id184562.diff (9 KB)

Event Timeline