merged with upstream

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-11-02 23:29:51 +01:00
commit 6174923799
30 changed files with 527 additions and 230 deletions

View file

@ -72,7 +72,7 @@ usage (int status)
fprintf (stderr, "Try ``grub-editenv --help'' for more information.\n");
else
printf ("\
Usage: grub-editenv [OPTIONS] FILENAME COMMAND\n\
Usage: grub-editenv [OPTIONS] [FILENAME] COMMAND\n\
\n\
Tool to edit environment block.\n\
\nCommands:\n\
@ -85,7 +85,10 @@ Tool to edit environment block.\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
If not given explicitly, FILENAME defaults to %s.\n\
\n\
Report bugs to <%s>.\n",
DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT);
exit (status);
}
@ -288,12 +291,14 @@ main (int argc, char *argv[])
if (optind + 1 >= argc)
{
fprintf (stderr, "no command specified\n");
usage (1);
filename = DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG;
command = argv[optind];
}
else
{
filename = argv[optind];
command = argv[optind + 1];
}
filename = argv[optind];
command = argv[optind + 1];
if (strcmp (command, "create") == 0)
create_envblk_file (filename);

View file

@ -1,76 +0,0 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2008,2009 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@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
case "${GRUB_DISTRIBUTOR}" in
Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
*) OS="FreeBSD" ;;
esac
if test -e /boot/device.hints ; then
devices=/boot/device.hints
fi
if test -e /boot/kernel/kernel ; then
kfreebsd=/boot/kernel/kernel
fi
if test -e /boot/kernel/kernel.gz ; then
kfreebsd=/boot/kernel/kernel.gz
fi
if [ "x$kfreebsd" != "x" ] ; then
echo "Found kernel of FreeBSD: $kfreebsd" >&2
kfreebsd_basename=`basename $kfreebsd`
kfreebsd_dirname=`dirname $kfreebsd`
kfreebsd_rel_dirname=`make_system_path_relative_to_its_root $kfreebsd_dirname`
if [ x"$devices" != "x" ] ; then
devices_basename=`basename $devices`
devices_dirname=`dirname $devices`
devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
fi
case ${GRUB_FS} in
ufs1 | ufs2) kfreebsd_fs=ufs ;;
*) kfreebsd_fs=${GRUB_FS} ;;
esac
cat << EOF
menuentry "${OS}" {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
kfreebsd ${kfreebsd_rel_dirname}/${kfreebsd_basename}
EOF
if [ x"$devices" != "x" ] ; then
cat << EOF
kfreebsd_loadenv ${devices_rel_dirname}/${devices_basename}
EOF
fi
cat << EOF
set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE}
set kFreeBSD.vfs.root.mountfrom.options=rw
}
EOF
fi

View file

@ -71,15 +71,18 @@ fi
cat << EOF
menuentry "${OS}" {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
cat << EOF
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
EOF
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
cat << EOF
multiboot ${kernel} root=device:${GRUB_DEVICE}
module /hurd/${hurd_fs}.static --readonly \\
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
--device-master-port='\${device-port}' \\
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
'\$(task-create)' '\$(task-resume)'
module /lib/ld.so.1 /hurd/exec '\$(exec-task=task-create)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF

106
util/grub.d/10_kfreebsd.in Normal file
View file

@ -0,0 +1,106 @@
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 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@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
case "${GRUB_DISTRIBUTOR}" in
Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
*) OS="FreeBSD" ;;
esac
kfreebsd_entry ()
{
cat << EOF
menuentry "$1" {
EOF
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
kfreebsd ${rel_dirname}/${basename}
EOF
if test -n "${devices}" ; then
cat << EOF
kfreebsd_loadenv ${devices_rel_dirname}/${devices_basename}
EOF
fi
if test -n "${acpi_ko}" ; then
cat << EOF
kfreebsd_module_elf ${acpi_ko_rel_dirname}/${acpi_ko_basename}
EOF
fi
cat << EOF
set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE}
set kFreeBSD.vfs.root.mountfrom.options=rw
}
EOF
}
list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
prepare_boot_cache=
while [ "x$list" != "x" ] ; do
kfreebsd=`version_find_latest $list`
echo "Found kernel of FreeBSD: $kfreebsd" >&2
basename=`basename $kfreebsd`
dirname=`dirname $kfreebsd`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
if [ -f /boot/device.hints ] ; then
devices=/boot/device.hints
devices_basename=`basename $devices`
devices_dirname=`dirname $devices`
devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
fi
case ${GRUB_FS} in
ufs1 | ufs2) kfreebsd_fs=ufs ;;
*) kfreebsd_fs=${GRUB_FS} ;;
esac
version=`echo $basename | sed -e "s,^[^0-9]*-,,g;s/\.gz$//g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
acpi_ko=
for i in "/lib/modules/${version}/acpi.ko" "/lib/modules/${alt_version}/acpi.ko" \
"/boot/kernel/acpi.ko"; do
if test -e "$i" ; then
acpi_ko="$i"
break
fi
done
if test -n "${acpi_ko}" ; then
echo "Found ACPI module: ${acpi_ko}" >&2
acpi_ko_basename=`basename ${acpi_ko}`
acpi_ko_dirname=`dirname ${acpi_ko}`
acpi_ko_rel_dirname=`make_system_path_relative_to_its_root $acpi_ko_dirname`
fi
kfreebsd_entry "${OS}, kFreeBSD ${version}"
list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '`
done

View file

@ -47,7 +47,10 @@ linux_entry ()
cat << EOF
menuentry "$1" {
EOF
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | 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
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2
EOF
@ -64,6 +67,7 @@ EOF
list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
prepare_boot_cache=
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`

View file

@ -74,6 +74,7 @@ EOF
;;
linux)
LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
prepare_boot_cache=
for LINUX in ${LINUXPROBED} ; do
LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
@ -90,7 +91,10 @@ EOF
cat << EOF
menuentry "${LLABEL} (on ${DEVICE})" {
EOF
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linux ${LKERNEL} ${LPARAMS}
EOF
@ -155,7 +159,28 @@ EOF
EOF
;;
hurd|*)
echo " ${LONGNAME} is not yet supported by grub-mkconfig." >&2
cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
EOF
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
mach_device="`echo "${grub_device}" | tr -d '()' | tr , s`"
grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
case "${grub_fs}" in
*fs) hurd_fs="${grub_fs}" ;;
*) hurd_fs="${grub_fs}fs" ;;
esac
cat << EOF
multiboot /boot/gnumach.gz root=device:${mach_device}
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
--multiboot-command-line='\${kernel-command-line}' \\
--host-priv-port='\${host-port}' \\
--device-master-port='\${device-port}' \\
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
'\$(task-create)' '\$(task-resume)'
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF
;;
esac
done

View file

@ -1057,7 +1057,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
n = strtol (p, &q, 10);
if (p != q && n != GRUB_LONG_MIN && n != GRUB_LONG_MAX)
{
dos_part = (int) n;
dos_part = (int) n - 1;
if (*q >= 'a' && *q <= 'g')
bsd_part = *q - 'a';

View file

@ -319,14 +319,7 @@ else
$grub_mkimage -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
fi
# Prompt the user to check if the device map is correct.
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
cat $device_map
# Bye.
exit 0

View file

@ -86,7 +86,7 @@ grub_refresh (void)
static void
setup (const char *dir,
const char *boot_file, const char *core_file,
const char *root, const char *dest, int must_embed, int force)
const char *root, const char *dest, int must_embed, int force, int fs_probe)
{
char *boot_path, *core_path, *core_path_dev;
char *boot_img, *core_img;
@ -251,6 +251,22 @@ setup (const char *dir,
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
grub_util_error ("%s", grub_errmsg);
if (dest_dev->disk->partition && fs_probe)
{
grub_fs_t fs;
fs = grub_fs_probe (dest_dev);
if (! fs)
grub_util_error ("Unable to identify a filesystem in %s; safety check can't be performed.",
dest_dev->disk->name);
if (! fs->reserved_first_sector)
grub_util_error ("%s appears to contain a %s filesystem which isn't known to "
"reserve space for DOS-style boot. Installing GRUB there could "
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
"by grub-setup (--skip-fs-probe disables this "
"check, use at your own risk).", dest_dev->disk->name, fs->name);
}
/* Copy the possible DOS BPB. */
memcpy (boot_img + GRUB_BOOT_MACHINE_BPB_START,
tmp_img + GRUB_BOOT_MACHINE_BPB_START,
@ -556,6 +572,7 @@ static struct option options[] =
{"device-map", required_argument, 0, 'm'},
{"root-device", required_argument, 0, 'r'},
{"force", no_argument, 0, 'f'},
{"skip-fs-probe", no_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
@ -580,6 +597,7 @@ DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
-r, --root-device=DEV use DEV as the root device [default=guessed]\n\
-f, --force install even if problems are detected\n\
-s, --skip-fs-probe do not probe for filesystems in DEVICE\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
@ -613,7 +631,7 @@ main (int argc, char *argv[])
char *dev_map = 0;
char *root_dev = 0;
char *dest_dev;
int must_embed = 0, force = 0;
int must_embed = 0, force = 0, fs_probe = 1;
progname = "grub-setup";
@ -666,6 +684,10 @@ main (int argc, char *argv[])
force = 1;
break;
case 's':
fs_probe = 0;
break;
case 'h':
usage (0);
break;
@ -767,7 +789,7 @@ main (int argc, char *argv[])
setup (dir ? : DEFAULT_DIRECTORY,
boot_file ? : DEFAULT_BOOT_FILE,
core_file ? : DEFAULT_CORE_FILE,
root_dev, grub_util_get_grub_dev (devicelist[i]), 1, force);
root_dev, grub_util_get_grub_dev (devicelist[i]), 1, force, fs_probe);
}
}
else
@ -776,7 +798,7 @@ main (int argc, char *argv[])
setup (dir ? : DEFAULT_DIRECTORY,
boot_file ? : DEFAULT_BOOT_FILE,
core_file ? : DEFAULT_CORE_FILE,
root_dev, dest_dev, must_embed, force);
root_dev, dest_dev, must_embed, force, fs_probe);
/* Free resources. */
grub_fini_all ();