diff options
Diffstat (limited to 'images/fedora/genimg')
| -rwxr-xr-x | images/fedora/genimg | 82 | +34 −48 |
1 files changed, 34 insertions, 48 deletions
diff --git a/images/fedora/genimg b/images/fedora/genimg index 8215ec5..3e4e668 100755 --- a/images/fedora/genimg +++ b/images/fedora/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 # Network Block Device used to interact with the QCOW2 image. @@ -10,7 +10,7 @@ self=$(dirname "$(readlink -f "$0")") cd "$self" release=${1:-} -arch=${2:-amd64} +arch=${2:-x86_64} case $release in 42 | 43 | 44) ;; @@ -21,8 +21,7 @@ case $release in esac case $arch in -amd64) - fedora_arch=x86_64 +x86_64) iface=ens3 ;; *) @@ -38,7 +37,6 @@ cleanup() { umount /mnt/dev 2>/dev/null || true umount /mnt/proc 2>/dev/null || true umount /mnt/run 2>/dev/null || true - umount /mnt/sys/firmware 2>/dev/null || true umount /mnt/sys 2>/dev/null || true umount /mnt/boot 2>/dev/null || true umount /mnt 2>/dev/null || true @@ -103,15 +101,6 @@ mount --bind /proc /mnt/proc mount --bind /run /mnt/run mount --bind /sys /mnt/sys -# This is a BIOS-only image (no ESP), but the build host may boot via UEFI. Since -# /sys is bind-mounted from the host, grub2-mkconfig's 10_linux sees the host's -# /sys/firmware/efi and probes the nonexistent /boot/efi ("failed to get canonical -# path of /boot/efi/"). Shadow /sys/firmware with an empty tmpfs so the chroot's -# grub sees a BIOS platform regardless of how the host booted. Make the bind -# private first so the tmpfs doesn't propagate back and hide firmware on the host. -mount --make-rprivate /mnt/sys -mount -t tmpfs tmpfs /mnt/sys/firmware - # Remove systemd-networkd symlink, which is useless in our chroot. rm -f /mnt/etc/resolv.conf @@ -141,8 +130,7 @@ run_root systemctl enable systemd-timesyncd.service run_root dnf -y \ --releasever="$release" \ install \ - @development-tools git mercurial openssh-server sudo kernel grub2 \ - qemu-guest-agent + @development-tools git mercurial openssh-server sudo kernel grub2 run_root dnf clean all @@ -150,14 +138,7 @@ run_root dnf clean all cat >/mnt/etc/dracut.conf.d/virtio-blk.conf <<EOF add_drivers="virtio-blk" EOF -kernel_path= -for candidate in /mnt/boot/vmlinuz-*."$fedora_arch"; do - [ -e "$candidate" ] || continue - kernel_path=$candidate - break -done -[ -n "$kernel_path" ] -kernel_version=${kernel_path##*/vmlinuz-} +kernel_version=$(ls /mnt/boot | grep "vmlinuz.*.$arch" | cut -d- -f2-) run_root dracut --force --kver "$kernel_version" run_root grub2-install --target=i386-pc $NBD_DEVICE @@ -174,7 +155,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 sshd -run_root systemctl enable qemu-guest-agent boot_uuid=$(blkid --match-tag UUID --output value ${NBD_DEVICE}p1) swap_uuid=$(blkid --match-tag UUID --output value ${NBD_DEVICE}p2) @@ -191,41 +171,34 @@ sync cleanup trap : EXIT -# --- Hule machine configuration (`config.json`) ------------------------------ -# amd64 only, self-booting via grub2 (BIOS). No boot.cmdline: grub owns it and +# --- Hule Machine Manifest (.hmm) -- docs/boot-protocol.md 10b --------------- +# x86_64 only, self-booting via grub2 (BIOS). No boot.cmdline: grub owns it and # firmware-disk boot takes no cmdline from the VMM. +case "$arch" in +x86_64) march=amd64 ;; +*) march=$arch ;; +esac disk_sha=$(sha256sum "$out/root.hmi" | cut -d' ' -f1) disk_bytes=$(stat -c%s "$out/root.hmi") virtual_bytes=$((size_gib * 1024 * 1024 * 1024)) mem_min=$((256 * 1024 * 1024)) mem_def=$((1024 * 1024 * 1024)) -cat >"$out/config.json" <<EOF +cat >"$out/image.hmm" <<EOF { "schemaVersion": 1, "kind": "MachineImage", "system": { - "os": "linux", - "name": "fedora", - "version": "$release", - "architecture": "$arch" + "family": "linux", + "distro": "fedora", + "release": "$release" }, "machine": { + "arch": "$march", "cpu": { "minimum": 1, "default": 2 }, - "ram": { "minimum": $mem_min, "default": $mem_def }, - "boot": [ - { - "protocol": "firmware-disk/bios", - "disk": "root" - } - ], - "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": [ @@ -233,10 +206,23 @@ cat >"$out/config.json" <<EOF "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": [ + { + "id": "firmware-disk/bios", + "disk": "root" + } + ], + + "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 |
