Merge mainline into yeeloongfw

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-06-30 02:30:05 +02:00
commit b7e79e8a6a
155 changed files with 5949 additions and 2562 deletions

View file

@ -28,11 +28,13 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <dirent.h>
#include <grub/util/misc.h>
#include <grub/util/deviceiter.h>
#include <grub/list.h>
#include <grub/misc.h>
#include <grub/emu/misc.h>
#ifdef __linux__
# if !defined(__GLIBC__) || \
@ -344,18 +346,37 @@ get_xvd_disk_name (char *name, int unit)
}
#endif
/* Check if DEVICE can be read. If an error occurs, return zero,
otherwise return non-zero. */
static int
check_device (const char *device)
static struct seen_device
{
struct seen_device *next;
const char *name;
} *seen;
/* Check if DEVICE can be read. Skip any DEVICE that we have already seen.
If an error occurs, return zero, otherwise return non-zero. */
static int
check_device_readable_unique (const char *device)
{
char *real_device;
char buf[512];
FILE *fp;
struct seen_device *seen_elt;
/* If DEVICE is empty, just return error. */
if (*device == 0)
return 0;
/* Have we seen this device already? */
real_device = canonicalize_file_name (device);
if (! real_device)
return 0;
if (grub_named_list_find (GRUB_AS_NAMED_LIST (seen), real_device))
{
grub_dprintf ("deviceiter", "Already seen %s (%s)\n",
device, real_device);
goto fail;
}
fp = fopen (device, "r");
if (! fp)
{
@ -378,7 +399,7 @@ check_device (const char *device)
break;
}
/* Error opening the device. */
return 0;
goto fail;
}
/* Make sure CD-ROMs don't get assigned a BIOS disk number
@ -386,7 +407,7 @@ check_device (const char *device)
#ifdef __linux__
# ifdef CDROM_GET_CAPABILITY
if (ioctl (fileno (fp), CDROM_GET_CAPABILITY, 0) >= 0)
return 0;
goto fail;
# else /* ! CDROM_GET_CAPABILITY */
/* Check if DEVICE is a CD-ROM drive by the HDIO_GETGEO ioctl. */
{
@ -394,14 +415,14 @@ check_device (const char *device)
struct stat st;
if (fstat (fileno (fp), &st))
return 0;
goto fail;
/* If it is a block device and isn't a floppy, check if HDIO_GETGEO
succeeds. */
if (S_ISBLK (st.st_mode)
&& MAJOR (st.st_rdev) != FLOPPY_MAJOR
&& ioctl (fileno (fp), HDIO_GETGEO, &hdg))
return 0;
goto fail;
}
# endif /* ! CDROM_GET_CAPABILITY */
#endif /* __linux__ */
@ -409,7 +430,7 @@ check_device (const char *device)
#if defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
# ifdef CDIOCCLRDEBUG
if (ioctl (fileno (fp), CDIOCCLRDEBUG, 0) >= 0)
return 0;
goto fail;
# endif /* CDIOCCLRDEBUG */
#endif /* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ */
@ -417,21 +438,43 @@ check_device (const char *device)
if (fread (buf, 1, 512, fp) != 512)
{
fclose (fp);
return 0;
goto fail;
}
/* Remember that we've seen this device. */
seen_elt = xmalloc (sizeof (*seen_elt));
seen_elt->name = real_device; /* steal memory */
grub_list_push (GRUB_AS_LIST_P (&seen), GRUB_AS_LIST (seen_elt));
fclose (fp);
return 1;
fail:
free (real_device);
return 0;
}
static void
clear_seen_devices (void)
{
while (seen)
{
struct seen_device *seen_elt = seen;
seen = seen->next;
free (seen_elt);
}
seen = NULL;
}
#ifdef __linux__
# ifdef HAVE_DEVICE_MAPPER
struct dmraid_seen
/* Like strcmp, but doesn't require a cast for use as a qsort comparator. */
static int
compare_file_names (const void *a, const void *b)
{
struct dmraid_seen *next;
const char *name;
};
# endif /* HAVE_DEVICE_MAPPER */
const char *left = *(const char **) a;
const char *right = *(const char **) b;
return strcmp (left, right);
}
#endif /* __linux__ */
void
@ -440,6 +483,8 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
{
int i;
clear_seen_devices ();
/* Floppies. */
for (i = 0; i < floppy_disks; i++)
{
@ -449,13 +494,63 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
get_floppy_disk_name (name, i);
if (stat (name, &st) < 0)
break;
/* In floppies, write the map, whether check_device succeeds
or not, because the user just may not insert floppies. */
/* In floppies, write the map, whether check_device_readable_unique
succeeds or not, because the user just may not insert floppies. */
if (hook (name, 1))
return;
goto out;
}
#ifdef __linux__
{
DIR *dir = opendir ("/dev/disk/by-id");
if (dir)
{
struct dirent *entry;
char **names;
size_t names_len = 0, names_max = 1024, i;
names = xmalloc (names_max * sizeof (*names));
/* Dump all the directory entries into names, resizing if
necessary. */
for (entry = readdir (dir); entry; entry = readdir (dir))
{
/* Skip partition entries. */
if (strstr (entry->d_name, "-part"))
continue;
if (names_len >= names_max)
{
names_max *= 2;
names = xrealloc (names, names_max * sizeof (*names));
}
names[names_len++] = xasprintf (entry->d_name);
}
/* /dev/disk/by-id/ usually has a few alternative identifications of
devices (e.g. ATA vs. SATA). check_device_readable_unique will
ensure that we only get one for any given disk, but sort the list
so that the choice of which one we get is stable. */
qsort (names, names_len, sizeof (*names), &compare_file_names);
closedir (dir);
/* Now add all the devices in sorted order. */
for (i = 0; i < names_len; ++i)
{
char *path = xasprintf ("/dev/disk/by-id/%s", names[i]);
if (check_device_readable_unique (path))
{
if (hook (path, 0))
goto out;
}
free (path);
free (names[i]);
}
free (names);
}
}
if (have_devfs ())
{
i = 0;
@ -475,10 +570,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
{
strcat (name, "/disc");
if (hook (name, 0))
return;
goto out;
}
}
return;
goto out;
}
#endif /* __linux__ */
@ -488,10 +583,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[16];
get_ide_disk_name (name, i);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
@ -502,10 +597,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[16];
get_virtio_disk_name (name, i);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
@ -515,10 +610,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[20];
get_ataraid_disk_name (name, i);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
@ -528,10 +623,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[16];
get_xvd_disk_name (name, i);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
#endif /* __linux__ */
@ -542,10 +637,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[16];
get_scsi_disk_name (name, i);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
@ -565,10 +660,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[24];
get_dac960_disk_name (name, controller, drive);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
}
@ -586,10 +681,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[24];
get_acceleraid_disk_name (name, controller, drive);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
}
@ -607,10 +702,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[24];
get_cciss_disk_name (name, controller, drive);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
}
@ -628,10 +723,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[24];
get_ida_disk_name (name, controller, drive);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
}
@ -646,10 +741,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[24];
get_i2o_disk_name (name, unit);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
}
@ -660,10 +755,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
char name[16];
get_mmc_disk_name (name, i);
if (check_device (name))
if (check_device_readable_unique (name))
{
if (hook (name, 0))
return;
goto out;
}
}
@ -676,113 +771,91 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
}
/* DM-RAID. */
{
struct dm_tree *tree = NULL;
struct dm_task *task = NULL;
struct dm_names *names = NULL;
unsigned int next = 0;
void *top_handle, *second_handle;
struct dm_tree_node *root, *top, *second;
struct dmraid_seen *seen = NULL;
if (grub_device_mapper_supported ())
{
struct dm_tree *tree = NULL;
struct dm_task *task = NULL;
struct dm_names *names = NULL;
unsigned int next = 0;
void *top_handle, *second_handle;
struct dm_tree_node *root, *top, *second;
/* Build DM tree for all devices. */
tree = dm_tree_create ();
dmraid_check (tree, "dm_tree_create failed\n");
task = dm_task_create (DM_DEVICE_LIST);
dmraid_check (task, "dm_task_create failed\n");
dmraid_check (dm_task_run (task), "dm_task_run failed\n");
names = dm_task_get_names (task);
dmraid_check (names, "dm_task_get_names failed\n");
dmraid_check (names->dev, "No DM devices found\n");
do
{
names = (void *) names + next;
dmraid_check (dm_tree_add_dev (tree, MAJOR (names->dev),
MINOR (names->dev)),
"dm_tree_add_dev (%s) failed\n", names->name);
next = names->next;
}
while (next);
/* Build DM tree for all devices. */
tree = dm_tree_create ();
dmraid_check (tree, "dm_tree_create failed\n");
task = dm_task_create (DM_DEVICE_LIST);
dmraid_check (task, "dm_task_create failed\n");
dmraid_check (dm_task_run (task), "dm_task_run failed\n");
names = dm_task_get_names (task);
dmraid_check (names, "dm_task_get_names failed\n");
dmraid_check (names->dev, "No DM devices found\n");
do
{
names = (void *) names + next;
dmraid_check (dm_tree_add_dev (tree, MAJOR (names->dev),
MINOR (names->dev)),
"dm_tree_add_dev (%s) failed\n", names->name);
next = names->next;
}
while (next);
/* Walk the second-level children of the inverted tree; that is, devices
which are directly composed of non-DM devices such as hard disks.
This class includes all DM-RAID disks and excludes all DM-RAID
partitions. */
root = dm_tree_find_node (tree, 0, 0);
top_handle = NULL;
top = dm_tree_next_child (&top_handle, root, 1);
while (top)
{
second_handle = NULL;
second = dm_tree_next_child (&second_handle, top, 1);
while (second)
{
const char *node_name, *node_uuid;
char *name;
struct dmraid_seen *seen_elt;
/* Walk the second-level children of the inverted tree; that is, devices
which are directly composed of non-DM devices such as hard disks.
This class includes all DM-RAID disks and excludes all DM-RAID
partitions. */
root = dm_tree_find_node (tree, 0, 0);
top_handle = NULL;
top = dm_tree_next_child (&top_handle, root, 1);
while (top)
{
second_handle = NULL;
second = dm_tree_next_child (&second_handle, top, 1);
while (second)
{
const char *node_name, *node_uuid;
char *name;
node_name = dm_tree_node_get_name (second);
dmraid_check (node_name, "dm_tree_node_get_name failed\n");
node_uuid = dm_tree_node_get_uuid (second);
dmraid_check (node_uuid, "dm_tree_node_get_uuid failed\n");
if (strncmp (node_uuid, "DMRAID-", 7) != 0)
{
grub_dprintf ("deviceiter", "%s is not DM-RAID\n", node_name);
goto dmraid_next_child;
}
node_name = dm_tree_node_get_name (second);
dmraid_check (node_name, "dm_tree_node_get_name failed\n");
node_uuid = dm_tree_node_get_uuid (second);
dmraid_check (node_uuid, "dm_tree_node_get_uuid failed\n");
if (strncmp (node_uuid, "DMRAID-", 7) != 0)
{
grub_dprintf ("deviceiter", "%s is not DM-RAID\n", node_name);
goto dmraid_next_child;
}
/* Have we already seen this node? There are typically very few
DM-RAID disks, so a list should be fast enough. */
if (grub_named_list_find (GRUB_AS_NAMED_LIST (seen), node_name))
{
grub_dprintf ("deviceiter", "Already seen DM device %s\n",
node_name);
goto dmraid_next_child;
}
name = xasprintf ("/dev/mapper/%s", node_name);
if (check_device (name))
{
if (hook (name, 0))
{
free (name);
while (seen)
{
struct dmraid_seen *seen_elt =
grub_list_pop (GRUB_AS_LIST_P (&seen));
free (seen_elt);
}
if (task)
dm_task_destroy (task);
if (tree)
dm_tree_free (tree);
return;
}
}
free (name);
seen_elt = xmalloc (sizeof *seen_elt);
seen_elt->name = node_name;
grub_list_push (GRUB_AS_LIST_P (&seen), GRUB_AS_LIST (seen_elt));
name = xasprintf ("/dev/mapper/%s", node_name);
if (check_device_readable_unique (name))
{
if (hook (name, 0))
{
free (name);
if (task)
dm_task_destroy (task);
if (tree)
dm_tree_free (tree);
goto out;
}
}
free (name);
dmraid_next_child:
second = dm_tree_next_child (&second_handle, top, 1);
}
top = dm_tree_next_child (&top_handle, root, 1);
}
second = dm_tree_next_child (&second_handle, top, 1);
}
top = dm_tree_next_child (&top_handle, root, 1);
}
dmraid_end:
while (seen)
{
struct dmraid_seen *seen_elt = grub_list_pop (GRUB_AS_LIST_P (&seen));
free (seen_elt);
}
if (task)
dm_task_destroy (task);
if (tree)
dm_tree_free (tree);
}
if (task)
dm_task_destroy (task);
if (tree)
dm_tree_free (tree);
}
# endif /* HAVE_DEVICE_MAPPER */
#endif /* __linux__ */
out:
clear_seen_devices ();
}

View file

@ -21,7 +21,6 @@
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/lib/envblk.h>
#include <grub/handler.h>
#include <grub/i18n.h>
#include <stdio.h>

View file

@ -55,9 +55,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{

View file

@ -34,6 +34,8 @@ font=@datadir@/@PACKAGE_TARNAME@/ascii.pf2
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
localedir=@datadir@/locale
self=`basename $0`
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
@ -48,6 +50,7 @@ no_floppy=
force_lba=
recheck=no
debug=no
debug_image=
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
disk_module=biosdisk
@ -61,7 +64,7 @@ fi
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION] install_device
Usage: $self [OPTION] install_device
Install GRUB on your drive.
-h, --help print this message and exit
@ -91,52 +94,101 @@ fi
INSTALL_DEVICE can be a GRUB device name or a system device filename.
grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and
$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 grub-install will copy
If the --root-directory option is used, then $self will copy
images into the operating system installation rooted at that directory.
Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--font)
font=`argument $option "$@"`; shift;;
--font=*)
font=`echo "$option" | sed 's/--font=//'` ;;
--root-directory)
rootdir=`argument $option "$@"`; shift;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-setup)
grub_setup=`argument $option "$@"`; shift;;
--grub-setup=*)
grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-mkdevicemap)
grub_mkdevicemap=`argument $option "$@"`; shift;;
--grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
--grub-probe)
grub_probe=`argument $option "$@"`; shift;;
--grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
--no-floppy)
no_floppy="--no-floppy" ;;
--recheck)
recheck=yes ;;
--disk-module)
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
disk_module=`argument $option "$@"`; shift;
fi ;;
--disk-module=*)
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
disk_module=`echo "$option" | sed 's/--disk-module=//'`
fi ;;
# This is an undocumented feature...
--debug)
debug=yes ;;
--debug-image)
debug_image=`argument $option "$@"`; shift;;
--debug-image=*)
debug_image=`echo "$option" | sed 's/--debug-image=//'` ;;
-f | --force)
setup_force="--force" ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
@ -303,6 +355,13 @@ fi
prefix_drive=
config_opt=
rm -f ${grubdir}/load.cfg
if [ "x${debug_image}" != x ]; then
echo "set debug='${debug_image}'" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
fi
if [ "x${devabstraction_module}" = "x" ] ; then
if [ x"${install_device}" != x ]; then
if echo "${install_device}" | grep -qx "(.*)" ; then
@ -310,12 +369,12 @@ if [ "x${devabstraction_module}" = "x" ] ; then
else
install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1
fi
install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`"
install_drive="`echo ${install_drive} | sed -e s/,[a-z0-9,]*//g`"
fi
grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
# Strip partition number
grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*[a-z]*//g`"
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)
uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
@ -323,7 +382,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
exit 1
fi
echo "search.fs_uuid ${uuid} root " > ${grubdir}/load.cfg
echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"
@ -333,7 +392,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
exit 1
fi
echo "search.fs_uuid ${uuid} root " > ${grubdir}/load.cfg
echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"

View file

@ -23,7 +23,8 @@ exec_prefix=@exec_prefix@
sbindir=@sbindir@
libdir=@libdir@
sysconfdir=@sysconfdir@
package_version=@PACKAGE_VERSION@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_os=@host_os@
datarootdir=@datarootdir@
datadir=@datadir@
@ -31,6 +32,8 @@ pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
grub_cfg=""
grub_mkconfig_dir=${sysconfdir}/grub.d
self=`basename $0`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@ -38,7 +41,7 @@ grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION]
Usage: $self [OPTION]
Generate a grub config file
-o, --output=FILE output generated config to FILE [default=stdout]
@ -49,24 +52,32 @@ Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
next_grub_cfg=false
for option in "$@"; do
if $next_grub_cfg; then
grub_cfg=$option
next_grub_cfg=false
continue
fi
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$0 (GNU GRUB ${package_version})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
-o)
next_grub_cfg=:
;;
-o | --output)
grub_cfg=`argument $option "$@"`; shift;;
--output=*)
grub_cfg=`echo "$option" | sed 's/--output=//'`
;;
@ -75,13 +86,9 @@ for option in "$@"; do
usage
exit 1
;;
# Explicitly ignore non-option arguments, for compatibility.
esac
done
if $next_grub_cfg; then
echo "Missing argument to \`-o'" 1>&2
usage
exit 1
fi
. ${libdir}/grub/grub-mkconfig_lib
@ -89,11 +96,11 @@ 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}`
GRUB_PREFIX=`echo /grub | sed ${transform}`
;;
*)
# Use /boot/grub by default.
grub_prefix=`echo /boot/grub | sed ${transform}`
GRUB_PREFIX=`echo /boot/grub | sed ${transform}`
;;
esac
@ -113,7 +120,7 @@ if [ "$EUID" != 0 ] ; then
done ;;
esac
if [ $root != t ] ; then
echo "$0: You must run this as root" >&2
echo "$self: You must run this as root" >&2
exit 1
fi
fi
@ -134,9 +141,9 @@ else
exit 1
fi
mkdir -p ${grub_prefix}
mkdir -p ${GRUB_PREFIX}
if test -e ${grub_prefix}/device.map ; then : ; else
if test -e ${GRUB_PREFIX}/device.map ; then : ; else
${grub_mkdevicemap}
fi
@ -171,17 +178,14 @@ fi
for x in ${GRUB_TERMINAL_OUTPUT}; do
if [ "x${x}" = "xgfxterm" ]; then
# If this platform supports gfxterm, try to use it.
if ! test -e ${grub_prefix}/gfxterm.mod ; then
if ! test -e ${GRUB_PREFIX}/gfxterm.mod ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "gfxterm isn't available on your platform" >&2 ; exit 1
fi
GRUB_TERMINAL_OUTPUT=
break;
fi
# FIXME: this should do something smarter than just loading first
# video backend.
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
if [ ! -s "${GRUB_PREFIX}/video.lst" ] ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
fi
@ -239,7 +243,7 @@ export GRUB_DEVICE \
GRUB_FS \
GRUB_FONT_PATH \
GRUB_PRELOAD_MODULES \
GRUB_VIDEO_BACKEND
GRUB_PREFIX
# These are optional, user-defined variables.
export GRUB_DEFAULT \
@ -253,6 +257,8 @@ export GRUB_DEFAULT \
GRUB_DISTRIBUTOR \
GRUB_CMDLINE_LINUX \
GRUB_CMDLINE_LINUX_DEFAULT \
GRUB_CMDLINE_XEN \
GRUB_CMDLINE_XEN_DEFAULT \
GRUB_CMDLINE_NETBSD \
GRUB_CMDLINE_NETBSD_DEFAULT \
GRUB_TERMINAL_INPUT \
@ -261,6 +267,7 @@ export GRUB_DEFAULT \
GRUB_DISABLE_LINUX_UUID \
GRUB_DISABLE_LINUX_RECOVERY \
GRUB_DISABLE_NETBSD_RECOVERY \
GRUB_VIDEO_BACKEND \
GRUB_GFXMODE \
GRUB_BACKGROUND \
GRUB_THEME \
@ -284,7 +291,7 @@ cat << EOF
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by $0 using templates
# It is automatically generated by $self using templates
# from ${grub_mkconfig_dir} and settings from ${sysconfdir}/default/grub
#
EOF

View file

@ -107,7 +107,7 @@ prepare_grub_to_access_device ()
partmap="`${grub_probe} --device ${device} --target=partmap`"
for module in ${partmap} ; do
echo "insmod ${module}"
echo "insmod part_${module}"
done
fs="`${grub_probe} --device ${device} --target=fs`"

View file

@ -1301,7 +1301,7 @@ main (int argc, char *argv[])
image_target = &image_targets[i];
if (!image_target)
{
printf ("unknown target %s\n", optarg);
printf ("unknown target format %s\n", optarg);
usage (1);
}
break;
@ -1355,7 +1355,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("grub-mkimage (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':
@ -1370,7 +1370,7 @@ main (int argc, char *argv[])
if (!image_target)
{
printf ("Target not specified.\n");
printf ("Target format not specified (use the -O option).\n");
usage (1);
}

View file

@ -112,7 +112,7 @@ hexify (char *hex, grub_uint8_t *bin, grub_size_t n)
int
main (int argc, char *argv[])
{
unsigned int c = 10000, buflen = 64, saltlen = 64;
unsigned int count = 10000, buflen = 64, saltlen = 64;
char *pass1, *pass2;
char *bufhex, *salthex;
gcry_err_code_t gcry_err;
@ -137,7 +137,7 @@ main (int argc, char *argv[])
switch (c)
{
case 'c':
c = strtoul (optarg, NULL, 0);
count = strtoul (optarg, NULL, 0);
break;
case 'l':
@ -307,7 +307,7 @@ main (int argc, char *argv[])
gcry_err = grub_crypto_pbkdf2 (GRUB_MD_SHA512,
(grub_uint8_t *) pass1, strlen (pass1),
salt, saltlen,
c, buf, buflen);
count, buf, buflen);
memset (pass1, 0, strlen (pass1));
free (pass1);
@ -327,7 +327,8 @@ main (int argc, char *argv[])
hexify (bufhex, buf, buflen);
hexify (salthex, salt, saltlen);
printf ("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n", c, salthex, bufhex);
printf ("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n",
count, salthex, bufhex);
memset (buf, 0, buflen);
memset (bufhex, 0, 2 * buflen);
free (buf);

View file

@ -30,6 +30,8 @@ target_cpu=@target_cpu@
native_platform=@platform@
pkglib_DATA="@pkglib_DATA@"
self=`basename $0`
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot
qemu_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu
@ -40,56 +42,97 @@ rom_directory=
override_dir=
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
xorriso=xorriso
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] SOURCE...
Usage: $self [OPTION] SOURCE...
Make GRUB rescue image.
-h, --help print this message and exit
-v, --version print the version information and exit
--output=FILE save output in FILE [required]
-o, --output=FILE save output in FILE [required]
--modules=MODULES pre-load specified modules MODULES
--rom-directory=DIR save rom images in DIR [optional]
--xorriso=FILE use FILE as xorriso [optional]
--grub-mkimage=FILE use FILE as grub-mkimage
$0 generates a bootable rescue image with specified source files or directories.
$self generates a bootable rescue image with specified source files, source
directories, or mkisofs options listed by: xorriso -as mkisofs -help
Option -- switches to native xorriso command mode. or directories.
Report bugs to <bug-grub@gnu.org>.
Mail xorriso support requests to <bug-xorriso@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output)
output_image=`argument $option "$@"`; shift ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
--rom-directory)
rom_directory=`argument $option "$@"`; shift ;;
--rom-directory=*)
rom_directory=`echo "$option" | sed 's/--rom-directory=//'` ;;
# Intentionally undocumented
--override-directory)
override_dir=`argument $option "$@"`
shift
PATH=${override_dir}:$PATH
export PATH
;;
--override-directory=*)
override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
PATH=${override_dir}:$PATH
export PATH
;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
--xorriso)
xorriso=`argument $option "$@"`; shift ;;
--xorriso=*)
xorriso=`echo "${option}/" | sed 's/--xorriso=//'` ;;
*)
source="${source} ${option}" ;;
source="${source} ${option} $@"; break ;;
esac
done
@ -171,7 +214,7 @@ EOF
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir}
$grub_mkimage -O ${platform} -d "${source_directory}" -m "${memdisk_img}" -o "$3" --prefix='(memdisk)/boot/grub' \
search iso9660 configfile normal sh memdisk tar $4
search iso9660 configfile normal memdisk tar $4
rm -rf ${memdisk_img}
}
@ -267,7 +310,7 @@ if [ -e "${iso9660_dir}/boot/coreboot.elf" ] && [ -d "${rom_directory}" ]; then
fi
# build iso image
xorriso -pathspecs on -as mkisofs ${grub_mkisofs_arguments} --protective-msdos-label -o ${output_image} -r ${iso9660_dir} ${source}
"${xorriso}" -as mkisofs -graft-points ${grub_mkisofs_arguments} --protective-msdos-label -o ${output_image} -r ${iso9660_dir} --sort-weight 0 / --sort-weight 1 /boot ${source}
rm -rf ${iso9660_dir}
rm -f ${embed_img}

View file

@ -71,9 +71,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{

View file

@ -22,6 +22,10 @@ transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
@ -30,7 +34,7 @@ rootdir=
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] entry
Usage: $self [OPTION] entry
Set the default boot entry for GRUB, for the next boot only.
-h, --help print this message and exit
@ -44,17 +48,36 @@ Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-reboot (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage

View file

@ -26,8 +26,6 @@
#include <grub/parser.h>
#include <grub/script_sh.h>
#include <grub_script_check_init.h>
#define _GNU_SOURCE 1
#include <ctype.h>
@ -239,9 +237,6 @@ main (int argc, char *argv[])
}
}
/* Initialize all modules. */
grub_init_all ();
do
{
input = 0;
@ -260,8 +255,6 @@ main (int argc, char *argv[])
grub_free (input);
} while (script != 0);
/* Free resources. */
grub_fini_all ();
if (file) fclose (file);
return (found_input && script == 0);

View file

@ -22,6 +22,10 @@ transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
@ -30,7 +34,7 @@ rootdir=
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] entry
Usage: $self [OPTION] entry
Set the default boot entry for GRUB.
-h, --help print this message and exit
@ -44,17 +48,36 @@ Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-set-default (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage

View file

@ -21,8 +21,7 @@ transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
grub_prefix=`echo /boot/grub | sed ${transform}`
locale_dir=`echo /boot/grub/locale | sed ${transform}`
locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}`
grub_lang=`echo $LANG | cut -d _ -f 1`
. ${libdir}/grub/grub-mkconfig_lib
@ -61,8 +60,8 @@ set default="${GRUB_DEFAULT}"
EOF
fi
cat <<EOF
if [ \${prev_saved_entry} ]; then
set saved_entry=\${prev_saved_entry}
if [ "\${prev_saved_entry}" ]; then
set saved_entry="\${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
@ -70,11 +69,29 @@ if [ \${prev_saved_entry} ]; then
fi
function savedefault {
if [ -z \${boot_once} ]; then
saved_entry=\${chosen}
if [ -z "\${boot_once}" ]; then
saved_entry="\${chosen}"
save_env saved_entry
fi
}
function load_video {
EOF
if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
cat <<EOF
insmod ${GRUB_VIDEO_BACKEND}
EOF
else
# Insert all available backends; GRUB will use the most appropriate.
for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
cat <<EOF
insmod ${backend}
EOF
done
fi
cat <<EOF
}
EOF
serial=0;
@ -89,7 +106,7 @@ for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
done
if [ "x$serial" = x1 ]; then
if ! test -e ${grub_prefix}/serial.mod ; then
if ! test -e ${GRUB_PREFIX}/serial.mod ; then
echo "Serial terminal not available on this platform." >&2 ; exit 1
fi
@ -107,8 +124,8 @@ if [ "x$gfxterm" = x1 ]; then
cat << EOF
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
set gfxmode=${GRUB_GFXMODE}
load_video
insmod gfxterm
insmod ${GRUB_VIDEO_BACKEND}
EOF
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
&& is_path_readable_by_grub "$GRUB_THEME"; then
@ -195,7 +212,7 @@ EOF
esac
# Gettext variables and module
if [ "x${LANG}" != "xC" ] ; then
if [ "x${LANG}" != "xC" ] && [ -d "${locale_dir}" ] ; then
prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
cat << EOF
set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})

View file

@ -66,6 +66,9 @@ linux_entry ()
# Use ELILO's generic "efifb" when it's known to be available.
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
cat << EOF
load_video
EOF
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
cat << EOF
@ -97,7 +100,7 @@ EOF
EOF
}
list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
list=`for i in /boot/vmlinu[zx]-* /vmlinu[zx]-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
prepare_boot_cache=
@ -114,8 +117,9 @@ while [ "x$list" != "x" ] ; do
initrd=
for i in "initrd.img-${version}" "initrd-${version}.img" \
"initrd-${version}" "initrd.img-${alt_version}" \
"initrd-${alt_version}.img" "initrd-${alt_version}"; do
"initrd-${version}" "initramfs-${version}.img" \
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
"initrd-${alt_version}" "initramfs-${alt_version}.img"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break

141
util/grub.d/20_linux_xen.in Normal file
View file

@ -0,0 +1,141 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
CLASS="--class gnu-linux --class gnu --class os --class xen"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
/dev/loop/*|/dev/loop[0-9])
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
;;
esac
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
linux_entry ()
{
os="$1"
version="$2"
xen_version="$3"
recovery="$4"
args="$5"
xen_args="$6"
if ${recovery} ; then
title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")"
else
title="$(gettext_quoted "%s, with Linux %s and XEN %s")"
fi
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" "${xen_version}"
save_default_entry | sed -e "s/^/\t/"
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
cat << EOF
echo '$(gettext_quoted "Loading initial ramdisk ...")'
module ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF
}
linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
basename=$(basename $i)
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi
done`
xen_list=`for i in /boot/xen*; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
prepare_boot_cache=
while [ "x${xen_list}" != "x" ] ; do
list="${linux_list}"
current_xen=`version_find_latest $xen_list`
xen_basename=`basename ${current_xen}`
xen_dirname=`dirname ${current_xen}`
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
echo "Found linux image: $linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
initrd=
for i in "initrd.img-${version}" "initrd-${version}.img" \
"initrd-${version}" "initrd.img-${alt_version}" \
"initrd-${alt_version}.img" "initrd-${alt_version}"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break
fi
done
if test -n "${initrd}" ; then
echo "Found initrd image: ${dirname}/${initrd}" >&2
else
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
linux_root_device_thisversion=${GRUB_DEVICE}
fi
linux_entry "${OS}" "${version}" "${xen_version}" false \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}" "${version}" "${xen_version}" true \
"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
fi
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done
xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
done

View file

@ -44,7 +44,7 @@ EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
cat << EOF
insmod ${GRUB_VIDEO_BACKEND}
load_video
set do_resume=0
if [ /var/vm/sleepimage -nt10 / ]; then
if xnu_resume /var/vm/sleepimage; then

7
util/grub.d/41_custom.in Normal file
View file

@ -0,0 +1,7 @@
#!/bin/sh
cat <<EOF
if [ -f \$prefix/custom.cfg ]; then
source \$prefix/custom.cfg;
fi
EOF

View file

@ -33,6 +33,8 @@ host_os=@host_os@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
localedir=@datadir@/locale
self=`basename $0`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@ -50,7 +52,7 @@ debug=no
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION]
Usage: $self [OPTION]
Install GRUB on your EFI partition.
-h, --help print this message and exit
@ -64,32 +66,63 @@ Install GRUB on your EFI partition.
--no-floppy do not probe any floppy drive
--recheck probe a device map even if it already exists
grub-install copies GRUB images into the DIR/boot directory specified by
$self copies GRUB images into the DIR/boot directory specified by
--root-directory.
Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-mkdevicemap)
grub_mkdevicemap=`argument $option "$@"`; shift ;;
--grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
--grub-probe)
grub_probe=`argument $option "$@"`; shift ;;
--grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
--no-floppy)
no_floppy="--no-floppy" ;;
--recheck)
@ -219,7 +252,7 @@ $grub_mkimage -O ${target_cpu}-efi --output=${grubdir}/grub.efi $modules || exit
echo "Installation finished. No error reported."
echo "This is the contents of the device map $device_map."
echo "Check if this is correct or not. If any of the lines is incorrect,"
echo "fix it and re-run the script \`grub-install'."
echo "fix it and re-run the script \`$self'."
echo
cat $device_map

View file

@ -76,9 +76,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{
@ -102,6 +99,7 @@ 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 *prefix;
char *tmp_img;
int i;
grub_disk_addr_t first_sector;
@ -126,8 +124,8 @@ setup (const char *dir,
/* There's always an embed region, and it starts right after the MBR. */
embed_region.start = 1;
if (embed_region.end > p->start)
embed_region.end = p->start;
if (embed_region.end > grub_partition_get_start (p))
embed_region.end = grub_partition_get_start (p);
return 0;
}
@ -147,8 +145,8 @@ setup (const char *dir,
/* If there's an embed region, it is in a dedicated partition. */
if (! memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
{
embed_region.start = p->start;
embed_region.end = p->start + p->len;
embed_region.start = grub_partition_get_start (p);
embed_region.end = grub_partition_get_start (p) + grub_partition_get_len (p);
return 1;
}
@ -233,6 +231,8 @@ 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);
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);
@ -308,6 +308,18 @@ setup (const char *dir,
dos_part = root_dev->disk->partition->number;
bsd_part = -1;
}
if (prefix[0] != '(')
{
char *root_part_name, *new_prefix;
root_part_name =
grub_partition_get_name (root_dev->disk->partition);
new_prefix = xasprintf ("(,%s)%s", root_part_name, prefix);
strcpy (prefix, new_prefix);
free (new_prefix);
free (root_part_name);
}
}
else
dos_part = bsd_part = -1;
@ -361,7 +373,7 @@ setup (const char *dir,
else
grub_util_error (_("No DOS-style partitions found"));
if (embed_region.end == embed_region.start)
if (embed_region.end <= embed_region.start)
{
if (! strcmp (dest_partmap, "msdos"))
grub_util_warn (_("This msdos-style partition label has no post-MBR gap; embedding won't be possible!"));
@ -596,6 +608,8 @@ Usage: %s [OPTION]... DEVICE\n\
\n\
Set up images to boot from DEVICE.\n\
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
You should not normally run %s directly. Use grub-install instead.\n\
\n\
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
@ -610,7 +624,7 @@ DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
Report bugs to <%s>.\n\
"),
program_name,
program_name, program_name,
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
@ -702,7 +716,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("grub-setup (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -34,6 +34,8 @@ target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
self=`basename $0`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@ -53,7 +55,7 @@ nvsetenv=`which nvsetenv`
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION] [install_device]
Usage: $self [OPTION] [install_device]
Install GRUB on your drive.
-h, --help print this message and exit
@ -66,7 +68,7 @@ Install GRUB on your drive.
--grub-probe=FILE use FILE as grub-probe
--no-nvram don't update the boot-device NVRAM variable
grub-install copies GRUB images into the DIR/boot directory specified by
$self copies GRUB images into the DIR/boot directory specified by
--root-directory, and uses nvsetenv to set the Open Firmware boot-device
variable.
@ -74,25 +76,56 @@ Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-mkdevicemap)
grub_mkdevicemap=`argument $option "$@"`; shift ;;
--grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-probe)
grub_probe=`argument $option "$@"`; shift ;;
--grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
--no-nvram)
update_nvram=no ;;
# This is an undocumented feature...
@ -231,7 +264,7 @@ fi
echo "Installation finished. No error reported."
echo "This is the contents of the device map $device_map."
echo "Check if this is correct or not. If any of the lines is incorrect,"
echo "fix it and re-run the script \`grub-install'."
echo "fix it and re-run the script \`$self'."
echo
cat $device_map

View file

@ -30,13 +30,15 @@ target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
self=`basename $0`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: grub-mkrescue [OPTION] output_image
Usage: $self [OPTION] output_image
Make GRUB rescue image.
-h, --help print this message and exit
@ -46,29 +48,54 @@ Make GRUB rescue image.
default: ${pkglibdir}
--grub-mkimage=FILE use FILE as grub-mkimage
grub-mkimage generates a bootable rescue CD image for PowerMac and CHRP.
$self generates a bootable rescue CD image for PowerMac and CHRP.
Report bugs to <bug-grub@gnu.org>.
EOF
}
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
input_dir=${pkglibdir}
# Check the arguments.
for option in "$@"; do
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "grub-mkrescue (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--pkglibdir)
input_dir=`argument $option "$@"`; shift ;;
--pkglibdir=*)
input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage

View file

@ -102,9 +102,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{
@ -410,6 +407,8 @@ Usage: %s [OPTION]... DEVICE\n\
\n\
Set up images to boot from DEVICE.\n\
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
\n\
You should not normally run %s directly. Use grub-install instead.\n\
\n\
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
@ -421,7 +420,7 @@ DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
", program_name,
", program_name, program_name,
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
@ -503,7 +502,7 @@ parse_options (struct grub_setup_info *gp, int argc, char *argv[])
break;
case 'V':
printf ("grub-setup (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':