4
# grub-mkconfig helper script.
5
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
7
# GRUB is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# GRUB is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21
exec_prefix="@exec_prefix@"
22
datarootdir="@datarootdir@"
24
export TEXTDOMAIN=@PACKAGE@
25
export TEXTDOMAINDIR="@localedir@"
27
. "$pkgdatadir/grub-mkconfig_lib"
29
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
33
if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then
34
# missing os-prober and/or linux-boot-prober
38
OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
39
if [ -z "${OSPROBED}" ] ; then
40
# empty os-prober output, nothing doing
45
if [ x$2 = x32 ]; then
46
# TRANSLATORS: it refers to kernel architecture (32-bit)
47
bitstr="$(gettext "(32-bit)")"
49
# TRANSLATORS: it refers to kernel architecture (64-bit)
50
bitstr="$(gettext "(64-bit)")"
52
# TRANSLATORS: it refers on the OS residing on device %s
53
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
55
menuentry '$(echo "${LONGNAME} $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' {
57
save_default_entry | grub_add_tab
58
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
62
if [ /var/vm/sleepimage -nt10 / ]; then
63
if xnu_resume /var/vm/sleepimage; then
67
if [ \$do_resume = 0 ]; then
68
xnu_uuid ${OSXUUID} uuid
69
if [ -f /Extra/DSDT.aml ]; then
70
acpi -e /Extra/DSDT.aml
72
if [ /kernelcache -nt /System/Library/Extensions ]; then
73
$1 /kernelcache boot-uuid=\${uuid} rd=*uuid
74
elif [ -f /System/Library/Kernels/kernel ]; then
75
$1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid
76
xnu_kextdir /System/Library/Extensions
78
$1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
79
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
80
xnu_mkext /System/Library/Extensions.mkext
82
xnu_kextdir /System/Library/Extensions
85
if [ -f /Extra/Extensions.mkext ]; then
86
xnu_mkext /Extra/Extensions.mkext
88
if [ -d /Extra/Extensions ]; then
89
xnu_kextdir /Extra/Extensions
91
if [ -f /Extra/devprop.bin ]; then
92
xnu_devprop_load /Extra/devprop.bin
94
if [ -f /Extra/splash.jpg ]; then
96
xnu_splash /Extra/splash.jpg
98
if [ -f /Extra/splash.png ]; then
100
xnu_splash /Extra/splash.png
102
if [ -f /Extra/splash.tga ]; then
104
xnu_splash /Extra/splash.tga
111
used_osprober_linux_ids=
113
for OS in ${OSPROBED} ; do
114
DEVICE="`echo ${OS} | cut -d ':' -f 1`"
115
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
116
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
117
BOOT="`echo ${OS} | cut -d ':' -f 4`"
118
if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
121
if [ x"${DEVICE#*@}" != x ] ; then
122
EXPUUID="${EXPUUID}@${DEVICE#*@}"
125
if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
126
echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
131
BTRFS="`echo ${OS} | cut -d ':' -f 5`"
132
if [ "x$BTRFS" = "xbtrfs" ]; then
133
BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`"
134
BTRFSsubvol="`echo ${OS} | cut -d ':' -f 7`"
137
if [ -z "${LONGNAME}" ] ; then
141
# os-prober returns text string followed by optional counter
142
CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
144
gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
149
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
151
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
153
save_default_entry | grub_add_tab
154
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
156
if [ x"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos ]; then
158
parttool \${root} hidden-
163
Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
167
drivemap -s (hd0) \${root}
181
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
183
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
185
save_default_entry | sed -e "s/^/\t/"
186
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
189
chainloader ${EFIPATH}
194
if [ "x$BTRFS" = "xbtrfs" ]; then
195
LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
197
LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
202
title_correction_code=
205
for LINUX in ${LINUXPROBED} ; do
206
LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
207
LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
208
LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
209
LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
210
LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
211
LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
213
if [ -z "${LLABEL}" ] ; then
217
if [ "${LROOT}" != "${LBOOT}" ]; then
218
LKERNEL="${LKERNEL#/boot}"
219
LINITRD="${LINITRD#/boot}"
222
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
223
recovery_params="$(echo "${LPARAMS}" | grep single)" || true
225
while echo "$used_osprober_linux_ids" | grep 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id' > /dev/null; do
226
counter=$((counter+1));
228
if [ -z "$boot_device_id" ]; then
229
boot_device_id="$(grub_get_device_id "${DEVICE}")"
231
used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'"
233
if [ -z "${prepare_boot_cache}" ]; then
234
prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)"
237
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
239
menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
241
save_default_entry | grub_add_tab
242
printf '%s\n' "${prepare_boot_cache}"
244
linux ${LKERNEL} ${LPARAMS}
246
if [ -n "${LINITRD}" ] ; then
254
echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
257
title="${LLABEL} $onstr"
259
menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' {
261
save_default_entry | sed -e "s/^/$grub_tab$grub_tab/"
262
printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
264
linux ${LKERNEL} ${LPARAMS}
266
if [ -n "${LINITRD}" ] ; then
274
if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
275
replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
276
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
277
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
278
grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
281
if [ x"$is_top_level" != xtrue ]; then
284
echo "$title_correction_code"
287
if [ "${UUID}" ]; then
289
osx_entry xnu_kernel 32
290
osx_entry xnu_kernel64 64
294
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
296
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' {
298
save_default_entry | grub_add_tab
299
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
300
grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
301
mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`"
302
grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
304
*fs) hurd_fs="${grub_fs}" ;;
305
*) hurd_fs="${grub_fs}fs" ;;
308
multiboot /boot/gnumach.gz root=device:${mach_device}
309
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
310
--multiboot-command-line='\${kernel-command-line}' \\
311
--host-priv-port='\${host-port}' \\
312
--device-master-port='\${device-port}' \\
313
--exec-server-task='\${exec-task}' -T typed '\${root}' \\
314
'\$(task-create)' '\$(task-resume)'
315
module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
321
menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
323
save_default_entry | sed -e "s/^/\t/"
324
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
326
multiboot /boot/image_latest
331
# TRANSLATORS: %s is replaced by OS name.
332
gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2