diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1899954..1aab06b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,10 +103,16 @@ jobs: if-no-files-found: error retention-days: 2 base: + # One base per root: aarch64, and armv7 unpacked by the same arm64 tools without emulation. if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' needs: [test, orchard] + strategy: + matrix: + arch: [aarch64, armv7] env: HARDWARE_TAG: ${{ needs.orchard.outputs.tag }} + ARCH: ${{ matrix.arch }} + SUFFIX: ${{ matrix.arch == 'armv7' && '-armv7' || '' }} runs-on: ubuntu-24.04-arm timeout-minutes: 60 steps: @@ -114,7 +120,7 @@ jobs: if: inputs.reuse_base_run_id != '' uses: actions/download-artifact@v4 with: - name: minimal-base + name: ${{ matrix.arch == 'armv7' && 'minimal-base-armv7' || 'minimal-base' }} path: out run-id: ${{ inputs.reuse_base_run_id }} github-token: ${{ github.token }} @@ -133,13 +139,13 @@ jobs: - name: Build the pinned Alpine base without a container daemon if: inputs.reuse_base_run_id == '' run: | - mkdir -p out/base - sudo "$PWD/.venv/bin/python" build_base.py --native --output out/base/base.tar.gz - tar -C out -czf out/alpine-base.tar.gz base + mkdir -p "out/base$SUFFIX" + sudo "$PWD/.venv/bin/python" build_base.py --native --arch "$ARCH" --output "out/base$SUFFIX/base.tar.gz" + tar -C out -czf "out/alpine-base$SUFFIX.tar.gz" "base$SUFFIX" - uses: actions/upload-artifact@v4 with: - name: minimal-base - path: out/alpine-base.tar.gz + name: ${{ matrix.arch == 'armv7' && 'minimal-base-armv7' || 'minimal-base' }} + path: out/alpine-base${{ matrix.arch == 'armv7' && '-armv7' || '' }}.tar.gz compression-level: 0 if-no-files-found: error retention-days: 2 @@ -224,12 +230,27 @@ jobs: --version "$VERSION" --output out/release python audit.py out/release --orchard .orchard python -m orchard.manifests --verify-local out/release/index.toml + # The 32-bit root, its own release beside it: orchard's 32-bit index (platforms-armv7.toml) from + # the same orchard build, and Alpine's tools in place of orchard's static arm64 ones. + tar -xzf out/downloads/alpine-base-armv7.tar.gz -C out + python pin_components.py --splash out/boot/artwork/splash --logo out/boot/artwork/logo.bin \ + --output out/inputs-armv7 + python build.py --arch armv7 --base out/base-armv7/base.tar.gz \ + --base-receipt out/base-armv7/base.tar.gz.json --inputs out/inputs-armv7/inputs.json \ + --orchard-release "$HARDWARE_TAG" --orchard .orchard --version "$VERSION" --output out/release-armv7 + python audit.py out/release-armv7 --orchard .orchard + python -m orchard.manifests --verify-local out/release-armv7/index.toml # The installer: install.sh and orchard-install.pyz with orchard's launch loaders. python -m orchard.installer release out/release \ --pongo "$tools/quiet/pongo.bin" --m1n1 "$tools/quiet/m1n1.bin" + # One release, both roots: its index pins each root's manifest, the board picks by architecture. python -m orchard.image.publish --distro minimal-linux --tag "$TAG" \ - --release-dir out/release --output out/publication + --release-dir out/release --release-dir out/release-armv7 --output out/publication cp out/release/rootfs.json out/release/build-receipt.json out/base/* out/publication/ + cp out/release-armv7/rootfs.json out/publication/rootfs-armv7.json + cp out/release-armv7/build-receipt.json out/publication/build-receipt-armv7.json + cp out/base-armv7/base.tar.gz out/publication/base-armv7.tar.gz + cp out/base-armv7/base.tar.gz.json out/publication/base-armv7.tar.gz.json git archive --format=tar.gz -o out/publication/minimal-linux-source.tar.gz HEAD (cd out/publication && sha256sum ./* > ../SHA256SUMS && mv ../SHA256SUMS .) - name: Attest public build diff --git a/BUILD.md b/BUILD.md index 2196332..b9be5ad 100644 --- a/BUILD.md +++ b/BUILD.md @@ -2,7 +2,7 @@ ## GitHub Actions -`.github/workflows/build.yml` runs unit tests on pull requests and `main`. Version tags (`v*`) and manual dispatches build the image: macOS renders the loader artwork, Linux ARM64 builds m1n1, and Linux ARM64 extracts the digest-pinned Alpine OCI base with `skopeo`/`umoci` and runs `system/install-base` in a native chroot. This is the same install recipe used by the local Containerfile, without Podman or a container daemon. +`.github/workflows/build.yml` runs unit tests on pull requests and `main`. Version tags (`v*`) and manual dispatches build the image: macOS renders the loader artwork, Linux ARM64 builds m1n1, and Linux ARM64 extracts the digest-pinned Alpine OCI base with `skopeo`/`umoci` and runs `system/install-base` in a native chroot. This is the same install recipe used by the local Containerfile, without Podman or a container daemon. A second base job on the same runner builds the armv7 base (`build_base.py --arch armv7`, see [32-bit](#32-bit-armv7)), and assembly builds the armv7 root as a release of its own from orchard's `platforms-armv7.toml`; `orchard.image.publish` then publishes both roots as one release, whose `index.toml` pins the aarch64 manifest as `[release]` and the armv7 one as `[releases.armv7]` (`release-armv7.toml`, `root-armv7.blocks.zst`, `rootfs-armv7.json`, `build-receipt-armv7.json`, `base-armv7.tar.gz`). The installer picks the root of the attached board's architecture. Select the published orchard release with the compiled components in manual dispatch; tag builds use the explicit default in the workflow. `ci/dependencies` checks out orchard's `main` (or `ORCHARD_REF`), verifies that release's component bundle and exposes its compiled kernel/modules/tools. The build receipt records the exact orchard commit. @@ -25,7 +25,8 @@ installs it. The rest of this page is what that entry runs, step by step. ### 32-bit (armv7) -A release has one root of one architecture. `orchard build --platform apple-armv7` +A local build has one root of one architecture (a tagged release carries both, see +above). `orchard build --platform apple-armv7` (or `tools/build.py --arch armv7`) builds the armv7 root and its own release, for orchard's 32-bit platforms: the same packages, services and configuration as the arm64 root, with Alpine's dropbear and udhcpd (`busybox-extras`) in place of diff --git a/build.py b/build.py index 0f2da30..b77b2ba 100644 --- a/build.py +++ b/build.py @@ -203,7 +203,9 @@ def manifests(output, version, root, offered, orchard, arch='aarch64'): document += table('install_tools', offered['install_tools']) for name, layer in sorted(offered['platforms'].items()): document += f'\n[platforms.{name}]\nboards = {json.dumps(layer["boards"])}\n' - document += table(f'platforms.{name}.layer', {key: value for key, value in layer.items() if key != 'boards'}) + # The 32-bit index says each layer's architecture; the release is of one architecture and doesn't. + document += table(f'platforms.{name}.layer', {key: value for key, value in layer.items() + if key not in ('boards', 'architecture')}) path = output / 'release.toml' path.write_text(document) (output / 'index.toml').write_text('schema = 2\nkind = "orchard.index"\ndistro = "minimal-linux"\n' diff --git a/tests/test_armv7_root.py b/tests/test_armv7_root.py index 7b9a4bc..d2bde8e 100644 --- a/tests/test_armv7_root.py +++ b/tests/test_armv7_root.py @@ -15,6 +15,7 @@ PROJECT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(PROJECT)) import snapshot # noqa: E402 +from orchard.manifests import validate # noqa: E402 the release CI checks every manifest against the schema def load(name, path): @@ -153,7 +154,8 @@ def test_loaders_and_boards_come_from_the_32_bit_index(self): 'install_tools': build.receipt(source / 'install-tools-armv7.tar.gz'), 'platforms': {'apple-armv7': {**build.receipt(source / 'platform-apple-armv7.tar.gz'), 'compression': 'gzip', 'expanded_bytes': 10, 'members': 2, - 'kernel_release': '6.12-armv7', 'boards': ['p105']}}} + 'kernel_release': '6.12-armv7', 'boards': ['p105'], + 'architecture': 'arm'}}} manifest = tomllib.loads(build.manifests(source, '1', root, offered, {'commit': 'c' * 40, 'modified': False}, 'armv7').read_text()) self.assertEqual(manifest['boot_method'], 'recovery-autogo') @@ -163,6 +165,8 @@ def test_loaders_and_boards_come_from_the_32_bit_index(self): self.assertNotIn('m1n1', manifest) self.assertEqual(manifest['platforms']['apple-armv7']['boards'], ['p105']) self.assertEqual(manifest['root']['file'], 'root.blocks.zst') + self.assertNotIn('architecture', manifest['platforms']['apple-armv7']['layer']) + validate(manifest, schema=True) if __name__ == '__main__': diff --git a/tests/test_publication.py b/tests/test_publication.py index f3b9d1d..b6139e8 100644 --- a/tests/test_publication.py +++ b/tests/test_publication.py @@ -30,6 +30,21 @@ def release(source): return build.manifests(source, '0.1.0', root, offered, {'commit': 'c' * 40, 'modified': False}) +def armv7_release(source): + """A fake 32-bit release: its root image, and what orchard's platforms-armv7.toml offers.""" + for name in ('root.blocks.zst', 'root.map.json', 'cascadia-p105.bin', 'install-tools-armv7.tar.gz', + 'platform-apple-armv7.tar.gz'): + (source / name).write_bytes(b'armv7 ' + name.encode()) + root = {**build.receipt(source / 'root.blocks.zst'), 'compression': 'zstd', 'format': 'blocks', 'expanded_bytes': 100, + 'members': 3, 'map': build.receipt(source / 'root.map.json')} + offered = {'architecture': 'arm', 'loaders': {'cascadia': {'p105': build.receipt(source / 'cascadia-p105.bin')}}, + 'install_tools': build.receipt(source / 'install-tools-armv7.tar.gz'), + 'platforms': {'apple-armv7': {**build.receipt(source / 'platform-apple-armv7.tar.gz'), + 'compression': 'gzip', 'expanded_bytes': 10, 'members': 2, + 'kernel_release': '6.12-armv7', 'boards': ['p105'], 'architecture': 'arm'}}} + return build.manifests(source, '0.1.0', root, offered, {'commit': 'c' * 40, 'modified': False}, 'armv7') + + class Publication(unittest.TestCase): def test_one_manifest_for_every_platform_with_the_account(self): with tempfile.TemporaryDirectory() as directory: @@ -63,6 +78,24 @@ def test_minimal_manifest_is_rewritten_and_rehashed(self): with self.assertRaises(FileExistsError): publish(source, 'v0.1.0', output, distro='minimal-linux') + def test_both_roots_publish_as_one_release(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + arm64, armv7 = root / 'release', root / 'release-armv7' + arm64.mkdir(), armv7.mkdir() + release(arm64), armv7_release(armv7) + output = root / 'hosted' + index = tomllib.loads(publish([arm64, armv7], 'v0.1.0', output, distro='minimal-linux').read_text()) + validate(index) + base = 'https://github.com/OrchardLinux/minimal-linux/releases/download/v0.1.0/' + self.assertEqual(index['release']['url'], base + 'release.toml') + self.assertEqual(index['releases']['armv7']['url'], base + 'release-armv7.toml') + hosted = tomllib.loads((output / 'release-armv7.toml').read_text()) + validate(hosted) + self.assertEqual(hosted['root']['url'], base + 'root-armv7.blocks.zst') + self.assertEqual((output / 'root-armv7.blocks.zst').read_bytes(), b'armv7 root.blocks.zst') + self.assertEqual((output / 'root.blocks.zst').read_bytes(), b'root.blocks.zst') + def test_repository_path_cannot_escape_the_distro_name(self): with self.assertRaisesRegex(ValueError, 'Invalid distro'): publish(Path('/unused'), 'v1.0.0', Path('/unused'), distro='../other')