windows_init/src/iso.sh

84 lines
1.7 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
2021-10-04 05:39:20 +00:00
printf '%b\n' "\n\033[1m"WINDOWS_INIT:"\033[0m"" Executing extract_iso.sh"
2021-09-28 17:38:12 +00:00
src/extract_iso.sh
2021-10-03 21:01:26 +00:00
EXTRACT="win/"
#printf '%b\n' "\n\033[1m"WINDOWS_INIT:"\033[0m"" Executing bootsect.sh"
#./src/bootsect.sh
#BOOT="bootsect.bin"
2021-09-28 17:38:12 +00:00
# add answerfile
2021-10-03 21:01:26 +00:00
cp data/autounattend.xml ${EXTRACT}
# data for mkisofs
BOOT="boot/etfsboot.com"
EFI="efi/boot/bootx64.efi"
LOAD_SEG="$(dumpet -i Win*.iso \
| grep "Media load segment: " \
| cut -d ':' -f2 \
| cut -d ' ' -f2)"
LOAD_SIZE="$(dumpet -i Win*.iso \
| grep "Load Sectors: " \
| grep -o "[^:]*$" \
| cut -d ' ' -f2 \
| head -1)"
2021-10-08 05:05:37 +00:00
LBA="$(dumpet -i Win*.iso \
| grep "LBA" \
| tail -n 1 \
| awk '{printf $3}')"
CDROM_SECTOR_SIZE=2048
FLOPPY_SECTOR_SIZE=512
2021-10-08 05:12:10 +00:00
dd \
if=`printf Win*.iso` \
bs=${CDROM_SECTOR_SIZE} \
skip=${LBA} \
count=1 \
> win.dmp
FLOPPY_SECTORS="$(file win.dmp \
| sed -e "s/.*sectors\ //" \
| awk '{printf $1}')"
CDROM_SECTORS=`expr $FLOPPY_SECTOR_SIZE \
\* $FLOPPY_SECTORS \
/ $CDROM_SECTOR_SIZE`
dd \
2021-10-08 05:12:10 +00:00
if=`printf Win*.iso` \
bs=${CDROM_SECTOR_SIZE} \
2021-10-08 05:05:37 +00:00
skip=${LBA} \
count=${CDROM_SECTORS} \
of=win_efi_boot.img
2021-09-28 17:38:12 +00:00
# install mkisofs
# recreate iso
2021-10-05 02:33:57 +00:00
cd ${EXTRACT}
2021-10-03 21:01:26 +00:00
mkisofs \
-allow-limited-size \
-no-emul-boot \
-b ${BOOT} \
-boot-load-seg ${LOAD_SEG} \
-boot-load-size ${LOAD_SIZE} \
-eltorito-alt-boot \
-b ${EFI} \
-eltorito-platform efi \
2021-10-03 21:01:26 +00:00
-iso-level 2 \
2021-10-07 22:58:39 +00:00
-boot-info-table \
-udf \
-J -l -joliet-long \
-D \
-N \
-relaxed-filenames \
2021-10-03 21:01:26 +00:00
-V "WINSP" \
-o winsp.iso \
2021-10-05 02:33:57 +00:00
.
2021-09-28 17:38:12 +00:00
mv winsp.iso ..
2021-10-04 04:52:36 +00:00
2021-10-05 02:33:57 +00:00
# clean up bootsect and iso extract
cd ..
rm win.dmp
#rm -rf bootsect/
2021-10-03 21:01:26 +00:00
sudo rm -rf ${EXTRACT}