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@"
23 quick_boot
="@QUICK_BOOT@"
25 export TEXTDOMAIN
=@PACKAGE@
26 export TEXTDOMAINDIR
="@localedir@"
28 .
"@datadir@/@PACKAGE@/grub-mkconfig_lib"
33 if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
35 set timeout_style=menu
36 if [ "\${timeout}" = 0 ]; then
43 if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
47 if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
48 # missing os-prober and/or linux-boot-prober
52 OSPROBED
="`os-prober | tr ' ' '^' | paste -s -d ' '`"
53 if [ -z "${OSPROBED}" ] ; then
54 # empty os-prober output, nothing doing
60 if [ x
$2 = x32
]; then
61 # TRANSLATORS: it refers to kernel architecture (32-bit)
62 bitstr
="$(gettext "(32-bit)")"
64 # TRANSLATORS: it refers to kernel architecture (64-bit)
65 bitstr
="$(gettext "(64-bit)")"
67 # TRANSLATORS: it refers on the OS residing on device %s
68 onstr
="$(gettext_printf "(on
%s
)" "${DEVICE}")"
70 menuentry '$(echo "${LONGNAME} $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' {
72 save_default_entry | grub_add_tab
73 prepare_grub_to_access_device
${DEVICE} | grub_add_tab
77 if [ /var/vm/sleepimage -nt10 / ]; then
78 if xnu_resume /var/vm/sleepimage; then
82 if [ \$do_resume = 0 ]; then
83 xnu_uuid ${OSXUUID} uuid
84 if [ -f /Extra/DSDT.aml ]; then
85 acpi -e /Extra/DSDT.aml
87 if [ /kernelcache -nt /System/Library/Extensions ]; then
88 $1 /kernelcache boot-uuid=\${uuid} rd=*uuid
90 $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
91 if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
92 xnu_mkext /System/Library/Extensions.mkext
94 xnu_kextdir /System/Library/Extensions
97 if [ -f /Extra/Extensions.mkext ]; then
98 xnu_mkext /Extra/Extensions.mkext
100 if [ -d /Extra/Extensions ]; then
101 xnu_kextdir /Extra/Extensions
103 if [ -f /Extra/devprop.bin ]; then
104 xnu_devprop_load /Extra/devprop.bin
106 if [ -f /Extra/splash.jpg ]; then
108 xnu_splash /Extra/splash.jpg
110 if [ -f /Extra/splash.png ]; then
112 xnu_splash /Extra/splash.png
114 if [ -f /Extra/splash.tga ]; then
116 xnu_splash /Extra/splash.tga
123 used_osprober_linux_ids
=
127 for OS
in ${OSPROBED} ; do
128 DEVICE
="`echo ${OS} | cut -d ':' -f 1`"
129 LONGNAME
="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
130 LABEL
="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
131 BOOT
="`echo ${OS} | cut -d ':' -f 4`"
132 if UUID
="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
135 if [ x
"${DEVICE#*@}" != x
] ; then
136 EXPUUID
="${EXPUUID}@${DEVICE#*@}"
139 if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" -a "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
140 echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
145 BTRFS
="`echo ${OS} | cut -d ':' -f 5`"
146 if [ "x$BTRFS" = "xbtrfs" ]; then
147 BTRFSuuid
="`echo ${OS} | cut -d ':' -f 6`"
148 BTRFSsubvol
="`echo ${OS} | cut -d ':' -f 7`"
151 if [ -z "${LONGNAME}" ] ; then
155 gettext_printf
"Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
162 if [ -z "$wubi" ]; then
163 if [ -x /usr
/share
/lupin-support
/grub-mkimage
] && \
164 /usr
/share
/lupin-support
/grub-mkimage
--test; then
170 if [ "$wubi" = yes ]; then
171 echo "Skipping ${LONGNAME} on Wubi system" >&2
178 onstr
="$(gettext_printf "(on
%s
)" "${DEVICE}")"
180 menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
182 save_default_entry | grub_add_tab
183 prepare_grub_to_access_device
${DEVICE} | grub_add_tab
185 if [ x
"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos
]; then
187 parttool \${root} hidden-
192 Windows\ Vista
*|Windows\
7*|Windows\ Server\
2008*)
196 drivemap -s (hd0) \${root}
211 onstr
="$(gettext_printf "(on
%s
)" "${DEVICE}")"
213 menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
215 save_default_entry |
sed -e "s/^/\t/"
216 prepare_grub_to_access_device
${DEVICE} |
sed -e "s/^/\t/"
219 chainloader ${EFIPATH}
224 if [ "x$BTRFS" = "xbtrfs" ]; then
225 LINUXPROBED
="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
227 LINUXPROBED
="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
232 title_correction_code
=
235 for LINUX
in ${LINUXPROBED} ; do
236 LROOT
="`echo ${LINUX} | cut -d ':' -f 1`"
237 LBOOT
="`echo ${LINUX} | cut -d ':' -f 2`"
238 LLABEL
="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
239 LKERNEL
="`echo ${LINUX} | cut -d ':' -f 4`"
240 LINITRD
="`echo ${LINUX} | cut -d ':' -f 5`"
241 LPARAMS
="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
243 if [ -z "${LLABEL}" ] ; then
247 if [ "${LROOT}" != "${LBOOT}" ]; then
248 LKERNEL
="${LKERNEL#/boot}"
249 LINITRD
="${LINITRD#/boot}"
252 if [ -z "${prepare_boot_cache}" ]; then
253 prepare_boot_cache
="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)"
254 [ "${prepare_boot_cache}" ] ||
continue
258 onstr
="$(gettext_printf "(on
%s
)" "${DEVICE}")"
259 recovery_params
="$(echo "${LPARAMS}" | grep 'single\|recovery')" || true
261 while echo "$used_osprober_linux_ids" |
grep 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id' > /dev
/null
; do
262 counter
=$
((counter
+1));
264 if [ -z "$boot_device_id" ]; then
265 boot_device_id
="$(grub_get_device_id "${DEVICE}")"
267 used_osprober_linux_ids
="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'"
269 if [ "x$is_top_level" = xtrue
] && [ "x${GRUB_DISABLE_SUBMENU}" != xy
]; then
271 menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
273 save_default_entry | grub_add_tab
274 printf '%s\n' "${prepare_boot_cache}"
276 linux ${LKERNEL} ${LPARAMS}
278 if [ -n "${LINITRD}" ] ; then
286 echo "submenu '$(gettext_printf "Advanced options
for %s
" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
289 title
="${LLABEL} $onstr"
291 menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' {
293 save_default_entry |
sed -e "s/^/$grub_tab$grub_tab/"
294 printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
296 linux ${LKERNEL} ${LPARAMS}
298 if [ -n "${LINITRD}" ] ; then
306 if [ x
"$title" = x
"$GRUB_ACTUAL_DEFAULT" ] ||
[ x
"Previous Linux versions>$title" = x
"$GRUB_ACTUAL_DEFAULT" ]; then
307 replacement_title
="$(echo "Advanced options
for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
308 quoted
="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
309 title_correction_code
="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
310 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")"
313 if [ x"$is_top_level" != xtrue ]; then
316 echo "$title_correction_code"
319 if [ "${UUID}" ]; then
321 osx_entry xnu_kernel 32
322 osx_entry xnu_kernel64 64
327 onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
329 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}")' {
331 save_default_entry | grub_add_tab
332 prepare_grub_to_access_device ${DEVICE} | grub_add_tab
333 grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
334 mach_device="`echo "${grub_device}" | sed -e 's
/(\
(hd.
*\
),msdos\
(.
*\
))/\
1s\
2/'`"
335 grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
337 *fs) hurd_fs="${grub_fs}" ;;
338 *) hurd_fs="${grub_fs}fs" ;;
341 multiboot /boot/gnumach.gz root=device:${mach_device}
342 module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
343 --multiboot-command-line='\
${kernel-command-line}' \\
344 --host-priv-port='\
${host-port}' \\
345 --device-master-port='\
${device-port}' \\
346 --exec-server-task='\
${exec-task}' -T typed '\
${root}' \\
347 '\$
(task-create
)' '\$
(task-resume
)'
348 module /lib/ld.so.1 exec /hurd/exec '\$
(exec-task
=task-create
)'
354 menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
356 save_default_entry | sed -e "s/^/\t/"
357 prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
359 multiboot /boot/image_latest
365 # TRANSLATORS: %s is replaced by OS name.
366 gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2