diff options
Diffstat (limited to 'images/debian/genimg')
| -rwxr-xr-x | images/debian/genimg | 86 | +40 −46 |
1 files changed, 40 insertions, 46 deletions
diff --git a/images/debian/genimg b/images/debian/genimg index 2dedba5..eafe118 100755 --- a/images/debian/genimg +++ b/images/debian/genimg @@ -1,6 +1,6 @@ #!/bin/sh -eux # SPDX-FileCopyrightText: 2017-2026 Drew DeVault -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov # SPDX-License-Identifier: AGPL-3.0-only self=$(dirname "$(readlink -f "$0")") @@ -19,18 +19,18 @@ esac case $arch in amd64) - darch=amd64 iface=ens3 + qarch=x86_64 kpkg=linux-image-amd64 ;; arm64) - darch=arm64 iface=enp0s1 + qarch=aarch64 kpkg=linux-image-arm64 ;; -ppc64le) - darch=ppc64el +ppc64el) iface=enp0s0 + qarch=ppc64le kpkg=linux-image-powerpc64le ;; *) @@ -64,7 +64,7 @@ qemu-img create -f qcow2 -o compat=1.1 "$out/root.hmi" "${size_gib}G" modprobe nbd max_part=16 qemu-nbd --connect=/dev/nbd0 "$out/root.hmi" for i in $(seq 1 5); do - sleep "0.$i" + sleep 0.$i partprobe /dev/nbd0 && break done trap cleanup EXIT @@ -88,9 +88,9 @@ mkdir /mnt/boot mount /dev/nbd0p1 /mnt/boot if [ "$arch" = "amd64" ]; then - debootstrap --include=gnupg2 --arch="$darch" "$release" /mnt + debootstrap --include=gnupg2 --arch=$arch $release /mnt else - ./qemu-debootstrap --include=gnupg2 --arch="$darch" "$release" /mnt + ./qemu-debootstrap --include=gnupg2 --arch=$arch $release /mnt fi mount --bind /dev /mnt/dev @@ -132,7 +132,7 @@ run_root apt-get -y install locales run_root apt-get -y install $kpkg run_root apt-get -y install build-essential git mercurial ssh sudo \ gnupg dirmngr ca-certificates apt-transport-https curl dbus \ - systemd-timesyncd ncurses-term qemu-guest-agent + systemd-timesyncd ncurses-term run_root ln -sf /usr/share/zoneinfo/UTC /etc/localtime run_root systemctl enable systemd-timesyncd.service @@ -144,7 +144,6 @@ echo '%sudo ALL=(ALL) NOPASSWD: ALL' >>/mnt/etc/sudoers echo "PermitEmptyPasswords yes" >>/mnt/etc/ssh/sshd_config echo ssh >>/mnt/etc/securetty run_root systemctl enable ssh -run_root systemctl enable qemu-guest-agent # Prevent docker from mucking up networking mkdir -p /mnt/etc/docker @@ -156,14 +155,7 @@ EOF run_root update-initramfs -u -kernel_path= -for candidate in /mnt/boot/vmlinuz-*; do - [ -e "$candidate" ] || continue - kernel_path=$candidate - break -done -[ -n "$kernel_path" ] -linuxver=${kernel_path##*/vmlinuz-} +linuxver=$(ls /mnt/boot | grep vmlinuz | cut -d- -f2-) # Reference partitions by PARTUUID so boot survives whatever the VMM names the # disk. cmdline is canonical: identical for every boot protocol (extlinux append @@ -198,7 +190,7 @@ arm64) cp /mnt/boot/vmlinuz-* "$out/vmlinuz" cp /mnt/boot/initrd.img-* "$out/initrd" ;; -ppc64le) +ppc64el) cp /mnt/boot/vmlinux-* "$out/vmlinux" cp /mnt/boot/initrd.img-* "$out/initrd" ;; @@ -210,7 +202,7 @@ sync cleanup trap : EXIT -# --- Hule machine configuration (`config.json`) ------------------------------ +# --- Hule Machine Manifest (.hmm) -- docs/boot-protocol.md 10b --------------- disk_sha=$(sha256sum "$out/root.hmi" | cut -d' ' -f1) disk_bytes=$(stat -c%s "$out/root.hmi") virtual_bytes=$((size_gib * 1024 * 1024 * 1024)) @@ -223,7 +215,7 @@ amd64) protocols=$( cat <<JSON { - "protocol": "firmware-disk/bios", + "id": "firmware-disk/bios", "disk": "root" } JSON @@ -235,25 +227,25 @@ arm64) protocols=$( cat <<JSON { - "protocol": "linux/direct", + "id": "linux/arm64-image", "disk": "root", - "kernel": { "path": "vmlinuz", "digest": "sha256:$kernel_sha" }, - "initrd": { "path": "initrd", "digest": "sha256:$initrd_sha" }, + "kernel": { "path": "vmlinuz", "checksum": "sha256:$kernel_sha" }, + "initrd": { "path": "initrd", "checksum": "sha256:$initrd_sha" }, "cmdline": "$cmdline" } JSON ) ;; -ppc64le) +ppc64el) kernel_sha=$(sha256sum "$out/vmlinux" | cut -d' ' -f1) initrd_sha=$(sha256sum "$out/initrd" | cut -d' ' -f1) protocols=$( cat <<JSON { - "protocol": "linux/direct", + "id": "linux/ppc64le-elf", "disk": "root", - "kernel": { "path": "vmlinux", "digest": "sha256:$kernel_sha" }, - "initrd": { "path": "initrd", "digest": "sha256:$initrd_sha" }, + "kernel": { "path": "vmlinux", "checksum": "sha256:$kernel_sha" }, + "initrd": { "path": "initrd", "checksum": "sha256:$initrd_sha" }, "cmdline": "$cmdline" } JSON @@ -261,29 +253,21 @@ JSON ;; esac -cat >"$out/config.json" <<EOF +cat >"$out/image.hmm" <<EOF { "schemaVersion": 1, "kind": "MachineImage", "system": { - "os": "linux", - "name": "debian", - "version": "$release", - "architecture": "$arch" + "family": "linux", + "distro": "debian", + "release": "$release" }, "machine": { + "arch": "$arch", "cpu": { "minimum": 1, "default": 2 }, - "ram": { "minimum": $mem_min, "default": $mem_def }, - "boot": [ -$protocols - ], - "access": [ - { "type": "ssh", "port": 22, "user": "build", "auth": "empty-password" }, - { "type": "qga" } - ], - "network": { "mode": "static", "address": "10.0.2.15/24", "gateway": "10.0.2.2" } + "ram": { "minimum": $mem_min, "default": $mem_def } }, "disks": [ @@ -291,10 +275,20 @@ $protocols "id": "root", "format": "qcow2", "path": "root.hmi", - "digest": "sha256:$disk_sha", - "virtSize": $virtual_bytes, - "diskSize": $disk_bytes + "checksum": "sha256:$disk_sha", + "virtualSize": $virtual_bytes, + "physicalSize": $disk_bytes } - ] + ], + + "boot": [ +$protocols + ], + + "access": [ + { "type": "ssh", "port": 22, "user": "build", "auth": "empty-password" } + ], + + "network": { "mode": "static", "address": "10.0.2.15/24", "gateway": "10.0.2.2" } } EOF |
