use uuids on efi

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-04-27 11:08:53 +02:00
parent 19ba92760a
commit 13ac43057b
2 changed files with 67 additions and 33 deletions

View file

@ -24,6 +24,7 @@
#include <grub/misc.h>
#include <grub/env.h>
#include <grub/mm.h>
#include <grub/kernel.h>
void
grub_efi_init (void)
@ -41,39 +42,58 @@ grub_efi_init (void)
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 *device;
char *file;
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);
file = grub_efi_get_filename (image->file_path);
if (device && file)
if (image && !path)
{
char *p;
char *prefix;
path = grub_efi_get_filename (image->file_path);
/* Get the directory. */
p = grub_strrchr (file, '/');
p = grub_strrchr (path, '/');
if (p)
*p = '\0';
}
prefix = grub_xasprintf ("(%s)%s", device, 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 (file);
}
grub_free (path);
}
void

View file

@ -150,14 +150,16 @@ else
esac
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
if test -e "${coreboot_dir}" ; then
echo "Enabling coreboot support ..."
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
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}"
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
@ -176,7 +178,6 @@ EOF
memdisk tar search iso9660 configfile sh \
ata at_keyboard
rm -f ${memdisk_img}
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
fi
# build BIOS core.img
@ -213,8 +214,21 @@ fi
# build bootx64.efi
if test -e "${efi64_dir}" ; then
echo "Enabling EFI64 support ..."
grub-mkimage -O x86_64-efi -d "${efi64_dir}" -o "${efi_dir}"/efi/boot/bootx64.efi --prefix=/boot/grub/x86_64-efi \
search iso9660 configfile sh
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