#!/bin/sh set -eu (set -o pipefail) 2>/dev/null && set -o pipefail HIPERISO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" GUI="$HIPERISO_ROOT/src/gui" PLUGSON="$HIPERISO_ROOT/src/plugson" PAYLOAD="$HIPERISO_ROOT/build/payload" VENTOY_INSTALL="$HIPERISO_ROOT/reference/Ventoy/INSTALL" CFLAGS="-O2 -std=gnu99 -D_FILE_OFFSET_BITS=64 -DSTATIC=static -DINIT= -DLINUX -Wno-unused-function" INCLUDES_GUI="-I$GUI/Core -I$GUI/Web -I$GUI/GTK -I$GUI/Include -I$GUI \ -I$GUI/Lib/libhttp/include -I$GUI/Lib/fat_io_lib/include \ -I$GUI/Lib/xz-embedded/linux/include -I$GUI/Lib/xz-embedded/linux/include/linux \ -I$GUI/Lib/xz-embedded/userspace -I$GUI/Lib/exfat/src/libexfat \ -I$GUI/Lib/exfat/src/mkfs -I$GUI/Lib/fat_io_lib" INCLUDES_PS="-I$PLUGSON/src -I$PLUGSON/src/Core -I$PLUGSON/src/Web -I$PLUGSON/src/Include \ -I$PLUGSON/src/Lib/libhttp/include -I$PLUGSON/src/Lib/fat_io_lib/include \ -I$PLUGSON/src/Lib/xz-embedded/linux/include -I$PLUGSON/src/Lib/xz-embedded/linux/include/linux \ -I$PLUGSON/src/Lib/xz-embedded/userspace -I$PLUGSON/src/Lib/exfat/src/libexfat \ -I$PLUGSON/src/Lib/exfat/src/mkfs -I$PLUGSON/src/Lib/fat_io_lib" build_civetweb() { echo ">>> Compiling civetweb ($1)" gcc -std=gnu99 -D_FILE_OFFSET_BITS=64 -O2 -Wall -Wno-unused-function \ -DLINUX -DNDEBUG -DNO_CGI -DNO_CACHING -DNO_SSL \ -DSQLITE_DISABLE_LFS -DSSL_ALREADY_INITIALIZED \ -DUSE_STACK_SIZE=102400 -fPIC \ -I"$1/Lib/libhttp/include" \ -c "$1/Lib/libhttp/include/civetweb.c" -o "$2/civetweb.o" } safe_install_bin() { src="$1" dst="$2" tmp="${dst}.new" cp "$src" "$tmp" chmod +x "$tmp" 2>/dev/null || true mv -f "$tmp" "$dst" } mkdir -p "$PAYLOAD/tool/x86_64" "$PAYLOAD/WebUI" "$PAYLOAD/plugson.www" cp "$HIPERISO_ROOT/reference/Ventoy/LANGUAGES/languages.json" "$PAYLOAD/tool/languages.json" cp "$HIPERISO_ROOT/reference/Ventoy/INSTALL/tool/VentoyGTK.glade" "$PAYLOAD/tool/HiperisoGTK.glade" sed -i 's/Ventoy/Hiperiso/g; s/ventoy/hiperiso/g' "$PAYLOAD/tool/languages.json" "$PAYLOAD/tool/HiperisoGTK.glade" 2>/dev/null || true # ── Qt5 GUI ── echo ">>> Building Hiperiso2Disk.qt5" cd "$GUI/QT" mkdir -p build_output qmake Hiperiso2Disk.pro -o build_output/Makefile make -j"$(nproc)" -C build_output 2>&1 | tail -5 strip build_output/Hiperiso2Disk safe_install_bin build_output/Hiperiso2Disk "$PAYLOAD/tool/x86_64/Hiperiso2Disk.qt5" # ── GTK3 GUI ── echo ">>> Building Hiperiso2Disk.gtk3" BUILDDIR=$(mktemp -d) cd "$BUILDDIR" build_civetweb "$GUI" . gcc $CFLAGS $(pkg-config --cflags gtk+-3.0) $INCLUDES_GUI \ "$GUI/main_gtk.c" "$GUI/Core/"*.c "$GUI/Web/"*.c "$GUI/GTK/"*.c \ "$GUI/Lib/xz-embedded/linux/lib/decompress_unxz.c" \ "$GUI/Lib/exfat/src/libexfat/"*.c "$GUI/Lib/exfat/src/mkfs/"*.c \ "$GUI/Lib/fat_io_lib/"*.c civetweb.o \ $(pkg-config --libs gtk+-3.0) -lpthread \ -o Hiperiso2Disk.gtk3 strip Hiperiso2Disk.gtk3 safe_install_bin Hiperiso2Disk.gtk3 "$PAYLOAD/tool/x86_64/Hiperiso2Disk.gtk3" # ── GUI launcher wrapper ── echo ">>> Building HiperisoGUI" gcc -O2 -D_FILE_OFFSET_BITS=64 \ "$GUI/hiperiso_gui.c" "$GUI/Core/hiperiso_json.c" \ -I"$GUI/Core" -DHISO_GUI_ARCH="\"x86_64\"" \ -o HiperisoGUI.x86_64 strip HiperisoGUI.x86_64 safe_install_bin HiperisoGUI.x86_64 "$PAYLOAD/HiperisoGUI.x86_64" # ── WebUI ── echo ">>> Building HiperisoWeb" build_civetweb "$GUI" . gcc $CFLAGS $INCLUDES_GUI \ "$GUI/main_webui.c" \ "$GUI/Core/hiperiso_json.c" "$GUI/Core/hiperiso_util.c" \ "$GUI/Core/hiperiso_disk.c" "$GUI/Core/hiperiso_log.c" \ "$GUI/Core/hiperiso_md5.c" "$GUI/Core/hiperiso_crc32.c" \ "$GUI/Web/"*.c \ "$GUI/Lib/xz-embedded/linux/lib/decompress_unxz.c" \ "$GUI/Lib/exfat/src/libexfat/"*.c "$GUI/Lib/exfat/src/mkfs/"*.c \ "$GUI/Lib/fat_io_lib/"*.c civetweb.o \ -lpthread -o HiperisoWeb strip HiperisoWeb safe_install_bin HiperisoWeb "$PAYLOAD/tool/x86_64/HiperisoWeb" cp -a "$HIPERISO_ROOT/reference/Ventoy/LinuxGUI/WebUI/"* "$PAYLOAD/WebUI/" sed -i 's/Ventoy/Hiperiso/g; s/ventoy/hiperiso/g' "$PAYLOAD/WebUI/index.html" "$PAYLOAD/WebUI/static/js/"*.js 2>/dev/null || true 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 # ── 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 # ── Generate languages.js from languages.json ── python3 - "$PAYLOAD/tool/languages.json" "$PAYLOAD/WebUI/static/js/languages.js" <<'PY' import json, sys with open(sys.argv[1], 'r', encoding='utf-8') as f: langs = json.load(f) with open(sys.argv[2], 'w', encoding='utf-8') as f: f.write('// Auto-generated from languages.json - do not edit manually\n') f.write('var hiso_language_data = ') json.dump(langs, f, ensure_ascii=False, separators=(',', ':')) f.write(';\n') PY # ── Add logo to header ── sed -i 's#
#
\n
Hiperiso
#' "$PAYLOAD/WebUI/index.html" 2>/dev/null || true # ── Replace Chinese defaults with English (overwritten by language JS at runtime) ── sed -i \ -e 's/在磁盘最后保留一段空间/Reserve space at the end of disk/g' \ -e 's/分区按照 4KB 对齐/Align partitions to 4KB boundaries/g' \ -e 's/>确定OK取消Cancel配置选项 />Option /g' \ -e 's/>安全启动支持Secure Boot Support分区类型Partition Style分区设置Partition Configuration清除 HiperisoClear Hiperiso显示所有设备Show All Devices设备Device安装包内 Hiperiso 版本Hiperiso in Package设备内部 Hiperiso 版本Hiperiso in Device状态 - 准备就绪Status - Ready安装Install升级Update/dev/null || true # ── Remove overflow:hidden from body ── sed -i 's///g' "$PAYLOAD/WebUI/index.html" 2>/dev/null || true # ── Apply brand color (#2d8e57) to WebUI ── sed -i 's/#2F7095/#2d8e57/g' "$PAYLOAD/WebUI/static/css/hiso.css" 2>/dev/null || true sed -i 's/color:#ea991f/color:#2d8e57/g' "$PAYLOAD/WebUI/index.html" 2>/dev/null || true cat >> "$PAYLOAD/WebUI/static/css/hiso.css" << 'BRANDCSS' #HisoBtnInstall, #HisoBtnUpdate { background-color: #2d8e57 !important; border-color: #256e44 !important; color: #ffffff !important; } #HisoBtnInstall:hover, #HisoBtnUpdate:hover { background-color: #329f66 !important; border-color: #256e44 !important; } #HisoBtnInstall:disabled, #HisoBtnUpdate:disabled { background-color: #a9cdb8 !important; border-color: #94bda3 !important; } BRANDCSS # ── Plugson ── echo ">>> Building Plugson" build_civetweb "$PLUGSON/src" . gcc $CFLAGS $INCLUDES_PS \ "$PLUGSON/src/main_linux.c" \ "$PLUGSON/src/Core/hiperiso_crc32.c" "$PLUGSON/src/Core/hiperiso_disk.c" \ "$PLUGSON/src/Core/hiperiso_disk_linux.c" "$PLUGSON/src/Core/hiperiso_json.c" \ "$PLUGSON/src/Core/hiperiso_log.c" "$PLUGSON/src/Core/hiperiso_md5.c" \ "$PLUGSON/src/Core/hiperiso_utf.c" "$PLUGSON/src/Core/hiperiso_util.c" \ "$PLUGSON/src/Core/hiperiso_util_linux.c" \ "$PLUGSON/src/Web/"*.c \ "$PLUGSON/src/Lib/xz-embedded/linux/lib/decompress_unxz.c" \ "$PLUGSON/src/Lib/fat_io_lib/"*.c civetweb.o \ -lpthread -o Plugson strip Plugson safe_install_bin Plugson "$PAYLOAD/tool/x86_64/Plugson" cp -a "$PLUGSON/www" "$PAYLOAD/plugson.www" # ── Utility binaries ── echo ">>> Building utility binaries" gcc -O2 -D_FILE_OFFSET_BITS=64 -fno-pie -no-pie \ "$HIPERISO_ROOT/src/hisocli/hisocli.c" \ "$HIPERISO_ROOT/src/hisocli/hisofat.c" \ "$HIPERISO_ROOT/src/hisocli/hisogpt.c" \ "$HIPERISO_ROOT/src/hisocli/crc32.c" \ "$HIPERISO_ROOT/src/hisocli/partresize.c" \ -I"$HIPERISO_ROOT/src/hisocli/fat_io_lib/include" \ "$HIPERISO_ROOT/src/hisocli/fat_io_lib/lib/libfat_io_64.a" \ -o hisocli strip hisocli safe_install_bin hisocli "$PAYLOAD/tool/x86_64/hisocli" VLNK_TMP=$(mktemp -d) cp "$HIPERISO_ROOT/reference/Ventoy/Vlnk/src/crc32.c" "$VLNK_TMP/" cp "$HIPERISO_ROOT/reference/Ventoy/Vlnk/src/main_linux.c" "$VLNK_TMP/" cp "$HIPERISO_ROOT/reference/Ventoy/Vlnk/src/vlnk.c" "$VLNK_TMP/" cp "$HIPERISO_ROOT/reference/Ventoy/Vlnk/src/vlnk.h" "$VLNK_TMP/" sed -i 's/\.vtoy/\.hiso/g; s/www\.ventoy\.net/www.hiperiso.net/g' "$VLNK_TMP/vlnk.c" "$VLNK_TMP/vlnk.h" VLNK_TMP_PATH="$VLNK_TMP/vlnk.h" python3 - <<'PY' from pathlib import Path import os path = Path(os.environ['VLNK_TMP_PATH']) text = path.read_text() text = text.replace( '#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}', '#define VENTOY_GUID { 0x4849534f, 0x4850, 0x4953, { 0x4f, 0x2d, 0x4c, 0x49, 0x4e, 0x4b, 0x2d, 0x31 }}' ) path.write_text(text) PY gcc -O2 -D_FILE_OFFSET_BITS=64 -fno-pie -no-pie \ "$VLNK_TMP/crc32.c" \ "$VLNK_TMP/main_linux.c" \ "$VLNK_TMP/vlnk.c" \ -I"$VLNK_TMP" \ -o hisolnk strip hisolnk safe_install_bin hisolnk "$PAYLOAD/tool/x86_64/hisolnk" rm -rf "$VLNK_TMP" chmod +x "$PAYLOAD/tool/x86_64/"* # ── Launcher scripts ── cp "$HIPERISO_ROOT/src/installer/Hiperiso.sh" "$PAYLOAD/" 2>/dev/null || true cp "$HIPERISO_ROOT/src/installer/HiperisoQt.sh" "$PAYLOAD/" 2>/dev/null || true cp "$HIPERISO_ROOT/src/installer/HiperisoGtk.sh" "$PAYLOAD/" 2>/dev/null || true cp "$HIPERISO_ROOT/src/installer/HiperisoWeb.sh" "$PAYLOAD/" 2>/dev/null || true cp "$HIPERISO_ROOT/src/installer/HiperisoPlugson.sh" "$PAYLOAD/" 2>/dev/null || true cp "$HIPERISO_ROOT/src/installer/hisocli" "$PAYLOAD/" 2>/dev/null || true cp "$HIPERISO_ROOT/src/installer/hisolnk" "$PAYLOAD/" 2>/dev/null || true cd "$HIPERISO_ROOT" rm -rf "${BUILDDIR:-}" echo "" echo "=== All GUI/web tools built ===" ls -lh "$PAYLOAD/tool/x86_64/"