Files
w3cjandClaude Opus 5.5 9f24d2639e refactor: group devvm's files under assets/
assets/ holds the files devvm ships: base.yaml, layers/, features/,
shared-tools/ (mise.toml, build.sh, the tools' policies), guest/ and
oci/. devvm reads them from assets/ beside its binary (paths.Root,
paths.RootOf); releases, the Homebrew formula, the CLI tests and e2e
put them there. Image keys hash them by their names in assets/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 17:08:33 -06:00

22 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Turn a distro's vmlinuz into a kernel Lima can boot directly. Runs in the build VM (oci/build.sh).
# Usage: kernel.sh VMLINUZ OUT
# Virtualization.framework needs an uncompressed arm64 Image. Ubuntu ships it wrapped in an EFI
# executable with a zstd (or gzip) payload; try each candidate stream until one decodes to a
# kernel with the arm64 magic "ARMd" at offset 0x38. Other architectures use vmlinuz as-is (QEMU).
set -euo pipefail
in=$1 out=$2
is_arm64() { [[ "$(dd if="$out" bs=1 skip=56 count=4 2>/dev/null)" == ARMd ]]; }
cp "$in" "$out" # already uncompressed on some distros
[[ "$(uname -m)" == aarch64 ]] || exit 0
is_arm64 || for fmt in "28b52ffd zstd -dc" "1f8b08 gunzip -c"; do
read -r hex dec <<<"$fmt"
pat=""; for ((j = 0; j < ${#hex}; j += 2)); do pat+="\\x${hex:j:2}"; done
for off in $(LC_ALL=C grep -obUaP "$pat" "$in" | cut -d: -f1 | head -5); do
# shellcheck disable=SC2086 # $dec is a command and its flag
tail -c +$((off + 1)) "$in" | $dec > "$out" 2>/dev/null || true
is_arm64 && break 2
done
done
is_arm64 || { echo "could not extract an arm64 kernel from $in" >&2; exit 1; }