60 lines
2.6 KiB
Bash
60 lines
2.6 KiB
Bash
#!/bin/bash
|
|
# Rebuild ADD/ABA images with a dual-arch EFI boot image (x64 + ia32).
|
|
set -e
|
|
W=/tmp/acrbuild2
|
|
OLD=/path/to/pf/acronis/prev # previous images (mkrescue, BIOS+boot x64)
|
|
rm -rf "$W"; mkdir -p "$W"
|
|
|
|
apt-get install -y grub-efi-ia32-bin grub-efi-amd64-bin grub-pc-bin mtools xorriso >/tmp/apt2.log 2>&1 || true
|
|
|
|
build_one() {
|
|
local name="$1" srcdir="$2" kernel="$3" initrds="$4"
|
|
local tree="$W/$name"
|
|
mkdir -p "$tree/boot/grub/i386-pc" "$tree/$srcdir"
|
|
|
|
echo "=== $name ($srcdir)"
|
|
# source files: take from the existing image to avoid re-extracting from the 4.4G ISO
|
|
xorriso -osirrox on -indev "/tmp/acrbuild/$name.iso" \
|
|
-extract "/$srcdir" "$tree/$srcdir" >/dev/null 2>&1
|
|
xorriso -osirrox on -indev "/tmp/acrbuild/$name.iso" \
|
|
-extract /boot/grub/i386-pc/eltorito.img "$tree/boot/grub/i386-pc/eltorito.img" >/dev/null 2>&1
|
|
|
|
cat > "$W/$name.cfg" <<EOF
|
|
search --no-floppy --set=root --file /$srcdir/$kernel
|
|
linux /$srcdir/$kernel force_modules=usbhid quiet lang=RU_ru
|
|
initrd $(for i in $initrds; do echo -n "/$srcdir/$i "; done)
|
|
boot
|
|
EOF
|
|
|
|
local mods64="linux normal iso9660 search search_label search_fs_file part_msdos echo test"
|
|
local mods32="$mods64"
|
|
|
|
grub-mkimage -O x86_64-efi -o "$W/BOOTX64.EFI" -p /boot/grub -d /usr/lib/grub/x86_64-efi -c "$W/$name.cfg" $mods64
|
|
grub-mkimage -O i386-efi -o "$W/BOOTIA32.EFI" -p /boot/grub -d /usr/lib/grub/i386-efi -c "$W/$name.cfg" $mods32
|
|
ls -l "$W/BOOTX64.EFI" "$W/BOOTIA32.EFI"
|
|
|
|
# FAT image with both loaders
|
|
rm -f "$W/efi.img"
|
|
dd if=/dev/zero of="$W/efi.img" bs=1M count=16 status=none
|
|
mkfs.vfat -n EFI "$W/efi.img" >/dev/null
|
|
mmd -i "$W/efi.img" ::/EFI ::/EFI/BOOT
|
|
mcopy -i "$W/efi.img" "$W/BOOTX64.EFI" ::/EFI/BOOT/BOOTX64.EFI
|
|
mcopy -i "$W/efi.img" "$W/BOOTIA32.EFI" ::/EFI/BOOT/BOOTIA32.EFI
|
|
mdir -i "$W/efi.img" ::/EFI/BOOT
|
|
|
|
cp -f "$W/efi.img" "$tree/efi.img"
|
|
xorriso -as mkisofs -o "$W/$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/xorriso_$name.log 2>&1 || { tail -10 /tmp/xorriso_$name.log; return 1; }
|
|
|
|
printf " -> %s.iso : %s bytes\n" "$name" "$(stat -c %s "$W/$name.iso")"
|
|
xorriso -indev "$W/$name.iso" -report_el_torito plain 2>&1 | grep -E 'El Torito boot img' | sed 's/^/ /'
|
|
echo -n " efi.img contents: "
|
|
xorriso -osirrox on -indev "$W/$name.iso" -extract /efi.img /tmp/chk_efi.img >/dev/null 2>&1
|
|
mdir -i /tmp/chk_efi.img ::/EFI/BOOT | tr '\n' ' '; echo
|
|
}
|
|
|
|
build_one ADD ATI2025 dat10.dat "dat11.dat dat12.dat"
|
|
build_one ABA ADDH12 dat14.dat "dat15.dat dat16.dat"
|