~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to util/i386/efi/grub-install.in

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  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 for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
 
3
 
# Install GRUB on your EFI partition.
4
 
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  Free Software Foundation, Inc.
5
 
#
6
 
# GRUB is free software: you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation, either version 3 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# GRUB is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18
 
 
19
 
# Initialize some variables.
20
 
transform="@program_transform_name@"
21
 
 
22
 
prefix=@prefix@
23
 
exec_prefix=@exec_prefix@
24
 
sbindir=@sbindir@
25
 
bindir=@bindir@
26
 
libdir=@libdir@
27
 
PACKAGE_NAME=@PACKAGE_NAME@
28
 
PACKAGE_TARNAME=@PACKAGE_TARNAME@
29
 
PACKAGE_VERSION=@PACKAGE_VERSION@
30
 
target_cpu=@target_cpu@
31
 
platform=@platform@
32
 
host_os=@host_os@
33
 
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
34
 
localedir=@datadir@/locale
35
 
 
36
 
self=`basename $0`
37
 
 
38
 
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
39
 
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
40
 
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
41
 
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
42
 
rootdir=
43
 
grub_prefix=`echo /boot/grub | sed ${transform}`
44
 
modules=
45
 
 
46
 
no_floppy=
47
 
force_lba=
48
 
recheck=no
49
 
debug=no
50
 
 
51
 
# Usage: usage
52
 
# Print the usage.
53
 
usage () {
54
 
    cat <<EOF
55
 
Usage: $self [OPTION]
56
 
Install GRUB on your EFI partition.
57
 
 
58
 
  -h, --help              print this message and exit
59
 
  -v, --version           print the version information and exit
60
 
  --modules=MODULES       pre-load specified modules MODULES
61
 
  --root-directory=DIR    install GRUB images under the directory DIR
62
 
                          instead of the root directory
63
 
  --grub-mkimage=FILE     use FILE as grub-mkimage
64
 
  --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
65
 
  --grub-probe=FILE       use FILE as grub-probe
66
 
  --no-floppy             do not probe any floppy drive
67
 
  --recheck               probe a device map even if it already exists
68
 
 
69
 
$self copies GRUB images into the DIR/boot directory specified by
70
 
--root-directory.
71
 
 
72
 
Report bugs to <bug-grub@gnu.org>.
73
 
EOF
74
 
}
75
 
 
76
 
argument () {
77
 
  opt=$1
78
 
  shift
79
 
 
80
 
  if test $# -eq 0; then
81
 
      echo "$0: option requires an argument -- '$opt'" 1>&2
82
 
      exit 1
83
 
  fi
84
 
  echo $1
85
 
}
86
 
 
87
 
# Check the arguments.
88
 
while test $# -gt 0
89
 
do
90
 
    option=$1
91
 
    shift
92
 
 
93
 
    case "$option" in
94
 
    -h | --help)
95
 
        usage
96
 
        exit 0 ;;
97
 
    -v | --version)
98
 
        echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
99
 
        exit 0 ;;
100
 
 
101
 
    --modules)
102
 
        modules=`argument $option "$@"`; shift ;;
103
 
    --modules=*)
104
 
        modules=`echo "$option" | sed 's/--modules=//'` ;;
105
 
 
106
 
    --root-directory)
107
 
        rootdir=`argument $option "$@"`; shift ;;
108
 
    --root-directory=*)
109
 
        rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
110
 
 
111
 
    --grub-mkimage)
112
 
        grub_mkimage=`argument $option "$@"`; shift ;;
113
 
    --grub-mkimage=*)
114
 
        grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
115
 
 
116
 
    --grub-mkdevicemap)
117
 
        grub_mkdevicemap=`argument $option "$@"`; shift ;;
118
 
    --grub-mkdevicemap=*)
119
 
        grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
120
 
 
121
 
    --grub-probe)
122
 
        grub_probe=`argument $option "$@"`; shift ;;
123
 
    --grub-probe=*)
124
 
        grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
125
 
 
126
 
    --no-floppy)
127
 
        no_floppy="--no-floppy" ;;
128
 
    --recheck)
129
 
        recheck=yes ;;
130
 
    # This is an undocumented feature...
131
 
    --debug)
132
 
        debug=yes ;;
133
 
    *)
134
 
        echo "Unrecognized option \`$option'" 1>&2
135
 
        usage
136
 
        exit 1
137
 
        ;;
138
 
    esac
139
 
done
140
 
 
141
 
# If the debugging feature is enabled, print commands.
142
 
if test $debug = yes; then
143
 
    set -x
144
 
fi
145
 
 
146
 
# Initialize these directories here, since ROOTDIR was initialized.
147
 
case "$host_os" in
148
 
netbsd* | openbsd*)
149
 
    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
150
 
    # instead of /boot/grub.
151
 
    grub_prefix=`echo /grub | sed ${transform}`
152
 
    bootdir=${rootdir}
153
 
    ;;
154
 
*)
155
 
    # Use /boot/grub by default.
156
 
    bootdir=${rootdir}/boot
157
 
    ;;
158
 
esac
159
 
 
160
 
grubdir=${bootdir}/`echo grub | sed ${transform}`
161
 
device_map=${grubdir}/device.map
162
 
 
163
 
# Check if GRUB is installed.
164
 
set $grub_mkimage dummy
165
 
if test -f "$1"; then
166
 
    :
167
 
else
168
 
    echo "$1: Not found." 1>&2
169
 
    exit 1
170
 
fi
171
 
 
172
 
set $grub_mkdevicemap dummy
173
 
if test -f "$1"; then
174
 
    :
175
 
else
176
 
    echo "$1: Not found." 1>&2
177
 
    exit 1
178
 
fi
179
 
 
180
 
# Create the GRUB directory if it is not present.
181
 
mkdir -p "$grubdir" || exit 1
182
 
 
183
 
# If --recheck is specified, remove the device map, if present.
184
 
if test $recheck = yes; then
185
 
    rm -f $device_map
186
 
fi
187
 
 
188
 
# Create the device map file if it is not present.
189
 
if test -f "$device_map"; then
190
 
    :
191
 
else
192
 
    # Create a safe temporary file.
193
 
    test -n "$mklog" && log_file=`$mklog`
194
 
 
195
 
    $grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1
196
 
fi
197
 
 
198
 
# Make sure that there is no duplicated entry.
199
 
tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \
200
 
    | sort | uniq -d | sed -n 1p`
201
 
if test -n "$tmp"; then
202
 
    echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2
203
 
    exit 1
204
 
fi
205
 
 
206
 
# Copy the GRUB images to the GRUB directory.
207
 
for file in ${grubdir}/*.mod ${grubdir}/*.lst; do
208
 
    if test -f $file && [ "`basename $file`" != menu.lst ]; then
209
 
        rm -f $file || exit 1
210
 
    fi
211
 
done
212
 
for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
213
 
    cp -f $file ${grubdir} || exit 1
214
 
done
215
 
 
216
 
# Copy gettext files
217
 
mkdir -p ${grubdir}/locale/
218
 
for dir in ${localedir}/*; do
219
 
    if test -f "$dir/LC_MESSAGES/grub.mo"; then
220
 
        cp -f "$dir/LC_MESSAGES/grub.mo" "${grubdir}/locale/${dir##*/}.mo"
221
 
    fi
222
 
done
223
 
 
224
 
if ! test -f ${grubdir}/grubenv; then
225
 
    $grub_editenv ${grubdir}/grubenv create
226
 
fi
227
 
 
228
 
# Create the core image. First, auto-detect the filesystem module.
229
 
fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
230
 
if test "x$fs_module" = xfat; then :; else
231
 
    echo "${grubdir} doesn't look like an EFI partition." 1>&2
232
 
    exit 1
233
 
fi
234
 
 
235
 
# Then the partition map module.  In order to support partition-less media,
236
 
# this command is allowed to fail (--target=fs already grants us that the
237
 
# filesystem will be accessible).
238
 
partmap_module=
239
 
for x in `$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`; do
240
 
   partmap_module="$partmap_module part_$x";
241
 
done
242
 
 
243
 
# Device abstraction module, if any (lvm, raid).
244
 
devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
245
 
 
246
 
# The order in this list is critical.  Be careful when modifying it.
247
 
modules="$modules $fs_module $partmap_module $devabstraction_module"
248
 
 
249
 
$grub_mkimage -p "" -O ${target_cpu}-efi --output=${grubdir}/grub.efi $modules || exit 1
250
 
 
251
 
# Prompt the user to check if the device map is correct.
252
 
echo "Installation finished. No error reported."
253
 
echo "This is the contents of the device map $device_map."
254
 
echo "Check if this is correct or not. If any of the lines is incorrect,"
255
 
echo "fix it and re-run the script \`$self'."
256
 
echo
257
 
 
258
 
cat $device_map
259
 
 
260
 
# Bye.
261
 
exit 0