2008-11-04 Robert Millan <rmh@aybabtu.com>
[grub2/phcoder/solaris.git] / util / grub.d / 10_freebsd.in
blob61d5450b1c53a97849e7520d9f071a0c71fbf0c0
1 #! /bin/sh -e
3 # grub-mkconfig helper script.
4 # Copyright (C) 2008 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 devices=/boot/devices.hints
25 if ! test -e ${devices} ; then
26 # not FreeBSD
27 exit 0
30 if test -e /boot/kernel/kernel ; then
31 kfreebsd=/boot/kernel/kernel
34 if [ "x$kfreebsd" != "x" ] ; then
35 echo "Found kernel of FreeBSD: $kfreebsd" >&2
37 kfreebsd_basename=`basename $kfreebsd`
38 kfreebsd_dirname=`dirname $kfreebsd`
39 kfreebsd_rel_dirname=`make_system_path_relative_to_its_root $kfreebsd_dirname`
41 devices_basename=`basename $devices`
42 devices_dirname=`dirname $devices`
43 devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
45 root_device=`basename ${GRUB_DEVICE}`
47 # For "ufs" it's the same. Do we care about the others?
48 kfreebsd_fs=${GRUB_FS}
50 cat << EOF
51 menuentry "FreeBSD" {
52 EOF
53 prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
54 cat << EOF
55 freebsd ${kfreebsd_rel_dirname}/${kfreebsd_basename}
56 freebsd_loadenv ${devices_rel_dirname}/${devices_basename}
57 set FreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${root_device}
59 EOF