Skip to content

Commit

Permalink
Use sane paths for intermediate EFI files
Browse files Browse the repository at this point in the history
This way we also don't remove them from the chroot *after* building
the squashfs.
  • Loading branch information
Christian Hofstaedtler committed Dec 21, 2011
1 parent 5f895b3 commit 4efbf69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
32 changes: 15 additions & 17 deletions etc/grml/fai/config/scripts/GRMLBASE/45-efi
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ if ! [ -r "${target}"/usr/lib/grub/x86_64-efi/moddep.lst ] ; then
exit 0
fi

GRUB_EFI_IMAGE="${target}/tmp/grub_efi_image"
BOOTX64="${target}/boot/bootx64.efi"
EFI_IMG="${target}/boot/efi.img"
TMP_CONFIG="${target}/tmp/grub_config_efi"
EFI_IMAGE="${target}/tmp/efi_image"

rm -f "$GRUB_EFI_IMAGE" "$TMP_CONFIG" "$EFI_IMAGE"
rm -f "$BOOTX64" "$EFI_IMG" "$TMP_CONFIG"

cat > "$TMP_CONFIG" <<EOF
search --set -f /conf/bootid.txt root
Expand All @@ -37,37 +37,35 @@ else
fi
EOF

GRUB_EFI_IMAGE="${GRUB_EFI_IMAGE##${target}}"
BOOTX64="${BOOTX64##${target}}"
EFI_IMG="${EFI_IMG##${target}}"
TMP_CONFIG="${TMP_CONFIG##${target}}"
EFI_IMAGE="${EFI_IMAGE##${target}}"

$ROOTCMD grub-mkimage -O x86_64-efi -o "$GRUB_EFI_IMAGE" --prefix=/boot/grub/ --config="$TMP_CONFIG" \
$ROOTCMD grub-mkimage -O x86_64-efi -o "$BOOTX64" --prefix=/boot/grub/ --config="$TMP_CONFIG" \
bitmap boot btrfs cat chain cmp configfile cpio echo efi_gop \
efi_uga elf ext2 fat gfxmenu gfxterm gzio help iso9660 jpeg linux \
loopback lvm minicmd multiboot normal part_gpt part_msdos play png \
probe raid regexp reiserfs search search_fs_file search_fs_uuid \
search_label squash4 terminal test video videoinfo xfs

if ! [ -r "${target}/${GRUB_EFI_IMAGE}" ] ; then
if ! [ -r "${target}/${BOOTX64}" ] ; then
echo "Can not access grub efi image." >&2
exit 1
fi

SIZE=$(du -sk "${target}/${GRUB_EFI_IMAGE}" | awk -F" " '{print $1'})
SIZE=$(du -sk "${target}/${BOOTX64}" | awk -F" " '{print $1'})
SIZE=$(((($SIZE / 32 )+2)*32))

dd if=/dev/zero of="${target}/${EFI_IMAGE}" bs=1k count="$SIZE" 2>/dev/null
$ROOTCMD mkfs.vfat -n GRML "$EFI_IMAGE" >/dev/null
$ROOTCMD mmd -i "$EFI_IMAGE" ::EFI
$ROOTCMD mmd -i "$EFI_IMAGE" ::EFI/BOOT
$ROOTCMD mcopy -i "$EFI_IMAGE" "$GRUB_EFI_IMAGE" ::EFI/BOOT/bootx64.efi >/dev/null
dd if=/dev/zero of="${target}/${EFI_IMG}" bs=1k count="$SIZE" 2>/dev/null
$ROOTCMD mkfs.vfat -n GRML "$EFI_IMG" >/dev/null
$ROOTCMD mmd -i "$EFI_IMG" ::EFI
$ROOTCMD mmd -i "$EFI_IMG" ::EFI/BOOT
$ROOTCMD mcopy -i "$EFI_IMG" "$BOOTX64" ::EFI/BOOT/bootx64.efi >/dev/null

rm -f "${target}/${TMP_CONFIG}"
mv "${target}/${EFI_IMAGE}" "${target}/var/lib/grml_live_efi.img"
mv "${target}/${GRUB_EFI_IMAGE}" "${target}/var/lib/grml_live_bootx64.efi"

echo "Generated EFI image ${target}/var/lib/grml_live_efi.img"
echo "Generated bootx64 image ${target}/var/lib/grml_live_bootx64.efi"
echo "Generated EFI image $BOOTX64"
echo "Generated bootx64 image $EFI_IMG"

## END OF FILE #################################################################
# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2
26 changes: 13 additions & 13 deletions grml-live
Original file line number Diff line number Diff line change
Expand Up @@ -1213,24 +1213,21 @@ else
eindent

if ! dpkg --compare-versions $(dpkg-query -W -f='${Version}\n' xorriso 2>/dev/null) gt-nl 1.1.6-1 ; then
log "Disabling (U)EFI boot support since xorriso version is not recent enough."
ewarn "Disabling (U)EFI boot support since xorriso version is not recent enough." ; eend 0
log "Disabling (U)EFI boot support because xorriso version is too old."
ewarn "Disabling (U)EFI boot support because xorriso version is too old." ; eend 0
else
log "xorriso with -eltorito-alt-boot present, enabling (U)EFI boot support."
einfo "xorriso with -eltorito-alt-boot present, enabling (U)EFI boot support." ; eend 0

if [ -r "${CHROOT_OUTPUT}/var/lib/grml_live_efi.img" ] ; then
einfo "Found /var/lib/grml_live_efi.img - moving to /boot/efi.img for ISO."
log "Found /var/lib/grml_live_efi.img - moving to /boot/efi.img for ISO."
mv "${CHROOT_OUTPUT}/var/lib/grml_live_efi.img" "${BUILD_OUTPUT}/boot/efi.img"
if [ -r "${CHROOT_OUTPUT}/boot/efi.img" ] ; then
einfo "Found /boot/efi.img - using for ISO."
log "Found /boot/efi.img - using for ISO."
cp "${CHROOT_OUTPUT}/boot/efi.img" "${BUILD_OUTPUT}/boot/efi.img"
eend $?
fi

if [ -r "${CHROOT_OUTPUT}/var/lib/grml_live_bootx64.efi" ] ; then
einfo "Found /var/lib/grml_live_bootx64.efi - moving to /efi/boot/bootx64.efi for ISO"
log "Found /var/lib/grml_live_bootx64.efi - moving to /efi/boot/bootx64.efi for ISO"
if [ -r "${CHROOT_OUTPUT}/boot/bootx64.efi" ] ; then
einfo "Found /boot/bootx64.efi - using as /efi/boot/bootx64.efi for ISO."
log "Found /boot/bootx64.efi - using as /efi/boot/bootx64.efi for ISO."
mkdir -p "${BUILD_OUTPUT}/efi/boot/"
mv "${CHROOT_OUTPUT}/var/lib/grml_live_bootx64.efi" "${BUILD_OUTPUT}/efi/boot/bootx64.efi"
cp "${CHROOT_OUTPUT}/boot/bootx64.efi" "${BUILD_OUTPUT}/efi/boot/bootx64.efi"
eend $?
fi

Expand All @@ -1239,6 +1236,9 @@ else
log "/boot/efi.img found and amd64 architecture present, extending boot arguments."
BOOT_ARGS="$BOOT_ARGS -boot-info-table -eltorito-alt-boot -e boot/efi.img -no-emul-boot"
eend $?
else
log "Disabling (U)EFI boot support because /boot/efi.img is missing."
ewarn "Disabling (U)EFI boot support because /boot/efi.img is missing." ; eend 0
fi
fi

Expand Down

0 comments on commit 4efbf69

Please sign in to comment.