source: src-sh/pc-extractoverlay/ports-overlay/usr/local/etc/grub.d/00_header @ e2fa25c

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since e2fa25c was e2fa25c, checked in by Kris Moore <kris@…>, 17 months ago

Update the grub theme to use the new background and fix up the sizes

Also fix a warning message from GRUB about not finding en_US

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