merge rescue-efi into boottest

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-04-27 11:15:23 +02:00
commit 55620b982d
3 changed files with 111 additions and 35 deletions

View file

@ -6,6 +6,9 @@ sbin_SCRIPTS = grub-install
# For grub-install. # For grub-install.
grub_install_SOURCES = util/i386/efi/grub-install.in grub_install_SOURCES = util/i386/efi/grub-install.in
bin_SCRIPTS += grub-mkrescue
grub_mkrescue_SOURCES = util/grub-mkrescue.in
# Modules. # Modules.
pkglib_PROGRAMS = kernel.img pkglib_PROGRAMS = kernel.img
pkglib_MODULES = chain.mod appleldr.mod \ pkglib_MODULES = chain.mod appleldr.mod \

View file

@ -24,6 +24,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/env.h> #include <grub/env.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/kernel.h>
void void
grub_efi_init (void) grub_efi_init (void)
@ -41,39 +42,58 @@ grub_efi_init (void)
void void
grub_efi_set_prefix (void) grub_efi_set_prefix (void)
{ {
grub_efi_loaded_image_t *image; grub_efi_loaded_image_t *image = NULL;
char *device = NULL;
char *path = NULL;
image = grub_efi_get_loaded_image (grub_efi_image_handle); {
if (image) char *pptr = NULL;
if (grub_prefix[0] == '(')
{
pptr = grub_strrchr (grub_prefix, ')');
if (pptr)
{
device = grub_strndup (grub_prefix + 1, pptr - grub_prefix - 1);
pptr++;
}
}
if (!pptr)
pptr = grub_prefix;
if (pptr[0])
path = grub_strdup (pptr);
}
if (!device || !path)
image = grub_efi_get_loaded_image (grub_efi_image_handle);
if (image && !device)
device = grub_efidisk_get_device_name (image->device_handle);
if (image && !path)
{ {
char *device; char *p;
char *file;
device = grub_efidisk_get_device_name (image->device_handle); path = grub_efi_get_filename (image->file_path);
file = grub_efi_get_filename (image->file_path);
if (device && file) /* Get the directory. */
{ p = grub_strrchr (path, '/');
char *p; if (p)
char *prefix; *p = '\0';
/* Get the directory. */
p = grub_strrchr (file, '/');
if (p)
*p = '\0';
prefix = grub_xasprintf ("(%s)%s", device, file);
if (prefix)
{
grub_env_set ("prefix", prefix);
grub_free (prefix);
}
}
grub_free (device);
grub_free (file);
} }
if (device && path)
{
char *prefix;
prefix = grub_xasprintf ("(%s)%s", device, path);
if (prefix)
{
grub_env_set ("prefix", prefix);
grub_free (prefix);
}
}
grub_free (device);
grub_free (path);
} }
void void

View file

@ -32,6 +32,8 @@ pkglib_DATA="@pkglib_DATA@"
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
@ -128,24 +130,36 @@ if [ "${override_dir}" = "" ] ; then
if test -e "${pc_dir}" ; then if test -e "${pc_dir}" ; then
process_input_dir ${pc_dir} pc process_input_dir ${pc_dir} pc
fi fi
if test -e "${efi32_dir}" ; then
process_input_dir ${efi32_dir} efi32
fi
if test -e "${efi64_dir}" ; then
process_input_dir ${efi64_dir} efi64
fi
else else
process_input_dir ${override_dir} ${native_platform} process_input_dir ${override_dir} ${native_platform}
coreboot_dir= coreboot_dir=
pc_dir= pc_dir=
case "${native_platform}" in efi32_dir=
coreboot) coreboot_dir=${override_dir} ;; efi64_dir=
pc) pc_dir=${override_dir} ;; case "${target_cpu}-${native_platform}" in
i386-coreboot) coreboot_dir=${override_dir} ;;
i386-pc) pc_dir=${override_dir} ;;
i386-efi) efi32_dir=${override_dir} ;;
x86_64-efi) efi64_dir=${override_dir} ;;
esac esac
fi fi
# obtain date-based UUID
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
# build coreboot core.img # build coreboot core.img
if test -e "${coreboot_dir}" ; then if test -e "${coreboot_dir}" ; then
echo "Enabling coreboot support ..." echo "Enabling coreboot support ..."
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"` memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"` memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p ${memdisk_dir}/boot/grub mkdir -p ${memdisk_dir}/boot/grub
# obtain date-based UUID
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}" modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
@ -164,7 +178,6 @@ EOF
memdisk tar search iso9660 configfile sh \ memdisk tar search iso9660 configfile sh \
ata at_keyboard ata at_keyboard
rm -f ${memdisk_img} rm -f ${memdisk_img}
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
fi fi
# build BIOS core.img # build BIOS core.img
@ -191,8 +204,48 @@ if test -e "${pc_dir}" ; then
--embedded-boot ${embed_img}" --embedded-boot ${embed_img}"
fi fi
if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
efi_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p "${efi_dir}/efi/boot"
else
efi_dir=
fi
# build bootx64.efi
if test -e "${efi64_dir}" ; then
echo "Enabling EFI64 support ..."
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p ${memdisk_dir}/boot/grub
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
search --fs-uuid --set ${iso_uuid}
set prefix=(\${root})/boot/grub/${target_cpu}-efi
EOF
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir}
grub-mkimage -O x86_64-efi -d "${efi64_dir}" -m "${memdisk_img}" -o "${efi_dir}"/efi/boot/bootx64.efi --prefix='(memdisk)/boot/grub' \
search iso9660 configfile sh memdisk tar
rm -f ${memdisk_img}
modules="$(cat "${efi64_dir}"/partmap.lst) ${modules}"
(for i in ${modules} ; do
echo "insmod $i"
done ; \
echo "source /boot/grub/grub.cfg") \
> "${iso9660_dir}"/boot/grub/x86_64-efi/grub.cfg
fi
if test x"${efi_dir}" != x; then
mformat -C -f 2880 -L 16 -i "${iso9660_dir}"/efi.img ::
mcopy -s -i "${iso9660_dir}"/efi.img ${efi_dir}/efi ::/
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img"
fi
# build iso image # build iso image
grub-mkisofs ${grub_mkisofs_arguments} --protective-msdos-label -o ${output_image} -r ${iso9660_dir} ${source} xorrisofs ${grub_mkisofs_arguments} --protective-msdos-label -o ${output_image} -r ${iso9660_dir} ${source}
rm -rf ${iso9660_dir} rm -rf ${iso9660_dir}
rm -f ${embed_img} rm -f ${embed_img}