merge with mainline

This commit is contained in:
BVK Chaitanya 2010-05-04 09:09:03 +05:30
commit 81827e248c
69 changed files with 2217 additions and 592 deletions

View file

@ -239,11 +239,14 @@ export GRUB_DEFAULT \
GRUB_DISTRIBUTOR \
GRUB_CMDLINE_LINUX \
GRUB_CMDLINE_LINUX_DEFAULT \
GRUB_CMDLINE_NETBSD \
GRUB_CMDLINE_NETBSD_DEFAULT \
GRUB_TERMINAL_INPUT \
GRUB_TERMINAL_OUTPUT \
GRUB_SERIAL_COMMAND \
GRUB_DISABLE_LINUX_UUID \
GRUB_DISABLE_LINUX_RECOVERY \
GRUB_DISABLE_NETBSD_RECOVERY \
GRUB_GFXMODE \
GRUB_BACKGROUND \
GRUB_THEME \

View file

@ -1,5 +1,5 @@
# Helper library for grub-mkconfig
# Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
# Copyright (C) 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
@ -31,6 +31,12 @@ if test "x$grub_mkrelpath" = x; then
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
fi
if $(which gettext >/dev/null 2>/dev/null) ; then
gettext="gettext"
else
gettext="echo"
fi
grub_warn ()
{
echo "Warning: $@" >&2
@ -38,21 +44,7 @@ grub_warn ()
make_system_path_relative_to_its_root ()
{
path="`${grub_mkrelpath} $1`"
case "`uname 2>/dev/null`" in
CYGWIN*)
# Cygwin: Check if regular or emulated mount.
if [ -z "$dir" ] || [ "`stat -c %D "$dir/.."`" != 620000 ] ; then
# Reached some mount point not below /cygdrive.
# GRUB does not know Cygwin's emulated mounts,
# convert to Win32 path and remove drive letter.
path=`cygpath -m "$path" | sed -n 's,^[A-Za-z]:,,p'`
test ! -z "$path" || return 1
fi ;;
esac
echo "$path"
${grub_mkrelpath} $1
}
is_path_readable_by_grub ()
@ -190,5 +182,5 @@ version_find_latest ()
}
gettext_quoted () {
gettext "$@" | sed "s/'/'\\\\''/g"
$gettext "$@" | sed "s/'/'\\\\''/g"
}

View file

@ -19,6 +19,7 @@
#include <stdio.h>
#include <grub/util/misc.h>
#include <grub/emu/misc.h>
#include <grub/i18n.h>
#include <getopt.h>
@ -98,7 +99,7 @@ main (int argc, char *argv[])
argument = argv[optind];
relpath = make_system_path_relative_to_its_root (argument);
relpath = grub_make_system_path_relative_to_its_root (argument);
printf ("%s\n", relpath);
free (relpath);

View file

@ -30,7 +30,7 @@ target_cpu=@target_cpu@
native_platform=@platform@
pkglib_DATA="@pkglib_DATA@"
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-multiboot
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
# Usage: usage
@ -122,45 +122,45 @@ process_input_dir ()
}
if [ "${override_dir}" = "" ] ; then
if test -e "${coreboot_dir}" ; then
process_input_dir ${coreboot_dir} coreboot
if test -e "${multiboot_dir}" ; then
process_input_dir ${multiboot_dir} multiboot
fi
if test -e "${pc_dir}" ; then
process_input_dir ${pc_dir} pc
fi
else
process_input_dir ${override_dir} ${native_platform}
coreboot_dir=
multiboot_dir=
pc_dir=
case "${native_platform}" in
coreboot) coreboot_dir=${override_dir} ;;
multiboot) multiboot_dir=${override_dir} ;;
pc) pc_dir=${override_dir} ;;
esac
fi
# build coreboot core.img
if test -e "${coreboot_dir}" ; then
echo "Enabling coreboot support ..."
# build multiboot core.img
if test -e "${multiboot_dir}" ; then
echo "Enabling multiboot support ..."
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p ${memdisk_dir}/boot/grub
# obtain date-based UUID
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
modules="$(cat ${multiboot_dir}/partmap.lst) ${modules}"
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
search --fs-uuid --set ${iso_uuid}
set prefix=(\${root})/boot/grub/${target_cpu}-coreboot
set prefix=(\${root})/boot/grub/${target_cpu}-multiboot
EOF
(for i in ${modules} ; do
echo "insmod $i"
done ; \
echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-coreboot/grub.cfg
> ${iso9660_dir}/boot/grub/i386-multiboot/grub.cfg
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir}
grub-mkelfimage -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
grub-mkelfimage -d ${multiboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
memdisk tar search iso9660 configfile sh \
ata at_keyboard
rm -f ${memdisk_img}

View file

@ -262,7 +262,7 @@ probe (const char *path, char *device_name)
grub_util_info ("reading %s via OS facilities", path);
filebuf_via_sys = grub_util_read_image (path);
rel_path = make_system_path_relative_to_its_root (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);

86
util/grub.d/10_netbsd.in Normal file
View file

@ -0,0 +1,86 @@
#! /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@
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=NetBSD
else
OS="${GRUB_DISTRIBUTOR} NetBSD"
fi
netbsd_entry ()
{
loader="$1" # "knetbsd" or "multiboot"
kernel="$2" # absolute path to the kernel file
recovery="$3" # is this is a recovery entry?
args="$4" # extra arguments appended to loader command
kroot_device="$(echo ${GRUB_DEVICE} | sed -e 's,^/dev/r,,')"
if ${recovery} ; then
title="$(gettext_quoted "%s, with kernel %s (via %s, recovery mode)")"
else
title="$(gettext_quoted "%s, with kernel %s (via %s)")"
fi
printf "menuentry \"${title}\" {\n" \
"${OS}" "$(echo ${kernel} | sed -e 's,^.*/,,')" "${loader}"
printf "%s\n" "${prepare_boot_cache}"
case "${loader}" in
knetbsd)
printf "\tknetbsd %s -r %s %s\n" \
"${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
;;
multiboot)
printf "\tmultiboot %s %s root=%s %s\n" \
"${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
;;
esac
printf "}\n"
}
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e 's,^, ,')"
# We look for NetBSD kernels in / but not in subdirectories. We simply
# pick all statically linked ELF executable files (or links) in / with a
# name that starts with `netbsd'.
pattern="^ELF[^,]*executable.*statically linked"
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
continue
fi
echo "Found NetBSD kernel: $k" >&2
netbsd_entry "knetbsd" "$k" false "${GRUB_CMDLINE_NETBSD_DEFAULT}"
netbsd_entry "multiboot" "$k" false "${GRUB_CMDLINE_NETBSD_DEFAULT}"
if [ "x${GRUB_DISABLE_NETBSD_RECOVERY}" != "xtrue" ]; then
netbsd_entry "knetbsd" "$k" true "-s"
netbsd_entry "multiboot" "$k" true "-s"
fi
done

View file

@ -53,6 +53,11 @@
# include <malloc.h>
#endif
#ifdef __CYGWIN__
# include <sys/cygwin.h>
# define DEV_CYGDRIVE_MAJOR 98
#endif
#ifdef __MINGW32__
#include <windows.h>
#include <winioctl.h>
@ -299,102 +304,26 @@ canonicalize_file_name (const char *path)
return ret;
}
/* This function never prints trailing slashes (so that its output
can be appended a slash unconditionally). */
char *
make_system_path_relative_to_its_root (const char *path)
#ifdef __CYGWIN__
/* Convert POSIX path to Win32 path,
remove drive letter, replace backslashes. */
static char *
get_win32_path (const char *path)
{
struct stat st;
char *p, *buf, *buf2, *buf3;
uintptr_t offset = 0;
dev_t num;
size_t len;
char winpath[PATH_MAX];
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
grub_util_error ("cygwin_conv_path() failed");
/* canonicalize. */
p = canonicalize_file_name (path);
int len = strlen (winpath);
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
if (p == NULL)
grub_util_error ("failed to get canonical path of %s", path);
len = strlen (p) + 1;
buf = xstrdup (p);
free (p);
if (stat (buf, &st) < 0)
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
buf2 = xstrdup (buf);
num = st.st_dev;
/* This loop sets offset to the number of chars of the root
directory we're inspecting. */
while (1)
{
p = strrchr (buf, '/');
if (p == NULL)
/* This should never happen. */
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
if (p != buf)
*p = 0;
else
*++p = 0;
if (stat (buf, &st) < 0)
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
/* buf is another filesystem; we found it. */
if (st.st_dev != num)
{
/* offset == 0 means path given is the mount point.
This works around special-casing of "/" in Un*x. This function never
prints trailing slashes (so that its output can be appended a slash
unconditionally). Each slash in is considered a preceding slash, and
therefore the root directory is an empty string. */
if (offset == 0)
{
free (buf);
free (buf2);
return xstrdup ("");
}
else
break;
}
offset = p - buf;
/* offset == 1 means root directory. */
if (offset == 1)
{
free (buf);
len = strlen (buf2);
while (buf2[len - 1] == '/' && len > 1)
{
buf2[len - 1] = '\0';
len--;
}
if (len > 1)
return buf2;
else
{
/* This means path given is just a backslash. As above
we have to return an empty string. */
free (buf2);
return xstrdup ("");
}
}
}
free (buf);
buf3 = xstrdup (buf2 + offset);
free (buf2);
len = strlen (buf3);
while (buf3[len - 1] == '/' && len > 1)
{
buf3[len - 1] = '\0';
len--;
}
return buf3;
int i;
for (i = offs; i < len; i++)
if (winpath[i] == '\\')
winpath[i] = '/';
return xstrdup (winpath + offs);
}
#endif
#ifdef GRUB_UTIL
void

View file

@ -627,7 +627,8 @@ main (int argc, char *argv[])
find_dest_dev (&ginfo, argv);
ginfo.prefix = grub_get_prefix (ginfo.dir ? : DEFAULT_DIRECTORY);
ginfo.prefix = make_system_path_relative_to_its_root (ginfo.dir ?
: DEFAULT_DIRECTORY);
check_root_dev (&ginfo);