| 192 |
- |
1 |
#! /bin/sh
|
|
|
2 |
set -e
|
|
|
3 |
|
|
|
4 |
# grub-mkconfig helper script.
|
|
|
5 |
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
|
|
6 |
#
|
|
|
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.
|
|
|
11 |
#
|
|
|
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.
|
|
|
16 |
#
|
|
|
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/>.
|
|
|
19 |
|
|
|
20 |
prefix="/usr"
|
|
|
21 |
exec_prefix="/usr"
|
|
|
22 |
datarootdir="/usr/share"
|
|
|
23 |
grub_lang=`echo $LANG | cut -d . -f 1`
|
|
|
24 |
|
|
|
25 |
export TEXTDOMAIN=grub
|
|
|
26 |
export TEXTDOMAINDIR="${datarootdir}/locale"
|
|
|
27 |
|
|
|
28 |
. "$pkgdatadir/grub-mkconfig_lib"
|
|
|
29 |
|
|
|
30 |
if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
|
|
|
31 |
[ "x${GRUB_FS}" = "xbtrfs" ] ; then
|
|
|
32 |
cat <<EOF
|
|
|
33 |
set btrfs_relative_path="y"
|
|
|
34 |
export btrfs_relative_path
|
|
|
35 |
EOF
|
|
|
36 |
fi
|
|
|
37 |
|
|
|
38 |
# Do this as early as possible, since other commands might depend on it.
|
|
|
39 |
# (e.g. the `loadfont' command might need lvm or raid modules)
|
|
|
40 |
for i in ${GRUB_PRELOAD_MODULES} ; do
|
|
|
41 |
echo "insmod $i"
|
|
|
42 |
done
|
|
|
43 |
|
|
|
44 |
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
|
|
|
45 |
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
|
|
|
46 |
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
|
|
|
47 |
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
|
|
|
48 |
|
|
|
49 |
if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
|
|
|
50 |
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
|
|
|
51 |
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
|
|
|
52 |
|
|
|
53 |
cat << EOF
|
|
|
54 |
set pager=1
|
|
|
55 |
|
|
|
56 |
if [ -f \${config_directory}/grubenv ]; then
|
|
|
57 |
load_env -f \${config_directory}/grubenv
|
|
|
58 |
elif [ -s \$prefix/grubenv ]; then
|
|
|
59 |
load_env
|
|
|
60 |
fi
|
|
|
61 |
EOF
|
|
|
62 |
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
|
|
63 |
cat <<EOF
|
|
|
64 |
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
|
|
65 |
set default="${GRUB_DEFAULT_BUTTON}"
|
|
|
66 |
elif [ "\${next_entry}" ] ; then
|
|
|
67 |
set default="\${next_entry}"
|
|
|
68 |
set next_entry=
|
|
|
69 |
save_env next_entry
|
|
|
70 |
set boot_once=true
|
|
|
71 |
else
|
|
|
72 |
set default="${GRUB_DEFAULT}"
|
|
|
73 |
fi
|
|
|
74 |
EOF
|
|
|
75 |
else
|
|
|
76 |
cat <<EOF
|
|
|
77 |
if [ "\${next_entry}" ] ; then
|
|
|
78 |
set default="\${next_entry}"
|
|
|
79 |
set next_entry=
|
|
|
80 |
save_env next_entry
|
|
|
81 |
set boot_once=true
|
|
|
82 |
else
|
|
|
83 |
set default="${GRUB_DEFAULT}"
|
|
|
84 |
fi
|
|
|
85 |
EOF
|
|
|
86 |
fi
|
|
|
87 |
cat <<EOF
|
|
|
88 |
|
|
|
89 |
if [ x"\${feature_menuentry_id}" = xy ]; then
|
|
|
90 |
menuentry_id_option="--id"
|
|
|
91 |
else
|
|
|
92 |
menuentry_id_option=""
|
|
|
93 |
fi
|
|
|
94 |
|
|
|
95 |
export menuentry_id_option
|
|
|
96 |
|
|
|
97 |
if [ "\${prev_saved_entry}" ]; then
|
|
|
98 |
set saved_entry="\${prev_saved_entry}"
|
|
|
99 |
save_env saved_entry
|
|
|
100 |
set prev_saved_entry=
|
|
|
101 |
save_env prev_saved_entry
|
|
|
102 |
set boot_once=true
|
|
|
103 |
fi
|
|
|
104 |
|
|
|
105 |
function savedefault {
|
|
|
106 |
if [ -z "\${boot_once}" ]; then
|
|
|
107 |
saved_entry="\${chosen}"
|
|
|
108 |
save_env saved_entry
|
|
|
109 |
fi
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
function load_video {
|
|
|
113 |
EOF
|
|
|
114 |
if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
|
|
|
115 |
cat <<EOF
|
|
|
116 |
insmod ${GRUB_VIDEO_BACKEND}
|
|
|
117 |
EOF
|
|
|
118 |
else
|
|
|
119 |
# If all_video.mod isn't available load all modules available
|
|
|
120 |
# with versions prior to introduction of all_video.mod
|
|
|
121 |
cat <<EOF
|
|
|
122 |
if [ x\$feature_all_video_module = xy ]; then
|
|
|
123 |
insmod all_video
|
|
|
124 |
else
|
|
|
125 |
insmod efi_gop
|
|
|
126 |
insmod efi_uga
|
|
|
127 |
insmod ieee1275_fb
|
|
|
128 |
insmod vbe
|
|
|
129 |
insmod vga
|
|
|
130 |
insmod video_bochs
|
|
|
131 |
insmod video_cirrus
|
|
|
132 |
fi
|
|
|
133 |
EOF
|
|
|
134 |
fi
|
|
|
135 |
cat <<EOF
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
EOF
|
|
|
139 |
|
|
|
140 |
serial=0;
|
|
|
141 |
gfxterm=0;
|
|
|
142 |
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
|
|
143 |
if [ xserial = "x$x" ]; then
|
|
|
144 |
serial=1;
|
|
|
145 |
fi
|
|
|
146 |
if [ xgfxterm = "x$x" ]; then
|
|
|
147 |
gfxterm=1;
|
|
|
148 |
fi
|
|
|
149 |
done
|
|
|
150 |
|
|
|
151 |
if [ "x$serial" = x1 ]; then
|
|
|
152 |
if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
|
|
|
153 |
grub_warn "$(gettext "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used.")"
|
|
|
154 |
GRUB_SERIAL_COMMAND=serial
|
|
|
155 |
fi
|
|
|
156 |
echo "${GRUB_SERIAL_COMMAND}"
|
|
|
157 |
fi
|
|
|
158 |
|
|
|
159 |
if [ "x$gfxterm" = x1 ]; then
|
|
|
160 |
if [ -n "$GRUB_FONT" ] ; then
|
|
|
161 |
# Make the font accessible
|
|
|
162 |
prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`
|
|
|
163 |
cat << EOF
|
|
|
164 |
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
|
|
|
165 |
EOF
|
|
|
166 |
else
|
|
|
167 |
for dir in "${pkgdatadir}" "`echo '/boot/grub2' | sed "s,//*,/,g"`" /usr/share/grub ; do
|
|
|
168 |
for basename in unicode unifont ascii; do
|
|
|
169 |
path="${dir}/${basename}.pf2"
|
|
|
170 |
if is_path_readable_by_grub "${path}" > /dev/null ; then
|
|
|
171 |
font_path="${path}"
|
|
|
172 |
else
|
|
|
173 |
continue
|
|
|
174 |
fi
|
|
|
175 |
break 2
|
|
|
176 |
done
|
|
|
177 |
done
|
|
|
178 |
if [ -n "${font_path}" ] ; then
|
|
|
179 |
cat << EOF
|
|
|
180 |
if [ x\$feature_default_font_path = xy ] ; then
|
|
|
181 |
font=unicode
|
|
|
182 |
else
|
|
|
183 |
EOF
|
|
|
184 |
# Make the font accessible
|
|
|
185 |
prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
|
|
|
186 |
cat << EOF
|
|
|
187 |
font="`make_system_path_relative_to_its_root "${font_path}"`"
|
|
|
188 |
fi
|
|
|
189 |
|
|
|
190 |
if loadfont \$font ; then
|
|
|
191 |
EOF
|
|
|
192 |
else
|
|
|
193 |
cat << EOF
|
|
|
194 |
if loadfont unicode ; then
|
|
|
195 |
EOF
|
|
|
196 |
fi
|
|
|
197 |
fi
|
|
|
198 |
|
|
|
199 |
cat << EOF
|
|
|
200 |
set gfxmode=${GRUB_GFXMODE}
|
|
|
201 |
load_video
|
|
|
202 |
insmod gfxterm
|
|
|
203 |
EOF
|
|
|
204 |
|
|
|
205 |
# Gettext variables and module
|
|
|
206 |
if [ "x${LANG}" != "xC" ] && [ "x${LANG}" != "x" ]; then
|
|
|
207 |
cat << EOF
|
|
|
208 |
set locale_dir=\$prefix/locale
|
|
|
209 |
set lang=${grub_lang}
|
|
|
210 |
insmod gettext
|
|
|
211 |
EOF
|
|
|
212 |
fi
|
|
|
213 |
|
|
|
214 |
cat <<EOF
|
|
|
215 |
fi
|
|
|
216 |
EOF
|
|
|
217 |
fi
|
|
|
218 |
|
|
|
219 |
case x${GRUB_TERMINAL_INPUT} in
|
|
|
220 |
x)
|
|
|
221 |
# Just use the native terminal
|
|
|
222 |
;;
|
|
|
223 |
x*)
|
|
|
224 |
cat << EOF
|
|
|
225 |
terminal_input ${GRUB_TERMINAL_INPUT}
|
|
|
226 |
EOF
|
|
|
227 |
;;
|
|
|
228 |
esac
|
|
|
229 |
|
|
|
230 |
case x${GRUB_TERMINAL_OUTPUT} in
|
|
|
231 |
x)
|
|
|
232 |
# Just use the native terminal
|
|
|
233 |
;;
|
|
|
234 |
x*)
|
|
|
235 |
cat << EOF
|
|
|
236 |
terminal_output ${GRUB_TERMINAL_OUTPUT}
|
|
|
237 |
EOF
|
|
|
238 |
;;
|
|
|
239 |
esac
|
|
|
240 |
|
|
|
241 |
if [ "x$gfxterm" = x1 ]; then
|
|
|
242 |
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
|
|
|
243 |
&& is_path_readable_by_grub "$GRUB_THEME"; then
|
|
|
244 |
gettext_printf "Found theme: %s\n" "$GRUB_THEME" >&2
|
|
|
245 |
|
|
|
246 |
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`
|
|
|
247 |
cat << EOF
|
|
|
248 |
insmod gfxmenu
|
|
|
249 |
EOF
|
|
|
250 |
themedir="`dirname "$GRUB_THEME"`"
|
|
|
251 |
for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
|
|
|
252 |
if [ -f "$x" ]; then
|
|
|
253 |
cat << EOF
|
|
|
254 |
loadfont (\$root)`make_system_path_relative_to_its_root $x`
|
|
|
255 |
EOF
|
|
|
256 |
fi
|
|
|
257 |
done
|
|
|
258 |
if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
|
|
|
259 |
cat << EOF
|
|
|
260 |
insmod jpeg
|
|
|
261 |
EOF
|
|
|
262 |
fi
|
|
|
263 |
if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
|
|
|
264 |
cat << EOF
|
|
|
265 |
insmod png
|
|
|
266 |
EOF
|
|
|
267 |
fi
|
|
|
268 |
if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
|
|
|
269 |
cat << EOF
|
|
|
270 |
insmod tga
|
|
|
271 |
EOF
|
|
|
272 |
fi
|
|
|
273 |
|
|
|
274 |
cat << EOF
|
|
|
275 |
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
|
|
|
276 |
export theme
|
|
|
277 |
EOF
|
|
|
278 |
elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
|
|
|
279 |
&& is_path_readable_by_grub "$GRUB_BACKGROUND"; then
|
|
|
280 |
gettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2
|
|
|
281 |
case "$GRUB_BACKGROUND" in
|
|
|
282 |
*.png) reader=png ;;
|
|
|
283 |
*.tga) reader=tga ;;
|
|
|
284 |
*.jpg|*.jpeg) reader=jpeg ;;
|
|
|
285 |
*) gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;
|
|
|
286 |
esac
|
|
|
287 |
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`
|
|
|
288 |
cat << EOF
|
|
|
289 |
insmod $reader
|
|
|
290 |
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
|
|
|
291 |
EOF
|
|
|
292 |
fi
|
|
|
293 |
fi
|
|
|
294 |
|
|
|
295 |
make_timeout ()
|
|
|
296 |
{
|
|
|
297 |
if [ "x${3}" != "x" ] ; then
|
|
|
298 |
timeout="${2}"
|
|
|
299 |
style="${3}"
|
|
|
300 |
elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then
|
|
|
301 |
# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
|
|
|
302 |
timeout="${1}"
|
|
|
303 |
if [ "x${2}" != "x0" ] ; then
|
|
|
304 |
grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
|
|
|
305 |
fi
|
|
|
306 |
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
|
|
307 |
style="hidden"
|
|
|
308 |
verbose=
|
|
|
309 |
else
|
|
|
310 |
style="countdown"
|
|
|
311 |
verbose=" --verbose"
|
|
|
312 |
fi
|
|
|
313 |
else
|
|
|
314 |
# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
|
|
|
315 |
timeout="${2}"
|
|
|
316 |
style="menu"
|
|
|
317 |
fi
|
|
|
318 |
cat << EOF
|
|
|
319 |
if [ x\$feature_timeout_style = xy ] ; then
|
|
|
320 |
set timeout_style=${style}
|
|
|
321 |
set timeout=${timeout}
|
|
|
322 |
EOF
|
|
|
323 |
if [ "x${style}" = "xmenu" ] ; then
|
|
|
324 |
cat << EOF
|
|
|
325 |
# Fallback normal timeout code in case the timeout_style feature is
|
|
|
326 |
# unavailable.
|
|
|
327 |
else
|
|
|
328 |
set timeout=${timeout}
|
|
|
329 |
EOF
|
|
|
330 |
else
|
|
|
331 |
cat << EOF
|
|
|
332 |
# Fallback hidden-timeout code in case the timeout_style feature is
|
|
|
333 |
# unavailable.
|
|
|
334 |
elif sleep${verbose} --interruptible ${timeout} ; then
|
|
|
335 |
set timeout=0
|
|
|
336 |
EOF
|
|
|
337 |
fi
|
|
|
338 |
cat << EOF
|
|
|
339 |
fi
|
|
|
340 |
EOF
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
|
|
344 |
cat <<EOF
|
|
|
345 |
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
|
|
346 |
EOF
|
|
|
347 |
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_STYLE_BUTTON}"
|
|
|
348 |
echo else
|
|
|
349 |
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
|
|
|
350 |
echo fi
|
|
|
351 |
else
|
|
|
352 |
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
|
|
|
353 |
fi
|
|
|
354 |
|
|
|
355 |
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
|
|
|
356 |
cat <<EOF
|
|
|
357 |
cmosclean $GRUB_BUTTON_CMOS_ADDRESS
|
|
|
358 |
EOF
|
|
|
359 |
fi
|
|
|
360 |
|
|
|
361 |
# Play an initial tune
|
|
|
362 |
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
|
|
|
363 |
echo "play ${GRUB_INIT_TUNE}"
|
|
|
364 |
fi
|
|
|
365 |
|
|
|
366 |
if [ "x${GRUB_BADRAM}" != "x" ] ; then
|
|
|
367 |
echo "badram ${GRUB_BADRAM}"
|
|
|
368 |
fi
|