merge trunk

This commit is contained in:
Colin Watson 2011-03-14 22:01:32 +00:00
commit 7bdeb3987a
83 changed files with 1453 additions and 383 deletions

View file

@ -64,7 +64,7 @@ if test -f "${sysconfdir}/default/grub" ; then
. "${sysconfdir}/default/grub"
fi
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | cut -d' ' -f1)"
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr 'A-Z' 'a-z' | cut -d' ' -f1)"
if test -z "$bootloader_id"; then
bootloader_id=grub
fi
@ -270,6 +270,11 @@ if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
exit 1
fi
if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
install_device=
fi
# If the debugging feature is enabled, print commands.
setup_verbose=
if test x"$debug" = xyes; then
@ -516,27 +521,24 @@ if [ "x${devabstraction_module}" = "x" ] ; then
# 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
if [ "$disk_module" = ata ] || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]) ; then
# generic method (used on coreboot and ata mod)
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
if [ "x${uuid}" = "x" ] ; then
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]; then
echo "UUID needed with $platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
elif [ "$disk_module" = ata ]; then
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
else
echo "UUID needed with cross-disk installs, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
fi
exit 1
fi
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"
elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
if [ "x${uuid}" = "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 '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.
if [ x"$grub_partition" = x ]; then

View file

@ -1,5 +1,11 @@
#!/bin/sh
transform="@program_transform_name@"
prefix="@prefix@"
exec_prefix="@exec_prefix@"
bindir="@bindir@"
grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}`
ckbcomp "$@" | $grub_mklayout -o "$1".gkb

View file

@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <grub/util/misc.h>
#include <grub/misc.h>
int
main (int argc, char **argv)
@ -78,9 +79,12 @@ main (int argc, char **argv)
{
char *oldname = NULL;
char *newsuffix;
char *ptr;
for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
oldname = entryname;
parsed = grub_legacy_parse (buf, &entryname, &newsuffix);
parsed = grub_legacy_parse (ptr, &entryname, &newsuffix);
if (newsuffix)
{
suffixlen += strlen (newsuffix);

View file

@ -61,6 +61,12 @@ is_path_readable_by_grub ()
return 1
fi
# ... or if we can't figure out the abstraction module, for example if
# memberlist fails on an LVM volume group.
if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else
return 1
fi
return 0
}
@ -107,7 +113,12 @@ prepare_grub_to_access_device ()
partmap="`${grub_probe} --device ${device} --target=partmap`"
for module in ${partmap} ; do
echo "insmod part_${module}"
case "${module}" in
netbsd | openbsd)
echo "insmod part_bsd";;
*)
echo "insmod part_${module}";;
esac
done
fs="`${grub_probe} --device ${device} --target=fs`"

View file

@ -859,7 +859,7 @@ void
write_font_pf2 (struct grub_font_info *font_info, char *output_file)
{
FILE *file;
grub_uint32_t leng, data;
grub_uint32_t leng;
char style_name[20], *font_name;
int offset;
struct grub_glyph_info *cur;
@ -959,12 +959,14 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
for (cur = font_info->glyphs_sorted;
cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++)
{
data = grub_cpu_to_be32 (cur->char_code);
grub_util_write_image ((char *) &data, 4, file);
data = 0;
grub_util_write_image ((char *) &data, 1, file);
data = grub_cpu_to_be32 (offset);
grub_util_write_image ((char *) &data, 4, file);
grub_uint32_t data32;
grub_uint8_t data8;
data32 = grub_cpu_to_be32 (cur->char_code);
grub_util_write_image ((char *) &data32, 4, file);
data8 = 0;
grub_util_write_image ((char *) &data8, 1, file);
data32 = grub_cpu_to_be32 (offset);
grub_util_write_image ((char *) &data32, 4, file);
offset += 10 + cur->bitmap_size;
}
@ -976,6 +978,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
for (cur = font_info->glyphs_sorted;
cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++)
{
grub_uint16_t data;
data = grub_cpu_to_be16 (cur->width);
grub_util_write_image ((char *) &data, 2, file);
data = grub_cpu_to_be16 (cur->height);

View file

@ -29,6 +29,7 @@
#include <grub/util/resolve.h>
#include <grub/misc.h>
#include <grub/offsets.h>
#include <grub/crypto.h>
#include <time.h>
#include <stdio.h>
@ -1167,12 +1168,37 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
size_t rom_size;
char *boot_path, *boot_img;
size_t boot_size;
grub_uint8_t context[GRUB_MD_SHA512->contextsize];
/* fwstart.img is the only part which can't be testes by using *-elf
target. Check it against the checksum. This checksum is obtained with
sha512sum utility after compiling on Gnewsense.
*/
const grub_uint8_t fwstart_good_hash[] =
{ 0x75, 0xbf, 0xa3, 0x0e, 0x7c, 0xd1, 0x03, 0x82,
0xe1, 0x34, 0x55, 0xd7, 0x09, 0x1e, 0x6c, 0xcc,
0xef, 0x08, 0x61, 0xc1, 0x3c, 0xd8, 0xc7, 0x9f,
0xe8, 0x2d, 0x3d, 0xb2, 0xda, 0x41, 0xd3, 0x83,
0xd7, 0xb8, 0xe3, 0xd7, 0x13, 0xec, 0x9b, 0xf6,
0xf6, 0xae, 0x6b, 0x32, 0x29, 0xc1, 0x69, 0x82,
0xfa, 0x65, 0x2d, 0x97, 0x3e, 0x83, 0x6e, 0x6c,
0xce, 0x34, 0x10, 0x59, 0x74, 0x0e, 0x96, 0x26 };
boot_path = grub_util_get_path (dir, "fwstart.img");
boot_size = grub_util_get_image_size (boot_path);
boot_img = grub_util_read_image (boot_path);
rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024);
grub_memset (context, 0, sizeof (context));
GRUB_MD_SHA512->init (context);
GRUB_MD_SHA512->write (context, boot_img, boot_size);
GRUB_MD_SHA512->final (context);
if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash,
GRUB_MD_SHA512->mdlen) != 0)
grub_util_warn ("fwstart.img doesn't match the known good version. "
"Proceed at your own risk");
if (core_size + boot_size > 512 * 1024)
grub_util_error ("firmware image is too big");
rom_size = 512 * 1024;
rom_img = xmalloc (rom_size);
memset (rom_img, 0, rom_size);

View file

@ -60,6 +60,8 @@ static struct console_grub_equivalence console_grub_equivalences_shift[] = {
{"KP_8", '8'},
{"KP_9", '9'},
{"KP_Period", '.'},
{NULL, '\0'}
};
static struct console_grub_equivalence console_grub_equivalences_unshift[] = {
@ -74,6 +76,8 @@ static struct console_grub_equivalence console_grub_equivalences_unshift[] = {
{"KP_8", GRUB_TERM_KEY_UP},
{"KP_9", GRUB_TERM_KEY_PPAGE},
{"KP_Period", GRUB_TERM_KEY_DC},
{NULL, '\0'}
};
static struct console_grub_equivalence console_grub_equivalences_common[] = {
@ -259,8 +263,9 @@ usage (int status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
printf ("\
Usage: %s [OPTIONS] LAYOUT\n\
-o, --output set output base name file. Default is LAYOUT.gkb\n\
Usage: %s [OPTIONS]\n\
-i, --input set input filename. Default is STDIN\n\
-o, --output set output filename. Default is STDOUT\n\
-h, --help display this message and exit.\n\
-V, --version print version information and exit.\n\
-v, --verbose print verbose messages.\n\

View file

@ -337,7 +337,7 @@ write_symbol_table (FILE* fp, char *image,
else
bind = STB_LOCAL;
if ((type != STT_FUNC) && (pe_symtab->num_aux))
if ((pe_symtab->type != GRUB_PE32_DT_FUNCTION) && (pe_symtab->num_aux))
{
if (! pe_symtab->value)
type = STT_SECTION;

View file

@ -49,6 +49,7 @@
#include <grub/emu/getroot.h>
#include "progname.h"
#include <grub/reed_solomon.h>
#include <grub/msdos_partition.h>
#define _GNU_SOURCE 1
#include <argp.h>
@ -339,6 +340,12 @@ setup (const char *dir,
{
if (p->parent != container)
return 0;
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
so they are safe to ignore.
*/
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
return 0;
if (dest_partmap == NULL)
{
dest_partmap = p->partmap;
@ -352,6 +359,15 @@ setup (const char *dir,
grub_partition_iterate (dest_dev->disk, identify_partmap);
if (container && grub_strcmp (container->partmap->name, "msdos") == 0
&& dest_partmap
&& (container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|| container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
{
grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
goto unable_to_embed;
}
fs = grub_fs_probe (dest_dev);
if (!fs)
grub_errno = GRUB_ERR_NONE;

View file

@ -84,11 +84,16 @@ if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
EOF
else
# Insert all available backends; GRUB will use the most appropriate.
have_video=0;
for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
have_video=1;
cat <<EOF
insmod ${backend}
EOF
done
if [ x$have_video = x0 ]; then
echo "true"
fi
fi
cat <<EOF
}

View file

@ -28,7 +28,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU
else
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
fi
at_least_one=false

View file

@ -31,7 +31,7 @@ CLASS="--class os"
case "${GRUB_DISTRIBUTOR}" in
Debian)
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
;;
*)
OS="FreeBSD"

View file

@ -32,7 +32,7 @@ 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}"
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

View file

@ -27,11 +27,65 @@ export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=NetBSD
OS="NetBSD"
else
OS="${GRUB_DISTRIBUTOR} NetBSD"
fi
netbsd_load_fs_module ()
{
loader="$1" # "knetbsd" or "multiboot"
kernel="$2" # absolute path to the kernel file
case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
Intel80386)
karch="i386"
;;
x86-64)
karch="amd64"
;;
*)
return
;;
esac
case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
ext2)
kmod="ext2fs"
;;
fat)
kmod="msdosfs"
;;
ntfs)
kmod="ntfs"
;;
ufs*)
kmod="ffs"
;;
*)
return
;;
esac
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
return
fi
kmodule_rel=$(make_system_path_relative_to_its_root "$kmodule") || return
prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,'
case "${loader}" in
knetbsd)
printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}"
;;
multiboot)
printf "\tmodule %s\n" "${kmodule_rel}"
;;
esac
}
netbsd_entry ()
{
loader="$1" # "knetbsd" or "multiboot"
@ -59,6 +113,9 @@ netbsd_entry ()
"${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
;;
esac
netbsd_load_fs_module "${loader}" "${kernel}"
printf "}\n"
}
@ -72,8 +129,7 @@ for k in $(ls -t /netbsd*) ; do
if ! grub_file_is_not_garbage "$k" ; then
continue
fi
if ! ((file -bL "$k" | grep -q "${pattern}") ||
(zcat "$k" | file -bL - | grep -q "${pattern}")) 2>/dev/null ; then
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
continue
fi

View file

@ -32,7 +32,7 @@ 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}"
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
@ -98,6 +98,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
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`
if [ "x${linux_list}" = "x" ] ; then
exit 0
fi
xen_list=`for i in /boot/xen*; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`

View file

@ -377,8 +377,8 @@ grub_util_devname_to_ofpath (const char *devname)
if (! name_buf)
grub_util_error ("cannot get the real path of `%s'", devname);
device = get_basename (devname);
devnode = strip_trailing_digits (devname);
device = get_basename (name_buf);
devnode = strip_trailing_digits (name_buf);
devicenode = strip_trailing_digits (device);
ofpath = xmalloc (OF_PATH_MAX);
@ -391,6 +391,13 @@ grub_util_devname_to_ofpath (const char *devname)
else if (device[0] == 'v' && device[1] == 'd' && device[2] == 'i'
&& device[3] == 's' && device[4] == 'k')
of_path_of_vdisk(ofpath, name_buf, device, devnode, devicenode);
else if (device[0] == 'f' && device[1] == 'd'
&& device[2] == '0' && device[3] == '\0')
/* All the models I've seen have a devalias "floppy".
New models have no floppy at all. */
strcpy (ofpath, "floppy");
else
grub_util_error ("unknown device type %s\n", device);
free (devnode);
free (devicenode);