From e747a371c4287f6b6af58d5558c7961d3d1866a0 Mon Sep 17 00:00:00 2001 From: Andreas Loibl Date: Thu, 29 Sep 2011 19:46:39 +0200 Subject: added scripts to generate the EFI-partition-images --- mkefipart-fat | 26 ++++++++++++++++++++++++++ mkefipart-hfsplus | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100755 mkefipart-fat create mode 100755 mkefipart-hfsplus diff --git a/mkefipart-fat b/mkefipart-fat new file mode 100755 index 0000000..21bfdc8 --- /dev/null +++ b/mkefipart-fat @@ -0,0 +1,26 @@ +#! /bin/sh +# mkefipart-fat - written by Andreas Loibl +# +# Generate an image for a FAT-EFI-partition + +if [ ! -x /usr/bin/mmd ]; then + echo "Error: mtools are needed! Run: apt-get install mtools" + exit 1 +fi + +img=efi-fat.img +[ "$1" ] && img="$1" + +# Stuff boot*.efi into a FAT filesystem, making it as small as possible. 24KiB +# headroom seems to be enough; (x+31)/32*32 rounds up to multiple of 32. +mkfs.msdos -n EFI -C "$img" \ + $(( ($(stat -c %s binary/efi/boot/boot*.efi | awk '{s+=$1} END {print s}') / 1024 + 55) \ + / 32 * 32 )) +mmd -i "$img" ::efi +mmd -i "$img" ::efi/boot +for file in binary/efi/boot/boot*.efi +do + mcopy -i "$img" $file "::efi/boot/$(basename "$file")" +done + +exit 0 diff --git a/mkefipart-hfsplus b/mkefipart-hfsplus new file mode 100755 index 0000000..b858160 --- /dev/null +++ b/mkefipart-hfsplus @@ -0,0 +1,55 @@ +#! /bin/sh +# mkefipart-hfsplus - written by Andreas Loibl +# +# Generate an image for a HFS+-EFI-partition + +set -e + +img=efi-hfs.img +[ "$1" ] && img="$1" + +label=efi-hfs.vollabel +[ "$2" ] && label="$2" +[ ! -f "$label" ] && wget -O$label http://kanotix.acritox.com/files/mac/label.vollabel + +workdir= + +cleanup () { + [ "$workdir" ] || exit + umount "$workdir" 2>/dev/null | : + rm -rf "$workdir" +} +trap cleanup EXIT HUP INT QUIT TERM + +workdir="$(mktemp -d efi-image.XXXXXX)" + +# Stuff boot*.efi into a HFS+ filesystem, making it as small as possible (in MB steps). +# (x+1023)/1024*1024 rounds up to multiple of 1024. +dd if=/dev/zero of="$img" bs=1k count=$(( ($(stat -c %s binary/efi/boot/boot*.efi | awk '{s+=$1} END {print s}') / 1024 + 1023) / 1024 * 1024 )) 2>/dev/null +mkfs.hfsplus "$img" +mount -o loop,creator=prhc,type=jxbt,uid=99,gid=99 "$img" "$workdir" +cp "$label" "$workdir"/.disk_label +mkdir -p "$workdir"/efi/boot + +for file in binary/efi/boot/boot*.efi +do + cp "$file" "$workdir/efi/boot/$(basename "$file")" +done + +set -- $(ls -i $workdir/efi/boot/boot*.efi) +inode=$1 + +umount "$workdir" + +echo "Blessing file with inode $inode ($(basename "$2"))..." +perl <