46ac25c
#!/bin/sh
46ac25c
46ac25c
# args
46ac25c
dir="$1"
46ac25c
46ac25c
# cfg
46ac25c
shell="$dir/Shell.efi"
46ac25c
enroll="$dir/EnrollDefaultKeys.efi"
46ac25c
vfat="$dir/shell.img"
46ac25c
iso="$dir/UefiShell.iso"
46ac25c
export MTOOLS_SKIP_CHECK=1
46ac25c
46ac25c
# calc size
46ac25c
s1=$(stat --format=%s -- $shell)
46ac25c
s2=$(stat --format=%s -- $enroll)
46ac25c
size=$(( ($s1 + $s2) * 11 / 10 ))
46ac25c
set -x
46ac25c
46ac25c
# create non-partitioned FAT image
46ac25c
/usr/sbin/mkdosfs -C "$vfat" -n UEFI_SHELL -- "$(( $size / 1024 ))"
46ac25c
mmd	-i "$vfat"			::efi
46ac25c
mmd	-i "$vfat"			::efi/boot
46ac25c
mcopy	-i "$vfat"	"$shell"	::efi/boot/bootx64.efi
46ac25c
mcopy	-i "$vfat"	"$enroll"	::
46ac25c
#mdir	-i "$vfat"	-/		::
46ac25c
46ac25c
# build ISO with FAT image file as El Torito EFI boot image
46ac25c
genisoimage -input-charset ASCII -J -rational-rock \
46ac25c
	-efi-boot "${vfat##*/}" -no-emul-boot -o "$iso" -- "$vfat"
46ac25c
rm -f "$vfat"