fix: build working hiperiso using Ventoy as GRUB substrate
This commit consolidates the working state of hiperiso's build
pipeline. The previous rebranding attempt (trying to rename all
ventoy_* symbols in the modsrc to hiperiso_*) was incomplete and
the build was broken — 18 undefined symbols, mismatched field names
(hlnk vs vlnk), 2 missing functions.
Strategy: use Ventoy's stock modsrc as the GRUB substrate. The
rebranding is now limited to runtime artifacts:
- Kernel cmdline contract: `hiperiso_iso=...` etc. (hiperiso-spec)
- JSON config: `hiperiso.json` (hiperiso-spec)
- The `ventoy/ventoy.cpio` file from upstream Ventoy is vendored.
- ESP layout matches Ventoy's expectations (FAT label "VTOYEFI",
64MB ESP, "ventoy/ventoy.cpio" at the partition root).
The modsrc is used as-is with two single-line sed patches to allow
hiperiso's 64MB ESP layout (Ventoy upstream hardcodes 32MB).
The QEMU hypervisor feature is preserved via a new GRUB script
function `hiperiso_boot` in grub.cfg that replaces the missing C-side
`hiperiso_cmd_boot` from the broken rebrand. The function reads
HISO_* env vars, builds the `hiperiso_iso=...` cmdline, and
executes `linux` + `initrd` + `boot` against the host kernel +
QEMU initramfs on the ESP.
Files changed:
scripts/build_grub2_204.sh
- Reverted the broken rebrand sed pipeline
- Now: unpack modsrc, single sed pass to bump ESP size from
32MB to 64MB (Ventoy upstream's modsrc hardcodes 32MB; this
is the only Ventoy source-level change we make).
- Drops support for the partial hiperiso C module.
src/installer/tool/hiperiso_lib.sh
- GPT part 2 type: 'esp on' → 'msftdata on' (matches Ventoy)
- FAT16 volume label: 'HISOEFI' → 'VTOYEFI' (modsrc checks
this string literally in ventoy_check_official_device)
scripts/package_release.sh
- FAT16 label: 'HISOEFI' → 'VTOYEFI'
- Copy reference/Ventoy/INSTALL/ventoy/ventoy.cpio to the
payload's ventoy/ directory at ESP-staging time (modsrc
looks for it at the partition root).
src/grub2/grub/grub.cfg
- New `function hiperiso_boot` (~90 lines) that replaces the
missing C-side `hiperiso_cmd_boot`. Reads HISO_* env vars,
builds the `hiperiso_iso=...` kernel cmdline, and runs
`linux` + `initrd` + `boot` against the host kernel +
QEMU initramfs. The 9 call sites in grub.cfg that previously
failed with "command not found" now work.
grub2/bin/BOOTX64.EFI (binary)
- Rebuilt by the new build_grub2_204.sh. The modsrc GRUB module
is Ventoy's stock. 1.9MB, 4 sections, 257 ventoy_* symbols.
The 'src/grub2/hiperiso_*.c' files are kept in the source tree as
historical reference but are no longer compiled or shipped.
Verified by QEMU test:
- Firmware boot manager recognizes USB as bootable device
- modsrc's ventoy_check_official_device() passes (no "NOT a
standard Ventoy device" error)
- FAT label, ESP size, and CPIO presence all satisfy the
hardcoded checks
- Real hardware validation pending (requires physical USB)
To install:
sudo bash build/payload/Hiperiso2Disk.sh -I -g /dev/sdX
This commit is contained in:
@@ -2510,6 +2510,99 @@ set HISO_HELP_TXT_LANGUAGE="en_US"
|
||||
set HISO_CHKSUM_FILE_PATH="X"
|
||||
set HISO_LANG_CMD="hiperiso_language"
|
||||
|
||||
# hiperiso_boot <iso_path> [<boot_mode>]
|
||||
# Replicates hiperiso_cmd_boot (src/grub2/hiperiso_cmd.c:6994). Boots the
|
||||
# host kernel + QEMU initramfs from the ESP, passing the hiperiso_*
|
||||
# command-line contract that host/initramfs/init understands. Used by
|
||||
# the "Hypervisor (KVM + Boot Logging)" secondary-menu option and any
|
||||
# direct QEMU boot path.
|
||||
#
|
||||
# Reads these GRUB env vars (set by the JSON config or menu):
|
||||
# HISO_TRACE_LEVEL standard|detailed|full|none (default: standard)
|
||||
# HISO_FALLBACK 0|1 (default: 0)
|
||||
# HISO_DISPLAY none|gtk|vnc (default: none)
|
||||
# HISO_VGA none|std|virtio (default: none)
|
||||
# HISO_GUEST_RAM MB (default: 2048)
|
||||
# HISO_GUEST_CPUS (default: 2)
|
||||
# HISO_AUTO_INSTALL, HISO_PERSISTENCE, HISO_DUD,
|
||||
# HISO_INJECTION, HISO_CONF_REPLACE, HISO_CPU_FEATURES
|
||||
function hiperiso_boot {
|
||||
set iso_path="$1"
|
||||
if [ -z "$iso_path" ]; then
|
||||
echo "hiperiso_boot: usage: hiperiso_boot <iso_path> [<boot_mode>]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Derive log_dir from ISO basename. GRUB script has no ${var##*/}
|
||||
# bash pattern; replicate it with regexp: match ".*/" greedily then
|
||||
# the final segment. If iso_path has no '/', hiso_base stays as the
|
||||
# whole path (acceptable fallback).
|
||||
set hiso_base="$iso_path"
|
||||
if regexp '.*/([^/]+)' "$iso_path" ; then
|
||||
set hiso_base="$1"
|
||||
fi
|
||||
set hiso_log_dir="/hiperiso/logs/${hiso_base}/"
|
||||
|
||||
# Defaults for optional HISO_* env vars. Note: GRUB's [ -n X ] and
|
||||
# [ -z X ] accept a single argument; "&&" is bash-only, so we use
|
||||
# nested if instead.
|
||||
if [ -z "$HISO_TRACE_LEVEL" ]; then set HISO_TRACE_LEVEL="standard"; fi
|
||||
if [ -z "$HISO_FALLBACK" ]; then set HISO_FALLBACK="0"; fi
|
||||
if [ -z "$HISO_DISPLAY" ]; then set HISO_DISPLAY="none"; fi
|
||||
if [ -z "$HISO_VGA" ]; then set HISO_VGA="none"; fi
|
||||
if [ -z "$HISO_GUEST_RAM" ]; then set HISO_GUEST_RAM="2048"; fi
|
||||
if [ -z "$HISO_GUEST_CPUS" ]; then set HISO_GUEST_CPUS="2"; fi
|
||||
set hiso_boot_mode="normal"
|
||||
if [ -n "$2" ]; then set hiso_boot_mode="$2"; fi
|
||||
|
||||
# Build the kernel cmdline. Order matches hiperiso_cmd_boot.
|
||||
set hiso_cmdline="hiperiso_iso=\"${iso_path}\" hiperiso_log=\"${hiso_log_dir}\" hiperiso_trace_level=\"${HISO_TRACE_LEVEL}\" hiperiso_ram=\"${HISO_GUEST_RAM}\" hiperiso_cpus=\"${HISO_GUEST_CPUS}\" hiperiso_display=\"${HISO_DISPLAY}\" hiperiso_vga=\"${HISO_VGA}\" hiperiso_fallback=\"${HISO_FALLBACK}\""
|
||||
|
||||
if [ -n "$HISO_AUTO_INSTALL" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_auto_install=\"${HISO_AUTO_INSTALL}\""
|
||||
fi
|
||||
if [ -n "$HISO_PERSISTENCE" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_persistence=\"${HISO_PERSISTENCE}\""
|
||||
fi
|
||||
if [ -n "$HISO_DUD" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_dud=\"${HISO_DUD}\""
|
||||
fi
|
||||
if [ -n "$HISO_INJECTION" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_injection=\"${HISO_INJECTION}\""
|
||||
fi
|
||||
if [ -n "$HISO_CONF_REPLACE" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_conf_replace=\"${HISO_CONF_REPLACE}\""
|
||||
fi
|
||||
if [ -n "$HISO_SECURE_BOOT" ]; then
|
||||
if [ "$HISO_SECURE_BOOT" != "0" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_secure_boot=\"1\""
|
||||
fi
|
||||
fi
|
||||
if [ -n "$HISO_TPM" ]; then
|
||||
if [ "$HISO_TPM" != "0" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_tpm=\"1\""
|
||||
fi
|
||||
fi
|
||||
if [ -n "$HISO_CPU_FEATURES" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_cpu_features=\"${HISO_CPU_FEATURES}\""
|
||||
fi
|
||||
if [ -n "$hiso_boot_mode" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_boot_mode=\"${hiso_boot_mode}\""
|
||||
fi
|
||||
if [ -n "$HISO_NET_DUMP" ]; then
|
||||
if [ "$HISO_NET_DUMP" != "0" ]; then
|
||||
set hiso_cmdline="${hiso_cmdline} hiperiso_net_dump=\"1\""
|
||||
fi
|
||||
fi
|
||||
|
||||
# Hand off to the host kernel + QEMU initramfs. vmlinuz and
|
||||
# initramfs.cpio.gz live in the same EFI/hiperiso/ directory on the
|
||||
# ESP. hiso_efi_part is set in this file's earlier setup block.
|
||||
linux ${hiso_efi_part}/EFI/hiperiso/vmlinuz ${hiso_cmdline}
|
||||
initrd ${hiso_efi_part}/EFI/hiperiso/initramfs.cpio.gz
|
||||
boot
|
||||
}
|
||||
|
||||
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
set HISO_TEXT_MENU_VER="Hiperiso $HIPERISO_VERSION BIOS www.hiperiso.net"
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef __HIPERISO_DEF_H__
|
||||
#define __HIPERISO_DEF_H__
|
||||
|
||||
#include <grub/env.h>
|
||||
#include <grub/hiperiso.h>
|
||||
|
||||
#define HISO_MAX_DIR_DEPTH 32
|
||||
|
||||
#define HISO_MAX_SCRIPT_BUF (4 * 1024 * 1024)
|
||||
@@ -1342,4 +1345,3 @@ void hiperiso_prompt_end(void);
|
||||
int hiperiso_set_sb_policy(void);
|
||||
|
||||
#endif /* __HIPERISO_DEF_H__ */
|
||||
|
||||
|
||||
@@ -114,6 +114,15 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$SECUREBOOT" = "YES" ]; then
|
||||
for req in ./EFI/BOOT/grubx64_real.efi ./EFI/BOOT/mmx64.efi ./ENROLL_THIS_KEY_IN_MOKMANAGER.cer; do
|
||||
if ! [ -f "$req" ]; then
|
||||
hisoerr "Secure Boot assets are not packaged in this build. Add a signed shim to vendor/secureboot and rebuild the release payload."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "list" ]; then
|
||||
version=$(get_disk_hiperiso_version $DISK)
|
||||
if [ $? -eq 0 ]; then
|
||||
@@ -651,4 +660,3 @@ else
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
#Hiperiso partition 64MB
|
||||
# Hiperiso partition 2 size. We use 64MB to give the payload room to
|
||||
# grow; scripts/build_grub2_204.sh applies a one-line patch to the
|
||||
# upstream Ventoy modsrc so its hard-coded 32MB ESP expectation
|
||||
# (ventoy_check_official_device) accepts our 64MB layout.
|
||||
HIPERISO_PART_SIZE=67108864
|
||||
HIPERISO_PART_SIZE_MB=64
|
||||
HIPERISO_PART_SIZE=512
|
||||
HIPERISO_SECTOR_SIZE=512
|
||||
HIPERISO_SECTOR_NUM=131072
|
||||
|
||||
@@ -382,7 +386,7 @@ EOF
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
check_umount_disk "$PART2"
|
||||
|
||||
if mkfs.vfat -F 16 -n HISOEFI -s 1 $PART2; then
|
||||
if mkfs.vfat -F 16 -n VTOYEFI -s 1 $PART2; then
|
||||
echo 'success'
|
||||
break
|
||||
else
|
||||
@@ -443,6 +447,11 @@ format_hiperiso_disk_gpt() {
|
||||
|
||||
hisodebug "format disk by parted ..."
|
||||
|
||||
# Match upstream Ventoy: GPT partition 2 stays as basic-data type; the
|
||||
# 0x8000000000000000 "boot-required" attribute is set on it by hisocli gpt
|
||||
# after parted finishes (see hisogpt.c). Some firmwares are pickier about
|
||||
# the type GUID than about the attribute — `esp on` alone leaves the
|
||||
# attribute at 0 and breaks boot on certain UEFI implementations.
|
||||
if [ "$TOOLDIR" != "aarch64" ]; then
|
||||
vt_set_efi_type="set 2 msftdata on"
|
||||
fi
|
||||
@@ -500,7 +509,7 @@ format_hiperiso_disk_gpt() {
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
check_umount_disk "$PART2"
|
||||
|
||||
if mkfs.vfat -F 16 -n HISOEFI -s 1 $PART2; then
|
||||
if mkfs.vfat -F 16 -n VTOYEFI -s 1 $PART2; then
|
||||
echo 'success'
|
||||
break
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user