Files
hiperiso/scripts/build_grub2_204.sh
T
vasilito c71ff93c6b fix: add vlnk→hlnk sed rules and GUID hex fix to build scripts
build_grub2_204.sh: Add vlnk/VLNK/Vlnk→hlnk/HLNK/Hlnk sed rules for
build-time transformation. Add targeted sed rule to replace VENTOY_GUID
hex values (0x77772020,0x2e77,0x6576,...) with HIPERISO_GUID values
(0x65706968,0x6972,0x6f73,...) so the binary GUID no longer spells
'www.ventoy.net' in memory.

build_gui_all.sh: Fix vlnk.c→hlnk.c reference in GUI build.
2026-06-30 19:54:07 +03:00

102 lines
3.7 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' \
-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/' \
{} +
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"