Files
Ventoy/build-scripts/integration/acronis/build-acronis-hybrid.sh
T

77 lines
3.7 KiB
Bash

#!/bin/bash
# Hybrid Acronis images: x64 set (our GRUB2 menu) + x86 set (xorboot/ia32).
# EFI boot image carries an i386 GRUB that boots the 32-bit kernel, so
# 32-bit UEFI firmware works too. BIOS El Torito is kept for legacy.
set -e
SRC=/path/to/pf/acronis/Acronis_Boot_Disk_2024.iso
OUT=/path/to/pf/acronis/hybrid
W=/root/hybrid
rm -rf "$W"; mkdir -p "$W" "$OUT"
apt-get install -y grub-pc-bin grub-efi-amd64-bin grub-efi-ia32-bin mtools xorriso >/tmp/apt4.log 2>&1 || true
build_one() {
local name="$1" dir="$2" k64="$3" i64="$4" k32="$5" i32="$6"
local tree="$W/$name"
mkdir -p "$tree/$dir" "$tree/efi/boot" "$tree/EFI/BOOT" "$tree/boot/grub"
echo "=== $name : $dir"
7z e -y -o"$tree/$dir" "$SRC" \
"ACR/$dir/$k64" $(for i in $i64; do echo "ACR/$dir/$i"; done) \
"ACR/$dir/$k32" $(for i in $i32; do echo "ACR/$dir/$i"; done) >/dev/null
du -sh "$tree/$dir"
# ---- configs
cat > "$W/$name.32.cfg" <<EOF
search --no-floppy --set=root --file /$dir/$k32
linux /$dir/$k32 vga=791 mbrcrcs=on force_modules=usbhid lang=ru quiet
initrd $(for i in $i32; do echo -n "/$dir/$i "; done)
boot
EOF
cat > "$W/$name.64.cfg" <<EOF
search --no-floppy --set=root --file /$dir/$k64
linux /$dir/$k64 vga=791 mbrcrcs=on force_modules=usbhid lang=ru quiet
initrd $(for i in $i64; do echo -n "/$dir/$i "; done)
boot
EOF
MODS="linux normal iso9660 search search_label search_fs_file part_msdos echo test"
grub-mkimage -O i386-efi -o "$W/BOOTIA32.EFI" -p /boot/grub -d /usr/lib/grub/i386-efi -c "$W/$name.32.cfg" $MODS
grub-mkimage -O x86_64-efi -o "$W/BOOTX64.EFI" -p /boot/grub -d /usr/lib/grub/x86_64-efi -c "$W/$name.64.cfg" $MODS
# lowercase copy for xorboot (old Acronis layout) and uppercase for firmware
cp -f "$W/BOOTIA32.EFI" "$tree/efi/boot/bootia32.efi"
cp -f "$W/BOOTX64.EFI" "$tree/efi/boot/bootx64.efi"
cp -f "$W/BOOTIA32.EFI" "$tree/EFI/BOOT/BOOTIA32.EFI"
cp -f "$W/BOOTX64.EFI" "$tree/EFI/BOOT/BOOTX64.EFI"
# ---- EFI boot image (FAT12, both loaders)
dd if=/dev/zero of="$tree/efi.img" bs=1k count=1440 status=none
mkfs.vfat -F 12 -n EFI "$tree/efi.img" >/dev/null
mmd -i "$tree/efi.img" ::/EFI ::/EFI/BOOT
mcopy -i "$tree/efi.img" "$W/BOOTIA32.EFI" ::/EFI/BOOT/BOOTIA32.EFI
mcopy -i "$tree/efi.img" "$W/BOOTIA32.EFI" ::/EFI/BOOT/BOOTX64.EFI # xorboot looks for this name
mcopy -i "$tree/efi.img" "$W/BOOTX64.EFI" ::/EFI/BOOT/BOOTX64X.EFI >/dev/null 2>&1 || true
# ---- base image (BIOS El Torito comes from grub-mkrescue)
grub-mkrescue -o "$W/$name.base.iso" "$tree" >/tmp/mk_$name.log 2>&1
xorriso -osirrox on -indev "$W/$name.base.iso" \
-extract /boot/grub/i386-pc/eltorito.img "$tree/boot/grub/i386-pc/eltorito.img" >/dev/null 2>&1
# ---- final ISO (Rock Ridge + Joliet so lowercase paths are visible)
xorriso -as mkisofs -R -J -joliet-long -V PARAVIS_ACRONIS -o "$OUT/$name.iso" \
-b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table \
-eltorito-alt-boot -e efi.img -no-emul-boot \
"$tree" >/tmp/xor_$name.log 2>&1
printf " -> %s: %s bytes\n" "$name" "$(stat -c %s "$OUT/$name.iso")"
xorriso -indev "$OUT/$name.iso" -report_el_torito plain 2>&1 | grep -E 'El Torito boot img' | sed 's/^/ /'
printf " tree: "; 7z l -ba "$OUT/$name.iso" 2>/dev/null | grep -oE '(efi|EFI)/boot/[Bb][Oo][Oo][Tt](IA32|X64|ia32|x64)\.efi' | tr '\n' ' '; echo
}
# ADD = True Image 2025 : x64 dat10/11/12, x86 dat2/3/4
build_one ADD ATI2025 dat10.dat "dat11.dat dat12.dat" dat2.dat "dat3.dat dat4.dat"
# ABA = Disk Director 12.5 : x64 dat14/15/16, x86 dat10/11/12
build_one ABA ADDH12 dat14.dat "dat15.dat dat16.dat" dat10.dat "dat11.dat dat12.dat"
ls -l "$OUT"