Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions orchard.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ name = "minimal-linux"
[release]
build = "tools/build.py"
selects-platform = true # tools/build.py takes --platform NAME ... or --platform all
# orchard's parts the release takes, handed to tools/build.py as --inputs FILE
# (orchard docs/distribution-contract.md); 32-bit releases take the loaders and m1n1's 32-bit build.
inputs = ["kernel", "m1n1", "pongo", "tools", "cascadia", "m1n1-armv7"]
11 changes: 2 additions & 9 deletions snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ def root(explicit=None):


def command(snapshot, module, *argv, **kwargs):
"""Run orchard's producer MODULE (orchard.NAME) from SNAPSHOT.

Under the orchard tool's build (ORCHARD_TOOL names it) the tool resolves the
inputs itself: the same arguments and the same document, with paths into its cache.
"""
"""Run orchard's producer MODULE (orchard.NAME) from SNAPSHOT; never the orchard command."""
environment = {**os.environ, 'PYTHONPATH': str(Path(snapshot) / 'src'), 'ORCHARD_CHECKOUT': str(snapshot)}
if module == 'inputs' and os.environ.get('ORCHARD_TOOL'):
argv = [os.environ['ORCHARD_TOOL'], 'inputs', *map(str, argv)]
else:
argv = [sys.executable, '-m', f'orchard.{module}', *map(str, argv)]
argv = [sys.executable, '-m', f'orchard.{module}', *map(str, argv)]
print('+', ' '.join(argv), flush=True)
return subprocess.run(argv, env=environment, check=True, **kwargs)

Expand Down
33 changes: 21 additions & 12 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
[--platform NAME ... | --platform all] [--arch aarch64|armv7]` in this checkout. A release has one
root, of one architecture: the selected platforms' (apple-armv7: armv7), else --arch, else aarch64. The loader and base land in out/components/NAME/KEY/, keyed
by the files they are made from, so a build redoes only what changed.
orchard supplies m1n1, Pongo, the static tools and every platform's kernel
from its shared cache; the Alpine artwork is data for orchard's m1n1. The release itself is always assembled anew.
How orchard got them (built, reused, or downloaded from a nightly) stays in
out/releases/VERSION.orchard-inputs.json, beside the release.
orchard's parts (m1n1, Pongo, the static tools, every platform's kernel) come finished as
--inputs FILE, the document orchard's orchard.inputs writes: orchard build gets the parts orchard.toml
declares and hands them over (out/releases/VERSION.inputs.json, which also says how each was got), and
this script never runs the orchard command. The Alpine artwork is data for orchard's m1n1. The release
itself is always assembled anew.
"""
import argparse
import json
Expand Down Expand Up @@ -42,8 +43,14 @@ def main():
parser.add_argument('--arch', choices=sorted(set(snapshot.ARCHITECTURES.values())),
help="the root's architecture (default: the selected platforms', else aarch64)")
parser.add_argument('--orchard', type=Path, help='orchard snapshot (default: ORCHARD_CHECKOUT, then .orchard)')
parser.add_argument('--inputs', type=Path, help="orchard's parts, as orchard.inputs writes them (orchard build "
'hands them over)')
args = parser.parse_args()
orchard = snapshot.root(args.orchard)
if args.inputs is None or not args.inputs.is_file():
parser.error("Give orchard's parts as --inputs FILE: orchard build hands them over; by hand, write it with "
"PYTHONPATH=ORCHARD/src python3 -m orchard.inputs, from parts orchard's producers made "
'(orchard docs/distribution-contract.md)')
if 'all' in args.platform and len(args.platform) > 1:
parser.error('--platform all builds every platform and combines with no other')
known = snapshot.platforms(orchard)
Expand All @@ -57,8 +64,14 @@ def main():
arch = architectures.pop() if architectures else 'aarch64'
if not named and arch != 'aarch64':
named = sorted(name for name, value in known.items() if value == arch)
# Without names, orchard's inputs cover every arm64 platform.
selected = [part for name in named for part in ('--platform', name)]
# The handed parts cover the platforms named (every arm64 one when none is), of this architecture.
resolved = args.inputs.resolve()
document = json.loads(resolved.read_text())
if (document.get('architecture') == 'arm') != (arch == 'armv7'):
parser.error(f'{resolved} holds the parts of another root architecture than {arch}')
missing = sorted(set(named) - set(document.get('platforms', {})))
if missing:
parser.error(f'{resolved} has no parts for {", ".join(missing)}')

if arch == 'aarch64':
base = snapshot.component('base', INPUTS['base'],
Expand All @@ -71,15 +84,11 @@ def main():
lambda path, work: python('boot/build-artwork.py', '--output', path),
artifact='artwork')
(PROJECT / 'out').mkdir(exist_ok=True)
# What orchard supplies finished: kernels, boards, m1n1, Pongo, tools (orchard.inputs). Kept beside the
# release, not in it (its paths are this host's): under "produced" it says how orchard got each one.
resolved = args.output.parent / f'{args.output.name}.orchard-inputs.json'
resolved.parent.mkdir(parents=True, exist_ok=True)
# What orchard supplies finished, handed over: kernels, boards, m1n1, Pongo, tools.
with tempfile.TemporaryDirectory(prefix='.inputs-', dir=PROJECT / 'out') as temporary:
snapshot.command(orchard, 'inputs', '--output', resolved, *selected)
inputs = Path(temporary) / 'public'
pinned = ['--splash', artwork / 'splash', '--logo', artwork / 'logo.bin']
shared = json.loads(resolved.read_text())['shared']
shared = document['shared']
if arch == 'aarch64':
# orchard's static arm64 tools; an armv7 root has Alpine's packages of them.
tools = {name: Path(path) for name, path in shared['tools'].items()}
Expand Down
Loading