Merge mainline into legacy_parser
This commit is contained in:
commit
bd9603071a
55 changed files with 2072 additions and 327 deletions
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Install GRUB on your drive.
|
||||
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -41,7 +41,8 @@ grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
|||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
||||
bootdir=
|
||||
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
|
||||
modules=
|
||||
|
||||
install_device=
|
||||
|
@ -69,8 +70,8 @@ Install GRUB on your drive.
|
|||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--modules=MODULES pre-load specified modules MODULES
|
||||
--root-directory=DIR install GRUB images under the directory DIR
|
||||
instead of the root directory
|
||||
--boot-directory=DIR install GRUB images under the directory DIR/@grubdirname@
|
||||
instead of the $grubdir directory
|
||||
--grub-setup=FILE use FILE as grub-setup
|
||||
--grub-mkimage=FILE use FILE as grub-mkimage
|
||||
--grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
|
||||
|
@ -88,11 +89,8 @@ fi
|
|||
|
||||
INSTALL_DEVICE can be a GRUB device name or a system device filename.
|
||||
|
||||
$self copies GRUB images into /boot/grub (or /grub on NetBSD and
|
||||
OpenBSD), and uses grub-setup to install grub into the boot sector.
|
||||
|
||||
If the --root-directory option is used, then $self will copy
|
||||
images into the operating system installation rooted at that directory.
|
||||
$self copies GRUB images into $grubdir, and uses grub-setup
|
||||
to install grub into the boot sector.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
|
@ -134,11 +132,17 @@ do
|
|||
--font=*)
|
||||
;;
|
||||
|
||||
# Accept for compatibility
|
||||
--root-directory)
|
||||
rootdir=`argument $option "$@"`; shift;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
|
||||
--boot-directory)
|
||||
bootdir=`argument $option "$@"`; shift;;
|
||||
--boot-directory=*)
|
||||
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
|
||||
|
||||
--grub-setup)
|
||||
grub_setup=`argument $option "$@"`; shift;;
|
||||
--grub-setup=*)
|
||||
|
@ -215,23 +219,18 @@ if test $debug = yes; then
|
|||
setup_verbose="--verbose"
|
||||
fi
|
||||
|
||||
# Initialize these directories here, since ROOTDIR was initialized.
|
||||
case "$host_os" in
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
grub_prefix=`echo /grub | sed ${transform}`
|
||||
bootdir=${rootdir}
|
||||
;;
|
||||
*)
|
||||
# Use /boot/grub by default.
|
||||
bootdir=${rootdir}/boot
|
||||
;;
|
||||
esac
|
||||
if [ -z "$bootdir" ]; then
|
||||
# Default bootdir if bootdir not initialized.
|
||||
bootdir=/@bootdirname@
|
||||
|
||||
grubdir=${bootdir}/`echo grub | sed ${transform}`
|
||||
if [ -n "$rootdir" ] ; then
|
||||
# Initialize bootdir if rootdir was initialized.
|
||||
bootdir=${rootdir}/@bootdirname@
|
||||
fi
|
||||
fi
|
||||
|
||||
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
||||
device_map=${grubdir}/device.map
|
||||
|
||||
grub_probe="${grub_probe} --device-map=${device_map}"
|
||||
|
||||
# Check if GRUB is installed.
|
||||
|
@ -328,8 +327,7 @@ if test "x$fs_module" = x -a "x$modules" = x; then
|
|||
fi
|
||||
|
||||
# Then the partition map module. In order to support partition-less media,
|
||||
# this command is allowed to fail (--target=fs already grants us that the
|
||||
# filesystem will be accessible).
|
||||
# this command is allowed to fail.
|
||||
partmap_module=
|
||||
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
|
||||
partmap_module="$partmap_module part_$x";
|
||||
|
@ -369,6 +367,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
|
||||
|
||||
# Strip partition number
|
||||
grub_partition="`echo ${grub_drive} | sed -e 's/^[^,]*,//; s/)$//'`"
|
||||
grub_drive="`echo ${grub_drive} | sed -e s/,[a-z0-9,]*//g`"
|
||||
if [ "$disk_module" = ata ] ; then
|
||||
# generic method (used on coreboot and ata mod)
|
||||
|
@ -391,6 +390,9 @@ 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 ] || [ "x$platform" = xpc ]; then
|
||||
# we need to hardcode the partition number in the core image's prefix.
|
||||
prefix_drive="(,$grub_partition)"
|
||||
fi
|
||||
else
|
||||
prefix_drive=`$grub_probe --target=drive --device ${grub_device}` || exit 1
|
||||
|
@ -403,9 +405,24 @@ case "${target_cpu}-${platform}" in
|
|||
*) mkimage_target=i386-coreboot;
|
||||
esac
|
||||
|
||||
# Verify readability of a few critical files
|
||||
for file in grubenv normal.mod ; 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
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
||||
$grub_mkimage ${config_opt} -O ${mkimage_target} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
|
||||
|
||||
# This is a temporary workaround; it can be merged back into the check
|
||||
# above once the install branch is merged.
|
||||
if is_path_readable_by_grub ${grubdir}/core.img ${grub_device} ${relative_grubdir}/core.img ; then : ; else
|
||||
echo "GRUB is unable to read ${grubdir}/core.img" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now perform the installation.
|
||||
$grub_setup ${setup_verbose} ${setup_force} --directory=${grubdir} --device-map=${device_map} \
|
||||
${install_device} || exit 1
|
||||
|
|
|
@ -38,6 +38,8 @@ self=`basename $0`
|
|||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
|
||||
GRUB_PREFIX=`echo '/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
|
@ -93,18 +95,6 @@ done
|
|||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
case "$host_os" in
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
GRUB_PREFIX=`echo /grub | sed ${transform}`
|
||||
;;
|
||||
*)
|
||||
# Use /boot/grub by default.
|
||||
GRUB_PREFIX=`echo /boot/grub | sed ${transform}`
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "x$EUID" = "x" ] ; then
|
||||
EUID=`id -u`
|
||||
fi
|
||||
|
@ -158,7 +148,7 @@ GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_u
|
|||
|
||||
# Filesystem for the device containing our userland. Used for stuff like
|
||||
# choosing Hurd filesystem module.
|
||||
GRUB_FS="`${grub_probe} --target=fs / 2> /dev/null || echo unknown`"
|
||||
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
|
||||
|
||||
if test -f ${sysconfdir}/default/grub ; then
|
||||
. ${sysconfdir}/default/grub
|
||||
|
@ -200,7 +190,7 @@ for x in ${GRUB_TERMINAL_OUTPUT}; do
|
|||
exit 1
|
||||
fi
|
||||
else
|
||||
for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do
|
||||
for dir in ${pkgdatadir} ${GRUB_PREFIX} /usr/share/grub ; do
|
||||
for basename in unicode unifont ascii; do
|
||||
path="${dir}/${basename}.pf2"
|
||||
if is_path_readable_by_grub ${path} > /dev/null ; then
|
||||
|
@ -313,6 +303,14 @@ for i in ${grub_mkconfig_dir}/* ; do
|
|||
esac
|
||||
done
|
||||
|
||||
# Verify readability of ${grub_cfg}.new
|
||||
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
|
||||
# none of the children aborted with error, install the new grub.cfg
|
||||
mv -f ${grub_cfg}.new ${grub_cfg}
|
||||
|
|
|
@ -30,6 +30,9 @@ fi
|
|||
if test "x$grub_mkrelpath" = x; then
|
||||
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
|
||||
fi
|
||||
if test "x$grub_fstest" = x; then
|
||||
grub_fstest=${bindir}/`echo grub-fstest | sed ${transform}`
|
||||
fi
|
||||
|
||||
if $(which gettext >/dev/null 2>/dev/null) ; then
|
||||
gettext="gettext"
|
||||
|
@ -50,14 +53,24 @@ make_system_path_relative_to_its_root ()
|
|||
is_path_readable_by_grub ()
|
||||
{
|
||||
path=$1
|
||||
device=$2
|
||||
relpath=$3
|
||||
|
||||
# abort if path doesn't exist
|
||||
if test -e $path ; then : ;else
|
||||
return 1
|
||||
fi
|
||||
|
||||
# abort if file is in a filesystem we can't read
|
||||
if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
|
||||
if [ "${device}" = "" ] ; then
|
||||
device=$(${grub_probe} --target=device $path)
|
||||
fi
|
||||
if [ "${relpath}" = "" ] ; then
|
||||
relpath=$(${grub_mkrelpath} $path)
|
||||
fi
|
||||
|
||||
# abort if file read through GRUB doesn't match file read through system
|
||||
# facilities
|
||||
if ${grub_fstest} $device cmp $relpath $path > /dev/null 2>&1 ; then : ; else
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -226,49 +226,16 @@ probe (const char *path, char *device_name)
|
|||
|
||||
if (print == PRINT_FS)
|
||||
{
|
||||
if (path)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
stat (path, &st);
|
||||
|
||||
if (S_ISREG (st.st_mode))
|
||||
{
|
||||
/* Regular file. Verify that we can read it properly. */
|
||||
|
||||
grub_file_t file;
|
||||
char *rel_path;
|
||||
grub_util_info ("reading %s via OS facilities", path);
|
||||
filebuf_via_sys = grub_util_read_image (path);
|
||||
|
||||
rel_path = grub_make_system_path_relative_to_its_root (path);
|
||||
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
|
||||
free (rel_path);
|
||||
grub_util_info ("reading %s via GRUB facilities", grub_path);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (grub_path);
|
||||
if (! file)
|
||||
grub_util_error ("cannot open %s via GRUB facilities", grub_path);
|
||||
filebuf_via_grub = xmalloc (file->size);
|
||||
grub_file_read (file, filebuf_via_grub, file->size);
|
||||
|
||||
grub_util_info ("comparing");
|
||||
|
||||
if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
|
||||
grub_util_error ("files differ");
|
||||
}
|
||||
}
|
||||
|
||||
printf ("%s\n", fs->name);
|
||||
}
|
||||
|
||||
if (print == PRINT_FS_UUID)
|
||||
else if (print == PRINT_FS_UUID)
|
||||
{
|
||||
char *uuid;
|
||||
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);
|
||||
}
|
||||
|
@ -278,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);
|
||||
}
|
||||
|
@ -422,6 +390,13 @@ main (int argc, char *argv[])
|
|||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
|
||||
grub_lvm_fini ();
|
||||
grub_mdraid_fini ();
|
||||
grub_raid_fini ();
|
||||
grub_raid_init ();
|
||||
grub_mdraid_init ();
|
||||
grub_lvm_init ();
|
||||
|
||||
/* Do it. */
|
||||
if (argument_is_device)
|
||||
probe (NULL, argument);
|
||||
|
|
|
@ -29,6 +29,8 @@ self=`basename $0`
|
|||
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
bootdir=
|
||||
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
|
@ -39,8 +41,8 @@ Set the default boot entry for GRUB, for the next boot only.
|
|||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--root-directory=DIR expect GRUB images under the directory DIR
|
||||
instead of the root directory
|
||||
--boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
|
||||
instead of the $grubdir directory
|
||||
|
||||
ENTRY is a number or a menu item title.
|
||||
|
||||
|
@ -73,11 +75,17 @@ do
|
|||
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
|
||||
exit 0 ;;
|
||||
|
||||
# Accept for compatibility
|
||||
--root-directory)
|
||||
rootdir=`argument $option "$@"`; shift ;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
|
||||
--boot-directory)
|
||||
bootdir=`argument $option "$@"`; shift;;
|
||||
--boot-directory=*)
|
||||
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
|
||||
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
|
@ -99,21 +107,17 @@ if test "x$entry" = x; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize these directories here, since ROOTDIR was initialized.
|
||||
case "$host_os" in
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
grub_prefix=`echo /grub | sed ${transform}`
|
||||
bootdir=${rootdir}
|
||||
;;
|
||||
*)
|
||||
# Use /boot/grub by default.
|
||||
bootdir=${rootdir}/boot
|
||||
;;
|
||||
esac
|
||||
if [ -z "$bootdir" ]; then
|
||||
# Default bootdir if bootdir not initialized.
|
||||
bootdir=/@bootdirname@
|
||||
|
||||
grubdir=${bootdir}/`echo grub | sed ${transform}`
|
||||
if [ -n "$rootdir" ] ; then
|
||||
# Initialize bootdir if rootdir was initialized.
|
||||
bootdir=${rootdir}/@bootdirname@
|
||||
fi
|
||||
fi
|
||||
|
||||
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
||||
|
||||
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
|
||||
if [ "$prev_saved_entry" ]; then
|
||||
|
|
|
@ -29,6 +29,8 @@ self=`basename $0`
|
|||
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
bootdir=
|
||||
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
|
@ -39,8 +41,8 @@ Set the default boot entry for GRUB.
|
|||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--root-directory=DIR expect GRUB images under the directory DIR
|
||||
instead of the root directory
|
||||
--boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
|
||||
instead of the $grubdir directory
|
||||
|
||||
ENTRY is a number or a menu item title.
|
||||
|
||||
|
@ -73,11 +75,17 @@ do
|
|||
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
|
||||
exit 0 ;;
|
||||
|
||||
# Accept for compatibility
|
||||
--root-directory)
|
||||
rootdir=`argument $option "$@"`; shift ;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
|
||||
--boot-directory)
|
||||
bootdir=`argument $option "$@"`; shift;;
|
||||
--boot-directory=*)
|
||||
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
|
||||
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
|
@ -99,21 +107,17 @@ if test "x$entry" = x; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize these directories here, since ROOTDIR was initialized.
|
||||
case "$host_os" in
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
grub_prefix=`echo /grub | sed ${transform}`
|
||||
bootdir=${rootdir}
|
||||
;;
|
||||
*)
|
||||
# Use /boot/grub by default.
|
||||
bootdir=${rootdir}/boot
|
||||
;;
|
||||
esac
|
||||
if [ -z "$bootdir" ]; then
|
||||
# Default bootdir if bootdir not initialized.
|
||||
bootdir=/@bootdirname@
|
||||
|
||||
grubdir=${bootdir}/`echo grub | sed ${transform}`
|
||||
if [ -n "$rootdir" ] ; then
|
||||
# Initialize bootdir if rootdir was initialized.
|
||||
bootdir=${rootdir}/@bootdirname@
|
||||
fi
|
||||
fi
|
||||
|
||||
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
||||
|
||||
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
||||
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -40,7 +40,7 @@ fi
|
|||
|
||||
osx_entry() {
|
||||
cat << EOF
|
||||
menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" {
|
||||
menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" --class osx --class darwin --class os {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
|
@ -105,7 +105,7 @@ for OS in ${OSPROBED} ; do
|
|||
chain)
|
||||
|
||||
cat << EOF
|
||||
menuentry "${LONGNAME} (on ${DEVICE})" {
|
||||
menuentry "${LONGNAME} (on ${DEVICE})" --class windows --class os {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
|
@ -147,7 +147,7 @@ EOF
|
|||
fi
|
||||
|
||||
cat << EOF
|
||||
menuentry "${LLABEL} (on ${DEVICE})" {
|
||||
menuentry "${LLABEL} (on ${DEVICE})" --class gnu-linux --class gnu --class os {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
|
@ -174,7 +174,7 @@ EOF
|
|||
;;
|
||||
hurd)
|
||||
cat << EOF
|
||||
menuentry "${LONGNAME} (on ${DEVICE})" {
|
||||
menuentry "${LONGNAME} (on ${DEVICE})" --class hurd --class gnu --class os {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
|
|
|
@ -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);
|
||||
|
@ -751,6 +732,13 @@ main (int argc, char *argv[])
|
|||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
|
||||
grub_lvm_fini ();
|
||||
grub_mdraid_fini ();
|
||||
grub_raid_fini ();
|
||||
grub_raid_init ();
|
||||
grub_mdraid_init ();
|
||||
grub_lvm_init ();
|
||||
|
||||
dest_dev = get_device_name (argv[optind]);
|
||||
if (! dest_dev)
|
||||
{
|
||||
|
|
|
@ -614,6 +614,13 @@ main (int argc, char *argv[])
|
|||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
|
||||
grub_lvm_fini ();
|
||||
grub_mdraid_fini ();
|
||||
grub_raid_fini ();
|
||||
grub_raid_init ();
|
||||
grub_mdraid_init ();
|
||||
grub_lvm_init ();
|
||||
|
||||
find_dest_dev (&ginfo, argv);
|
||||
|
||||
ginfo.prefix = grub_make_system_path_relative_to_its_root (ginfo.dir ?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue