Merge mainline into install

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-11 17:28:46 +02:00
commit 76e61597b4
25 changed files with 728 additions and 57 deletions

View file

@ -527,9 +527,8 @@ if [ "x${devabstraction_module}" = "x" ] ; then
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"
elif [ "x$platform" = xefi ]; then
# No grub-setup, so we need to hardcode the partition number in the
# core image's prefix.
elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then
# we need to hardcode the partition number in the core image's prefix.
prefix_drive="(,$grub_partition)"
fi
else
@ -562,7 +561,7 @@ elif [ "${target_cpu}-${platform}" = "i386-efi" ] || [ "${target_cpu}-${platform
fi
# Verify readability of a few critical files
for file in grubenv core.${imgext} normal.mod ; do
for file in grubenv normal.mod core.${imgext} ; do
if is_path_readable_by_grub ${grubdir}/${file} ${grub_device} ${relative_grubdir}/${file} ; then : ; else
echo "GRUB is unable to read ${grubdir}/${file}" >&2
exit 1

View file

@ -304,9 +304,11 @@ for i in ${grub_mkconfig_dir}/* ; do
done
# Verify readability of ${grub_cfg}.new
if is_path_readable_by_grub ${grub_cfg}.new ; then : ; else
echo "GRUB is unable to read ${grubdir}/${file}" >&2
exit 1
if test "x${grub_cfg}" != "x"; then
if is_path_readable_by_grub ${grub_cfg}.new ; then : ; else
echo "GRUB is unable to read ${grubdir}/${file}" >&2
exit 1
fi
fi
if test "x${grub_cfg}" != "x" ; then

View file

@ -234,7 +234,8 @@ probe (const char *path, char *device_name)
if (! fs->uuid)
grub_util_error ("%s does not support UUIDs", fs->name);
fs->uuid (dev, &uuid);
if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
printf ("%s\n", uuid);
}
@ -244,7 +245,8 @@ probe (const char *path, char *device_name)
if (! fs->label)
grub_util_error ("%s does not support labels", fs->name);
fs->label (dev, &label);
if (fs->label (dev, &label) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
printf ("%s\n", label);
}

View file

@ -41,6 +41,14 @@ for i in /boot/gnumach* ; do
basename=`basename $i`
dirname=`dirname $i`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
if ! is_path_readable_by_grub ${dirname}/${basename} \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/${basename} ; then
echo "${dirname}/${basename} is not readable by GRUB" >&2
exit 1
fi
echo "Found GNU Mach: $i" >&2
kernels="${kernels} ${rel_dirname}/${basename}"
at_least_one=true

View file

@ -44,7 +44,7 @@ load_kfreebsd_module ()
mod="$1"
allow_fail="$2"
if ! test -e "${module_dir}/${mod}.ko" ; then
if ! is_path_readable_by_grub "${module_dir}/${mod}.ko" ; then
if [ "${allow_fail}" = "true" ] ; then
# Return silently
return
@ -77,6 +77,13 @@ kfreebsd_entry ()
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
if ! is_path_readable_by_grub ${dirname}/${basename} \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/${basename} ; then
echo "${dirname}/${basename} is not readable by GRUB" >&2
exit 1
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
@ -95,7 +102,13 @@ EOF
zfs)
load_kfreebsd_module opensolaris false
ls "${dirname}/zfs/zpool.cache" > /dev/null
if ! is_path_readable_by_grub ${dirname}/zfs/zpool.cache \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/zfs/zpool.cache ; then
echo "${dirname}/zfs/zpool.cache is not readable by GRUB" >&2
exit 1
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
kfreebsd_module ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache
@ -138,7 +151,12 @@ while [ "x$list" != "x" ] ; do
esac
case ${GRUB_FS} in
zfs) kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE}) ;;
zfs)
# zpool name
kfreebsd_device=$(grub-probe -t fs_label --device ${GRUB_DEVICE})
# filesystem name (empty string for the main filesystem)
kfreebsd_device="${kfreebsd_device}$(grub-mkrelpath / | sed -e "s,/*@$,,")"
;;
*) kfreebsd_device=${GRUB_DEVICE} ;;
esac

View file

@ -83,6 +83,15 @@ EOF
EOF
fi
for i in ${basename} ${initrd} ; do
if ! is_path_readable_by_grub ${dirname}/${i} \
${GRUB_DEVICE_BOOT} \
${rel_dirname}/${i} ; then
echo "${dirname}/${i} is not readable by GRUB" >&2
exit 1
fi
done
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi

View file

@ -81,8 +81,6 @@ setup (const char *dir,
struct grub_boot_blocklist *first_block, *block;
grub_int32_t *install_dos_part, *install_bsd_part;
grub_int32_t dos_part, bsd_part;
char *install_prefix;
char *prefix = NULL;
char *tmp_img;
int i;
grub_disk_addr_t first_sector;
@ -214,8 +212,6 @@ setup (const char *dir,
+ GRUB_KERNEL_MACHINE_INSTALL_DOS_PART);
install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_MACHINE_INSTALL_BSD_PART);
install_prefix = (char *) (core_img + GRUB_DISK_SECTOR_SIZE +
GRUB_KERNEL_MACHINE_PREFIX);
/* Open the root device and the destination device. */
root_dev = grub_device_open (root);
@ -291,16 +287,6 @@ setup (const char *dir,
dos_part = root_dev->disk->partition->number;
bsd_part = -1;
}
if (install_prefix[0] != '(')
{
char *root_part_name;
root_part_name =
grub_partition_get_name (root_dev->disk->partition);
prefix = xasprintf ("(,%s)%s", root_part_name, install_prefix);
free (root_part_name);
}
}
else
dos_part = bsd_part = -1;
@ -389,8 +375,6 @@ setup (const char *dir,
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* The first blocklist contains the whole sectors. */
first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
@ -553,8 +537,6 @@ unable_to_embed:
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* Write the first two sectors of the core image onto the disk. */
grub_util_info ("opening the core image `%s'", core_path);
@ -574,7 +556,6 @@ unable_to_embed:
/* Sync is a Good Thing. */
sync ();
free (prefix);
free (core_path);
free (core_img);
free (boot_img);