merge mainline into newreloc
This commit is contained in:
commit
c6fb51295b
35 changed files with 414 additions and 394 deletions
|
@ -79,103 +79,6 @@ xgetcwd (void)
|
|||
return path;
|
||||
}
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* Convert POSIX path to Win32 path,
|
||||
remove drive letter, replace backslashes. */
|
||||
static char *
|
||||
get_win32_path (const char *path)
|
||||
{
|
||||
char winpath[PATH_MAX];
|
||||
cygwin_conv_to_full_win32_path (path, winpath);
|
||||
|
||||
int len = strlen (winpath);
|
||||
if (len > 2 && winpath[1] == ':')
|
||||
{
|
||||
len -= 2;
|
||||
memmove (winpath, winpath + 2, len + 1);
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
if (winpath[i] == '\\')
|
||||
winpath[i] = '/';
|
||||
return xstrdup (winpath);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
grub_get_prefix (const char *dir)
|
||||
{
|
||||
char *saved_cwd;
|
||||
char *abs_dir, *prev_dir;
|
||||
char *prefix;
|
||||
struct stat st, prev_st;
|
||||
|
||||
/* Save the current directory. */
|
||||
saved_cwd = xgetcwd ();
|
||||
|
||||
if (chdir (dir) < 0)
|
||||
grub_util_error ("cannot change directory to `%s'", dir);
|
||||
|
||||
abs_dir = xgetcwd ();
|
||||
strip_extra_slashes (abs_dir);
|
||||
prev_dir = xstrdup (abs_dir);
|
||||
|
||||
if (stat (".", &prev_st) < 0)
|
||||
grub_util_error ("cannot stat `%s'", dir);
|
||||
|
||||
if (! S_ISDIR (prev_st.st_mode))
|
||||
grub_util_error ("`%s' is not a directory", dir);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (chdir ("..") < 0)
|
||||
grub_util_error ("cannot change directory to the parent");
|
||||
|
||||
if (stat (".", &st) < 0)
|
||||
grub_util_error ("cannot stat current directory");
|
||||
|
||||
if (! S_ISDIR (st.st_mode))
|
||||
grub_util_error ("current directory is not a directory???");
|
||||
|
||||
if (prev_st.st_dev != st.st_dev || prev_st.st_ino == st.st_ino)
|
||||
break;
|
||||
|
||||
free (prev_dir);
|
||||
prev_dir = xgetcwd ();
|
||||
prev_st = st;
|
||||
}
|
||||
|
||||
strip_extra_slashes (prev_dir);
|
||||
prefix = xmalloc (strlen (abs_dir) - strlen (prev_dir) + 2);
|
||||
prefix[0] = '/';
|
||||
strcpy (prefix + 1, abs_dir + strlen (prev_dir));
|
||||
strip_extra_slashes (prefix);
|
||||
|
||||
if (chdir (saved_cwd) < 0)
|
||||
grub_util_error ("cannot change directory to `%s'", dir);
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
||||
{
|
||||
/* Reached some mount point not below /cygdrive.
|
||||
GRUB does not know Cygwin's emulated mounts,
|
||||
convert to Win32 path. */
|
||||
grub_util_info ("Cygwin prefix = %s", prefix);
|
||||
char * wprefix = get_win32_path (prefix);
|
||||
free (prefix);
|
||||
prefix = wprefix;
|
||||
}
|
||||
#endif
|
||||
|
||||
free (saved_cwd);
|
||||
free (abs_dir);
|
||||
free (prev_dir);
|
||||
|
||||
grub_util_info ("prefix = %s", prefix);
|
||||
return prefix;
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
static char *
|
||||
|
|
|
@ -242,7 +242,7 @@ main (int argc, char *argv[])
|
|||
if (strcmp (root_dev, "host") == 0)
|
||||
dir = xstrdup (dir);
|
||||
else
|
||||
dir = grub_get_prefix (dir);
|
||||
dir = make_system_path_relative_to_its_root (dir);
|
||||
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
||||
sprintf (prefix, "(%s)%s", root_dev, dir);
|
||||
free (dir);
|
||||
|
|
|
@ -99,6 +99,28 @@ struct image_target_desc image_targets[] =
|
|||
.mod_gap = GRUB_KERNEL_I386_COREBOOT_MOD_GAP,
|
||||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-multiboot",
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
|
||||
.data_end = GRUB_KERNEL_I386_COREBOOT_DATA_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
|
||||
.elf_target = EM_386,
|
||||
.link_align = 4,
|
||||
.mod_gap = GRUB_KERNEL_I386_COREBOOT_MOD_GAP,
|
||||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-pc",
|
||||
.voidp_sizeof = 4,
|
||||
|
|
|
@ -30,7 +30,7 @@ target_cpu=@target_cpu@
|
|||
native_platform=@platform@
|
||||
pkglib_DATA="@pkglib_DATA@"
|
||||
|
||||
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
|
||||
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-multiboot
|
||||
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
|
||||
|
@ -124,8 +124,8 @@ process_input_dir ()
|
|||
}
|
||||
|
||||
if [ "${override_dir}" = "" ] ; then
|
||||
if test -e "${coreboot_dir}" ; then
|
||||
process_input_dir ${coreboot_dir} coreboot
|
||||
if test -e "${multiboot_dir}" ; then
|
||||
process_input_dir ${multiboot_dir} multiboot
|
||||
fi
|
||||
if test -e "${pc_dir}" ; then
|
||||
process_input_dir ${pc_dir} pc
|
||||
|
@ -138,12 +138,12 @@ if [ "${override_dir}" = "" ] ; then
|
|||
fi
|
||||
else
|
||||
process_input_dir ${override_dir} ${native_platform}
|
||||
coreboot_dir=
|
||||
multiboot_dir=
|
||||
pc_dir=
|
||||
efi32_dir=
|
||||
efi64_dir=
|
||||
case "${target_cpu}-${native_platform}" in
|
||||
i386-coreboot) coreboot_dir=${override_dir} ;;
|
||||
case "${native_platform}" in
|
||||
i386-multiboot) multiboot_dir=${override_dir} ;;
|
||||
i386-pc) pc_dir=${override_dir} ;;
|
||||
i386-efi) efi32_dir=${override_dir} ;;
|
||||
x86_64-efi) efi64_dir=${override_dir} ;;
|
||||
|
@ -154,28 +154,28 @@ fi
|
|||
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 ..."
|
||||
# build multiboot core.img
|
||||
if test -e "${multiboot_dir}" ; then
|
||||
echo "Enabling multiboot support ..."
|
||||
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||
mkdir -p ${memdisk_dir}/boot/grub
|
||||
|
||||
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
|
||||
modules="$(cat ${multiboot_dir}/partmap.lst) ${modules}"
|
||||
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
|
||||
search --fs-uuid --set ${iso_uuid}
|
||||
set prefix=(\${root})/boot/grub/${target_cpu}-coreboot
|
||||
set prefix=(\${root})/boot/grub/${target_cpu}-multiboot
|
||||
source \$prefix/grub.cfg
|
||||
EOF
|
||||
(for i in ${modules} ; do
|
||||
echo "insmod $i"
|
||||
done ; \
|
||||
echo "source /boot/grub/grub.cfg") \
|
||||
> ${iso9660_dir}/boot/grub/i386-coreboot/grub.cfg
|
||||
> ${iso9660_dir}/boot/grub/i386-multiboot/grub.cfg
|
||||
|
||||
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
|
||||
rm -rf ${memdisk_dir}
|
||||
grub-mkimage -O i386-coreboot -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
|
||||
grub-mkimage -O i386-multiboot -d ${multiboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
|
||||
memdisk tar search iso9660 configfile sh \
|
||||
ata at_keyboard
|
||||
rm -f ${memdisk_img}
|
||||
|
|
|
@ -634,7 +634,8 @@ main (int argc, char *argv[])
|
|||
|
||||
find_dest_dev (&ginfo, argv);
|
||||
|
||||
ginfo.prefix = grub_get_prefix (ginfo.dir ? : DEFAULT_DIRECTORY);
|
||||
ginfo.prefix = make_system_path_relative_to_its_root (ginfo.dir ?
|
||||
: DEFAULT_DIRECTORY);
|
||||
|
||||
check_root_dev (&ginfo);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue