Merge branch 'makefile' into haiku
[grub2/phcoder.git] / util / grub.d / 30_os-prober.in
blobb36c2a3660fe1378d8fcb374a71f63ec58ed8ae0
1 #! /bin/sh -e
3 # grub-mkconfig helper script.
4 # Copyright (C) 2006,2007,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@
23 . ${libdir}/grub/grub-mkconfig_lib
25 if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
26 # missing os-prober and/or linux-boot-prober
27 exit 0
30 OSPROBED="`os-prober 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
31 if [ -z "${OSPROBED}" ] ; then
32 # empty os-prober output, nothing doing
33 exit 0
36 for OS in ${OSPROBED} ; do
37 DEVICE="`echo ${OS} | cut -d ':' -f 1`"
38 LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
39 LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
40 BOOT="`echo ${OS} | cut -d ':' -f 4`"
42 if [ -z "${LONGNAME}" ] ; then
43 LONGNAME="${LABEL}"
46 echo "Found ${LONGNAME} on ${DEVICE}" >&2
48 case ${BOOT} in
49 chain)
51 cat << EOF
52 menuentry "${LONGNAME} (on ${DEVICE})" {
53 EOF
54 prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
56 if [ "${LONGNAME}" != "Windows Vista (loader)" ] ; then
57 cat << EOF
58 drivemap -s (hd0) \${root}
59 EOF
61 cat <<EOF
62 chainloader +1
64 EOF
66 linux)
67 LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
69 for LINUX in ${LINUXPROBED} ; do
70 LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
71 LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
72 LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
73 LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
74 LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
75 LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
77 if [ -z "${LLABEL}" ] ; then
78 LLABEL="${LONGNAME}"
81 cat << EOF
82 menuentry "${LLABEL} (on ${DEVICE})" {
83 EOF
84 prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
85 cat << EOF
86 linux ${LKERNEL} ${LPARAMS}
87 EOF
88 if [ -n "${LINITRD}" ] ; then
89 cat << EOF
90 initrd ${LINITRD}
91 EOF
93 cat << EOF
95 EOF
96 done
98 macosx)
99 OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
100 cat << EOF
101 menuentry "${LONGNAME} (on ${DEVICE})" {
103 prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
104 cat << EOF
105 insmod vbe
106 do_resume=0
107 if [ /var/vm/sleepimage -nt10 / ]; then
108 if xnu_resume /var/vm/sleepimage; then
109 do_resume=1
112 if [ \$do_resume == 0 ]; then
113 xnu_uuid ${OSXUUID} uuid
114 if [ -f /Extra/DSDT.aml ]; then
115 acpi -e /Extra/DSDT.aml
117 xnu_kernel /mach_kernel boot-uuid=\${uuid} rd=*uuid
118 if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
119 xnu_mkext /System/Library/Extensions.mkext
120 else
121 xnu_kextdir /System/Library/Extensions
123 if [ -f /Extra/Extensions.mkext ]; then
124 xnu_mkext /Extra/Extensions.mkext
126 if [ -d /Extra/Extensions ]; then
127 xnu_kextdir /Extra/Extensions
129 if [ -f /Extra/devtree.txt ]; then
130 xnu_devtree /Extra/devtree.txt
132 if [ -f /Extra/splash.jpg ]; then
133 insmod jpeg
134 xnu_splash /Extra/splash.jpg
136 if [ -f /Extra/splash.png ]; then
137 insmod png
138 xnu_splash /Extra/splash.png
140 if [ -f /Extra/splash.tga ]; then
141 insmod tga
142 xnu_splash /Extra/splash.tga
148 hurd|*)
149 echo " ${LONGNAME} is not yet supported by grub-mkconfig." >&2
151 esac
152 done