Merge branch 'makefile' into haiku
[grub2/phcoder.git] / util / grub.d / 10_freebsd.in
blob2addf03a1542655759357d7f387cffb44c7b87e2
1 #! /bin/sh -e
3 # grub-mkconfig helper script.
4 # Copyright (C) 2008,2009 Free Software Foundation, Inc.
6 # GRUB is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # GRUB is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 prefix=@prefix@
20 exec_prefix=@exec_prefix@
21 libdir=@libdir@
22 . ${libdir}/grub/grub-mkconfig_lib
24 case "${GRUB_DISTRIBUTOR}" in
25 Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
26 *) OS="FreeBSD" ;;
27 esac
29 if test -e /boot/device.hints ; then
30 devices=/boot/device.hints
33 if test -e /boot/kernel/kernel ; then
34 kfreebsd=/boot/kernel/kernel
36 if test -e /boot/kernel/kernel.gz ; then
37 kfreebsd=/boot/kernel/kernel.gz
40 if [ "x$kfreebsd" != "x" ] ; then
41 echo "Found kernel of FreeBSD: $kfreebsd" >&2
43 kfreebsd_basename=`basename $kfreebsd`
44 kfreebsd_dirname=`dirname $kfreebsd`
45 kfreebsd_rel_dirname=`make_system_path_relative_to_its_root $kfreebsd_dirname`
47 if [ x"$devices" != "x" ] ; then
48 devices_basename=`basename $devices`
49 devices_dirname=`dirname $devices`
50 devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
53 root_device=`basename ${GRUB_DEVICE}`
55 # For "ufs" it's the same. Do we care about the others?
56 kfreebsd_fs=${GRUB_FS}
58 cat << EOF
59 menuentry "${OS}" {
60 EOF
61 prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
62 cat << EOF
63 freebsd ${kfreebsd_rel_dirname}/${kfreebsd_basename}
64 EOF
66 if [ x"$devices" != "x" ] ; then
67 cat << EOF
68 freebsd_loadenv ${devices_rel_dirname}/${devices_basename}
69 EOF
71 cat << EOF
72 set FreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${root_device}
74 EOF