1# $FreeBSD$ 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 instructions 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=" 133LOCAL_XTOOL_DIRS=usr.bin/mkimg 134WITHOUT_ACPI=true 135WITHOUT_ATM=true 136WITHOUT_AUDIT=true 137WITHOUT_BIND_DNSSEC=true 138WITHOUT_BIND_ETC=true 139WITHOUT_BIND_LIBS_LWRES=true 140WITHOUT_BLUETOOTH=true 141WITHOUT_CALENDAR=true 142WITHOUT_CVS=true 143WITHOUT_DICT=true 144WITHOUT_EXAMPLES=true 145WITHOUT_FORTRAN=true 146WITHOUT_GAMES=true 147WITHOUT_GCOV=true 148WITHOUT_GPIB=true 149WITHOUT_HTML=true 150WITHOUT_I4B=true 151WITHOUT_IPFILTER=true 152WITHOUT_IPX=true 153WITHOUT_LIBKSE=true 154WITHOUT_LOCALES=true 155WITHOUT_LPR=true 156WITHOUT_MAN=true 157WITHOUT_NETCAT=true 158WITHOUT_NIS=true 159WITHOUT_NLS=true 160WITHOUT_NS_CACHING=true 161WITHOUT_OBJC=true 162WITHOUT_PROFILE=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 local fmt 203 204 [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}" 205 206 pprint 2 "build diskimage ${NANO_NAME}" 207 pprint 3 "log: ${NANO_LOG}/_.di" 208 pprint 3 "image in: ${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt}" 209 210 ( 211 local extra i sz fmt fmtarg bootmbr bootbsd skiparg 212 set -o xtrace 213 # Tell mtools not to be too picky 214 export MTOOLS_SKIP_CHECK=1 215 216 [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}" 217 [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}" 218 bootmbr=${NANO_BOOT_MBR:+-b ${NANO_BOOT_MBR}} 219 bootbsd=${NANO_BOOT_BSD:+-b ${NANO_BOOT_BSD}} 220 skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}} 221 222 for i in s1 s2 s3 s4 p1 p2 p3 p4 p5 empty; do 223 rm -fr ${NANO_LOG}/_.${i}* 224 done 225 226 # Populate the FAT partition, if needed 227 if [ -n "${NANO_SLICE_FAT}" ]; then 228 echo Creating MSDOS partition for kernel 229 newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \ 230 ${NANO_LOG}/_.${NANO_SLICE_FAT} 231 if [ -d ${NANO_FAT_DIR} ]; then 232 # Need to copy files from ${NANO_FATDIR} with mtools, or use 233 # makefs -t msdos once that's supported 234 mcopy -i ${NANO_LOG}/_.${NANO_SLICE_FAT} ${NANO_FAT_DIR}/* :: 235 fi 236 fi 237 238 # Populate the Powerpc boot image, if needed 239 if [ "${NANO_LAYOUT}" = powerpc64-ibm ]; then 240 dd if=${NANO_WORLDDIR}/boot/boot1.elf of=${NANO_LOG}/_.s1 bs=800k count=1 conv=sync 241 fi 242 243 # Populate the / partition, and place it into a slice with a 244 # bsd label 245 [ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}" 246 sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}} 247 eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_LOG}/_.${NANO_ROOT}" \ 248 "${NANO_WORLDDIR}" 249 case ${NANO_DISK_SCHEME} in 250 mbr) 251 mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_LOG}/_.${NANO_ROOT} \ 252 -o ${NANO_LOG}/_.${NANO_SLICE_ROOT} 253 eval $NANO_SLICE_CFG=freebsd 254 eval $NANO_SLICE_ROOT=freebsd 255 ;; 256 gpt) 257 eval $NANO_SLICE_CFG=freebsd-ufs 258 eval $NANO_SLICE_ROOT=freebsd-ufs 259 ;; 260 esac 261 262 # Populate the /cfg partition, empty if none given 263 if [ -z "${NANO_CFGDIR}" ]; then 264 echo "Faking cfg dir, it's empty" 265 NANO_CFGDIR=${NANO_LOG}/_.empty 266 mkdir -p ${NANO_CFGDIR} 267 fi 268 # XXX -F cfg-mtree 269 eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \ 270 "${NANO_LOG}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}" 271 272 # data slice not supported since we need the part for FAT for 273 # booting 274 275 # Now shuffle all the slices together into the proper layout 276 if [ -n "$NANO_SLICE_FAT" ]; then 277 eval $NANO_SLICE_FAT=fat16b 278 fi 279 280 out=${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt} 281 # below depends on https://reviews.freebsd.org/D4403 not yet in the tree 282 # but there's problems: it marks all partitions as active, so you have to 283 # boot off partition 3 or 2 by hand if you're playing around with this WIP 284 case ${NANO_LAYOUT} in 285 std-embedded) 286 mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \ 287 -p ${s2}:=${NANO_LOG}/_.s2 \ 288 -p ${s3}:=${NANO_LOG}/_.s3 \ 289 -o ${out} 290 ;; 291 std-x86) 292 # s1 is cfg, s2 is /, not sure how to make that 293 # boot (marked as active) with mkimg yet 294 mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \ 295 -p ${s2}:=${NANO_LOG}/_.s2 \ 296 -o ${out} 297 ;; 298 std-uefi) 299 # s1 is boot, s2 is cfg, s3 is /, not sure how to make that 300 # boot (marked as active) with mkimg yet 301 mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr \ 302 -p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \ 303 -p ${s2}:=${NANO_LOG}/_.s2 \ 304 -p ${s3}:=${NANO_LOG}/_.s3 \ 305 -o ${out} 306 ;; 307 std-uefi-bios) 308 # p1 is boot for uefi, p2 is boot for gpt, p3 is cfg, p4 is / 309 # and p5 is alt-root (after resize) 310 mkimg -a 2 ${fmtarg} ${bootmbr} -s gpt \ 311 -p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \ 312 -p freebsd-boot:=${NAANO_WORLDDIR}/boot/gptboot \ 313 -p ${p3}:=${NANO_LOG}/_.p3 \ 314 -p ${p4}:=${NANO_LOG}/_.p4 \ 315 -o ${out} 316 ;; 317 powerpc64-ibm) 318 # A lie to make the boot loader work, it boots the first BSD partition 319 # it finds, regardless of the active flag. 320 s2=fat16b 321 # boot image is on a special partition, ala std-embedded, but that 322 # partition isn't FAT with special files, but a copy of the boot 323 # loader itself. 324 mkimg -a 1 ${fmtarg} -s mbr -p prepboot:=${NANO_LOG}/_.s1 \ 325 -p ${s2}:=${NANO_LOG}/_.s2 \ 326 -p ${s3}:=${NANO_LOG}/_.s3a \ 327 -o ${out} 328 ;; 329 esac 330 rm -f ${out}.xz 331 xz -9 --keep ${out} 332 ) > ${NANO_LOG}/_.di 2>&1 333) 334 335die( ) { 336 echo "$*" 337 exit 1 338} 339 340# Automatically include the packaging port here so it is always first so it 341# builds the port and adds the package so we can add other packages. 342#XXX Doesn't work for cross build, so punting until I can integreate qemu-static 343#XXX or poudriere, both of which require priv'd execution. Or qemu-system, 344#XXX which is super, super slow. 345#add_port ports-mgmt/pkg 346#add_port security/sudo 347#add_port ftp/curl 348 349rp=$(realpath ${NANO_OBJ}/) 350__a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'` 351if [ -n "$__a" ]; then 352 echo "unmounting $__a" 353 umount $__a 354fi 355 356if [ "$DEBUG" = 1 ]; then 357 DEBUG_BUILD=" 358DEBUG_FLAGS= -g 359" 360else 361 DEBUG_INSTALL=" 362INSTALL_NODEBUG= t 363" 364fi 365 366CONF_INSTALL="$CONF_BUILD 367${DEBUG_BUILD} 368" 369CONF_INSTALL="$CONF_INSTALL 370${DEBUG_INSTALL} 371" 372 373if [ "${NANO_PACKAGE_ONLY}" -eq 1 ]; then 374 CONF_INSTALL="${CONF_INSTALL} 375${PKG_ONLY_MAKE_CONF} 376" 377 echo "Automatically building a thin image with packages" 378else 379 echo "Automatically building a * * F A T * * image so we can build ports" 380fi 381 382VARS="MASTER_SITE_BACKUP MASTER_SITE_OVERRIDE PACKAGEROOT PACKAGESITE" 383 384for var in $VARS; do 385 val=$(eval echo "\$$var") 386 if [ -n "$val" ]; then 387 CONF_INSTALL="${CONF_INSTALL} 388$var=$val" 389 fi 390done 391 392typical_embedded ( ) ( 393 # Need to create rc.conf before we copy over /etc to /conf/base/etc 394 # so now's a good time. 395 396 local rc=${NANO_WORLDDIR}/etc/rc.conf 397 398 echo "hostname=nanobsd-${NANO_NAME}" > $rc 399 echo "growfs_enable=YES" >> $rc 400 echo "growfs_type=nanobsd-pingpong" >> $rc 401 echo "ntpdate_enable=YES" >> $rc 402 echo "ifconfig_DEFAULT=DHCP" >> $rc 403 echo "ntpdate_hosts='0.freebsd.pool.ntp.org 1.freebsd.pool.ntp.org'" >> $rc 404 # Make sure that firstboot scripts run so growfs works. 405 # Note: still some issues remvoing this XXX 406 touch ${NANO_WORLDDIR}/firstboot 407) 408customize_cmd typical_embedded 409 410fix_pkg ( ) ( 411 chdir ${NANO_WORLDDIR} 412 mkdir -p pkg 413 mkdir -p pkg/db 414 mkdir -p pkg/cache 415 mkdir -p pkg/tmp # Needed for pkg bootstrap 416 mkdir -p usr/local/etc # Will get moved to local/etc 417 ( 418 echo 'PKG_DBDIR = "/pkg/db"' 419 echo 'PKG_CACHEDIR = "/pkg/cache"' 420 echo 'DEFAULT_ALWAYS_YES = "yes"' 421 echo 'ASSUME_ALWAYS_YES = "yes"' 422 ) >> usr/local/etc/pkg.conf 423 [ -z ${NANO_NOPRIV_BUILD} ] || ( 424 echo "./pkg type=dir uname=root gname=wheel mode=0755" 425 echo "./pkg/cache type=dir uname=root gname=wheel mode=0755" 426 echo "./pkg/db type=dir uname=root gname=wheel mode=0755" 427 echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755" 428 ) >> ${NANO_METALOG} 429) 430customize_cmd fix_pkg 431 432save_build ( ) ( 433 VERSION_FILE=${NANO_WORLDDIR}/etc/version 434 if [ "${SVNREVISION}" = "${REVISION}" ]; then 435 echo "${NANO_NAME}" > "${VERSION_FILE}" 436 else 437 echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}" 438 fi 439) 440customize_cmd save_build 441 442shrink_md_fbsize ( ) ( 443 # We have a lot of little files on our memory disks. Let's decrease 444 # the block and frag size to fit more little files on them (this 445 # halves our space requirement by ~50% on /etc and /var on 8.x -- 446 # and gives us more back on 9.x as the default block and frag size 447 # are 4 times larger). 448 sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \ 449 ${NANO_WORLDDIR}/etc/rc.initdiskless 450) 451customize_cmd shrink_md_fbsize 452 453customize_cmd cust_comconsole 454 455dos_boot_part ( ) ( 456 local d=/usr/local/share/u-boot/${NANO_BOOT_PKG} 457 local f=${NANO_FAT_DIR} 458 459 # For now, just copy all the files. However, for iMX6 and Allwinner, 460 # we'll need to put a special boot block at a fixed location 461 # on the disk as well. 462 rm -rf $f 463 mkdir $f 464 chdir $f 465 cp ${d}/* . 466 467 # Also copy ubldr. u-boot will load it and it will load the kernel 468 # from the ufs partition 469 cp ${NANO_WORLDDIR}/boot/ubldr . 470 cp ${NANO_WORLDDIR}/boot/ubldr.bin . 471 472 # We have to touch the saveenv file 473 touch uEnv.txt 474 475 # Now we need to copy over dtb files from the build. 476 cp ${NANO_WORLDDIR}/boot/dtb/*.dtb . 477) 478 479if [ -n "$NANO_BOOT_PKG" ]; then 480 local d=/usr/local/share/u-boot/${NANO_BOOT_PKG} 481 if [ ! -d ${d} ]; then 482 echo ${NANO_BOOT_PKG} not installed. Sadly, it must be. 483 exit 1 484 fi 485 if [ ! -x /usr/local/bin/mcopy ]; then 486 echo mtools not installed. Sadly, we gotta have it. 487 exit 1 488 fi 489 customize_cmd dos_boot_part 490fi 491 492product_custom ( ) ( 493 # not quite ready to tweak these in nopriv build 494 if [ -z ${NANO_NOPRIV_BUILD} ]; then 495 # Last second tweaks -- generally not needed 496 chown -R root:wheel ${NANO_WORLDDIR}/root 497 chmod 0755 ${NANO_WORLDDIR}/root/* 498 chmod 0755 ${NANO_WORLDDIR}/* 499 chown -R root:wheel ${NANO_WORLDDIR}/etc 500 chown -R root:wheel ${NANO_WORLDDIR}/boot 501 chown root:wheel ${NANO_WORLDDIR}/ 502 chown root:wheel ${NANO_WORLDDIR}/usr 503 fi 504) 505late_customize_cmd product_custom 506 507# 508# Convenience routines to bring up many settings for standard environments 509# 510 511# 512# For each architecture, we have a standard set of settings to the extent 513# it makes sense. For architectures that don't have a standard environment 514# cfg files need to either define a lot of settings, provide their own disk 515# imaging, or set which of the variants we support. No subshells, since we 516# set global variables 517# 518 519std_aarch64 ( ) { 520} 521 522std_amd64 ( ) { 523 std_i386 524} 525 526std_arm ( ) { 527} 528 529std_armeb ( ) { 530 NANO_ENDIAN=big 531} 532 533std_armv6 ( ) { 534} 535 536std_i386 ( ) { 537 # Default values, if not overridden in .cfg file 538 : ${NANO_KERNEL:=GENERIC} 539 : ${NANO_DRIVE:=ada0} 540 : ${NANO_LAYOUT:=std-x86} 541 : ${NANO_BOOT_MBR:=${NANO_WORLDDIR}/boot/boot0sio} 542 : ${NANO_BOOT_BSD:=${NANO_WORLDDIR}/boot/boot} 543} 544 545std_mips ( ) { 546 NANO_ENDIAN=big 547} 548 549std_mipsel ( ) { 550} 551 552std_mips64 ( ) { 553 NANO_ENDIAN=big 554} 555 556std_mips64el ( ) { 557} 558 559std_powerpc ( ) { 560 NANO_ENDIAN=big 561} 562 563std_powerpc64 ( ) { 564 NANO_LAYOUT=powerpc64-ibm 565 NANO_ENDIAN=big 566} 567 568std_sparc64 ( ) { 569 NANO_ENDIAN=big 570} 571 572# 573# QEMU settings for the standard environments 574# 575qemu_env ( ) { 576 577 NANO_DISKIMAGE_FORMAT=qcow2 578} 579 580# other standard environments will go here 581 582eval std_${NANO_ARCH} 583 584# Slice 1: FAT for ROM loading bootstrap 585# Slice 2: Config partition 586# Slice 3: FreeBSD partition (sized exactly) 587# Slice 4: FreeBSD partition (empty) 588# on first boot, we resize slice 3 & 4 to be 1/2 of what's 589# left over on the SD card after slice 1 and 2 are taken 590# off the top. We also resize the 'a' partion on first boot 591# to the size of the partition for the ping/pong upgrade. 592# This feature needs support in the rc.d bootup script. 593# 594# Ideally, we'd not put BSD labels on the MBR disks. 595# However, we can't boot off raw MBR disks. First, 596# boot2 defaults to 'a' partition, and freaks out 597# unless you tell it to use 'c'. But even if we 598# hack that, then /boot/loader wants to load off 599# of 'c' partition. If you fix that, then we'll 600# try to mount root, but sanity checks prevent 601# slices from working. 602# 603 604: ${NANO_ENDIAN:=little} # make -V something to figure it out? 605: ${NANO_LAYOUT:=std-embedded} 606: ${NANO_MAKEFS_UFS:=makefs -t ffs -B ${NANO_ENDIAN}} 607: ${NANO_DISK_SCHEME:=mbr} # No others really supported ATM (well, gpt) 608case ${NANO_LAYOUT} in 609std-embedded) 610 NANO_SLICE_FAT=s1 611 NANO_SLICE_CFG=s2 612 NANO_SLICE_ROOT=s3 613 NANO_SLICE_ALTROOT=s4 614 NANO_ROOT=${NANO_SLICE_ROOT}a 615 NANO_ALTROOT=${NANO_SLICE_ALTROOT}a 616 ;; 617std-x86) 618 NANO_SLICE_CFG=s1 619 NANO_SLICE_ROOT=s2 620 NANO_SLICE_ALTROOT=s3 621 NANO_ROOT=${NANO_SLICE_ROOT}a 622 NANO_ALTROOT=${NANO_SLICE_ALTROOT}a 623 ;; 624powerpc64-ibm) 625 NANO_SLICE_PPCBOOT=s1 626 NANO_SLICE_CFG=s2 627 NANO_SLICE_ROOT=s3 628 NANO_SLICE_ALTROOT=s4 629 NANO_ROOT=${NANO_SLICE_ROOT}a 630 NANO_ALTROOT=${NANO_SLICE_ALTROOT}a 631 ;; 632powerpc64-apple) 633 echo Not yet 634 exit 1 635 ;; 636std-uefi) 637 NANO_SLICE_UEFI=s1 638 NANO_SLICE_CFG=s2 639 NANO_SLICE_ROOT=s3 640 NANO_SLICE_ALTROOT=s4 641 NANO_ROOT=${NANO_SLICE_ROOT} 642 NANO_ALTROOT=${NANO_SLICE_ALTROOT} 643 ;; 644std-uefi-bios) 645 NANO_DISK_SCHEME=gpt 646 NANO_SLICE_UEFI=p1 647 NANO_SLICE_BOOT=p2 648 NANO_SLICE_CFG=p3 649 NANO_SLICE_ROOT=p4 650 NANO_SLICE_ALTROOT=p5 651 NANO_ROOT=${NANO_SLICE_ROOT} 652 NANO_ALTROOT=${NANO_SLICE_ALTROOT} 653 ;; 654*) 655 echo Unknown Layout ${NANO_LAYOUT} 656 exit 1 657 ;; 658esac 659 660 661NANO_SLICE_DATA= # Not included 662 663# Each major disk scheme has its own routine. Generally 664# this is for mbr, gpt, etc. These are generally are widely 665# shared, but some specialized formats won't be shared. 666create_diskimage ( ) ( 667 eval create_diskimage_${NANO_DISK_SCHEME} 668) 669 670# Set the path to the same path we use for buldworld to use latest mkimg 671NANO_TARGET=$(cd ${NANO_SRC}; ${NANO_MAKE} TARGET_ARCH=${NANO_ARCH} -V _TARGET) 672NANO_TMPPATH=$(cd ${NANO_SRC}; ${NANO_MAKE} TARGET=${NANO_TARGET} TARGET_ARCH=${NANO_ARCH} -f Makefile.inc1 buildenv -V TMPPATH) 673export PATH="${NANO_TMPPATH}" 674