From fb121de75da7969bf24f957d312d4c31f51f2c13 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 30 Jun 2026 14:30:39 +0300 Subject: [PATCH] Add build scripts: build_all, build_grub2, build_gui, build_initramfs, etc. --- scripts/build_all.sh | 135 ++++++++++++++++++++ scripts/build_grub2_204.sh | 96 ++++++++++++++ scripts/build_gui_all.sh | 245 ++++++++++++++++++++++++++++++++++++ scripts/build_gui_qt.sh | 22 ++++ scripts/build_initramfs.sh | 92 ++++++++++++++ scripts/configure_qemu.sh | 54 ++++++++ scripts/download_sources.sh | 94 ++++++++++++++ scripts/fork_ventoy.sh | 119 ++++++++++++++++++ scripts/package_release.sh | 161 ++++++++++++++++++++++++ 9 files changed, 1018 insertions(+) create mode 100755 scripts/build_all.sh create mode 100644 scripts/build_grub2_204.sh create mode 100755 scripts/build_gui_all.sh create mode 100755 scripts/build_gui_qt.sh create mode 100755 scripts/build_initramfs.sh create mode 100755 scripts/configure_qemu.sh create mode 100755 scripts/download_sources.sh create mode 100755 scripts/fork_ventoy.sh create mode 100644 scripts/package_release.sh diff --git a/scripts/build_all.sh b/scripts/build_all.sh new file mode 100755 index 0000000..8f9f412 --- /dev/null +++ b/scripts/build_all.sh @@ -0,0 +1,135 @@ +#!/bin/bash +# +# build_all.sh — Master build orchestrator for hiperiso +# --------------------------------------------------------------------------- +# Runs the full pipeline: +# 1. download sources +# 2. build host kernel (KVM built-in) -> staging/vmlinuz +# 3. build stripped QEMU -> staging/qemu-system-x86_64 +# 4. build OVMF firmware (SMM + Secure Boot) -> staging/OVMF.fd +# 5. build GRUB2 with hiperiso module -> staging/BOOTX64.EFI +# 6. build busybox (static) -> staging/busybox +# 7. build hiperiso-log tool -> staging/hiperiso-log +# 8. pack initramfs -> staging/initramfs.cpio.gz +# 9. build GUI/tool payload -> build/payload/ +# 10. assemble final distributable payload -> build/payload/ +# +# Usage: ./build_all.sh [build_dir] +# SKIP_DOWNLOAD=1 ./build_all.sh # skip re-downloading +# +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +BUILD_DIR="${1:-$REPO_ROOT/build}" +STAGING="$BUILD_DIR/staging" +PAYLOAD="$BUILD_DIR/payload" +JOBS="${JOBS:-$(nproc)}" + +mkdir -p "$STAGING/efi" "$STAGING/initramfs" + +step() { printf '\n\033[1;34m=== [%d/%d] %s ===\033[0m\n' "$1" "$2" "$3"; } + +# ── 1. Download sources ───────────────────────────────────────────────────── +if [ "${SKIP_DOWNLOAD:-0}" != "1" ]; then + step 1 10 "Downloading sources" + "$SCRIPT_DIR/download_sources.sh" "$BUILD_DIR" +else + step 1 10 "Skipping download (SKIP_DOWNLOAD=1)" +fi + +# ── 2. Build host kernel ──────────────────────────────────────────────────── +step 2 10 "Building host kernel (KVM built-in)" +( + cd "$BUILD_DIR/linux" + cp "$REPO_ROOT/host/kernel/hiperiso_defconfig" .config + make olddefconfig + sed -i 's/^KBUILD_CFLAGS := -m\$(BITS) -O2/KBUILD_CFLAGS := -m$(BITS) -O2 -std=gnu11/' arch/x86/boot/compressed/Makefile + make -j"$JOBS" bzImage + cp arch/x86/boot/bzImage "$STAGING/efi/vmlinuz" +) +echo " [ok] $(du -h "$STAGING/efi/vmlinuz" | cut -f1) vmlinuz" + +# ── 3. Build QEMU ─────────────────────────────────────────────────────────── +step 3 10 "Building stripped QEMU" +( + cd "$BUILD_DIR/qemu" + "$SCRIPT_DIR/configure_qemu.sh" + make -j"$JOBS" qemu-system-x86_64 + cp build/qemu-system-x86_64 "$STAGING/qemu-system-x86_64" + strip "$STAGING/qemu-system-x86_64" || true +) + +# ── 4. Build OVMF firmware ────────────────────────────────────────────────── +step 4 10 "Acquiring OVMF firmware" +if [ -d "$BUILD_DIR/edk2" ] && command -v nasm >/dev/null 2>&1 && command -v iasl >/dev/null 2>&1; then + ( + cd "$BUILD_DIR/edk2" + bash "$REPO_ROOT/firmware/build_ovmf.sh" && \ + cp Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd "$STAGING/OVMF.fd" + ) || { + echo " [warn] EDK2 build failed, falling back to system OVMF" + cp /usr/share/edk2/x64/OVMF.4m.fd "$STAGING/OVMF.fd" 2>/dev/null || \ + cp /usr/share/OVMF/OVMF.fd "$STAGING/OVMF.fd" 2>/dev/null || \ + { echo "ERROR: No OVMF available"; exit 1; } + } +elif [ -f /usr/share/edk2/x64/OVMF.4m.fd ]; then + cp /usr/share/edk2/x64/OVMF.4m.fd "$STAGING/OVMF.fd" + echo " [ok] using system pre-built OVMF" +elif [ -f /usr/share/OVMF/OVMF.fd ]; then + cp /usr/share/OVMF/OVMF.fd "$STAGING/OVMF.fd" + echo " [ok] using system pre-built OVMF" +else + echo "ERROR: No OVMF available (install edk2-ovmf or build from source)" + exit 1 +fi + +# ── 5. Build GRUB2 (with full hiperiso module) ────────────────────────────── +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" + 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)" + exit 1 +fi + +# ── 6. Build busybox (static binary for initramfs) ────────────────────────── +step 6 10 "Building busybox (static)" +( + cd "$BUILD_DIR/busybox" + yes "" | make defconfig >/dev/null 2>&1 || [ $? -eq 141 ] + sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config + yes "" | make oldconfig >/dev/null 2>&1 || [ $? -eq 141 ] + sed -i 's/^CONFIG_TC=.*/# CONFIG_TC is not set/' .config + make -j"$JOBS" + cp busybox "$STAGING/busybox" +) +echo " [ok] $(du -h "$STAGING/busybox" | cut -f1) busybox" + +# ── 7. Build hiperiso-log ─────────────────────────────────────────────────── +step 7 10 "Building hiperiso-log tool" +if [ -f "$REPO_ROOT/logging/hiperiso-log/Makefile" ]; then + ( cd "$REPO_ROOT/logging/hiperiso-log" && make ) + cp "$REPO_ROOT/logging/hiperiso-log/hiperiso-log" "$STAGING/hiperiso-log" +else + echo " [warn] hiperiso-log Makefile not present — skipping (log tool task)" +fi + +# ── 8. Pack initramfs ─────────────────────────────────────────────────────── +step 8 10 "Packing initramfs" +"$SCRIPT_DIR/build_initramfs.sh" "$STAGING" + +# ── 9. Build GUI/tool payload ─────────────────────────────────────────────── +step 9 10 "Building GUI and installer tools" +sh "$SCRIPT_DIR/build_gui_all.sh" + +# ── 10. Assemble final distributable payload ──────────────────────────────── +step 10 10 "Assembling final payload" +bash "$SCRIPT_DIR/package_release.sh" + +printf '\n\033[1;32m=== hiperiso build complete ===\033[0m\n' +echo "Payload: $PAYLOAD" +echo "Run GUI: $PAYLOAD/Hiperiso.sh" +echo "Install CLI: sudo bash $PAYLOAD/Hiperiso2Disk.sh /dev/sdX" diff --git a/scripts/build_grub2_204.sh b/scripts/build_grub2_204.sh new file mode 100644 index 0000000..bb28a6e --- /dev/null +++ b/scripts/build_grub2_204.sh @@ -0,0 +1,96 @@ +#!/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" +VENTOY_MOD="$HIPERISO_ROOT/reference/Ventoy/GRUB2/MOD_SRC/grub-2.04" +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/" + +cp -a "$VENTOY_MOD/." "$SRC_DIR/" + +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" diff --git a/scripts/build_gui_all.sh b/scripts/build_gui_all.sh new file mode 100755 index 0000000..b4bd2ec --- /dev/null +++ b/scripts/build_gui_all.sh @@ -0,0 +1,245 @@ +#!/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/" diff --git a/scripts/build_gui_qt.sh b/scripts/build_gui_qt.sh new file mode 100755 index 0000000..a9f8c71 --- /dev/null +++ b/scripts/build_gui_qt.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +HIPERISO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +GUI_DIR="$HIPERISO_ROOT/src/gui/QT" +BUILD_DIR="$GUI_DIR/build_output" +PAYLOAD="$HIPERISO_ROOT/build/payload" + +cd "$GUI_DIR" +mkdir -p "$BUILD_DIR" + +qmake Hiperiso2Disk.pro -o "$BUILD_DIR/Makefile" +make -j"$(nproc)" -C "$BUILD_DIR" 2>&1 | tail -20 + +strip "$BUILD_DIR/Hiperiso2Disk" + +mkdir -p "$PAYLOAD/tool/x86_64" +cp "$BUILD_DIR/Hiperiso2Disk" "$PAYLOAD/tool/x86_64/Hiperiso2Disk.qt5" +chmod +x "$PAYLOAD/tool/x86_64/Hiperiso2Disk.qt5" + +echo "=== Hiperiso2Disk.qt5 ===" +ls -lh "$PAYLOAD/tool/x86_64/Hiperiso2Disk.qt5" diff --git a/scripts/build_initramfs.sh b/scripts/build_initramfs.sh new file mode 100755 index 0000000..8580ebd --- /dev/null +++ b/scripts/build_initramfs.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# build_initramfs.sh — Pack the hiperiso host initramfs +# --------------------------------------------------------------------------- +# Takes the staging directory (build/staging) and assembles a cpio.gz from: +# - host/initramfs/* (init scripts — written by the initramfs task) +# - busybox (static binary, built/downloaded separately) +# - qemu-system-x86_64 (from the QEMU build, already in staging) +# - hiperiso-log (from logging/hiperiso-log, already in staging) +# - OVMF.fd (from the EDK2 build, already in staging) +# +# Usage: build_initramfs.sh +# +set -euo pipefail + +STAGING="${1:?usage: build_initramfs.sh }" +STAGING="$(cd "$STAGING" && pwd)" +[ -d "$STAGING" ] || { echo "ERROR: staging dir '$STAGING' not found" >&2; exit 1; } + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +ROOT="$STAGING/initramfs" + +echo "=== Building initramfs in $ROOT ===" + +# ── Directory tree ────────────────────────────────────────────────────────── +mkdir -p "$ROOT"/{bin,sbin,etc,proc,sys,dev,tmp,run,mnt/usb,mnt/efi,usr/bin,usr/sbin,EFI/hiperiso/trace} + +# ── Init scripts (from host/initramfs/) — copied to root of initramfs ─────── +if [ -d "$REPO_ROOT/host/initramfs" ]; then + cp -a "$REPO_ROOT/host/initramfs/." "$ROOT/" + chmod +x "$ROOT"/init "$ROOT"/*.sh 2>/dev/null || true + echo " [ok] copied init scripts" +else + echo " [warn] host/initramfs/ missing — init scripts not packed yet" +fi + +# ── busybox (static binary) ───────────────────────────────────────────────── +BUSYBOX="${BUSYBOX:-$STAGING/busybox}" +if [ -x "$BUSYBOX" ]; then + install -m0755 "$BUSYBOX" "$ROOT/bin/busybox" + # Create common applet symlinks + for app in sh mount umount ls cat echo mkdir mkfifo poweroff reboot sync sleep ln cp mv rm switch_root date grep cut sed awk head tail tr wc basename dirname find mktemp dd mknod losetup blkid dmesg ps kill chmod chown env uname stat tar; do + ln -sf busybox "$ROOT/bin/$app" + done + echo " [ok] busybox installed" +else + echo " [warn] busybox not found at $BUSYBOX (set BUSYBOX=path)" +fi + +# ── qemu-system-x86_64 (stripped, from QEMU build) ────────────────────────── +if [ -x "$STAGING/qemu-system-x86_64" ]; then + install -m0755 "$STAGING/qemu-system-x86_64" "$ROOT/usr/bin/qemu-system-x86_64" + echo " [ok] qemu-system-x86_64 installed" +else + echo " [warn] qemu-system-x86_64 missing in staging" +fi + +# ── hiperiso-log (log analysis tool) ──────────────────────────────────────── +if [ -x "$STAGING/hiperiso-log" ]; then + install -m0755 "$STAGING/hiperiso-log" "$ROOT/usr/bin/hiperiso-log" + echo " [ok] hiperiso-log installed" +else + echo " [warn] hiperiso-log missing in staging" +fi + +# ── OVMF firmware (for QEMU -bios) ────────────────────────────────────────── +if [ -f "$STAGING/OVMF.fd" ]; then + install -m0644 "$STAGING/OVMF.fd" "$ROOT/EFI/hiperiso/OVMF.fd" + echo " [ok] OVMF.fd installed" +else + echo " [warn] OVMF.fd missing in staging" +fi + +# ── Trace event files ─────────────────────────────────────────────────────── +if ls "$REPO_ROOT"/logging/trace-*.events >/dev/null 2>&1; then + cp "$REPO_ROOT"/logging/trace-*.events "$ROOT/EFI/hiperiso/trace/" + echo " [ok] trace event files installed" +fi + +# ── /dev nodes ───────────────────────────────────────────────────────────── +# devtmpfs will populate /dev at runtime; just ensure the mountpoint exists. +# (Creating device nodes here would require root; devtmpfs handles it.) + +# ── Pack into cpio.gz ─────────────────────────────────────────────────────── +echo "=== Packing initramfs.cpio.gz ===" +( + cd "$ROOT" + find . -print0 | cpio --null -H newc -o --owner=root:root 2>/dev/null \ + | gzip -9 > "$STAGING/initramfs.cpio.gz" +) +echo "=== initramfs.cpio.gz ready ($(du -h "$STAGING/initramfs.cpio.gz" | cut -f1)) ===" diff --git a/scripts/configure_qemu.sh b/scripts/configure_qemu.sh new file mode 100755 index 0000000..7e9b5e4 --- /dev/null +++ b/scripts/configure_qemu.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# configure_qemu.sh — Configure QEMU for a stripped, minimal x86_64 build +# --------------------------------------------------------------------------- +# Must be run from inside the QEMU source tree (it invokes ./configure). +# Output goes to a local build/ subdir so the source tree stays clean. +# +# Rationale: hiperiso needs only x86_64 system emulation with KVM and the +# simpletrace backend. Every optional feature is disabled to shrink the +# resulting qemu-system-x86_64 binary that ships inside the initramfs. +# +set -euo pipefail + +# Allow callers to pass extra flags, e.g. EXTRA_QEMU_CONFIGURE="--enable-werror" +EXTRA_CONFIGURE="${EXTRA_QEMU_CONFIGURE:-}" + +echo "=== Configuring QEMU (stripped x86_64-softmmu, KVM + simpletrace) ===" + +# shellcheck disable=SC2086 # intentional: let EXTRA_CONFIGURE word-split into separate configure arguments +./configure \ + --target-list=x86_64-softmmu \ + --enable-kvm \ + --enable-trace-backends=simple \ + \ + --disable-tools \ + --disable-gtk \ + --disable-sdl \ + --enable-vnc \ + --disable-curses \ + --disable-brlapi \ + --disable-virtfs \ + --disable-install-blobs \ + --disable-guest-agent \ + --disable-docs \ + --disable-libusb \ + --disable-usb-redir \ + --disable-opengl \ + --disable-spice \ + --disable-smartcard \ + --disable-libnfs \ + --disable-libiscsi \ + --disable-rbd \ + --disable-glusterfs \ + --disable-zstd \ + --disable-lzo \ + --disable-bzip2 \ + --disable-snappy \ + --disable-lzfse \ + --disable-capstone \ + --disable-slirp \ + --disable-werror \ + $EXTRA_CONFIGURE + +echo "=== QEMU configured. Now run: make -j\$(nproc) qemu-system-x86_64 ===" diff --git a/scripts/download_sources.sh b/scripts/download_sources.sh new file mode 100755 index 0000000..2dec12f --- /dev/null +++ b/scripts/download_sources.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# +# download_sources.sh — Download and extract hiperiso external sources +# --------------------------------------------------------------------------- +# Downloads: Linux kernel, QEMU, EDK2 (for OVMF), GRUB2. +# Version numbers are variables (override via environment) — never hardcoded. +# +# Usage: ./download_sources.sh [build_dir] +# +set -euo pipefail + +# ── Version variables (override with e.g. KERNEL_VERSION=6.1 ./download_sources.sh) ── +KERNEL_VERSION="${KERNEL_VERSION:-6.12}" +QEMU_VERSION="${QEMU_VERSION:-9.0.0}" +EDK2_TAG="${EDK2_TAG:-edk2-stable202405}" +GRUB2_VERSION="${GRUB2_VERSION:-2.12}" +BUSYBOX_VERSION="${BUSYBOX_VERSION:-1.36.1}" + +# ── Source URLs ───────────────────────────────────────────────────────────── +KERNEL_MAJOR="${KERNEL_VERSION%%.*}" +KERNEL_URL="https://cdn.kernel.org/pub/linux/kernel/v${KERNEL_MAJOR}.x/linux-${KERNEL_VERSION}.tar.xz" +QEMU_URL="https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz" +EDK2_URL="https://github.com/tianocore/edk2.git" +GRUB2_URL="https://ftpmirror.gnu.org/grub/grub-${GRUB2_VERSION}.tar.xz" +BUSYBOX_URL="https://busybox.net/downloads/busybox-${BUSYBOX_VERSION}.tar.bz2" + +# ── Directories ───────────────────────────────────────────────────────────── +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +BUILD_DIR="${1:-$REPO_ROOT/build}" +DL_DIR="$BUILD_DIR/downloads" +mkdir -p "$DL_DIR" + +# Download and extract one tarball, renaming the top dir to a canonical name. +# Usage: fetch +fetch() { + local url="$1" archive="$2" topdir="$3" canonical="$4" + local target="$BUILD_DIR/$canonical" + if [ -d "$target" ]; then + echo " [skip] $canonical already present" + return 0 + fi + echo " [download] $url" + if [ ! -s "$DL_DIR/$archive" ]; then + rm -f "$DL_DIR/$archive" + if ! wget -c -q --show-progress -O "$DL_DIR/$archive" "$url"; then + rm -f "$DL_DIR/$archive" + echo "ERROR: failed to download $archive from $url" >&2 + return 1 + fi + fi + echo " [extract] $archive -> $canonical" + rm -rf "$target" "$BUILD_DIR/$topdir" + tar -xf "$DL_DIR/$archive" -C "$BUILD_DIR" + mv "$BUILD_DIR/$topdir" "$target" +} + +echo "=== hiperiso: downloading sources into $BUILD_DIR ===" + +fetch "$KERNEL_URL" "linux-${KERNEL_VERSION}.tar.xz" "linux-${KERNEL_VERSION}" "linux" +fetch "$QEMU_URL" "qemu-${QEMU_VERSION}.tar.xz" "qemu-${QEMU_VERSION}" "qemu" + +# EDK2 upstream submodules are not fully reliable for reproducible CI-style +# clones. We shallow-clone the main tree only and let the build step fall back +# to a system OVMF if an in-tree OVMF build cannot complete. +EDK2_TARGET="$BUILD_DIR/edk2" +if [ -d "$EDK2_TARGET" ]; then + echo " [skip] edk2 already present" +else + echo " [clone] $EDK2_URL ($EDK2_TAG, shallow clone)" + if ! git -c advice.detachedHead=false clone --depth 1 \ + --branch "$EDK2_TAG" \ + "$EDK2_URL" "$EDK2_TARGET"; then + rm -rf "$EDK2_TARGET" + echo "ERROR: failed to clone edk2 ($EDK2_TAG) from $EDK2_URL" >&2 + exit 1 + fi +fi + +fetch "$GRUB2_URL" "grub-${GRUB2_VERSION}.tar.xz" "grub-${GRUB2_VERSION}" "grub2" + +GRUB2_204_URL="https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz" +if [ ! -f "$DL_DIR/grub-2.04.tar.xz" ]; then + echo " [download] $GRUB2_204_URL" + wget -q -O "$DL_DIR/grub-2.04.tar.xz" "$GRUB2_204_URL" || { + echo " [warn] grub-2.04 download failed (needed for full module build)" + } +else + echo " [skip] grub-2.04.tar.xz already present" +fi + +fetch "$BUSYBOX_URL" "busybox-${BUSYBOX_VERSION}.tar.bz2" "busybox-${BUSYBOX_VERSION}" "busybox" + +echo "=== Sources ready in $BUILD_DIR ===" diff --git a/scripts/fork_ventoy.sh b/scripts/fork_ventoy.sh new file mode 100755 index 0000000..3b503bf --- /dev/null +++ b/scripts/fork_ventoy.sh @@ -0,0 +1,119 @@ +#!/bin/bash +# fork_ventoy.sh — Fork Ventoy source into hiperiso by bulk copy + rename +# This is the mechanical transformation step. All actual code changes +# happen AFTER this fork in targeted modification passes. +set -euo pipefail + +SRC="/mnt/data/Builds/hiperiso/reference/Ventoy" +DST="/mnt/data/Builds/hiperiso/src" + +rm -rf "$DST" +mkdir -p "$DST" + +echo "=== Phase 1: Copy GRUB2 module source ===" +mkdir -p "$DST/grub2" +cp -a "$SRC/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/"*.c "$DST/grub2/" +cp -a "$SRC/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/"*.h "$DST/grub2/" + +echo "=== Phase 2: Copy installer scripts ===" +mkdir -p "$DST/installer/tool" +cp "$SRC/INSTALL/Ventoy2Disk.sh" "$DST/installer/" +cp "$SRC/INSTALL/tool/ventoy_lib.sh" "$DST/installer/tool/" +cp "$SRC/INSTALL/tool/VentoyWorker.sh" "$DST/installer/tool/" +cp "$SRC/INSTALL/tool/create_ventoy_iso_part_dm.sh" "$DST/installer/tool/" +cp "$SRC/INSTALL/CreatePersistentImg.sh" "$DST/installer/" +cp "$SRC/INSTALL/ExtendPersistentImg.sh" "$DST/installer/" +cp "$SRC/INSTALL/VentoyWeb.sh" "$DST/installer/" +cp "$SRC/INSTALL/VentoyPlugson.sh" "$DST/installer/" + +echo "=== Phase 3: Copy GUI source (GTK + Qt + WebUI) ===" +mkdir -p "$DST/gui" +cp -a "$SRC/LinuxGUI/Ventoy2Disk/." "$DST/gui/" + +echo "=== Phase 4: Copy Plugson source ===" +mkdir -p "$DST/plugson" +cp -a "$SRC/Plugson/src/." "$DST/plugson/src/" +cp -a "$SRC/Plugson/www/." "$DST/plugson/www/" 2>/dev/null || true +cp "$SRC/Plugson/build.sh" "$DST/plugson/" 2>/dev/null || true + +echo "=== Phase 5: Copy vtoyfat (FAT manipulation tool) ===" +mkdir -p "$DST/vtoyfat" +cp -a "$SRC/vtoyfat/." "$DST/vtoyfat/" + +echo "=== Phase 6: Copy vtoygpt (GPT partition tool) ===" +mkdir -p "$DST/vtoygpt" +cp -a "$SRC/vtoygpt/." "$DST/vtoygpt/" 2>/dev/null || true + +echo "=== Phase 7: Copy vtoycli ===" +mkdir -p "$DST/vtoycli" +cp -a "$SRC/vtoycli/." "$DST/vtoycli/" 2>/dev/null || true + +echo "=== Phase 8: Copy GRUB2 build scripts ===" +cp "$SRC/GRUB2/buildgrub.sh" "$DST/grub2/" 2>/dev/null || true +cp -a "$SRC/GRUB2/MOD_SRC/grub-2.04/grub-core/Makefile.am" "$DST/grub2/" 2>/dev/null || true +cp -a "$SRC/GRUB2/MOD_SRC/grub-2.04/grub-core/Makefile.core.def" "$DST/grub2/" 2>/dev/null || true +cp -a "$SRC/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h" "$DST/grub2/" 2>/dev/null || true + +echo "" +echo "=== Phase 9: Bulk rename all files ===" + +find "$DST" -depth -name '*ventoy*' -exec bash -c ' + dir=$(dirname "$1") + old=$(basename "$1") + new=$(echo "$old" | sed "s/ventoy/hiperiso/g; s/VENTOY/HIPERISO/g; s/Ventoy/Hiperiso/g") + if [ "$old" != "$new" ]; then + mv "$1" "$dir/$new" + fi +' _ {} \; + +find "$DST" -depth -name '*Ventoy*' -exec bash -c ' + dir=$(dirname "$1") + old=$(basename "$1") + new=$(echo "$old" | sed "s/Ventoy/Hiperiso/g; s/ventoy/hiperiso/g") + if [ "$old" != "$new" ]; then + mv "$1" "$dir/$new" + fi +' _ {} \; + +find "$DST" -depth -name '*vtoy*' -exec bash -c ' + dir=$(dirname "$1") + old=$(basename "$1") + new=$(echo "$old" | sed "s/vtoy/hiso/g; s/VTOY/HISO/g") + if [ "$old" != "$new" ]; then + mv "$1" "$dir/$new" + fi +' _ {} \; + +echo "=== Phase 10: Bulk rename file contents ===" + +find "$DST" -type f \( -name '*.c' -o -name '*.h' -o -name '*.sh' \ + -o -name '*.cpp' -o -name '*.am' -o -name '*.def' \ + -o -name '*.txt' -o -name '*.cfg' -o -name '*.json' \ + -o -name '*.html' -o -name '*.js' -o -name '*.css' \ + -o -name '*.md' -o -name '*.py' -o -name '*.exp' \) -exec sed -i \ + -e 's/VENTOY/HIPERISO/g' \ + -e 's/Ventoy/Hiperiso/g' \ + -e 's/ventoy/hiperiso/g' \ + -e 's/VTOY/HISO/g' \ + -e 's/vtoy/hiso/g' \ + {} + + +echo "=== Phase 11: Rename directory names ===" +find "$DST" -depth -type d -name '*ventoy*' -o -name '*Ventoy*' -o -name '*vtoy*' | while read -r dir; do + parent=$(dirname "$dir") + old=$(basename "$dir") + new=$(echo "$old" | sed 's/ventoy/hiperiso/g; s/Ventoy/Hiperiso/g; s/vtoy/hiso/g') + if [ "$old" != "$new" ]; then + mv "$dir" "$parent/$new" + fi +done + +echo "" +echo "=== Fork complete ===" +echo "Source at: $DST" +echo "" +echo "File count:" +find "$DST" -type f | wc -l +echo "" +echo "Directory structure:" +find "$DST" -maxdepth 2 -type d | sort diff --git a/scripts/package_release.sh b/scripts/package_release.sh new file mode 100644 index 0000000..8ea7043 --- /dev/null +++ b/scripts/package_release.sh @@ -0,0 +1,161 @@ +#!/bin/sh +set -e + +_SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +HIPERISO_ROOT="$(cd "$_SCRIPT_DIR/.." && pwd)" +VENTOY_INSTALL="$HIPERISO_ROOT/reference/Ventoy/INSTALL" +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" + +GRUB_I386_DIR="$GRUB2_INSTALL/lib/grub/i386-pc" +[ -d "$GRUB_I386_DIR" ] || GRUB_I386_DIR="$VENTOY_INSTALL/grub/i386-pc" + +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 from Ventoy) ──────────────────────────── +cp "$VENTOY_INSTALL/grub/i386-pc/boot.img" "$PAYLOAD/boot/boot.img" +cp "$VENTOY_INSTALL/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 "$VENTOY_INSTALL/grub/i386-pc/"*.lst "$PAYLOAD/grub/i386-pc/" 2>/dev/null || true +cp -a "$GRUB_I386_DIR/." "$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/ (forked scripts + Ventoy binary tools, renamed) ─────────── +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/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 + +VENTOY_TOOLS="ash hexdump mkexfatfs mount.exfat-fuse xzcat" +for tool in $VENTOY_TOOLS; do + cp "$VENTOY_INSTALL/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" + +# ── Fix stale ventoy references in i386-pc moddep.lst ─────────────── +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"