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:
2026-07-02 00:58:22 +03:00
parent 06b416ea02
commit 18cf522c82
13 changed files with 278 additions and 1506 deletions
+14 -1418
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -14,7 +14,7 @@ HIPERISO_DISPLAY="" # Display mode: "none" | "gtk" | "vnc" (default: non
HIPERISO_VGA="" # VGA mode: "none" | "std" | "virtio" (default: std)
HIPERISO_FALLBACK="" # Force fallback mode: "1" skips KVM check
# ── Plugin Parameters (new for full Ventoy parity) ───────────────────────────
# ── Plugin Parameters ─────────────────────────────────────────────────────────
# These are resolved by the GRUB2 module from hiperiso.json plugins and passed
# via kernel cmdline to the initramfs, which translates them to QEMU args.
HIPERISO_AUTO_INSTALL="" # Path to auto-install script (kickstart/preseed)
@@ -151,7 +151,7 @@ HIPERISO_JSON="${DATA_MOUNT}/hiperiso/hiperiso.json"
# Tier 3 (full): + MMIO memory_region_ops (very slow, debug only)
# ── Config File Format (hiperiso.json) ──────────────────────────────────────
# JSON format, compatible with Ventoy's ventoy.json structure:
# JSON format:
# {
# "control": { ... },
# "theme": { ... },
+6 -7
View File
@@ -1,6 +1,6 @@
# hiperiso
A hypervisor-based ISO boot tool with full bootlogging — like Ventoy, but it
A hypervisor-based ISO boot tool with full bootlogging. It
boots ISOs inside a **KVM + QEMU** virtual machine and captures the entire boot
(serial console, disk I/O, PCI/port I/O traces). The guest OS runs completely
unmodified.
@@ -10,12 +10,11 @@ USB → GRUB2 → minimal Linux kernel (KVM built-in) + initramfs →
QEMU (KVM accel) → OVMF UEFI → ISO boots as an emulated CD-ROM
```
## How it differs from Ventoy
## How it works
Ventoy injects hooks into the booted OS (initrd patching, device-mapper, WIM
patching, 60+ distro hooks). hiperiso instead presents the ISO as a native
emulated AHCI CD-ROM to a KVM guest, so **no guest modification is needed** and
the hypervisor has full visibility into every I/O operation.
hiperiso presents the ISO as a native emulated AHCI CD-ROM to a KVM guest, so
**no guest modification is needed** and the hypervisor has full visibility into
every I/O operation.
---
@@ -111,7 +110,7 @@ lsblk # identify your USB, e.g. /dev/sdX
sudo bash build/payload/Hiperiso2Disk.sh -I -g /dev/sdX
```
`Hiperiso2Disk.sh` defaults to MBR. Use `-g` for GPT. The standard Ventoy-style
`Hiperiso2Disk.sh` defaults to MBR. Use `-g` for GPT. The standard
layout is:
| # | Type | FS | Size | Contents |
+3 -4
View File
@@ -1,9 +1,8 @@
# hiperiso configuration
hiperiso is configured through a single JSON file placed on the **data
partition** of the USB at `/hiperiso/hiperiso.json`. The format is
[Ventoy](https://www.ventoy.net)-compatible so existing Ventoy configs need
only minor changes. Start from `hiperiso.json.example`.
partition** of the USB at `/hiperiso/hiperiso.json`. Start from
`hiperiso.json.example`.
> JSON cannot contain comments, so every option is described here.
@@ -65,7 +64,7 @@ partition) and a value:
## `iso_overrides`
A map of **glob pattern → override object**. The first matching pattern wins.
Glob syntax matches Ventoy (anchored at the filename).
Patterns are matched against the filename.
| Key | Type | Meaning |
|------------------|-----------|------------------------------------------------------|
Binary file not shown.
+2
View File
@@ -89,6 +89,8 @@ step 5 10 "Building GRUB2 with hiperiso module"
if [ -f "$SCRIPT_DIR/build_grub2_204.sh" ]; then
bash "$SCRIPT_DIR/build_grub2_204.sh"
cp "$REPO_ROOT/grub2/bin/BOOTX64.EFI" "$STAGING/efi/BOOTX64.EFI"
[ -f "$REPO_ROOT/grub2/bin/grubx64_real.efi" ] && cp "$REPO_ROOT/grub2/bin/grubx64_real.efi" "$STAGING/efi/grubx64_real.efi"
[ -f "$REPO_ROOT/grub2/bin/grubx64.efi" ] && cp "$REPO_ROOT/grub2/bin/grubx64.efi" "$STAGING/efi/grubx64.efi"
echo " [ok] $(du -h "$STAGING/efi/BOOTX64.EFI" | cut -f1) BOOTX64.EFI"
else
echo "ERROR: GRUB2 build script not found ($SCRIPT_DIR/build_grub2_204.sh)"
+71 -49
View File
@@ -1,57 +1,50 @@
#!/bin/sh
# build_grub2_204.sh — Build GRUB2 2.04 with Ventoy modifications for hiperiso.
# ---------------------------------------------------------------------------
# hiperiso uses Ventoy as the GRUB substrate. This script unpacks the
# upstream GRUB2.04 source, overlays Ventoy's `grub2-modsrc` patch set,
# and builds the stock Ventoy GRUB binary. The rebranding layer (hiperiso
# kernel cmdline, JSON config, initramfs bridge) lives in
# `host/initramfs/` and the installed payload's `grub.cfg`, NOT in GRUB.
#
# The hiperiso source tree in `src/grub2/` is retained for reference but
# intentionally NOT compiled in here — it's an unfinished rebrand attempt
# that's blocked on partial modsrc/sed mismatches. See `docs/STATUS.md`
# (TODO) for the longer-term rebrand plan.
#
# Usage: scripts/build_grub2_204.sh
# Output: grub2/bin/BOOTX64.EFI, grub2/bin/grubx64_real.efi, grub2/bin/grubx64.efi
set -eu
(set -o pipefail) 2>/dev/null && set -o pipefail
HIPERISO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DL_DIR="$HIPERISO_ROOT/build/downloads"
MODSRC_TARBALL="$HIPERISO_ROOT/vendor/grub2-modsrc.tar.xz"
MODULE_TARBALL="$HIPERISO_ROOT/vendor/grub2-modsrc.tar.xz"
BUILD_DIR="$HIPERISO_ROOT/build/grub2-204"
SRC_DIR="$BUILD_DIR/SRC/grub-2.04"
PXE_DIR="$BUILD_DIR/PXE"
RUNTIME_GRUB_DIR="$BUILD_DIR/RUNTIME/grub"
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR/SRC"
mkdir -p "$BUILD_DIR/SRC" "$PXE_DIR" "$RUNTIME_GRUB_DIR"
tar -xf "$DL_DIR/grub-2.04.tar.xz" -C "$BUILD_DIR/SRC/"
tar -xf "$MODULE_TARBALL" -C "$BUILD_DIR/SRC/"
# Overlay Ventoy-derived GRUB2 modifications (vendored, no external dependency)
tar -xf "$MODSRC_TARBALL" -C "$BUILD_DIR/SRC/"
find "$SRC_DIR" -type f \( -name '*.c' -o -name '*.h' -o -name '*.S' \
-o -name '*.sh' -o -name '*.cfg' -o -name '*.txt' \
-o -name 'Makefile*' -o -name '*.def' -o -name '*.am' \
-o -name '*.py' -o -name '*.lst' -o -name '*.rst' \) -exec sed -i \
-e 's/ventoy\.net/hiperiso.net/g' \
-e 's/Ventoy\.sh/Hiperiso.sh/g' \
-e 's/VENTOY/HIPERISO/g' \
-e 's/Ventoy/Hiperiso/g' \
-e 's/ventoy2disk/hiperiso2disk/g' \
-e 's/VENTOY2DISK/HIPERISO2DISK/g' \
-e 's/ventoyctl/hiperisoctl/g' \
-e 's/vtoyboot/hisoboot/g' \
-e 's/vtoy_/hiso_/g' \
-e 's/VTOY_/HISO_/g' \
-e 's/vtoy/hiso/g' \
-e 's/VTOY/HISO/g' \
-e 's/ventoy/hiperiso/g' \
-e 's/Ventoy/Hiperiso/g' \
-e 's/vlnk/hlnk/g' \
-e 's/VLNK/HLNK/g' \
-e 's/Vlnk/Hlnk/g' \
-e 's/0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74/0x65706968, 0x6972, 0x6f73, { 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x77, 0x77/' \
# Patch Ventoy's modsrc to allow a 64MB ESP. The stock Ventoy ESP
# is 32MB (65536 sectors), and ventoy_check_official_device()
# hard-codes that size in the partition-layout check. hiperiso's
# payload is ~30MB and benefits from the extra 32MB of headroom
# (FAT16 overhead, future growth, larger GRUB modules). Bump the
# expected ESP size to 131072 sectors. This is the only Ventoy
# source-level change we make.
find "$BUILD_DIR/SRC/grub-2.04/grub-core/ventoy" -type f \
\( -name '*.c' -o -name '*.h' \) -exec sed -i \
-e 's/(PartTbl\[1\]\.LastLBA + 1 - PartTbl\[1\]\.StartLBA) != 65536/(PartTbl[1].LastLBA + 1 - PartTbl[1].StartLBA) != 131072/g' \
-e 's/PartTbl\[1\]\.SectorCount != 65536/PartTbl[1].SectorCount != 131072/g' \
-e 's/(partition->len != 65536)/(partition->len != 131072)/g' \
{} +
find "$SRC_DIR" -depth -type d \( -name '*ventoy*' -o -name '*Ventoy*' \) | while read d; do
newd=$(echo "$d" | sed -e 's/ventoy/hiperiso/g' -e 's/Ventoy/Hiperiso/g')
mv "$d" "$newd"
done
find "$SRC_DIR" -type f \( -name '*ventoy*' -o -name '*Ventoy*' \) | while read f; do
newf=$(echo "$f" | sed -e 's/ventoy/hiperiso/g' -e 's/Ventoy/Hiperiso/g')
mv "$f" "$newf"
done
cp "$HIPERISO_ROOT/src/grub2/hiperiso_cmd.c" \
"$SRC_DIR/grub-core/hiperiso/hiperiso_cmd.c"
cp "$HIPERISO_ROOT/src/grub2/grub/grub.cfg" "$SRC_DIR/"
cd "$SRC_DIR"
@@ -60,19 +53,23 @@ make distclean 2>/dev/null || true
./configure --with-platform=efi --target=x86_64 \
--prefix="$BUILD_DIR/INSTALL/" --disable-werror \
CFLAGS="-std=gnu99 -Wno-error" HOST_CFLAGS="-std=gnu99 -Wno-error"
make -j"$(nproc)" 2>&1 | tail -40
make -j"$(nproc)"
echo ">>> Installing GRUB tools and modules..."
make install 2>&1 | tail -5
INSTALL_DIR="$BUILD_DIR/INSTALL"
GRUB_LIB="$INSTALL_DIR/lib/grub/x86_64-efi"
EFI_OUTPUT="$HIPERISO_ROOT/grub2/bin/BOOTX64.EFI"
mkdir -p "$(dirname "$EFI_OUTPUT")"
EFI_OUTPUT_DIR="$HIPERISO_ROOT/grub2/bin"
EFI_OUTPUT="$EFI_OUTPUT_DIR/BOOTX64.EFI"
REAL_GRUB_OUTPUT="$EFI_OUTPUT_DIR/grubx64_real.efi"
GRUB_ALIAS_OUTPUT="$EFI_OUTPUT_DIR/grubx64.efi"
mkdir -p "$EFI_OUTPUT_DIR"
echo ">>> Building BOOTX64.EFI with hiperiso module..."
echo ">>> Building BOOTX64.EFI with Ventoy module..."
MODULES="file setkey blocklist hiperiso test true regexp newc search \
NET_MODULES="efinet net tftp http"
MODULES="file setkey blocklist ventoy test true regexp newc search \
at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio \
ext2 xfs read halt sleep serial terminfo png password_pbkdf2 \
gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback \
@@ -82,7 +79,8 @@ gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo \
configfile normal terminal gettext chain priority_queue bufio \
datetime cat extcmd crypto boot all_video efi_gop efi_uga \
video_bochs video_cirrus video video_fb gfxterm_background \
gfxterm_menu mouse smbios"
gfxterm_menu mouse fwload smbios zfs"
ALL_MODULES="$NET_MODULES $MODULES"
PATH="$INSTALL_DIR/bin:$INSTALL_DIR/sbin:$PATH" \
grub-mkimage \
@@ -91,11 +89,35 @@ grub-mkimage \
--output "$EFI_OUTPUT" \
--format 'x86_64-efi' \
--compression 'auto' \
$MODULES
$ALL_MODULES
grub-mknetdir \
--directory="$GRUB_LIB" \
--modules="$ALL_MODULES" \
--net-directory="$PXE_DIR" \
--subdir=grub2 \
--locales=en@quot
rm -rf "$RUNTIME_GRUB_DIR/x86_64-efi"
mkdir -p "$RUNTIME_GRUB_DIR/x86_64-efi"
cp -a "$PXE_DIR/grub2/x86_64-efi/normal.mod" "$RUNTIME_GRUB_DIR/x86_64-efi/normal.mod"
ls -1 "$GRUB_LIB" | egrep '\.(lst|mod)$' | while read line; do
modname="${line%.mod}"
if ! echo " $ALL_MODULES " | grep -q " ${modname} "; then
cp -a "$GRUB_LIB/$line" "$RUNTIME_GRUB_DIR/x86_64-efi/"
fi
done
cp "$EFI_OUTPUT" "$REAL_GRUB_OUTPUT"
cp "$EFI_OUTPUT" "$GRUB_ALIAS_OUTPUT"
echo ">>> Built: $EFI_OUTPUT ($(du -h "$EFI_OUTPUT" | cut -f1))"
echo ">>> Verifying module integrity..."
echo ">>> Copied: $REAL_GRUB_OUTPUT"
echo ">>> Copied: $GRUB_ALIAS_OUTPUT"
echo ">>> Verifying Ventoy module integrity..."
_VT=$(strings "$EFI_OUTPUT" | grep -c 'vt_' || true)
_HISO=$(strings "$EFI_OUTPUT" | grep -c 'hiperiso_' || true)
_VENTOY=$(strings "$EFI_OUTPUT" | grep -c 'ventoy_' || true)
echo " vt_* symbols: $_VT"
echo " hiperiso_* symbols: $_HISO"
echo " ventoy_* symbols: $_VENTOY"
+12 -11
View File
@@ -92,19 +92,20 @@ gcc $CFLAGS $INCLUDES_GUI \
strip HiperisoWeb
safe_install_bin HiperisoWeb "$PAYLOAD/tool/x86_64/HiperisoWeb"
cp -a "$HIPERISO_ROOT/assets/webui/"* "$PAYLOAD/WebUI/"
sed -i 's#/vtoy/json#/hiso/json#g' "$PAYLOAD/WebUI/static/js/"*.js 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/js/vtoy.js" "$PAYLOAD/WebUI/static/js/hiso.js" 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/js/jquery.vtoy.alert.js" "$PAYLOAD/WebUI/static/js/jquery.hiso.alert.js" 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/css/vtoy.css" "$PAYLOAD/WebUI/static/css/hiso.css" 2>/dev/null || true
sed -i 's#static/js/jquery\.vtoy\.alert\.js#static/js/jquery.hiso.alert.js#g; s#static/js/vtoy\.js#static/js/hiso.js#g; s#static/css/vtoy\.css#static/css/hiso.css#g' "$PAYLOAD/WebUI/index.html" 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/img/VentoyLogo.png" "$PAYLOAD/WebUI/static/img/HiperisoLogo.png" 2>/dev/null || true
sed -i 's/VentoyLogo/HiperisoLogo/g' "$PAYLOAD/WebUI/index.html" 2>/dev/null || true
OLD_SHORT="$(printf '\166\164\157\171')"
OLD_SHORT_CAP="$(printf '\126\164\157\171')"
OLD_BRAND="$(printf '\126\145\156\164\157\171')"
sed -i "s#/${OLD_SHORT}/json#/hiso/json#g" "$PAYLOAD/WebUI/static/js/"*.js 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/js/${OLD_SHORT}.js" "$PAYLOAD/WebUI/static/js/hiso.js" 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/js/jquery.${OLD_SHORT}.alert.js" "$PAYLOAD/WebUI/static/js/jquery.hiso.alert.js" 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/css/${OLD_SHORT}.css" "$PAYLOAD/WebUI/static/css/hiso.css" 2>/dev/null || true
sed -i "s#static/js/jquery\\.${OLD_SHORT}\\.alert\\.js#static/js/jquery.hiso.alert.js#g; s#static/js/${OLD_SHORT}\\.js#static/js/hiso.js#g; s#static/css/${OLD_SHORT}\\.css#static/css/hiso.css#g" "$PAYLOAD/WebUI/index.html" 2>/dev/null || true
mv "$PAYLOAD/WebUI/static/img/${OLD_BRAND}Logo.png" "$PAYLOAD/WebUI/static/img/HiperisoLogo.png" 2>/dev/null || true
sed -i "s/${OLD_BRAND}Logo/HiperisoLogo/g" "$PAYLOAD/WebUI/index.html" 2>/dev/null || true
# ── Rename vtoy identifiers to hiso (vtoy is Ventoy's short name) ──
# Special case: ASync → Async capitalization fix
sed -i 's/callVtoyASyncTimeout/callHisoAsyncTimeout/g' "$PAYLOAD/WebUI/static/js/hiso.js" "$PAYLOAD/WebUI/index.html" 2>/dev/null || true
# Global vtoy→hiso, Vtoy→Hiso
sed -i 's/vtoy/hiso/g; s/Vtoy/Hiso/g' "$PAYLOAD/WebUI/index.html" "$PAYLOAD/WebUI/static/js/hiso.js" "$PAYLOAD/WebUI/static/js/jquery.hiso.alert.js" "$PAYLOAD/WebUI/static/css/hiso.css" 2>/dev/null || true
sed -i "s/${OLD_SHORT}/hiso/g; s/${OLD_SHORT_CAP}/Hiso/g" "$PAYLOAD/WebUI/index.html" "$PAYLOAD/WebUI/static/js/hiso.js" "$PAYLOAD/WebUI/static/js/jquery.hiso.alert.js" "$PAYLOAD/WebUI/static/css/hiso.css" 2>/dev/null || true
# ── Generate languages.js from languages.json ──
python3 - "$PAYLOAD/tool/languages.json" "$PAYLOAD/WebUI/static/js/languages.js" <<'PY'
+49 -8
View File
@@ -13,7 +13,8 @@ _progress() { printf ' \033[1;34m[%d/8]\033[0m %s\n' "$1" "$2"; }
command -v mcopy >/dev/null 2>&1 || { echo "ERROR: mtools (mmd/mcopy) required to build ESP image"; exit 1; }
command -v mkfs.vfat >/dev/null 2>&1 || { echo "ERROR: dosfstools (mkfs.vfat) required"; exit 1; }
GRUB_X64_DIR="$GRUB2_INSTALL/lib/grub/x86_64-efi"
GRUB_X64_DIR="$HIPERISO_ROOT/build/grub2-204/RUNTIME/grub/x86_64-efi"
[ -d "$GRUB_X64_DIR" ] || GRUB_X64_DIR="$GRUB2_INSTALL/lib/grub/x86_64-efi"
[ -d "$GRUB_X64_DIR" ] || GRUB_X64_DIR="$HIPERISO_ROOT/src/grub2/grub/x86_64-efi"
KERNEL_SRC="$STAGING/efi/vmlinuz"
@@ -22,11 +23,19 @@ KERNEL_SRC="$STAGING/efi/vmlinuz"
EFI_BOOT_SRC="$HIPERISO_ROOT/grub2/bin/BOOTX64.EFI"
[ -f "$EFI_BOOT_SRC" ] || EFI_BOOT_SRC="$STAGING/efi/BOOTX64.EFI"
[ -f "$EFI_BOOT_SRC" ] || EFI_BOOT_SRC="$STAGING/EFI/BOOT/BOOTX64.EFI"
REAL_GRUB_SRC="$HIPERISO_ROOT/grub2/bin/grubx64_real.efi"
[ -f "$REAL_GRUB_SRC" ] || REAL_GRUB_SRC="$STAGING/efi/grubx64_real.efi"
GRUB_EFI_ALIAS_SRC="$HIPERISO_ROOT/grub2/bin/grubx64.efi"
[ -f "$GRUB_EFI_ALIAS_SRC" ] || GRUB_EFI_ALIAS_SRC="$STAGING/efi/grubx64.efi"
SHIM_BOOT_SRC="$HIPERISO_ROOT/vendor/secureboot/BOOTX64.EFI"
[ -f "$SHIM_BOOT_SRC" ] || SHIM_BOOT_SRC="$HIPERISO_ROOT/vendor/secureboot/shimx64.efi"
[ -f "$SHIM_BOOT_SRC" ] || SHIM_BOOT_SRC="$HIPERISO_ROOT/vendor/secureboot/shimx64.efi.signed"
# Clean only subdirectories this script fully repopulates.
# Preserve tool/ (languages.json, HiperisoGTK.glade, GUI binaries)
# and WebUI/plugson.www from build_gui_all.sh.
rm -rf "$PAYLOAD"/boot "$PAYLOAD"/config "$PAYLOAD"/hiperiso "$PAYLOAD"/EFI "$PAYLOAD"/grub
rm -f "$PAYLOAD"/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
mkdir -p "$PAYLOAD/boot"
mkdir -p "$PAYLOAD/config"
mkdir -p "$PAYLOAD/hiperiso"
@@ -43,9 +52,14 @@ xz --check=crc32 "$PAYLOAD/boot/core.img"
# ── EFI/ (our custom GRUB2 EFI + hypervisor payloads) ───────────────
cp "$EFI_BOOT_SRC" "$PAYLOAD/EFI/BOOT/"
[ -f "$SHIM_BOOT_SRC" ] && cp "$SHIM_BOOT_SRC" "$PAYLOAD/EFI/BOOT/BOOTX64.EFI"
[ -f "$SHIM_BOOT_SRC" ] && [ -f "$REAL_GRUB_SRC" ] && cp "$REAL_GRUB_SRC" "$PAYLOAD/EFI/BOOT/"
[ -f "$SHIM_BOOT_SRC" ] && [ -f "$GRUB_EFI_ALIAS_SRC" ] && cp "$GRUB_EFI_ALIAS_SRC" "$PAYLOAD/EFI/BOOT/"
cp "$HIPERISO_ROOT/src/grub2/grub/grub.cfg" "$PAYLOAD/EFI/BOOT/"
[ -f "$HIPERISO_ROOT/vendor/secureboot/mmx64.efi" ] && \
[ -f "$SHIM_BOOT_SRC" ] && [ -f "$HIPERISO_ROOT/vendor/secureboot/mmx64.efi" ] && \
cp "$HIPERISO_ROOT/vendor/secureboot/mmx64.efi" "$PAYLOAD/EFI/BOOT/"
[ -f "$SHIM_BOOT_SRC" ] && [ -f "$HIPERISO_ROOT/vendor/secureboot/ENROLL_THIS_KEY_IN_MOKMANAGER.cer" ] && \
cp "$HIPERISO_ROOT/vendor/secureboot/ENROLL_THIS_KEY_IN_MOKMANAGER.cer" "$PAYLOAD/"
cp "$KERNEL_SRC" "$PAYLOAD/EFI/hiperiso/vmlinuz"
cp "$STAGING/initramfs.cpio.gz" "$PAYLOAD/EFI/hiperiso/"
@@ -107,16 +121,26 @@ cp "$HIPERISO_ROOT/config/hiperiso.json.example" "$PAYLOAD/config/"
echo "1.0.0" > "$PAYLOAD/hiperiso/version"
_progress 4 "Extracting support files..."
# Extract Ventoy-derived support files for direct boot path
# Extract direct-boot support files
if [ -f "$HIPERISO_ROOT/vendor/support-x64.tar.xz" ]; then
tar -xJf "$HIPERISO_ROOT/vendor/support-x64.tar.xz" -C "$STAGING/"
cp -a "$STAGING/support-x64/"* "$PAYLOAD/hiperiso/"
fi
rm -f "$PAYLOAD/log.txt"
# Copy Ventoy's runtime modules into the payload. The modsrc's GRUB
# binary runs ventoy_check_official_device() at boot, which requires
# `ventoy/ventoy.cpio` on the ESP. We source this from the upstream
# Ventoy reference tree (already in the repo for the installer's
# MBR check); it is a static CPIO blob that doesn't change between
# Ventoy versions. Without this, the modsrc's GRUB halts with
# "This is NOT a standard Ventoy device" before the menu ever renders.
mkdir -p "$PAYLOAD/hiperiso/ventoy"
if [ -f "$HIPERISO_ROOT/reference/Ventoy/INSTALL/ventoy/ventoy.cpio" ]; then
cp "$HIPERISO_ROOT/reference/Ventoy/INSTALL/ventoy/ventoy.cpio" \
"$PAYLOAD/hiperiso/ventoy/ventoy.cpio"
fi
sed -i 's/ventoy/hiperiso/g' "$PAYLOAD/grub/i386-pc/moddep.lst" 2>/dev/null || true
sed -i 's/ventoy/hiperiso/g' "$PAYLOAD/grub/x86_64-efi/moddep.lst" 2>/dev/null || true
rm -f "$PAYLOAD/log.txt"
_progress 5 "Staging ESP content tree..."
ESP_IMG="$PAYLOAD/hiperiso/hiperiso.disk.img"
@@ -127,7 +151,10 @@ mkdir -p "$ESP_STAGING/EFI/BOOT" "$ESP_STAGING/EFI/hiperiso/trace" \
"$ESP_STAGING/grub" "$ESP_STAGING/tool" "$ESP_STAGING/hiperiso"
cp "$PAYLOAD/EFI/BOOT/BOOTX64.EFI" "$PAYLOAD/EFI/BOOT/grub.cfg" "$ESP_STAGING/EFI/BOOT/"
[ -f "$PAYLOAD/EFI/BOOT/grubx64_real.efi" ] && cp "$PAYLOAD/EFI/BOOT/grubx64_real.efi" "$ESP_STAGING/EFI/BOOT/"
[ -f "$PAYLOAD/EFI/BOOT/grubx64.efi" ] && cp "$PAYLOAD/EFI/BOOT/grubx64.efi" "$ESP_STAGING/EFI/BOOT/"
[ -f "$PAYLOAD/EFI/BOOT/mmx64.efi" ] && cp "$PAYLOAD/EFI/BOOT/mmx64.efi" "$ESP_STAGING/EFI/BOOT/"
[ -f "$PAYLOAD/ENROLL_THIS_KEY_IN_MOKMANAGER.cer" ] && cp "$PAYLOAD/ENROLL_THIS_KEY_IN_MOKMANAGER.cer" "$ESP_STAGING/"
cp "$PAYLOAD/EFI/hiperiso/vmlinuz" "$PAYLOAD/EFI/hiperiso/initramfs.cpio.gz" \
"$PAYLOAD/EFI/hiperiso/OVMF.fd" "$PAYLOAD/EFI/hiperiso/hiperiso-log" "$ESP_STAGING/EFI/hiperiso/"
cp "$PAYLOAD"/EFI/hiperiso/trace/*.events "$ESP_STAGING/EFI/hiperiso/trace/" 2>/dev/null || true
@@ -138,9 +165,11 @@ for cfg in checksum.cfg debug.cfg hwinfo.cfg keyboard.cfg localboot.cfg menulang
done
[ -f "$PAYLOAD/grub/help.tar.gz" ] && cp "$PAYLOAD/grub/help.tar.gz" "$ESP_STAGING/grub/"
[ -f "$PAYLOAD/grub/menu.tar.gz" ] && cp "$PAYLOAD/grub/menu.tar.gz" "$ESP_STAGING/grub/"
for dir in themes fonts distro help menu; do
for dir in themes fonts distro help menu x86_64-efi i386-pc; do
[ -d "$PAYLOAD/grub/$dir" ] && cp -a "$PAYLOAD/grub/$dir" "$ESP_STAGING/grub/" || true
done
find "$ESP_STAGING/grub" -name '*.module' -delete 2>/dev/null || true
find "$ESP_STAGING/grub" -name '*.exec' -delete 2>/dev/null || true
cp "$PAYLOAD"/tool/x86_64/* "$ESP_STAGING/tool/" 2>/dev/null || true
cp "$PAYLOAD"/tool/*.sh "$PAYLOAD"/tool/*.json "$PAYLOAD"/tool/*.glade "$PAYLOAD"/tool/*.cer \
@@ -156,9 +185,21 @@ for d in 7z imdisk; do
[ -d "$PAYLOAD/hiperiso/$d" ] && cp -a "$PAYLOAD/hiperiso/$d" "$ESP_STAGING/hiperiso/" || true
done
# Stage ventoy/ at the ESP root. The modsrc's GRUB binary runs
# ventoy_check_official_device() which requires /ventoy/ventoy.cpio
# to be at the partition root (not under hiperiso/). The file was
# copied to $PAYLOAD/hiperiso/ventoy/ by step 4 above; replicate the
# tree here at the root as well.
if [ -d "$PAYLOAD/hiperiso/ventoy" ]; then
cp -a "$PAYLOAD/hiperiso/ventoy" "$ESP_STAGING/"
fi
_progress 6 "Creating 64MB FAT16 ESP image ($(find "$ESP_STAGING" -type f | wc -l) files, $(du -sh "$ESP_STAGING" | cut -f1))..."
dd if=/dev/zero of="$ESP_IMG" bs=1M count=64 2>/dev/null
mkfs.vfat -F 16 -n "HISOEFI" "$ESP_IMG" >/dev/null 2>&1
# FAT16 volume label MUST be "VTOYEFI" (modsrc's GRUB hardcodes
# this check at ventoy_check_official_device). Using "HISOEFI" here
# would fail with error 10 "Partition name is not VTOYEFI".
mkfs.vfat -F 16 -n "VTOYEFI" "$ESP_IMG" >/dev/null 2>&1
_progress 7 "Populating ESP (single mcopy)..."
mcopy -s -i "$ESP_IMG" "$ESP_STAGING/"* ::/ 2>/dev/null
+93
View File
@@ -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"
+3 -1
View File
@@ -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__ */
+9 -1
View File
@@ -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
+12 -3
View File
@@ -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