New environment variable MKRESCUE_SED_UNPACK_EFI_TO_ISO
This commit is contained in:
parent
9e79f64cae
commit
3318fa47a3
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2015 - 2019
|
# Copyright (C) 2015 - 2022
|
||||||
# Thomas Schmitt <scdbackup@gmx.net>, libburnia-project.org
|
# Thomas Schmitt <scdbackup@gmx.net>, libburnia-project.org
|
||||||
# Provided under BSD license: Use, modify, and distribute as you like.
|
# Provided under BSD license: Use, modify, and distribute as you like.
|
||||||
|
|
||||||
@ -117,9 +117,9 @@ fi
|
|||||||
# command line.)
|
# command line.)
|
||||||
# Each argument must be a single word. No whitespace. No quotation marks.
|
# Each argument must be a single word. No whitespace. No quotation marks.
|
||||||
|
|
||||||
# "yes" overwrites the MBR partition table area in the EFI boot image by zeros.
|
# "yes" in MKRESCUE_SED_IN_EFI_NO_PT overwrites the MBR partition table area
|
||||||
# Some EFI implementations get stuck when seeing in the EFI partition a
|
# in the EFI boot image by zeros. Some EFI implementations get stuck when
|
||||||
# partition table entry which begins at LBA 0.
|
# seeing in the EFI partition a partition table entry which begins at LBA 0.
|
||||||
# "extra" not only zeros the partition table but also the MBR signature.
|
# "extra" not only zeros the partition table but also the MBR signature.
|
||||||
efi_zero_inner_pt=no
|
efi_zero_inner_pt=no
|
||||||
if test -n "$MKRESCUE_SED_IN_EFI_NO_PT"
|
if test -n "$MKRESCUE_SED_IN_EFI_NO_PT"
|
||||||
@ -127,6 +127,24 @@ then
|
|||||||
efi_zero_inner_pt="$MKRESCUE_SED_IN_EFI_NO_PT"
|
efi_zero_inner_pt="$MKRESCUE_SED_IN_EFI_NO_PT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# "yes" in MKRESCUE_SED_UNPACK_EFI_TO_ISO causes the file tree from the FAT
|
||||||
|
# image efi.img to be unpacked by mcopy to a directory in /tmp which then
|
||||||
|
# gets mapped into the root directory of the emerging ISO 9660 filesystem.
|
||||||
|
# This enables a way of installing the result image onto a USB stick with
|
||||||
|
# FAT filesystem by simply copying its full file tree from ISO to FAT.
|
||||||
|
# Whether the payload files of the ISO will be able to work from FAT depends
|
||||||
|
# on their expectation towards file names and attributes.
|
||||||
|
# WARNING: Make sure that the files in efi.img do not collide with your
|
||||||
|
# payload files or with files added to the ISO by GRUB. Before using
|
||||||
|
# MKRESCUE_SED_UNPACK_EFI_TO_ISO, make a vanilla grub-mkrescue ISO
|
||||||
|
# with your payload, mount it and then its /efi.img file, then use
|
||||||
|
# program "find" on the mount point of efi.img to see all its files.
|
||||||
|
# Compare this with the output of "find" on the ISO mount point.
|
||||||
|
efi_unpack_to_iso=no
|
||||||
|
if test -n "$MKRESCUE_SED_UNPACK_EFI_TO_ISO"
|
||||||
|
then
|
||||||
|
efi_unpack_to_iso="$MKRESCUE_SED_UNPACK_EFI_TO_ISO"
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Do the work
|
# Do the work
|
||||||
@ -190,10 +208,11 @@ done
|
|||||||
if test x"$debug" = xextra
|
if test x"$debug" = xextra
|
||||||
then
|
then
|
||||||
# Show files on disk
|
# Show files on disk
|
||||||
find "$dir"
|
find "$dir" 2>&1
|
||||||
|
echo 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$efi_zero_inner_pt" = yes -o "$efi_zero_inner_pt" = extra
|
if test x"$efi_zero_inner_pt" = xyes -o x"$efi_zero_inner_pt" = xextra
|
||||||
then
|
then
|
||||||
did_dd=0
|
did_dd=0
|
||||||
if test -e "$dir"/efi.img
|
if test -e "$dir"/efi.img
|
||||||
@ -222,6 +241,41 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
efi_temp_tree=
|
||||||
|
if test x"$efi_unpack_to_iso" = xyes
|
||||||
|
then
|
||||||
|
if test -e "$dir"/efi.img
|
||||||
|
then
|
||||||
|
temp_tree=/tmp/grub-mkrescue-sed-et."$$"
|
||||||
|
# The mcopy command is the inverse of what grub-mkrescue does to pack it up
|
||||||
|
if mcopy -s -i "$dir"/efi.img ::/ "$temp_tree"
|
||||||
|
then
|
||||||
|
efi_temp_tree="$temp_tree"
|
||||||
|
if test x"$debug" = xyes -o x"$debug" = xextra
|
||||||
|
then
|
||||||
|
echo "Temporarily extracted $dir/efi.img to $temp_tree" >&2
|
||||||
|
echo >&2
|
||||||
|
if test x"$debug" = xextra
|
||||||
|
then
|
||||||
|
# Show extracted files
|
||||||
|
find "$temp_tree" >&2
|
||||||
|
echo >&2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif test -e "$temp_tree"
|
||||||
|
then
|
||||||
|
rm -r "$temp_tree"
|
||||||
|
fi
|
||||||
|
if test -z "$efi_temp_tree"
|
||||||
|
then
|
||||||
|
echo >&2
|
||||||
|
echo "$0 : NOTE : Could not extract efi.img to $temp_tree" >&2
|
||||||
|
echo "$0 : NOTE : Thus cannot obey MKRESCUE_SED_UNPACK_EFI_TO_ISO." >&2
|
||||||
|
echo >&2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
efi_tmp_name=
|
efi_tmp_name=
|
||||||
if test x"$mode" = xmjg \
|
if test x"$mode" = xmjg \
|
||||||
-o x"$mode" = xmbr_only \
|
-o x"$mode" = xmbr_only \
|
||||||
@ -229,10 +283,15 @@ if test x"$mode" = xmjg \
|
|||||||
-o x"$mode" = xmbr_hfs
|
-o x"$mode" = xmbr_hfs
|
||||||
then
|
then
|
||||||
# Move EFI partition image file out of the "$dir" tree, i.e. out of the ISO
|
# Move EFI partition image file out of the "$dir" tree, i.e. out of the ISO
|
||||||
efi_tmp_name=grub-mkrescue-sed-efi-img.$$
|
efi_tmp_name=grub-mkrescue-sed-ei.$$
|
||||||
if test -e "$dir"/efi.img
|
if test -e "$dir"/efi.img
|
||||||
then
|
then
|
||||||
mv "$dir"/efi.img /tmp/$efi_tmp_name
|
mv "$dir"/efi.img /tmp/$efi_tmp_name
|
||||||
|
if test x"$debug" = xyes -o x"$debug" = xextra
|
||||||
|
then
|
||||||
|
echo "Temporarily moved $dir/efi.img to /tmp/$efi_tmp_name" >&2
|
||||||
|
echo >&2
|
||||||
|
fi
|
||||||
elif test -e /tmp/$efi_tmp_name
|
elif test -e /tmp/$efi_tmp_name
|
||||||
then
|
then
|
||||||
rm /tmp/$efi_tmp_name
|
rm /tmp/$efi_tmp_name
|
||||||
@ -322,6 +381,27 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if echo "$efi_temp_tree" | grep '^/tmp/' >/dev/null
|
||||||
|
then
|
||||||
|
# Does the xorriso run end in native command mode ?
|
||||||
|
separator_seen=0
|
||||||
|
for i in "$@"
|
||||||
|
do
|
||||||
|
if test x"$i" = x--
|
||||||
|
then
|
||||||
|
separator_seen=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if test "$separator_seen" = 1
|
||||||
|
then
|
||||||
|
# Native mode possible: Enable it for sure and then use -map
|
||||||
|
x=" $x -- -map $efi_temp_tree /"
|
||||||
|
else
|
||||||
|
# Hopefully nobody finds a way to leave mkisofs emulation without "--" arg
|
||||||
|
x=" $x -graft-points /=$efi_temp_tree"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if test x"$debug" = xyes -o x"$debug" = xextra
|
if test x"$debug" = xyes -o x"$debug" = xextra
|
||||||
then
|
then
|
||||||
echo "+ converted xorriso arguments:" >&2
|
echo "+ converted xorriso arguments:" >&2
|
||||||
@ -349,5 +429,11 @@ then
|
|||||||
mv /tmp/$efi_tmp_name "$dir"/efi.img
|
mv /tmp/$efi_tmp_name "$dir"/efi.img
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Remove possible extracted EFI partition tree
|
||||||
|
if echo "$efi_temp_tree" | grep '^/tmp/' >/dev/null
|
||||||
|
then
|
||||||
|
rm -r "$efi_temp_tree"
|
||||||
|
fi
|
||||||
|
|
||||||
exit $ret
|
exit $ret
|
||||||
|
|
||||||
|
BIN
frontend/grub-mkrescue-sed.sh.sig
Normal file
BIN
frontend/grub-mkrescue-sed.sh.sig
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user