Lines 129-135
Link Here
|
129 |
NANO_HEADS=16 |
129 |
NANO_HEADS=16 |
130 |
|
130 |
|
131 |
# boot0 flags/options and configuration |
131 |
# boot0 flags/options and configuration |
132 |
NANO_BOOT0CFG="-o packet -s 1 -m 3" |
132 |
NANO_BOOTFLAGS="" |
133 |
NANO_BOOTLOADER="boot/boot0sio" |
133 |
NANO_BOOTLOADER="boot/boot0sio" |
134 |
|
134 |
|
135 |
# boot2 flags/options |
135 |
# boot2 flags/options |
Lines 499-528
Link Here
|
499 |
populate_slice "$1" "$2" "$3" "$4" |
499 |
populate_slice "$1" "$2" "$3" "$4" |
500 |
) |
500 |
) |
501 |
|
501 |
|
502 |
create_diskimage ( ) ( |
502 |
calculate_partitioning ( ) ( |
503 |
pprint 2 "build diskimage" |
|
|
504 |
pprint 3 "log: ${NANO_OBJ}/_.di" |
505 |
|
506 |
( |
507 |
echo $NANO_MEDIASIZE $NANO_IMAGES \ |
503 |
echo $NANO_MEDIASIZE $NANO_IMAGES \ |
508 |
$NANO_SECTS $NANO_HEADS \ |
504 |
$NANO_SECTS $NANO_HEADS \ |
509 |
$NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE | |
505 |
$NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE | |
510 |
awk ' |
506 |
awk ' |
511 |
{ |
507 |
{ |
512 |
printf "# %s\n", $0 |
|
|
513 |
|
514 |
# size of cylinder in sectors |
508 |
# size of cylinder in sectors |
515 |
cs = $3 * $4 |
509 |
cs = $3 * $4 |
516 |
|
510 |
|
517 |
# number of full cylinders on media |
511 |
# number of full cylinders on media |
518 |
cyl = int ($1 / cs) |
512 |
cyl = int ($1 / cs) |
519 |
|
513 |
|
520 |
# output fdisk geometry spec, truncate cyls to 1023 |
|
|
521 |
if (cyl <= 1023) |
522 |
print "g c" cyl " h" $4 " s" $3 |
523 |
else |
524 |
print "g c" 1023 " h" $4 " s" $3 |
525 |
|
526 |
if ($7 > 0) { |
514 |
if ($7 > 0) { |
527 |
# size of data partition in full cylinders |
515 |
# size of data partition in full cylinders |
528 |
dsl = int (($7 + cs - 1) / cs) |
516 |
dsl = int (($7 + cs - 1) / cs) |
Lines 533-577
Link Here
|
533 |
# size of config partition in full cylinders |
521 |
# size of config partition in full cylinders |
534 |
csl = int (($6 + cs - 1) / cs) |
522 |
csl = int (($6 + cs - 1) / cs) |
535 |
|
523 |
|
|
|
524 |
# size of image partition(s) in full cylinders |
536 |
if ($5 == 0) { |
525 |
if ($5 == 0) { |
537 |
# size of image partition(s) in full cylinders |
|
|
538 |
isl = int ((cyl - dsl - csl) / $2) |
526 |
isl = int ((cyl - dsl - csl) / $2) |
539 |
} else { |
527 |
} else { |
540 |
isl = int (($5 + cs - 1) / cs) |
528 |
isl = int (($5 + cs - 1) / cs) |
541 |
} |
529 |
} |
542 |
|
530 |
|
543 |
# First image partition start at second track |
531 |
# First image partition start at second track |
544 |
print "p 1 165 " $3, isl * cs - $3 |
532 |
print $3, isl * cs - $3 |
545 |
c = isl * cs; |
533 |
c = isl * cs; |
546 |
|
534 |
|
547 |
# Second image partition (if any) also starts offset one |
535 |
# Second image partition (if any) also starts offset one |
548 |
# track to keep them identical. |
536 |
# track to keep them identical. |
549 |
if ($2 > 1) { |
537 |
if ($2 > 1) { |
550 |
print "p 2 165 " $3 + c, isl * cs - $3 |
538 |
print $3 + c, isl * cs - $3 |
551 |
c += isl * cs; |
539 |
c += isl * cs; |
552 |
} |
540 |
} |
553 |
|
541 |
|
554 |
# Config partition starts at cylinder boundary. |
542 |
# Config partition starts at cylinder boundary. |
555 |
print "p 3 165 " c, csl * cs |
543 |
print c, csl * cs |
556 |
c += csl * cs |
544 |
c += csl * cs |
557 |
|
545 |
|
558 |
# Data partition (if any) starts at cylinder boundary. |
546 |
# Data partition (if any) starts at cylinder boundary. |
559 |
if ($7 > 0) { |
547 |
if ($7 > 0) { |
560 |
print "p 4 165 " c, dsl * cs |
548 |
print c, dsl * cs |
561 |
} else if ($7 < 0 && $1 > c) { |
549 |
} else if ($7 < 0 && $1 > c) { |
562 |
print "p 4 165 " c, $1 - c |
550 |
print c, $1 - c |
563 |
} else if ($1 < c) { |
551 |
} else if ($1 < c) { |
564 |
print "Disk space overcommitted by", \ |
552 |
print "Disk space overcommitted by", \ |
565 |
c - $1, "sectors" > "/dev/stderr" |
553 |
c - $1, "sectors" > "/dev/stderr" |
566 |
exit 2 |
554 |
exit 2 |
567 |
} |
555 |
} |
568 |
|
|
|
569 |
# Force slice 1 to be marked active. This is necessary |
570 |
# for booting the image from a USB device to work. |
571 |
print "a 1" |
572 |
} |
556 |
} |
573 |
' > ${NANO_OBJ}/_.fdisk |
557 |
' > ${NANO_OBJ}/_.partitioning |
|
|
558 |
|
559 |
) |
560 |
|
561 |
create_code_slice ( ) ( |
562 |
pprint 2 "build code slice" |
563 |
pprint 3 "log: ${NANO_OBJ}/_.cs" |
564 |
|
565 |
( |
566 |
IMG=${NANO_DISKIMGDIR}/_.disk.image |
567 |
MNT=${NANO_OBJ}/_.mnt |
568 |
mkdir -p ${MNT} |
569 |
CODE_SIZE=`head -n 1 ${NANO_OBJ}/_.partitioning | awk '{ print $2 }'` |
570 |
|
571 |
if [ "${NANO_MD_BACKING}" = "swap" ] ; then |
572 |
MD=`mdconfig -a -t swap -s ${CODE_SIZE} -x ${NANO_SECTS} \ |
573 |
-y ${NANO_HEADS}` |
574 |
else |
575 |
echo "Creating md backing file..." |
576 |
rm -f ${IMG} |
577 |
dd if=/dev/zero of=${IMG} seek=${CODE_SIZE} count=0 |
578 |
MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \ |
579 |
-y ${NANO_HEADS}` |
580 |
fi |
581 |
|
582 |
trap "echo 'Running exit trap code' ; df -i ${MNT} ; umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT |
583 |
|
584 |
bsdlabel -w ${MD} |
585 |
if [ -f ${NANO_WORLDDIR}/boot/boot ]; then |
586 |
echo "Making bootable partition" |
587 |
gpart bootcode -b ${NANO_WORLDDIR}/boot/boot ${MD} |
588 |
else |
589 |
echo "Partition will not be bootable" |
590 |
fi |
591 |
bsdlabel ${MD} |
592 |
|
593 |
# Create first image |
594 |
populate_slice /dev/${MD}a ${NANO_WORLDDIR} ${MNT} "s1a" |
595 |
mount /dev/${MD}a ${MNT} |
596 |
echo "Generating mtree..." |
597 |
( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree |
598 |
( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du |
599 |
nano_umount ${MNT} |
574 |
|
600 |
|
|
|
601 |
if [ "${NANO_MD_BACKING}" = "swap" ] ; then |
602 |
echo "Writing out _.disk.image..." |
603 |
dd conv=sparse if=/dev/${MD} of=${NANO_DISKIMGDIR}/_.disk.image bs=64k |
604 |
fi |
605 |
mdconfig -d -u $MD |
606 |
|
607 |
trap - 1 2 15 EXIT |
608 |
|
609 |
) > ${NANO_OBJ}/_.cs 2>&1 |
610 |
) |
611 |
|
612 |
|
613 |
create_diskimage ( ) ( |
614 |
pprint 2 "build diskimage" |
615 |
pprint 3 "log: ${NANO_OBJ}/_.di" |
616 |
|
617 |
( |
575 |
IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME} |
618 |
IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME} |
576 |
MNT=${NANO_OBJ}/_.mnt |
619 |
MNT=${NANO_OBJ}/_.mnt |
577 |
mkdir -p ${MNT} |
620 |
mkdir -p ${MNT} |
Lines 587-615
Link Here
|
587 |
-y ${NANO_HEADS}` |
630 |
-y ${NANO_HEADS}` |
588 |
fi |
631 |
fi |
589 |
|
632 |
|
|
|
633 |
awk ' |
634 |
BEGIN { |
635 |
# Create MBR partition table |
636 |
print "gpart create -s mbr $1" |
637 |
} |
638 |
{ |
639 |
# Make partition |
640 |
print "gpart add -t freebsd -b ", $1, " -s ", $2, " $1" |
641 |
} |
642 |
END { |
643 |
# Force slice 1 to be marked active. This is necessary |
644 |
# for booting the image from a USB device to work. |
645 |
print "gpart set -a active -i 1 $1" |
646 |
} |
647 |
' ${NANO_OBJ}/_.partitioning > ${NANO_OBJ}/_.gpart |
648 |
|
590 |
trap "echo 'Running exit trap code' ; df -i ${MNT} ; nano_umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT |
649 |
trap "echo 'Running exit trap code' ; df -i ${MNT} ; nano_umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT |
591 |
|
650 |
|
592 |
fdisk -i -f ${NANO_OBJ}/_.fdisk ${MD} |
651 |
sh ${NANO_OBJ}/_.gpart ${MD} |
|
|
652 |
gpart show ${MD} |
593 |
fdisk ${MD} |
653 |
fdisk ${MD} |
594 |
# XXX: params |
654 |
# XXX: params |
595 |
# XXX: pick up cached boot* files, they may not be in image anymore. |
655 |
# XXX: pick up cached boot* files, they may not be in image anymore. |
596 |
if [ -f ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ]; then |
656 |
if [ -f ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ]; then |
597 |
boot0cfg -B -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOT0CFG} ${MD} |
657 |
gpart bootcode -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOTFLAGS} ${MD} |
598 |
fi |
658 |
fi |
599 |
if [ -f ${NANO_WORLDDIR}/boot/boot ]; then |
|
|
600 |
bsdlabel -w -B -b ${NANO_WORLDDIR}/boot/boot ${MD}s1 |
601 |
else |
602 |
bsdlabel -w ${MD}s1 |
603 |
fi |
604 |
bsdlabel ${MD}s1 |
605 |
|
659 |
|
606 |
# Create first image |
660 |
echo "Writing code image..." |
607 |
populate_slice /dev/${MD}s1a ${NANO_WORLDDIR} ${MNT} "s1a" |
661 |
dd conv=sparse if=${NANO_DISKIMGDIR}/_.disk.image of=/dev/${MD}s1 bs=64k |
608 |
mount /dev/${MD}s1a ${MNT} |
|
|
609 |
echo "Generating mtree..." |
610 |
( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree |
611 |
( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du |
612 |
nano_umount ${MNT} |
613 |
|
662 |
|
614 |
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then |
663 |
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then |
615 |
# Duplicate to second image (if present) |
664 |
# Duplicate to second image (if present) |
Lines 648-658
Link Here
|
648 |
echo "Writing out ${NANO_IMGNAME}..." |
697 |
echo "Writing out ${NANO_IMGNAME}..." |
649 |
dd conv=sparse if=/dev/${MD} of=${IMG} bs=64k |
698 |
dd conv=sparse if=/dev/${MD} of=${IMG} bs=64k |
650 |
fi |
699 |
fi |
651 |
|
|
|
652 |
if ${do_copyout_partition} ; then |
653 |
echo "Writing out _.disk.image..." |
654 |
dd conv=sparse if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k |
655 |
fi |
656 |
mdconfig -d -u $MD |
700 |
mdconfig -d -u $MD |
657 |
|
701 |
|
658 |
trap - 1 2 15 |
702 |
trap - 1 2 15 |
Lines 912-918
Link Here
|
912 |
echo " -K suppress installkernel" |
956 |
echo " -K suppress installkernel" |
913 |
echo " -b suppress builds (both kernel and world)" |
957 |
echo " -b suppress builds (both kernel and world)" |
914 |
echo " -c specify config file" |
958 |
echo " -c specify config file" |
915 |
echo " -f suppress code slice extraction" |
959 |
echo " -f suppress code slice extraction (implies -i)" |
916 |
echo " -i suppress disk image build" |
960 |
echo " -i suppress disk image build" |
917 |
echo " -k suppress buildkernel" |
961 |
echo " -k suppress buildkernel" |
918 |
echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc" |
962 |
echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc" |
Lines 930-937
Link Here
|
930 |
do_kernel=true |
974 |
do_kernel=true |
931 |
do_installkernel=true |
975 |
do_installkernel=true |
932 |
do_world=true |
976 |
do_world=true |
|
|
977 |
do_code=true |
933 |
do_image=true |
978 |
do_image=true |
934 |
do_copyout_partition=true |
|
|
935 |
do_native_xtools=false |
979 |
do_native_xtools=false |
936 |
|
980 |
|
937 |
set +e |
981 |
set +e |
Lines 970-976
Link Here
|
970 |
shift |
1014 |
shift |
971 |
;; |
1015 |
;; |
972 |
-f) |
1016 |
-f) |
973 |
do_copyout_partition=false |
1017 |
do_code=false |
|
|
1018 |
do_image=false |
974 |
shift |
1019 |
shift |
975 |
;; |
1020 |
;; |
976 |
-h) |
1021 |
-h) |
Lines 1120-1129
Link Here
|
1120 |
setup_nanobsd |
1165 |
setup_nanobsd |
1121 |
prune_usr |
1166 |
prune_usr |
1122 |
run_late_customize |
1167 |
run_late_customize |
1123 |
if $do_image ; then |
1168 |
if $do_code ; then |
1124 |
create_diskimage |
1169 |
calculate_partitioning |
|
|
1170 |
create_code_slice |
1171 |
if $do_image ; then |
1172 |
create_diskimage |
1173 |
else |
1174 |
pprint 2 "Skipping image build (as instructed)" |
1175 |
fi |
1125 |
else |
1176 |
else |
1126 |
pprint 2 "Skipping image build (as instructed)" |
1177 |
pprint 2 "Skipping code and image build (as instructed)" |
1127 |
fi |
1178 |
fi |
1128 |
last_orders |
1179 |
last_orders |
1129 |
|
1180 |
|