]>
Commit | Line | Data |
---|---|---|
78b51059 | 1 | #! /bin/sh -e |
2 | ||
25ad2323 | 3 | # grub-mkconfig helper script. |
4 | # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. | |
78b51059 | 5 | # |
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. | |
10 | # | |
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. | |
15 | # | |
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/>. | |
18 | ||
25ad2323 | 19 | prefix=@prefix@ |
20 | exec_prefix=@exec_prefix@ | |
21 | libdir=@libdir@ | |
22 | ||
23 | . ${libdir}/grub/grub-mkconfig_lib | |
24 | ||
c8c80635 | 25 | if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then |
26 | exit 0 | |
27 | fi | |
28 | ||
78b51059 | 29 | if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then |
30 | # missing os-prober and/or linux-boot-prober | |
31 | exit 0 | |
32 | fi | |
33 | ||
a83d079b | 34 | OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" |
78b51059 | 35 | if [ -z "${OSPROBED}" ] ; then |
36 | # empty os-prober output, nothing doing | |
37 | exit 0 | |
38 | fi | |
39 | ||
40 | for OS in ${OSPROBED} ; do | |
41 | DEVICE="`echo ${OS} | cut -d ':' -f 1`" | |
42 | LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" | |
43 | LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`" | |
44 | BOOT="`echo ${OS} | cut -d ':' -f 4`" | |
45 | ||
46 | if [ -z "${LONGNAME}" ] ; then | |
47 | LONGNAME="${LABEL}" | |
48 | fi | |
49 | ||
50 | echo "Found ${LONGNAME} on ${DEVICE}" >&2 | |
51 | ||
52 | case ${BOOT} in | |
53 | chain) | |
78b51059 | 54 | |
55 | cat << EOF | |
56 | menuentry "${LONGNAME} (on ${DEVICE})" { | |
25ad2323 | 57 | EOF |
58 | prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" | |
59 | ||
d52109a7 | 60 | case ${LONGNAME} in |
61 | Windows\ Vista*|Windows\ 7*) | |
62 | ;; | |
63 | *) | |
64 | cat << EOF | |
b97bcb19 | 65 | drivemap -s (hd0) \${root} |
6a6cbcaf | 66 | EOF |
d52109a7 | 67 | ;; |
68 | esac | |
69 | ||
6a6cbcaf | 70 | cat <<EOF |
78b51059 | 71 | chainloader +1 |
72 | } | |
73 | EOF | |
74 | ;; | |
75 | linux) | |
76 | LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`" | |
e4f6809b | 77 | prepare_boot_cache= |
b39f9d20 | 78 | |
78b51059 | 79 | for LINUX in ${LINUXPROBED} ; do |
80 | LROOT="`echo ${LINUX} | cut -d ':' -f 1`" | |
81 | LBOOT="`echo ${LINUX} | cut -d ':' -f 2`" | |
82 | LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`" | |
83 | LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`" | |
84 | LINITRD="`echo ${LINUX} | cut -d ':' -f 5`" | |
85 | LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`" | |
86 | ||
78b51059 | 87 | if [ -z "${LLABEL}" ] ; then |
88 | LLABEL="${LONGNAME}" | |
89 | fi | |
90 | ||
91 | cat << EOF | |
92 | menuentry "${LLABEL} (on ${DEVICE})" { | |
25ad2323 | 93 | EOF |
e4f6809b | 94 | if [ -z "${prepare_boot_cache}" ]; then |
95 | prepare_boot_cache="$(prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/")" | |
96 | fi | |
97 | printf '%s\n' "${prepare_boot_cache}" | |
25ad2323 | 98 | cat << EOF |
78b51059 | 99 | linux ${LKERNEL} ${LPARAMS} |
100 | EOF | |
101 | if [ -n "${LINITRD}" ] ; then | |
102 | cat << EOF | |
103 | initrd ${LINITRD} | |
104 | EOF | |
105 | fi | |
106 | cat << EOF | |
107 | } | |
108 | EOF | |
109 | done | |
110 | ;; | |
bbee0f2b | 111 | macosx) |
693fe637 | 112 | OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`" |
bbee0f2b | 113 | cat << EOF |
114 | menuentry "${LONGNAME} (on ${DEVICE})" { | |
25ad2323 | 115 | EOF |
116 | prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" | |
117 | cat << EOF | |
bbee0f2b | 118 | insmod vbe |
bbee0f2b | 119 | do_resume=0 |
120 | if [ /var/vm/sleepimage -nt10 / ]; then | |
121 | if xnu_resume /var/vm/sleepimage; then | |
122 | do_resume=1 | |
123 | fi | |
124 | fi | |
125 | if [ \$do_resume == 0 ]; then | |
693fe637 | 126 | xnu_uuid ${OSXUUID} uuid |
bbee0f2b | 127 | if [ -f /Extra/DSDT.aml ]; then |
128 | acpi -e /Extra/DSDT.aml | |
129 | fi | |
693fe637 | 130 | xnu_kernel /mach_kernel boot-uuid=\${uuid} rd=*uuid |
bbee0f2b | 131 | if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then |
132 | xnu_mkext /System/Library/Extensions.mkext | |
133 | else | |
134 | xnu_kextdir /System/Library/Extensions | |
135 | fi | |
136 | if [ -f /Extra/Extensions.mkext ]; then | |
137 | xnu_mkext /Extra/Extensions.mkext | |
138 | fi | |
139 | if [ -d /Extra/Extensions ]; then | |
140 | xnu_kextdir /Extra/Extensions | |
141 | fi | |
142 | if [ -f /Extra/devtree.txt ]; then | |
143 | xnu_devtree /Extra/devtree.txt | |
144 | fi | |
145 | if [ -f /Extra/splash.jpg ]; then | |
146 | insmod jpeg | |
147 | xnu_splash /Extra/splash.jpg | |
148 | fi | |
149 | if [ -f /Extra/splash.png ]; then | |
150 | insmod png | |
151 | xnu_splash /Extra/splash.png | |
152 | fi | |
153 | if [ -f /Extra/splash.tga ]; then | |
154 | insmod tga | |
155 | xnu_splash /Extra/splash.tga | |
156 | fi | |
157 | fi | |
158 | } | |
159 | EOF | |
160 | ;; | |
78b51059 | 161 | hurd|*) |
4f9dfb37 | 162 | cat << EOF |
163 | menuentry "${LONGNAME} (on ${DEVICE})" { | |
164 | EOF | |
165 | prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" | |
166 | grub_device="`${grub_probe} --device ${DEVICE} --target=drive`" | |
167 | mach_device="`echo "${grub_device}" | tr -d '()' | tr , s`" | |
168 | grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`" | |
169 | case "${grub_fs}" in | |
170 | *fs) hurd_fs="${grub_fs}" ;; | |
171 | *) hurd_fs="${grub_fs}fs" ;; | |
172 | esac | |
173 | cat << EOF | |
174 | multiboot /boot/gnumach.gz root=device:${mach_device} | |
175 | module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ | |
176 | --multiboot-command-line='\${kernel-command-line}' \\ | |
177 | --host-priv-port='\${host-port}' \\ | |
178 | --device-master-port='\${device-port}' \\ | |
179 | --exec-server-task='\${exec-task}' -T typed '\${root}' \\ | |
180 | '\$(task-create)' '\$(task-resume)' | |
181 | module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)' | |
182 | } | |
183 | EOF | |
78b51059 | 184 | ;; |
185 | esac | |
186 | done |