common revision 323738
1# $FreeBSD: stable/11/tools/tools/nanobsd/embedded/common 323738 2017-09-19 07:56:24Z n_hibma $ 2 3#- 4# Copyright (c) 2015 Warner Losh. All Rights Reserved. 5# Copyright (c) 2010-2011 iXsystems, Inc., All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL iXsystems, Inc OR CONTRIBUTORS BE LIABLE 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# 28# 29# This file is heavily derived from both Sam Leffler's Avilia config, 30# as well as the BSDRP project's config file. Neither of these have 31# an explicit copyright/license statement, but are implicitly BSDL. This 32# example has been taken from the FreeNAS project (an early version) and 33# simplified to meet the needs of the example. 34# 35 36# NB: You want the other file as the command line arg :) 37 38# Missing in base: 39# o mkimg setting active partition 40# o mkimg starting at arbitrary offset (needed for A10, et al) 41# o mtools still needed because we have no makefs -t msdos 42# o nanobsd doesn't record changes to WORLDTEMP in customization 43# scripts yet, so we have kludge to pick up all files 44# o easy way for pkg to grab files from other repos and put that 45# data on the image 46# o Need to have some way to create / resize the s4 slice to do ping 47# pong bouncing between s3 and s4 for an arbitrary image. we can resize 48# one slice, not two 49# o hints in the uboot ports for how to create the image 50# 51# Missing here 52# o documentation for how to run the qemu images 53# o msdos mtools fallback 54# o special boot for !x86 !arm platforms 55# o qemu image for arm 56# o qemu image for aarch64 57# o qemu image for armv6/armv7 58# o easy support for different image / vm formats 59# o need to promote much of this to nanobsd.sh and friends 60# o uses old kludge to build image w/o ownership being right 61# for many files. Should move to mtree-dedup.awk. 62# o support for EFI images 63# o support for GPT partitioning 64# 65# Long Term 66# o common tooling for creating images for odd-ball platforms 67# o support for boot loaders other than uboot in the image 68# or via special insturctions 69# o No pony support. Sadly, you cannot have a pony. 70# 71 72if [ -z $NANO_NAME ]; then 73 echo "NANO_NAME not defined. Use foo.cfg instead." 74fi 75 76NANO_SLICE_FAT_SIZE=32m 77NANO_SLICE_CFG_SIZE=32m 78 79NANO_BOOT2CFG="-P -S115200" 80 81NANO_RAM_ETCSIZE=8192 82NANO_RAM_TMPVARSIZE=8192 83NANO_IMAGES=2 84 85NANO_PMAKE="make -j $(sysctl -n hw.ncpu)" 86 87NANO_CFG_BASE=$(pwd) 88NANO_CFG_BASE=$(realpath ${NANO_CFG_BASE}/..) 89NANO_SRC=$(realpath ${NANO_CFG_BASE}/../../..) 90#### XXX share obj 91if [ -z ${NANO_CPUTYPE} ]; then 92 NANO_OBJ=${NANO_SRC}/../embedded/obj 93else 94 # Alas, I can't set OBJTREE to ${MACHINE}.${MACHINE_ARCH}.${CPUTYPE} 95 # so this will have to do until I can. 96 NANO_OBJ=${NANO_SRC}/../embedded/obj.${NANO_CPUTYPE} 97fi 98NANO_LOG=${NANO_OBJ}/../${NANO_NAME} 99NANO_DISKIMGDIR=${NANO_OBJ}/../images 100NANO_WORLDDIR=${NANO_LOG}/_.w 101NANO_INIT_IMG2=0 102NANO_NOPRIV_BUILD=t 103unset MAKEOBJDIRPREFIX 104 105mkdir -p ${NANO_OBJ} 106NANO_OBJ=$(realpath ${NANO_OBJ}) 107mkdir -p ${NANO_LOG} 108NANO_LOG=$(realpath ${NANO_LOG}) 109mkdir -p ${NANO_WORLDDIR} 110NANO_WORLDDIR=$(realpath ${NANO_WORLDDIR}) 111mkdir -p ${NANO_DISKIMGDIR} 112NANO_DISKIMGDIR=$(realpath ${NANO_DISKIMGDIR}) 113 114NANO_FAT_DIR=${NANO_LOG}/_.fat 115 116customize_cmd cust_allow_ssh_root 117 118add_etc_make_conf ( ) ( 119 touch ${NANO_WORLDDIR}/etc/make.conf 120) 121customize_cmd add_etc_make_conf 122 123cust_install_machine_files ( ) ( 124 echo "cd ${NANO_CFG_BASE}/Files" 125 cd ${NANO_CFG_BASE}/Files 126 find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${NANO_WORLDDIR} 127) 128customize_cmd cust_install_files 129customize_cmd cust_install_machine_files 130 131# NB: leave c++ enabled so devd can be built 132CONF_BUILD=" 133WITHOUT_ACPI=true 134WITHOUT_ATM=true 135WITHOUT_AUDIT=true 136WITHOUT_BIND_DNSSEC=true 137WITHOUT_BIND_ETC=true 138WITHOUT_BIND_LIBS_LWRES=true 139WITHOUT_BLUETOOTH=true 140WITHOUT_CALENDAR=true 141WITHOUT_CVS=true 142WITHOUT_DICT=true 143WITHOUT_EXAMPLES=true 144WITHOUT_FORTRAN=true 145WITHOUT_GAMES=true 146WITHOUT_GCOV=true 147WITHOUT_GPIB=true 148WITHOUT_HTML=true 149WITHOUT_I4B=true 150WITHOUT_IPFILTER=true 151WITHOUT_IPX=true 152WITHOUT_LIBKSE=true 153WITHOUT_LOCALES=true 154WITHOUT_LPR=true 155WITHOUT_MAN=true 156WITHOUT_NETCAT=true 157WITHOUT_NIS=true 158WITHOUT_NLS=true 159WITHOUT_NS_CACHING=true 160WITHOUT_OBJC=true 161WITHOUT_PROFILE=true 162WITHOUT_RCMDS=true 163WITHOUT_SENDMAIL=true 164WITHOUT_SHAREDOCS=true 165WITHOUT_SYSCONS=true 166WITHOUT_LIB32=true 167WITHOUT_TESTS=true 168WITHOUT_DEBUG_FILES=t 169WITHOUT_KERNEL_SYMBOLS=t 170" 171CONF_INSTALL="$CONF_BUILD 172INSTALL_NODEBUG=t 173NOPORTDOCS=t 174NO_INSTALL_MANPAGES=t 175" 176# The following would help... 177# WITHOUT_TOOLCHAIN=true can't build ports 178# WITHOUT_INSTALLLIB=true libgcc.a 179# 180# from the build 181# WITHOUT_INFO=true makeinfo 182# WITHOUT_RCS=true 183PKG_ONLY_MAKE_CONF=" 184WITHOUT_TOOLCHAIN=true 185WITHOUT_INSTALLLIB=true 186WITHOUT_INFO=true 187WITHOUT_RCS=true 188" 189 190NANO_PACKAGE_ONLY=1 191 192# Creates images for all the formats that use MBR / GPT 193# split later if the #ifdef soup gets too bad. 194create_diskimage_gpt ( ) ( 195 pprint 2 "build diskimage gpt ${NANO_NAME}" 196 197 create_diskimage_mbr $* 198) 199 200create_diskimage_mbr ( ) ( 201 202 pprint 2 "build diskimage ${NANO_NAME}" 203 pprint 3 "log: ${NANO_LOG}/_.di" 204 205 ( 206 local extra i sz fmt fmtarg bootmbr bootbsd skiparg 207 set -o xtrace 208 209 [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}" 210 [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}" 211 bootmbr=${NANO_BOOT_MBR:+-b ${NANO_BOOT_MBR}} 212 bootbsd=${NANO_BOOT_BSD:+-b ${NANO_BOOT_BSD}} 213 skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}} 214 215 for i in s1 s2 s3 s4 p1 p2 p3 p4 p5 empty; do 216 rm -fr ${NANO_LOG}/_.${i}* 217 done 218 219 # Populate the FAT partition, if needed 220 if [ -n "${NANO_SLICE_FAT}" ]; then 221 echo Creating MSDOS partition for kernel 222 newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \ 223 ${NANO_LOG}/_.${NANO_SLICE_FAT} 224 if [ -d ${NANO_FAT_DIR} ]; then 225 # Need to copy files from ${NANO_FATDIR} with mtools, or use 226 # makefs -t msdos once that's supported 227 mcopy -i ${NANO_LOG}/_.${NANO_SLICE_FAT} ${NANO_FAT_DIR}/* :: 228 fi 229 fi 230 231 # Populate the Powerpc boot image, if needed 232 if [ "${NANO_LAYOUT}" = powerpc64-ibm ]; then 233 dd if=${NANO_WORLDDIR}/boot/boot1.elf of=${NANO_LOG}/_.s1 bs=800k count=1 conv=sync 234 fi 235 236 # Populate the / partition, and place it into a slice with a 237 # bsd label 238 [ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}" 239 sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}} 240 eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_LOG}/_.${NANO_ROOT}" \ 241 "${NANO_WORLDDIR}" 242 case ${NANO_DISK_SCHEME} in 243 mbr) 244 mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_LOG}/_.${NANO_ROOT} \ 245 -o ${NANO_LOG}/_.${NANO_SLICE_ROOT} 246 eval $NANO_SLICE_CFG=freebsd 247 eval $NANO_SLICE_ROOT=freebsd 248 ;; 249 gpt) 250 eval $NANO_SLICE_CFG=freebsd-ufs 251 eval $NANO_SLICE_ROOT=freebsd-ufs 252 ;; 253 esac 254 255 # Populate the /cfg partition, empty if none given 256 if [ -z "${NANO_CFGDIR}" ]; then 257 echo "Faking cfg dir, it's empty" 258 NANO_CFGDIR=${NANO_LOG}/_.empty 259 mkdir -p ${NANO_CFGDIR} 260 fi 261 # XXX -F cfg-mtree 262 eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \ 263 "${NANO_LOG}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}" 264 265 # data slice not supported since we need the part for FAT for 266 # booting 267 268 # Now shuffle all the slices together into the proper layout 269 if [ -n "$NANO_SLICE_FAT" ]; then 270 eval $NANO_SLICE_FAT=fat16b 271 fi 272 273 out=${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt} 274 # below depends on https://reviews.freebsd.org/D4403 not yet in the tree 275 # but there's problems: it marks all partitions as active, so you have to 276 # boot off parittion 3 or 2 by hand if you're playing around with this WIP 277 case ${NANO_LAYOUT} in 278 std-embedded) 279 mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \ 280 -p ${s2}:=${NANO_LOG}/_.s2 \ 281 -p ${s3}:=${NANO_LOG}/_.s3 \ 282 -o ${out} 283 ;; 284 std-x86) 285 # s1 is cfg, s2 is /, not sure how to make that 286 # boot (marked as active) with mkimg yet 287 mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \ 288 -p ${s2}:=${NANO_LOG}/_.s2 \ 289 -o ${out} 290 ;; 291 std-uefi) 292 # s1 is boot, s2 is cfg, s3 is /, not sure how to make that 293 # boot (marked as active) with mkimg yet 294 mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr \ 295 -p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \ 296 -p ${s2}:=${NANO_LOG}/_.s2 \ 297 -p ${s3}:=${NANO_LOG}/_.s3 \ 298 -o ${out} 299 ;; 300 std-uefi-bios) 301 # p1 is boot for uefi, p2 is boot for gpt, p3 is cfg, p4 is / 302 # and p5 is alt-root (after resize) 303 mkimg -a 2 ${fmtarg} ${bootmbr} -s gpt \ 304 -p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \ 305 -p freebsd-boot:=${NAANO_WORLDDIR}/boot/gptboot \ 306 -p ${p3}:=${NANO_LOG}/_.p3 \ 307 -p ${p4}:=${NANO_LOG}/_.p4 \ 308 -o ${out} 309 ;; 310 powerpc64-ibm) 311 # A lie to make the boot loader work, it boots the first BSD partition 312 # it finds, regardless of the active flag. 313 s2=fat16b 314 # boot image is on a special partition, ala std-embedded, but that 315 # partition isn't FAT with special files, but a copy of the boot 316 # loader itself. 317 mkimg -a 1 ${fmtarg} -s mbr -p prepboot:=${NANO_LOG}/_.s1 \ 318 -p ${s2}:=${NANO_LOG}/_.s2 \ 319 -p ${s3}:=${NANO_LOG}/_.s3a \ 320 -o ${out} 321 ;; 322 esac 323 rm -f ${out}.xz 324 xz -9 --keep ${out} 325 ) > ${NANO_LOG}/_.di 2>&1 326) 327 328die( ) { 329 echo "$*" 330 exit 1 331} 332 333# Automatically include the packaging port here so it is always first so it 334# builds the port and adds the package so we can add other packages. 335#XXX Doesn't work for cross build, so punting until I can integreate qemu-static 336#XXX or poudere, both of which require priv'd execution. Or qemu-system, which 337#XXX is super, super slow. 338#add_port ports-mgmt/pkg 339#add_port security/sudo 340#add_port ftp/curl 341 342rp=$(realpath ${NANO_OBJ}/) 343__a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'` 344if [ -n "$__a" ]; then 345 echo "unmounting $__a" 346 umount $__a 347fi 348 349if [ "$DEBUG" = 1 ]; then 350 DEBUG_BUILD=" 351DEBUG_FLAGS= -g 352" 353else 354 DEBUG_INSTALL=" 355INSTALL_NODEBUG= t 356" 357fi 358 359CONF_INSTALL="$CONF_BUILD 360${DEBUG_BUILD} 361" 362CONF_INSTALL="$CONF_INSTALL 363${DEBUG_INSTALL} 364" 365 366if [ "${NANO_PACKAGE_ONLY}" -eq 1 ]; then 367 CONF_INSTALL="${CONF_INSTALL} 368${PKG_ONLY_MAKE_CONF} 369" 370 echo "Automatically building a thin image with packages" 371else 372 echo "Automatically building a * * F A T * * image so we can build ports" 373fi 374 375VARS="MASTER_SITE_BACKUP MASTER_SITE_OVERRIDE PACKAGEROOT PACKAGESITE" 376 377for var in $VARS; do 378 val=$(eval echo "\$$var") 379 if [ -n "$val" ]; then 380 CONF_INSTALL="${CONF_INSTALL} 381$var=$val" 382 fi 383done 384 385typical_embedded ( ) ( 386 # Need to create rc.conf before we copy over /etc to /conf/base/etc 387 # so now's a good time. 388 389 local rc=${NANO_WORLDDIR}/etc/rc.conf 390 391 echo "hostname=nanobsd-${NANO_NAME}" > $rc 392 echo "growfs_enable=YES" >> $rc 393 echo "growfs_type=nanobsd-pingpong" >> $rc 394 echo "ntpdate_enable=YES" >> $rc 395 echo "ifconfig_DEFAULT=DHCP" >> $rc 396 echo "ntpdate_hosts='0.freebsd.pool.ntp.org 1.freebsd.pool.ntp.org'" >> $rc 397 # Make sure that firstboot scripts run so growfs works. 398 # Note: still some issues remvoing this XXX 399 touch ${NANO_WORLDDIR}/firstboot 400) 401customize_cmd typical_embedded 402 403fix_pkg ( ) ( 404 chdir ${NANO_WORLDDIR} 405 mkdir -p pkg 406 mkdir -p pkg/db 407 mkdir -p pkg/cache 408 mkdir -p pkg/tmp # Needed for pkg bootstrap 409 mkdir -p usr/local/etc # Will get moved to local/etc 410 ( 411 echo 'PKG_DBDIR = "/pkg/db"' 412 echo 'PKG_CACHEDIR = "/pkg/cache"' 413 echo 'DEFAULT_ALWAYS_YES = "yes"' 414 echo 'ASSUME_ALWAYS_YES = "yes"' 415 ) >> usr/local/etc/pkg.conf 416 [ -z ${NANO_NOPRIV_BUILD} ] || ( 417 echo "./pkg type=dir uname=root gname=wheel mode=0755" 418 echo "./pkg/cache type=dir uname=root gname=wheel mode=0755" 419 echo "./pkg/db type=dir uname=root gname=wheel mode=0755" 420 echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755" 421 ) >> ${NANO_METALOG} 422) 423customize_cmd fix_pkg 424 425save_build ( ) ( 426 VERSION_FILE=${NANO_WORLDDIR}/etc/version 427 if [ "${SVNREVISION}" = "${REVISION}" ]; then 428 echo "${NANO_NAME}" > "${VERSION_FILE}" 429 else 430 echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}" 431 fi 432) 433customize_cmd save_build 434 435shrink_md_fbsize ( ) ( 436 # We have a lot of little files on our memory disks. Let's decrease 437 # the block and frag size to fit more little files on them (this 438 # halves our space requirement by ~50% on /etc and /var on 8.x -- 439 # and gives us more back on 9.x as the default block and frag size 440 # are 4 times larger). 441 sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \ 442 ${NANO_WORLDDIR}/etc/rc.initdiskless 443) 444customize_cmd shrink_md_fbsize 445 446customize_cmd cust_comconsole 447 448dos_boot_part ( ) ( 449 local d=/usr/local/share/u-boot/${NANO_BOOT_PKG} 450 local f=${NANO_FAT_DIR} 451 452 # For now, just copy all the files. However, for iMX6 and Allwinner, 453 # we'll need to put a special boot block at a fixed location 454 # on the disk as well. 455 rm -rf $f 456 mkdir $f 457 chdir $f 458 cp ${d}/* . 459 460 # Also copy ubldr. u-boot will load it and it will load the kernel 461 # from the ufs partition 462 cp ${NANO_WORLDDIR}/boot/ubldr . 463 cp ${NANO_WORLDDIR}/boot/ubldr.bin . 464 465 # We have to touch the saveenv file 466 touch uEnv.txt 467 468 # Now we need to copy over dtb files from the build. 469 cp ${NANO_WORLDDIR}/boot/dtb/*.dtb . 470) 471 472if [ -n "$NANO_BOOT_PKG" ]; then 473 if [ ! -d ${d} ]; then 474 echo ${NANO_BOOT_PKG} not installed. Sadly, it must be. 475 exit 1 476 fi 477 if [ ! -x /usr/local/bin/mcopy ]; then 478 echo mtools not installed. Sadly, we gotta have it. 479 exit 1 480 fi 481 customize_cmd dos_boot_part 482fi 483 484product_custom ( ) ( 485 # not quie ready to tweak these in nopriv build 486 if [ -z ${NANO_NOPRIV_BUILD} ]; then 487 # Last second tweaks -- generally not needed 488 chown -R root:wheel ${NANO_WORLDDIR}/root 489 chmod 0755 ${NANO_WORLDDIR}/root/* 490 chmod 0755 ${NANO_WORLDDIR}/* 491 chown -R root:wheel ${NANO_WORLDDIR}/etc 492 chown -R root:wheel ${NANO_WORLDDIR}/boot 493 chown root:wheel ${NANO_WORLDDIR}/ 494 chown root:wheel ${NANO_WORLDDIR}/usr 495 fi 496) 497late_customize_cmd product_custom 498 499# 500# Convenience routines to bring up many settings for standard environments 501# 502 503# 504# For each architecture, we have a standard set of settings to the extent 505# it makes sense. For architectures that don't have a standard environment 506# cfg files need to either define a lot of settings, provide their own disk 507# imaging, or set which of the variants we support. No subshells, since we 508# set global variables 509# 510 511std_aarch64 ( ) { 512} 513 514std_amd64 ( ) { 515 std_i386 516} 517 518std_arm ( ) { 519} 520 521std_armeb ( ) { 522 NANO_ENDIAN=big 523} 524 525std_armv6 ( ) { 526} 527 528std_i386 ( ) { 529 # Default values, if not overridden in .cfg file 530 : ${NANO_KERNEL:=GENERIC} 531 : ${NANO_DRIVE:=ada0} 532 : ${NANO_LAYOUT:=std-x86} 533 : ${NANO_BOOT_MBR:=${NANO_WORLDDIR}/boot/boot0sio} 534 : ${NANO_BOOT_BSD:=${NANO_WORLDDIR}/boot/boot} 535} 536 537std_mips ( ) { 538 NANO_ENDIAN=big 539} 540 541std_mipsel ( ) { 542} 543 544std_mips64 ( ) { 545 NANO_ENDIAN=big 546} 547 548std_mips64el ( ) { 549} 550 551std_powerpc ( ) { 552 NANO_ENDIAN=big 553} 554 555std_powerpc64 ( ) { 556 NANO_LAYOUT=powerpc64-ibm 557 NANO_ENDIAN=big 558} 559 560std_sparc64 ( ) { 561 NANO_ENDIAN=big 562} 563 564# 565# QEMU settings for the standard environments 566# 567qemu_env ( ) { 568 569 NANO_DISKIMAGE_FORMAT=qcow2 570} 571 572# other standard environments will go here 573 574eval std_${NANO_ARCH} 575 576# Slice 1: FAT for ROM loading bootstrap 577# Slice 2: Config partition 578# Slice 3: FreeBSD partition (sized exactly) 579# Slice 4: FreeBSD partition (empty) 580# on first boot, we resize slice 3 & 4 to be 1/2 of what's 581# left over on the SD card after slice 1 and 2 are taken 582# off the top. We also resize the 'a' partion on first boot 583# to the size of the partition for the ping/pong upgrade. 584# This feature needs support in the rc.d bootup script. 585# 586# Ideally, we'd not put BSD labels on the MBR disks. 587# However, we can't boot off raw MBR disks. First, 588# boot2 defaults to 'a' partition, and freaks out 589# unless you tell it to use 'c'. But even if we 590# hack that, then /boot/loader wants to load off 591# of 'c' partition. If you fix that, then we'll 592# try to mount root, but sanity checks prevent 593# slices from working. 594# 595 596: ${NANO_ENDIAN:=little} # make -V something to figure it out? 597: ${NANO_LAYOUT:=std-embedded} 598: ${NANO_MAKEFS_UFS:=makefs -t ffs -B ${NANO_ENDIAN}} 599: ${NANO_DISK_SCHEME:=mbr} # No others really supported ATM (well, gpt) 600case ${NANO_LAYOUT} in 601std-embedded) 602 NANO_SLICE_FAT=s1 603 NANO_SLICE_CFG=s2 604 NANO_SLICE_ROOT=s3 605 NANO_SLICE_ALTROOT=s4 606 ;; 607std-x86) 608 NANO_SLICE_CFG=s1 609 NANO_SLICE_ROOT=s2 610 NANO_SLICE_ALTROOT=s3 611 ;; 612powerpc64-ibm) 613 NANO_SLICE_PPCBOOT=s1 614 NANO_SLICE_CFG=s2 615 NANO_SLICE_ROOT=s3 616 NANO_SLICE_ALTROOT=s4 617 ;; 618powerpc64-apple) 619 echo Not yet 620 exit 1 621 ;; 622std-uefi) 623 NANO_SLICE_UEFI=s1 624 NANO_SLICE_CFG=s2 625 NANO_SLICE_ROOT=s3 626 NANO_SLICE_ALTROOT=s4 627 ;; 628std-uefi-bios) 629 NANO_DISK_SCHEME=gpt 630 NANO_SLICE_UEFI=p1 631 NANO_SLICE_BOOT=p2 632 NANO_SLICE_CFG=p3 633 NANO_SLICE_ROOT=p4 634 NANO_SLICE_ALTROOT=p5 635 # override root name 636 NANO_ROOT=${NANO_SLICE_ROOT} 637 NANO_ALTROOT=${NANO_SLICE_ALTROOT} 638 ;; 639*) 640 echo Unknown Layout ${NANO_LAYOUT} 641 exit 1 642 ;; 643esac 644 645 646NANO_SLICE_DATA= # Not included 647 648# Each major disk scheme has its own routine. Generally 649# this is for mbr, gpt, etc. These are generally are widely 650# shared, but some specialized formats won't be shared. 651create_diskimage ( ) ( 652 eval create_diskimage_${NANO_DISK_SCHEME} 653) 654