Files
hiperiso/scripts/package_release.sh
T
vasilito 025ae2701c refactor: make hiperiso fully standalone — zero Ventoy dependency
Vendor all previously external dependencies into the hiperiso repo:

Vendored:
- vendor/grub2-modsrc.tar.xz (364K) — GRUB2 build overlay, with dead
  compression files (huffman, lzx, xpress, miniz) removed from both
  the tarball and Makefile.core.def
- vendor/grub-i386-pc/ — BIOS boot images (boot.img, core.img, .lst)
- vendor/tool-x86_64/ — pre-built utility binaries (ash, hexdump,
  mkexfatfs, mount.exfat-fuse, xzcat)
- assets/ — languages.json, HiperisoGTK.glade, WebUI (renamed)
- src/gui/ — full GUI source tree (Qt5, GTK3, Web, Core, Libs)
- src/plugson/ — full Plugson web config tool source
- src/hisolnk/ — Vlnk tool source (renamed)

Dead code removed:
- src/grub2/huffman.c, huffman.h, lzx.c, lzx.h, xpress.c, xpress.h,
  miniz.c, miniz.h, wimboot.h — WIM/injection compression (~3700 lines)
- hiperiso_gzip_compress() stubbed (never called in hypervisor path)
- lzx_decompress(), xca_decompress() stubbed (WIM decompression)

Build scripts updated:
- build_grub2_204.sh: uses vendor/grub2-modsrc.tar.xz
- package_release.sh: uses vendor/ and assets/ paths
- build_gui_all.sh: uses src/gui/, src/plugson/, src/hisolnk/
- fork_ventoy.sh: removed (one-time fork complete)

Verified: GRUB2 BOOTX64.EFI builds clean (1.8M, 275 hiperiso symbols)
Zero reference/Ventoy/ references remain in any build script.
2026-06-30 15:40:05 +03:00

155 lines
7.1 KiB
Bash

#!/bin/sh
set -e
_SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
HIPERISO_ROOT="$(cd "$_SCRIPT_DIR/.." && pwd)"
GRUB2_INSTALL="$HIPERISO_ROOT/build/grub2-204/INSTALL"
PAYLOAD="$HIPERISO_ROOT/build/payload"
STAGING="$HIPERISO_ROOT/build/staging"
# ── Dependency checks ─────────────────────────────────────────────
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"
[ -d "$GRUB_X64_DIR" ] || GRUB_X64_DIR="$HIPERISO_ROOT/src/grub2/grub/x86_64-efi"
KERNEL_SRC="$STAGING/efi/vmlinuz"
[ -f "$KERNEL_SRC" ] || KERNEL_SRC="$STAGING/vmlinuz"
EFI_BOOT_SRC="$STAGING/efi/BOOTX64.EFI"
[ -f "$EFI_BOOT_SRC" ] || EFI_BOOT_SRC="$STAGING/EFI/BOOT/BOOTX64.EFI"
# 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
mkdir -p "$PAYLOAD/boot"
mkdir -p "$PAYLOAD/config"
mkdir -p "$PAYLOAD/hiperiso"
mkdir -p "$PAYLOAD/EFI/BOOT"
mkdir -p "$PAYLOAD/EFI/hiperiso/trace"
mkdir -p "$PAYLOAD/grub"
mkdir -p "$PAYLOAD/tool/x86_64"
# ── boot/ (BIOS boot images, vendored) ────────────────────────────
cp "$HIPERISO_ROOT/vendor/grub-i386-pc/boot.img" "$PAYLOAD/boot/boot.img"
cp "$HIPERISO_ROOT/vendor/grub-i386-pc/core.img" "$PAYLOAD/boot/core.img"
xz --check=crc32 "$PAYLOAD/boot/core.img"
# ── EFI/ (our custom GRUB2 EFI + hypervisor payloads) ───────────────
cp "$EFI_BOOT_SRC" "$PAYLOAD/EFI/BOOT/"
cp "$HIPERISO_ROOT/src/grub2/grub/grub.cfg" "$PAYLOAD/EFI/BOOT/"
cp "$KERNEL_SRC" "$PAYLOAD/EFI/hiperiso/vmlinuz"
cp "$STAGING/initramfs.cpio.gz" "$PAYLOAD/EFI/hiperiso/"
cp "$STAGING/OVMF.fd" "$PAYLOAD/EFI/hiperiso/"
cp "$STAGING/hiperiso-log" "$PAYLOAD/EFI/hiperiso/"
cp "$HIPERISO_ROOT/logging/trace-"*.events "$PAYLOAD/EFI/hiperiso/trace/"
# ── grub/ (configs, themes, modules from GRUB2 2.04 build) ──────────
cp "$HIPERISO_ROOT/src/grub2/grub/grub.cfg" "$PAYLOAD/grub/"
cp -a "$GRUB_X64_DIR" "$PAYLOAD/grub/x86_64-efi"
mkdir -p "$PAYLOAD/grub/i386-pc"
cp "$HIPERISO_ROOT/vendor/grub-i386-pc/"*.lst "$PAYLOAD/grub/i386-pc/" 2>/dev/null || true
cp "$HIPERISO_ROOT/vendor/grub-i386-pc/"*.mod "$PAYLOAD/grub/i386-pc/" 2>/dev/null || true
for cfg in checksum.cfg debug.cfg hwinfo.cfg keyboard.cfg localboot.cfg menulang.cfg power.cfg; do
cp "$HIPERISO_ROOT/src/grub2/grub/$cfg" "$PAYLOAD/grub/" 2>/dev/null || true
done
for dir in distro help menu themes fonts; do
cp -a "$HIPERISO_ROOT/src/grub2/grub/$dir" "$PAYLOAD/grub/" 2>/dev/null || true
done
if [ -d "$PAYLOAD/grub/help" ]; then
tar -C "$PAYLOAD/grub" -czf "$PAYLOAD/grub/help.tar.gz" help
fi
if [ -d "$PAYLOAD/grub/menu" ]; then
tar -C "$PAYLOAD/grub" -czf "$PAYLOAD/grub/menu.tar.gz" menu
fi
# ── tool/ (installer scripts + vendored assets + binary tools) ─────
cp "$HIPERISO_ROOT/src/installer/tool/hiperiso_lib.sh" "$PAYLOAD/tool/"
cp "$HIPERISO_ROOT/src/installer/tool/HiperisoWorker.sh" "$PAYLOAD/tool/"
cp "$HIPERISO_ROOT/src/installer/tool/create_hiperiso_iso_part_dm.sh" "$PAYLOAD/tool/"
cp "$HIPERISO_ROOT/assets/languages.json" "$PAYLOAD/tool/languages.json"
cp "$HIPERISO_ROOT/assets/HiperisoGTK.glade" "$PAYLOAD/tool/HiperisoGTK.glade"
for tool in ash hexdump mkexfatfs mount.exfat-fuse xzcat; do
cp "$HIPERISO_ROOT/vendor/tool-x86_64/$tool" "$PAYLOAD/tool/x86_64/"
chmod +x "$PAYLOAD/tool/x86_64/$tool"
done
# ── Top-level scripts ───────────────────────────────────────────────
cp "$HIPERISO_ROOT/src/installer/Hiperiso.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/HiperisoQt.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/HiperisoGtk.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/HiperisoWeb.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/HiperisoPlugson.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/Hiperiso2Disk.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/CreatePersistentImg.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/ExtendPersistentImg.sh" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/hisocli" "$PAYLOAD/"
cp "$HIPERISO_ROOT/src/installer/hisolnk" "$PAYLOAD/"
# ── config/ ─────────────────────────────────────────────────────────
cp "$HIPERISO_ROOT/config/hiperiso.json.example" "$PAYLOAD/config/"
# ── version ─────────────────────────────────────────────────────────
echo "1.0.0" > "$PAYLOAD/hiperiso/version"
rm -f "$PAYLOAD/log.txt"
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
# ── Build ESP disk image (32MB FAT16, what installer writes to Part 2) ──
ESP_IMG="$PAYLOAD/hiperiso/hiperiso.disk.img"
dd if=/dev/zero of="$ESP_IMG" bs=1M count=32 2>/dev/null
mkfs.vfat -F 16 -n "HISOEFI" "$ESP_IMG" >/dev/null 2>&1
mmd -i "$ESP_IMG" ::/EFI
mmd -i "$ESP_IMG" ::/EFI/BOOT
mmd -i "$ESP_IMG" ::/EFI/hiperiso
mmd -i "$ESP_IMG" ::/EFI/hiperiso/trace
mmd -i "$ESP_IMG" ::/grub
mmd -i "$ESP_IMG" ::/tool
mmd -i "$ESP_IMG" ::/hiperiso
mcopy -i "$ESP_IMG" "$PAYLOAD/EFI/BOOT/BOOTX64.EFI" ::/EFI/BOOT/
mcopy -i "$ESP_IMG" "$PAYLOAD/EFI/BOOT/grub.cfg" ::/EFI/BOOT/
mcopy -i "$ESP_IMG" "$PAYLOAD/EFI/hiperiso/vmlinuz" ::/EFI/hiperiso/
mcopy -i "$ESP_IMG" "$PAYLOAD/EFI/hiperiso/initramfs.cpio.gz" ::/EFI/hiperiso/
mcopy -i "$ESP_IMG" "$PAYLOAD/EFI/hiperiso/OVMF.fd" ::/EFI/hiperiso/
mcopy -i "$ESP_IMG" "$PAYLOAD/EFI/hiperiso/hiperiso-log" ::/EFI/hiperiso/
for f in "$PAYLOAD"/EFI/hiperiso/trace/*.events; do
mcopy -s -i "$ESP_IMG" "$f" ::/EFI/hiperiso/trace/ 2>/dev/null || true
done
mcopy -i "$ESP_IMG" "$PAYLOAD/grub/grub.cfg" ::/grub/
for cfg in checksum.cfg debug.cfg hwinfo.cfg keyboard.cfg localboot.cfg menulang.cfg power.cfg; do
[ -f "$PAYLOAD/grub/$cfg" ] && mcopy -i "$ESP_IMG" "$PAYLOAD/grub/$cfg" ::/grub/
done
[ -f "$PAYLOAD/grub/help.tar.gz" ] && mcopy -i "$ESP_IMG" "$PAYLOAD/grub/help.tar.gz" ::/grub/
[ -f "$PAYLOAD/grub/menu.tar.gz" ] && mcopy -i "$ESP_IMG" "$PAYLOAD/grub/menu.tar.gz" ::/grub/
for dir in themes fonts distro help menu; do
[ -d "$PAYLOAD/grub/$dir" ] && {
mmd -i "$ESP_IMG" "::/grub/$dir"
mcopy -s -i "$ESP_IMG" "$PAYLOAD/grub/$dir/." "::/grub/$dir/" 2>/dev/null || true
}
done
for f in "$PAYLOAD"/tool/x86_64/*; do
[ -f "$f" ] && mcopy -i "$ESP_IMG" "$f" ::/tool/
done
mcopy -i "$ESP_IMG" "$PAYLOAD/hiperiso/version" ::/hiperiso/
xz --check=crc32 "$ESP_IMG"
echo "=== hiperiso release package assembled ==="
du -sh "$PAYLOAD"
find "$PAYLOAD" -type f | wc -l
echo "files"