foundry
Foundry OS: the operating system built on the Rustbelt kernel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #!/usr/bin/env bash
# Turn the staging directory into a disk image (boot contract v1):
# * a raw file of IMAGE_MIB MiB,
# * a GPT partition table (sfdisk) with one partition at sector 2048,
# * a FAT32 file system in it (mkfs.vfat), filled with mtools.
# mtools (mmd/mcopy) write straight into the image file, so no root and no
# loop-mounting is needed. This is what the kernel's build.rs does.
#
# Usage: scripts/mkimage.sh STAGING IMAGE MIB LABEL "bin order..."
# The /bin files are copied in the given order (same as the kernel's
# build.rs), then any other file in STAGING/bin.
STAGING= IMAGE= MIB= LABEL= ORDER=
PATH=:/usr/sbin:/sbin
SECTORS=
START=2048
PART_SECTORS= # 1 MiB free at the end for the backup GPT
PART=.part
# 1. The FAT32 file system as its own file first. -s 1: one sector per
# cluster (FAT32 needs >= 65525 clusters). -i: a fixed volume serial
# number, so two builds of the same tree give the same bytes.
# Top-level entries (everything except bin/) in sorted order...
for; do
[ && continue
done
# ...then the programs.
done_list=" "
for; do
[ || { ; ; }
done_list+=" "
done
for; do
case "" in *" "*) ;; *) ;; esac
done
# 2. The whole disk: zeros + GPT, then the FAT32 file system in the partition.
|
|