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

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

Fix the grub error "no symbol table" from showing up

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