mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
assets/prelude.sh gives each of devvm's scripts that a build runs with
bash $devvm_arch (arm64 or amd64), $devvm_libc (musl where apk is, else
gnu) and devvm_sha TOOL (the script's TOOL_sha256_<arch>_musl on musl
where it pins one, else TOOL_sha256_<arch>). It replaces the arch and sha
helpers in layers/base.sh, layers/nix.sh, features/cli-tools.sh,
shared-tools/build.sh and oci/build.sh, and the Alpine checks in
docker.sh, desktop.sh and fzf.sh. Each script that reads it checks it
came first (: "${devvm_arch:?}").
image.OwnScript reads devvm's own scripts with the prelude before them:
base.sh, apt.sh, built-in layers (LayerData) and features (featureStep),
shared-tools/build.sh (the tools build and ToolFile's key) and the
conversion's oci/build.sh (Lima's convertSteps, written into the
conversion's own temp folder). Users' layers and features get none.
keyHash.own goes, its one caller now hashing OwnScript's bytes.
Image keys change: every image and every shared tool image rebuilds.
Tests: testdata/script/prelude.txtar pins which pin devvm_sha picks from
each script on arm64 (aarch64 and arm64) and amd64, gnu and musl, and
refuses another architecture and a missing pin; oci.txtar sources the
prelude first and checks build.sh stops without it; TestOwnScript,
TestPreludeUsers (only scripts that get the prelude use it, each checks
its variables), key rows for the prelude in build and tool keys, and
recipe expectations with the prelude before devvm's scripts only.
e2e's nix copy as a user layer starts with the prelude.
Docs: internals/images.md (the scripts' prelude, keys), contributing
(owner, agreement test), maintaining, assets/oci/README.md, AGENTS.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
49 lines
1.8 KiB
Plaintext
49 lines
1.8 KiB
Plaintext
# assets/oci/build.sh's pieces, sourced after the prelude (it runs main only
|
|
# when executed), with a stand-in crane in the folder it runs in.
|
|
exec bash libc-test.sh $DEVVM_REPO/assets/prelude.sh $DEVVM_REPO/assets/oci/build.sh
|
|
cmp stdout libc.want
|
|
|
|
# An image without this VM's architecture says which ones it has.
|
|
env STUB_UNAME_M=aarch64
|
|
! exec bash arch-test.sh $DEVVM_REPO/assets/prelude.sh $DEVVM_REPO/assets/oci/build.sh
|
|
stderr '^devvm: ''node:24'' has no linux/arm64 build \(it has: amd64 s390x\)$'
|
|
|
|
# crane is pinned for both architectures.
|
|
exec bash pins-test.sh $DEVVM_REPO/assets/prelude.sh $DEVVM_REPO/assets/oci/build.sh
|
|
|
|
# Without the prelude, it stops before anything runs.
|
|
! exec bash $DEVVM_REPO/assets/oci/build.sh
|
|
stderr 'devvm_arch: parameter null or not set'
|
|
|
|
-- libc-test.sh --
|
|
# libc_for: gnu for Debian and Ubuntu (and their derivatives), musl for
|
|
# Alpine, else a failure.
|
|
source "$1"; source "$2"
|
|
set +eu
|
|
for os in 'debian ' 'ubuntu debian' 'linuxmint ubuntu debian' 'alpine ' 'fedora rhel centos'; do
|
|
libc_for "$os" || echo "fails: $os"
|
|
done
|
|
-- libc.want --
|
|
gnu
|
|
gnu
|
|
gnu
|
|
musl
|
|
fails: fedora rhel centos
|
|
-- arch-test.sh --
|
|
source "$1"; source "$2"
|
|
set +eu
|
|
name=node:24 out=$PWD
|
|
cat > crane <<'SH'
|
|
#!/bin/bash
|
|
case $1 in
|
|
export) echo 'Error: no child with platform linux/riscv64 in index node:24' >&2; exit 1 ;;
|
|
manifest) echo '{"manifests":[{"platform":{"architecture":"amd64","os":"linux"}},{"platform":{"architecture": "s390x","os":"linux"}},{"platform":{"architecture":"unknown","os":"unknown"}}]}' ;;
|
|
esac
|
|
SH
|
|
chmod 755 crane
|
|
export_image node:24 rootfs.tar
|
|
-- pins-test.sh --
|
|
source "$1"; source "$2"
|
|
[[ $crane_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "crane_version: $crane_version" >&2; exit 1; }
|
|
[[ $crane_sha256_arm64 =~ ^[0-9a-f]{64}$ && $crane_sha256_amd64 =~ ^[0-9a-f]{64}$ ]] || { echo "crane's checksums" >&2; exit 1; }
|