Files
hiperiso/scripts/build_grub2_204.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

98 lines
3.5 KiB
Bash

#!/bin/sh
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"
BUILD_DIR="$HIPERISO_ROOT/build/grub2-204"
SRC_DIR="$BUILD_DIR/SRC/grub-2.04"
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR/SRC"
tar -xf "$DL_DIR/grub-2.04.tar.xz" -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' \
{} +
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"
make distclean 2>/dev/null || true
./autogen.sh
./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
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")"
echo ">>> Building BOOTX64.EFI with hiperiso module..."
MODULES="file setkey blocklist hiperiso 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 \
part_apple minicmd diskfilter linux relocator jpeg iso9660 udf \
hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale \
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"
PATH="$INSTALL_DIR/bin:$INSTALL_DIR/sbin:$PATH" \
grub-mkimage \
--directory "$GRUB_LIB" \
--prefix '(,2)/grub' \
--output "$EFI_OUTPUT" \
--format 'x86_64-efi' \
--compression 'auto' \
$MODULES
echo ">>> Built: $EFI_OUTPUT ($(du -h "$EFI_OUTPUT" | cut -f1))"
echo ">>> Verifying module integrity..."
_VT=$(strings "$EFI_OUTPUT" | grep -c 'vt_' || true)
_HISO=$(strings "$EFI_OUTPUT" | grep -c 'hiperiso_' || true)
echo " vt_* symbols: $_VT"
echo " hiperiso_* symbols: $_HISO"