Files
hiperiso/scripts/fork_ventoy.sh
T

120 lines
4.1 KiB
Bash
Executable File

#!/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