source: grub-pc/trunk/fuentes/.pc/gettext-print-typo.patch/util/grub-mkconfig.in @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 7.8 KB
Line 
1#! /bin/sh
2set -e
3
4# Generate grub.cfg by inspecting /boot contents.
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
20prefix="@prefix@"
21exec_prefix="@exec_prefix@"
22datarootdir="@datarootdir@"
23
24prefix="@prefix@"
25exec_prefix="@exec_prefix@"
26sbindir="@sbindir@"
27bindir="@bindir@"
28sysconfdir="@sysconfdir@"
29PACKAGE_NAME=@PACKAGE_NAME@
30PACKAGE_VERSION=@PACKAGE_VERSION@
31host_os=@host_os@
32datadir="@datadir@"
33if [ "x$pkgdatadir" = x ]; then
34    pkgdatadir="${datadir}/@PACKAGE@"
35fi
36grub_cfg=""
37grub_mkconfig_dir="${sysconfdir}"/grub.d
38
39self=`basename $0`
40
41grub_probe="${sbindir}/@grub_probe@"
42grub_file="${bindir}/@grub_file@"
43grub_editenv="${bindir}/@grub_editenv@"
44grub_script_check="${bindir}/@grub_script_check@"
45
46export TEXTDOMAIN=@PACKAGE@
47export TEXTDOMAINDIR="@localedir@"
48
49. "${pkgdatadir}/grub-mkconfig_lib"
50
51# Usage: usage
52# Print the usage.
53usage () {
54    gettext_printf "Usage: %s [OPTION]\n" "$self"
55    gettext "Generate a grub config file"; echo
56    echo
57    print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
58    print_option_help "-h, --help" "$(gettext "print this message and exit")"
59    print_option_help "-v, --version" "$(gettext "print the version information and exit")"
60    echo
61    gettext "Report bugs to <bug-grub@gnu.org>."; echo
62}
63
64argument () {
65  opt=$1
66  shift
67
68  if test $# -eq 0; then
69      gettext_printf "%s: option requires an argument -- \`%s'\n" "$self" "$opt" 1>&2
70      exit 1
71  fi
72  echo $1
73}
74
75# Check the arguments.
76while test $# -gt 0
77do
78    option=$1
79    shift
80
81    case "$option" in
82    -h | --help)
83        usage
84        exit 0 ;;
85    -v | --version)
86        echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
87        exit 0 ;;
88    -o | --output)
89        grub_cfg=`argument $option "$@"`; shift;;
90    --output=*)
91        grub_cfg=`echo "$option" | sed 's/--output=//'`
92        ;;
93    -*)
94        gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
95        usage
96        exit 1
97        ;;
98    # Explicitly ignore non-option arguments, for compatibility.
99    esac
100done
101
102if fgrep -qs '${GRUB_PREFIX}/video.lst' "${grub_mkconfig_dir}/00_header"; then
103  echo "GRUB >= 2.00 has been unpacked but not yet configured." >&2
104  echo "grub-mkconfig will not work until the upgrade is complete." >&2
105  echo "It should run later as part of configuring the new GRUB packages." >&2
106  exit 0
107fi
108
109if [ "x$EUID" = "x" ] ; then
110  EUID=`id -u`
111fi
112
113if [ "$EUID" != 0 ] ; then
114  root=f
115  case "`uname 2>/dev/null`" in
116    CYGWIN*)
117      # Cygwin: Assume root if member of admin group
118      for g in `id -G 2>/dev/null` ; do
119        case $g in
120          0|544) root=t ;;
121        esac
122      done ;;
123  esac
124  if [ $root != t ] ; then
125    gettext_printf "%s: You must run this as root\n" "$self" >&2
126    exit 1
127  fi
128fi
129
130set $grub_probe dummy
131if test -f "$1"; then
132    :
133else
134    gettext_print "%s: Not found.\n" "$1" 1>&2
135    exit 1
136fi
137
138# Device containing our userland.  Typically used for root= parameter.
139GRUB_DEVICE="`${grub_probe} --target=device /`"
140GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
141
142# Device containing our /boot partition.  Usually the same as GRUB_DEVICE.
143GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
144GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
145
146# Filesystem for the device containing our userland.  Used for stuff like
147# choosing Hurd filesystem module.
148GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
149
150if [ x"$GRUB_FS" = xunknown ]; then
151    GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
152fi
153
154if test -f ${sysconfdir}/default/grub ; then
155  . ${sysconfdir}/default/grub
156fi
157for x in ${sysconfdir}/default/grub.d/*.cfg ; do
158  if [ -e "${x}" ]; then
159    . "${x}"
160  fi
161done
162
163# XXX: should this be deprecated at some point?
164if [ "x${GRUB_TERMINAL}" != "x" ] ; then
165  GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"
166  GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
167fi
168
169termoutdefault=0
170if [ "x${GRUB_TERMINAL_OUTPUT}" = "x" ]; then
171    GRUB_TERMINAL_OUTPUT=gfxterm;
172    termoutdefault=1;
173fi
174
175for x in ${GRUB_TERMINAL_OUTPUT}; do
176    case "x${x}" in
177        xgfxterm) ;;
178        xconsole | xserial | xofconsole | xvga_text)
179            # make sure all our children behave in conformance with ascii..
180            export LANG=C;;
181        *) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
182    esac
183done
184
185GRUB_ACTUAL_DEFAULT="$GRUB_DEFAULT"
186
187if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi
188
189if [ "x${GRUB_RECOVERY_TITLE}" = "x" ]; then
190  GRUB_RECOVERY_TITLE="recovery mode"
191fi
192
193
194# These are defined in this script, export them here so that user can
195# override them.
196export GRUB_DEVICE \
197  GRUB_DEVICE_UUID \
198  GRUB_DEVICE_BOOT \
199  GRUB_DEVICE_BOOT_UUID \
200  GRUB_FS \
201  GRUB_FONT \
202  GRUB_PRELOAD_MODULES \
203  GRUB_ACTUAL_DEFAULT
204
205# These are optional, user-defined variables.
206export GRUB_DEFAULT \
207  GRUB_HIDDEN_TIMEOUT \
208  GRUB_HIDDEN_TIMEOUT_QUIET \
209  GRUB_TIMEOUT \
210  GRUB_TIMEOUT_STYLE \
211  GRUB_DEFAULT_BUTTON \
212  GRUB_HIDDEN_TIMEOUT_BUTTON \
213  GRUB_TIMEOUT_BUTTON \
214  GRUB_TIMEOUT_STYLE_BUTTON \
215  GRUB_BUTTON_CMOS_ADDRESS \
216  GRUB_BUTTON_CMOS_CLEAN \
217  GRUB_DISTRIBUTOR \
218  GRUB_CMDLINE_LINUX \
219  GRUB_CMDLINE_LINUX_DEFAULT \
220  GRUB_CMDLINE_XEN \
221  GRUB_CMDLINE_XEN_DEFAULT \
222  GRUB_CMDLINE_LINUX_XEN_REPLACE \
223  GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT \
224  GRUB_CMDLINE_NETBSD \
225  GRUB_CMDLINE_NETBSD_DEFAULT \
226  GRUB_CMDLINE_GNUMACH \
227  GRUB_TERMINAL_INPUT \
228  GRUB_TERMINAL_OUTPUT \
229  GRUB_SERIAL_COMMAND \
230  GRUB_DISABLE_LINUX_UUID \
231  GRUB_DISABLE_RECOVERY \
232  GRUB_VIDEO_BACKEND \
233  GRUB_GFXMODE \
234  GRUB_BACKGROUND \
235  GRUB_THEME \
236  GRUB_GFXPAYLOAD_LINUX \
237  GRUB_DISABLE_OS_PROBER \
238  GRUB_INIT_TUNE \
239  GRUB_SAVEDEFAULT \
240  GRUB_ENABLE_CRYPTODISK \
241  GRUB_BADRAM \
242  GRUB_OS_PROBER_SKIP_LIST \
243  GRUB_DISABLE_SUBMENU \
244  GRUB_RECORDFAIL_TIMEOUT \
245  GRUB_RECOVERY_TITLE
246
247if test "x${grub_cfg}" != "x"; then
248  rm -f "${grub_cfg}.new"
249  oldumask=$(umask); umask 077
250  exec > "${grub_cfg}.new"
251  umask $oldumask
252fi
253gettext "Generating grub configuration file ..." >&2
254echo >&2
255
256cat << EOF
257#
258# DO NOT EDIT THIS FILE
259#
260# It is automatically generated by $self using templates
261# from ${grub_mkconfig_dir} and settings from ${sysconfdir}/default/grub
262#
263EOF
264
265
266for i in "${grub_mkconfig_dir}"/* ; do
267  case "$i" in
268    # emacsen backup files. FIXME: support other editors
269    *~) ;;
270    # emacsen autosave files. FIXME: support other editors
271    */\#*\#) ;;
272    *)
273      if grub_file_is_not_garbage "$i" && test -x "$i" ; then
274        echo
275        echo "### BEGIN $i ###"
276        "$i"
277        echo "### END $i ###"
278      fi
279    ;;
280  esac
281done
282
283if [ "x${grub_cfg}" != "x" ] && ! grep "^password" ${grub_cfg}.new >/dev/null; then
284  chmod 444 ${grub_cfg}.new || true
285fi
286
287if test "x${grub_cfg}" != "x" ; then
288  if ! ${grub_script_check} ${grub_cfg}.new; then
289    # TRANSLATORS: %s is replaced by filename
290    gettext_printf "Syntax errors are detected in generated GRUB config file.
291Ensure that there are no errors in /etc/default/grub
292and /etc/grub.d/* files or please file a bug report with
293%s file attached." "${grub_cfg}.new" >&2
294    echo >&2
295  else
296    # none of the children aborted with error, install the new grub.cfg
297    mv -f ${grub_cfg}.new ${grub_cfg}
298  fi
299fi
300
301gettext "done" >&2
302echo >&2
Note: See TracBrowser for help on using the repository browser.