~psusi/ubuntu/saucy/grub2/fix-dmraid

« back to all changes in this revision

Viewing changes to .pc/ubuntu_default_grub_d.patch/util/grub-mkconfig.in

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2013-01-03 11:40:44 UTC
  • mfrom: (17.6.31 experimental)
  • Revision ID: package-import@ubuntu.com-20130103114044-et8gar9lol415wc9
Tags: 2.00-10ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme and an appropriate background for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel option.
  - Bypass menu unless other OSes are installed or Shift is pressed.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Reduce visual clutter in normal mode.
  - Remove verbose messages printed before reading configuration.
  - Suppress kernel/initrd progress messages, except in recovery mode.
  - Show the boot menu if the previous boot failed.
  - Adjust upgrade version checks for Ubuntu.
  - Suppress "GRUB loading" message unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Check hardware support before using gfxpayload=keep.
  - Set vt.handoff=7 for smooth handoff to kernel graphical mode.
  - In recovery mode, add nomodeset to the Linux kernel arguments, and
    remove the 'set gfxpayload=keep' command.
  - Skip Windows os-prober entries on Wubi systems, and suppress the menu
    by default if those are the only other-OS entries.
  - Handle probing striped DM-RAID devices.
  - Replace 'single' by 'recovery' when friendly-recovery is installed.
  - Disable cursor as early as possible in grub_main.
  - Apply patch from Fedora to add a "linuxefi" loader.
  - Automatically call linuxefi from linux when necessary.
  - On amd64, add raw-uefi custom upload tarballs for signing.
  - Generate configuration for signed UEFI kernels if available.
  - Install signed images if UEFI Secure Boot is enabled.
  - Output a menu entry for firmware setup on UEFI FastBoot systems.
  - Stop using the /usr/share/images/desktop-base/desktop-grub.png
    alternative as the fallback background.
  - If the postinst is running in a container, skip grub-install and all
    its associated questions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
set -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
 
 
20
 
transform="@program_transform_name@"
21
 
prefix="@prefix@"
22
 
exec_prefix="@exec_prefix@"
23
 
datarootdir="@datarootdir@"
24
 
 
25
 
prefix="@prefix@"
26
 
exec_prefix="@exec_prefix@"
27
 
sbindir="@sbindir@"
28
 
bindir="@bindir@"
29
 
sysconfdir="@sysconfdir@"
30
 
PACKAGE_NAME=@PACKAGE_NAME@
31
 
PACKAGE_VERSION=@PACKAGE_VERSION@
32
 
host_os=@host_os@
33
 
datadir="@datadir@"
34
 
if [ "x$pkgdatadir" = x ]; then
35
 
    pkgdatadir="${datadir}/@PACKAGE@"
36
 
fi
37
 
grub_cfg=""
38
 
grub_mkconfig_dir="${sysconfdir}"/grub.d
39
 
 
40
 
self=`basename $0`
41
 
 
42
 
grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`"
43
 
grub_editenv="${bindir}/`echo grub-editenv | sed "${transform}"`"
44
 
grub_script_check="${bindir}/`echo grub-script-check | sed "${transform}"`"
45
 
 
46
 
export TEXTDOMAIN=@PACKAGE@
47
 
export TEXTDOMAINDIR="@localedir@"
48
 
 
49
 
. "${pkgdatadir}/grub-mkconfig_lib"
50
 
 
51
 
# Usage: usage
52
 
# Print the usage.
53
 
usage () {
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
 
 
64
 
argument () {
65
 
  opt=$1
66
 
  shift
67
 
 
68
 
  if test $# -eq 0; then
69
 
      gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
70
 
      exit 1
71
 
  fi
72
 
  echo $1
73
 
}
74
 
 
75
 
# Check the arguments.
76
 
while test $# -gt 0
77
 
do
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
100
 
done
101
 
 
102
 
if 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
107
 
fi
108
 
 
109
 
if [ "x$EUID" = "x" ] ; then
110
 
  EUID=`id -u`
111
 
fi
112
 
 
113
 
if [ "$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
128
 
fi
129
 
 
130
 
set $grub_probe dummy
131
 
if test -f "$1"; then
132
 
    :
133
 
else
134
 
    gettext_print "%s: Not found.\n" "$1" 1>&2
135
 
    exit 1
136
 
fi
137
 
 
138
 
# Device containing our userland.  Typically used for root= parameter.
139
 
GRUB_DEVICE="`${grub_probe} --target=device /`"
140
 
GRUB_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.
143
 
GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
144
 
GRUB_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.
148
 
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
149
 
 
150
 
if test -f ${sysconfdir}/default/grub ; then
151
 
  . ${sysconfdir}/default/grub
152
 
fi
153
 
 
154
 
# XXX: should this be deprecated at some point?
155
 
if [ "x${GRUB_TERMINAL}" != "x" ] ; then
156
 
  GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"
157
 
  GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
158
 
fi
159
 
 
160
 
termoutdefault=0
161
 
if [ "x${GRUB_TERMINAL_OUTPUT}" = "x" ]; then
162
 
    GRUB_TERMINAL_OUTPUT=gfxterm;
163
 
    termoutdefault=1;
164
 
fi
165
 
 
166
 
for x in ${GRUB_TERMINAL_OUTPUT}; do
167
 
    case "x${x}" in
168
 
        xgfxterm) ;;
169
 
        xconsole | xserial | xofconsole)
170
 
            # make sure all our children behave in conformance with ascii..
171
 
            export LANG=C;;
172
 
        *) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
173
 
    esac
174
 
done
175
 
 
176
 
GRUB_ACTUAL_DEFAULT="$GRUB_DEFAULT"
177
 
 
178
 
if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi
179
 
 
180
 
 
181
 
# These are defined in this script, export them here so that user can
182
 
# override them.
183
 
export GRUB_DEVICE \
184
 
  GRUB_DEVICE_UUID \
185
 
  GRUB_DEVICE_BOOT \
186
 
  GRUB_DEVICE_BOOT_UUID \
187
 
  GRUB_FS \
188
 
  GRUB_FONT \
189
 
  GRUB_PRELOAD_MODULES \
190
 
  GRUB_ACTUAL_DEFAULT
191
 
 
192
 
# These are optional, user-defined variables.
193
 
export GRUB_DEFAULT \
194
 
  GRUB_HIDDEN_TIMEOUT \
195
 
  GRUB_HIDDEN_TIMEOUT_QUIET \
196
 
  GRUB_TIMEOUT \
197
 
  GRUB_DEFAULT_BUTTON \
198
 
  GRUB_HIDDEN_TIMEOUT_BUTTON \
199
 
  GRUB_TIMEOUT_BUTTON \
200
 
  GRUB_BUTTON_CMOS_ADDRESS \
201
 
  GRUB_BUTTON_CMOS_CLEAN \
202
 
  GRUB_DISTRIBUTOR \
203
 
  GRUB_CMDLINE_LINUX \
204
 
  GRUB_CMDLINE_LINUX_DEFAULT \
205
 
  GRUB_CMDLINE_XEN \
206
 
  GRUB_CMDLINE_XEN_DEFAULT \
207
 
  GRUB_CMDLINE_LINUX_XEN_REPLACE \
208
 
  GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT \
209
 
  GRUB_CMDLINE_NETBSD \
210
 
  GRUB_CMDLINE_NETBSD_DEFAULT \
211
 
  GRUB_CMDLINE_GNUMACH \
212
 
  GRUB_TERMINAL_INPUT \
213
 
  GRUB_TERMINAL_OUTPUT \
214
 
  GRUB_SERIAL_COMMAND \
215
 
  GRUB_DISABLE_LINUX_UUID \
216
 
  GRUB_DISABLE_RECOVERY \
217
 
  GRUB_VIDEO_BACKEND \
218
 
  GRUB_GFXMODE \
219
 
  GRUB_BACKGROUND \
220
 
  GRUB_THEME \
221
 
  GRUB_GFXPAYLOAD_LINUX \
222
 
  GRUB_DISABLE_OS_PROBER \
223
 
  GRUB_INIT_TUNE \
224
 
  GRUB_SAVEDEFAULT \
225
 
  GRUB_ENABLE_CRYPTODISK \
226
 
  GRUB_BADRAM \
227
 
  GRUB_RECORDFAIL_TIMEOUT
228
 
 
229
 
if test "x${grub_cfg}" != "x"; then
230
 
  rm -f "${grub_cfg}.new"
231
 
  oldumask=$(umask); umask 077
232
 
  exec > "${grub_cfg}.new"
233
 
  umask $oldumask
234
 
fi
235
 
gettext "Generating grub.cfg ..." >&2
236
 
echo >&2
237
 
 
238
 
cat << EOF
239
 
#
240
 
# DO NOT EDIT THIS FILE
241
 
#
242
 
# It is automatically generated by $self using templates
243
 
# from ${grub_mkconfig_dir} and settings from ${sysconfdir}/default/grub
244
 
#
245
 
EOF
246
 
 
247
 
for i in ${grub_mkconfig_dir}/* ; do
248
 
  case "$i" in
249
 
    # emacsen backup files. FIXME: support other editors
250
 
    *~) ;;
251
 
    # emacsen autosave files. FIXME: support other editors
252
 
    \#*\#) ;;
253
 
    *)
254
 
      if grub_file_is_not_garbage "$i" && test -x "$i" ; then
255
 
        echo
256
 
        echo "### BEGIN $i ###"
257
 
        "$i"
258
 
        echo "### END $i ###"
259
 
      fi
260
 
    ;;
261
 
  esac
262
 
done
263
 
 
264
 
if [ "x${grub_cfg}" != "x" ] && ! grep "^password " ${grub_cfg}.new >/dev/null; then
265
 
  chmod 444 ${grub_cfg}.new || true
266
 
fi
267
 
 
268
 
if test "x${grub_cfg}" != "x" ; then
269
 
  if ! ${grub_script_check} ${grub_cfg}.new; then
270
 
    # TRANSLATORS: %s is replaced by filename
271
 
    gettext_printf "Syntax errors are detected in generated GRUB config file.
272
 
Ensure that there are no errors in /etc/default/grub
273
 
and /etc/grub.d/* files or please file a bug report with
274
 
%s file attached." "${grub_cfg}.new" >&2
275
 
  else
276
 
    # none of the children aborted with error, install the new grub.cfg
277
 
    mv -f ${grub_cfg}.new ${grub_cfg}
278
 
  fi
279
 
fi
280
 
 
281
 
gettext "done" >&2
282
 
echo >&2