/usr/lib/live/build/efi-image is in live-build 1:20170213.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #! /bin/sh
set -e
# Copyright (C) 2010, 2011 Canonical Ltd.
# Author: Colin Watson <cjwatson@ubuntu.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# Make an EFI boot image.
if [ -z "$1" ] || [ -z "$2" ]; then
echo "usage: $0 OUTPUT-DIRECTORY GRUB-PLATFORM EFI-NAME NETBOOT-PREFIX"
exit 1
fi
outdir="$1"
platform="$2"
efi_name="$3"
netboot_prefix="$4"
memdisk_img=
workdir=
cleanup () {
[ -z "$memdisk_img" ] || rm -f "$memdisk_img"
[ -z "$workdir" ] || rm -rf "$workdir"
}
trap cleanup EXIT HUP INT QUIT TERM
rm -rf "$outdir"
mkdir -p "$outdir"
memdisk_img="$(mktemp efi-image.XXXXXX)"
workdir="$(mktemp -d efi-image.XXXXXX)"
# Skeleton configuration file which finds the real boot disk.
mkdir -p "$workdir/boot/grub"
cat >"$workdir/boot/grub/grub.cfg" <<EOF
search --file --set=root /.disk/info
set prefix=(\$root)/boot/grub
source \$prefix/$platform/grub.cfg
EOF
mkdir -p "$outdir/boot/grub/$platform"
(for i in /usr/lib/grub/$platform/part_*.mod; do
i=`echo $i | sed 's?^.*/??g;s?\.mod$??g;'`
echo "insmod $i"
done; \
echo "source /boot/grub/grub.cfg") >"$outdir/boot/grub/$platform/grub.cfg"
# Build the core image.
(cd "$workdir"; tar -cf - boot) >"$memdisk_img"
grub-mkimage -O "$platform" -m "$memdisk_img" \
-o "$workdir/boot$efi_name.efi" -p '(memdisk)/boot/grub' \
search iso9660 configfile normal memdisk tar part_msdos part_gpt fat
grub-mkimage -O "$platform" \
-o "$outdir/bootnet$efi_name.efi" -p "$netboot_prefix/grub" \
search configfile normal efinet tftp net
# Stuff it 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 -C "$outdir/efi.img" \
$(( ($(stat -c %s "$workdir/boot$efi_name.efi") / 1024 + 55) \
/ 32 * 32 ))
mmd -i "$outdir/efi.img" ::efi
mmd -i "$outdir/efi.img" ::efi/boot
mcopy -i "$outdir/efi.img" "$workdir/boot$efi_name.efi" \
"::efi/boot/boot$efi_name.efi"
grub-cpmodules "$outdir" "$platform"
cp /usr/share/grub/unicode.pf2 "$outdir/boot/grub/"
exit 0
|