1 | #! /bin/sh |
---|
2 | |
---|
3 | # 06/25/2004 |
---|
4 | # - better Mandrake 9.2 compatibility |
---|
5 | # |
---|
6 | # 06/14/2004 |
---|
7 | # - hacked about a bit by Hugo, to incorporate Red Hat's patches |
---|
8 | # and to add SuSE compatibility |
---|
9 | # |
---|
10 | #----------------------------------------------------------------------- |
---|
11 | # Install GRUB on your drive. |
---|
12 | # Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. |
---|
13 | # |
---|
14 | # This file is free software; you can redistribute it and/or modify it |
---|
15 | # under the terms of the GNU General Public License as published by |
---|
16 | # the Free Software Foundation; either version 2 of the License, or |
---|
17 | # (at your option) any later version. |
---|
18 | # |
---|
19 | # This program is distributed in the hope that it will be useful, but |
---|
20 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
22 | # General Public License for more details. |
---|
23 | # |
---|
24 | # You should have received a copy of the GNU General Public License |
---|
25 | # along with this program; if not, write to the Free Software |
---|
26 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
27 | |
---|
28 | # Initialize some variables. |
---|
29 | prefix=/usr |
---|
30 | exec_prefix=/usr |
---|
31 | sbindir=/sbin |
---|
32 | datadir=/usr/share |
---|
33 | PACKAGE=grub |
---|
34 | VERSION=0.93 |
---|
35 | host_cpu=`uname -i` |
---|
36 | host_os=linux-gnu |
---|
37 | host_vendor=redhat |
---|
38 | pkgdatadir=${datadir}/${PACKAGE}/${host_cpu}-${host_vendor} |
---|
39 | |
---|
40 | if [ ! -e "$pkgdatadir" ] && [ -e "/boot" ] ; then |
---|
41 | pkgdatadir="" |
---|
42 | for i in `find $prefix/*/grub $prefix/*/*/grub -maxdepth 1 2>/dev/null`; do |
---|
43 | last_resort=$i |
---|
44 | if echo "$i" | grep `uname -i` &> /dev/null && [ -e "$i/stage1" ]; then |
---|
45 | pkgdatadir=$i |
---|
46 | fi |
---|
47 | done |
---|
48 | [ ! "$pkgdatadir" ] && pkgdatadir=$last_resort |
---|
49 | if [ ! -e "$pkgdatadir/stage1" ] && [ -e "/boot/grub/stage1" ] ; then |
---|
50 | pkgdatadir=/tmp/grub |
---|
51 | mkdir -p $pkgdatadir |
---|
52 | cp -af /boot/grub/* $pkgdatadir |
---|
53 | fi |
---|
54 | datadir=/boot |
---|
55 | fi |
---|
56 | echo "pkgdatadir is now $pkgdatadir" |
---|
57 | echo "datadir is now $datadir" |
---|
58 | |
---|
59 | grub_shell=${sbindir}/grub |
---|
60 | [ ! -e "$grub_shell" ] && grub_shell=`which grub` |
---|
61 | log_file=/tmp/grub-install.log.$$ |
---|
62 | img_file=/tmp/grub-install.img.$$ |
---|
63 | rootdir= |
---|
64 | grub_prefix=/boot/grub |
---|
65 | |
---|
66 | install_device= |
---|
67 | force_lba= |
---|
68 | recheck=no |
---|
69 | debug=no |
---|
70 | justcopy=no |
---|
71 | |
---|
72 | # look for secure tempfile creation wrappers on this platform |
---|
73 | if test -x /bin/tempfile; then |
---|
74 | mklog="/bin/tempfile --prefix=grub" |
---|
75 | mkimg="/bin/tempfile --prefix=grub" |
---|
76 | elif test -x /bin/mktemp; then |
---|
77 | mklog="/bin/mktemp /tmp/grub-install.log.XXXXXX" |
---|
78 | mkimg="/bin/mktemp /tmp/grub-install.img.XXXXXX" |
---|
79 | else |
---|
80 | mklog="" |
---|
81 | mkimg="" |
---|
82 | fi |
---|
83 | |
---|
84 | # Usage: usage |
---|
85 | # Print the usage. |
---|
86 | usage () { |
---|
87 | cat <<EOF |
---|
88 | Usage: grub-install [OPTION] install_device |
---|
89 | Install GRUB on your drive. |
---|
90 | |
---|
91 | -h, --help print this message and exit |
---|
92 | -v, --version print the version information and exit |
---|
93 | --root-directory=DIR install GRUB images under the directory DIR |
---|
94 | instead of the root directory |
---|
95 | --grub-shell=FILE use FILE as the grub shell |
---|
96 | --force-lba force GRUB to use LBA mode even for a buggy |
---|
97 | BIOS |
---|
98 | --recheck probe a device map even if it already exists |
---|
99 | |
---|
100 | INSTALL_DEVICE can be a GRUB device name or a system device filename. |
---|
101 | |
---|
102 | Report bugs to <bug-grub@gnu.org>. |
---|
103 | EOF |
---|
104 | } |
---|
105 | |
---|
106 | # Usage: convert os_device |
---|
107 | # Convert an OS device to the corresponding GRUB drive. |
---|
108 | # This part is OS-specific. |
---|
109 | convert () { |
---|
110 | # First, check if the device file exists. |
---|
111 | if test -e "$1"; then |
---|
112 | : |
---|
113 | else |
---|
114 | echo "$1: Not found or not a block device." 1>&2 |
---|
115 | exit 1 |
---|
116 | fi |
---|
117 | |
---|
118 | # Break the device name into the disk part and the partition part. |
---|
119 | case "$host_os" in |
---|
120 | linux*) |
---|
121 | var=`echo $1 | grep -v '/dev/md'` |
---|
122 | if [ $? -eq 0 ]; then |
---|
123 | |
---|
124 | tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \ |
---|
125 | -e 's%\(fd[0-9]*\)$%\1%' \ |
---|
126 | -e 's%/part[0-9]*$%/disc%' \ |
---|
127 | -e 's%\(c[0-7]d[0-9]*\).*$%\1%'` |
---|
128 | tmp_part=`echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \ |
---|
129 | -e 's%.*/fd[0-9]*$%%' \ |
---|
130 | -e 's%.*/floppy/[0-9]*$%%' \ |
---|
131 | -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \ |
---|
132 | -e 's%.*c[0-7]d[0-9]*p*%%'` |
---|
133 | else |
---|
134 | |
---|
135 | LN1=`grep -n "$1" /etc/raidtab | cut -f1 -d\:` |
---|
136 | LN2=`grep -n raiddev /etc/raidtab | grep -A 1 "$LN1" | \ |
---|
137 | cut -f1 -d\: | grep -v "$LN1"` |
---|
138 | let LN2='LN2 - 1' |
---|
139 | let LN='LN2 - LN1' |
---|
140 | |
---|
141 | one=`grep -A $LN "$1" /etc/raidtab | grep device | head -1 \ |
---|
142 | | sed s/device//g | tr '\011' '\0' | sed 's/ *//g'` |
---|
143 | |
---|
144 | tmp_disk=`echo "$one" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \ |
---|
145 | -e 's%\(fd[0-9]*\)$%\1%' \ |
---|
146 | -e 's%/part[0-9]*$%/disc%' \ |
---|
147 | -e 's%\(c[0-7]d[0-9]*\).*$%\1%'` |
---|
148 | tmp_part=`echo "$one" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \ |
---|
149 | -e 's%.*/fd[0-9]*$%%' \ |
---|
150 | -e 's%.*/floppy/[0-9]*$%%' \ |
---|
151 | -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \ |
---|
152 | -e 's%.*c[0-7]d[0-9]*p*%%'` |
---|
153 | |
---|
154 | fi |
---|
155 | ;; |
---|
156 | gnu*) |
---|
157 | tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'` |
---|
158 | tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;; |
---|
159 | freebsd*) |
---|
160 | tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \ |
---|
161 | | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'` |
---|
162 | tmp_part=`echo "$1" \ |
---|
163 | | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \ |
---|
164 | | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"` |
---|
165 | ;; |
---|
166 | netbsd*) |
---|
167 | tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([sw]d[0-9]*\).*$%r\1d%' \ |
---|
168 | | sed 's%r\{0,1\}\(fd[0-9]*\).*$%r\1a%'` |
---|
169 | tmp_part=`echo "$1" \ |
---|
170 | | sed "s%.*/r\{0,1\}[sw]d[0-9]\([abe-p]\)%\1%"` |
---|
171 | ;; |
---|
172 | *) |
---|
173 | echo "grub-install does not support your OS yet." 1>&2 |
---|
174 | exit 1 ;; |
---|
175 | esac |
---|
176 | |
---|
177 | var=`echo $1 | grep -v '/dev/md'` |
---|
178 | if [ $? -eq 0 ]; then |
---|
179 | |
---|
180 | # Get the drive name. |
---|
181 | tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \ |
---|
182 | | sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'` |
---|
183 | |
---|
184 | else |
---|
185 | |
---|
186 | LN1=`grep -n "$1" /etc/raidtab | cut -f1 -d\:` |
---|
187 | LN2=`grep -n raiddev /etc/raidtab | grep -A 1 "$LN1" | \ |
---|
188 | cut -f1 -d\: | grep -v "$LN1"` |
---|
189 | let LN2='LN2 - 1' |
---|
190 | let LN='LN2 - LN1' |
---|
191 | |
---|
192 | tmp_raid=`grep -A $LN "$1" /etc/raidtab | grep device | head -1 \ |
---|
193 | | sed s/device//g | tr '\011' '\0' | sed 's/ *//g' | sed s/[0-9]//g` |
---|
194 | tmp_drive=`grep -v '^#' $device_map | grep "$tmp_raid *$" \ |
---|
195 | | sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'` |
---|
196 | |
---|
197 | fi |
---|
198 | |
---|
199 | # If not found, print an error message and exit. |
---|
200 | if test "x$tmp_drive" = x; then |
---|
201 | echo "$1 does not have any corresponding BIOS drive." 1>&2 |
---|
202 | exit 1 |
---|
203 | fi |
---|
204 | |
---|
205 | if test "x$tmp_part" != x; then |
---|
206 | # If a partition is specified, we need to translate it into the |
---|
207 | # GRUB's syntax. |
---|
208 | case "$host_os" in |
---|
209 | linux*) |
---|
210 | echo "$tmp_drive" | sed "s%)$%,`expr $tmp_part - 1`)%" ;; |
---|
211 | gnu*) |
---|
212 | if echo $tmp_part | grep "^s" >/dev/null; then |
---|
213 | tmp_pc_slice=`echo $tmp_part \ |
---|
214 | | sed "s%s\([0-9]*\)[a-g]*$%\1%"` |
---|
215 | tmp_drive=`echo "$tmp_drive" \ |
---|
216 | | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"` |
---|
217 | fi |
---|
218 | if echo $tmp_part | grep "[a-g]$" >/dev/null; then |
---|
219 | tmp_bsd_partition=`echo "$tmp_part" \ |
---|
220 | | sed "s%[^a-g]*\([a-g]\)$%\1%"` |
---|
221 | tmp_drive=`echo "$tmp_drive" \ |
---|
222 | | sed "s%)%,$tmp_bsd_partition)%"` |
---|
223 | fi |
---|
224 | echo "$tmp_drive" ;; |
---|
225 | freebsd*) |
---|
226 | if echo $tmp_part | grep "^s" >/dev/null; then |
---|
227 | tmp_pc_slice=`echo $tmp_part \ |
---|
228 | | sed "s%s\([0-9]*\)[a-h]*$%\1%"` |
---|
229 | tmp_drive=`echo "$tmp_drive" \ |
---|
230 | | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"` |
---|
231 | fi |
---|
232 | if echo $tmp_part | grep "[a-h]$" >/dev/null; then |
---|
233 | tmp_bsd_partition=`echo "$tmp_part" \ |
---|
234 | | sed "s%s\{0,1\}[0-9]*\([a-h]\)$%\1%"` |
---|
235 | tmp_drive=`echo "$tmp_drive" \ |
---|
236 | | sed "s%)%,$tmp_bsd_partition)%"` |
---|
237 | fi |
---|
238 | echo "$tmp_drive" ;; |
---|
239 | netbsd*) |
---|
240 | if echo $tmp_part | grep "^[abe-p]$" >/dev/null; then |
---|
241 | tmp_bsd_partition=`echo "$tmp_part" \ |
---|
242 | | sed "s%\([a-p]\)$%\1%"` |
---|
243 | tmp_drive=`echo "$tmp_drive" \ |
---|
244 | | sed "s%)%,$tmp_bsd_partition)%"` |
---|
245 | fi |
---|
246 | echo "$tmp_drive" ;; |
---|
247 | esac |
---|
248 | else |
---|
249 | # If no partition is specified, just print the drive name. |
---|
250 | echo "$tmp_drive" |
---|
251 | fi |
---|
252 | } |
---|
253 | |
---|
254 | # Usage: find_device file |
---|
255 | # Find block device on which the file resides. |
---|
256 | find_device () { |
---|
257 | # For now, this uses the program `df' to get the device name, but is |
---|
258 | # this really portable? |
---|
259 | tmp_fname=`df $1/ | sed -n 's%.*\(/dev/[^ ]*\).*%\1%p'` |
---|
260 | |
---|
261 | if test -z "$tmp_fname"; then |
---|
262 | echo "Could not find device for $1" 2>&1 |
---|
263 | exit 1 |
---|
264 | fi |
---|
265 | |
---|
266 | # Resolve symlinks |
---|
267 | while test -L $tmp_fname; do |
---|
268 | tmp_new_fname=`ls -al $tmp_fname | sed -n 's%.*-> %\1%p'` |
---|
269 | if test -z "$tmp_new_fname"; then |
---|
270 | echo "Unrecognized ls output" 2>&1 |
---|
271 | exit 1 |
---|
272 | fi |
---|
273 | |
---|
274 | # Convert relative symlinks |
---|
275 | case $tmp_new_fname in |
---|
276 | /*) tmp_fname="$tmp_new_fname" ;; |
---|
277 | *) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname" ;; |
---|
278 | esac |
---|
279 | done |
---|
280 | echo "$tmp_fname" |
---|
281 | } |
---|
282 | |
---|
283 | copy_images() { |
---|
284 | for file in ${pkgdatadir}/stage1 ${pkgdatadir}/stage2 ${pkgdatadir}/*stage1_5; do |
---|
285 | cp -f $file ${grubdir} || exit 1 |
---|
286 | done |
---|
287 | } |
---|
288 | |
---|
289 | # Check the arguments. |
---|
290 | for option in "$@"; do |
---|
291 | case "$option" in |
---|
292 | -h | --help) |
---|
293 | usage |
---|
294 | exit 0 ;; |
---|
295 | -v | --version) |
---|
296 | echo "grub-install (GNU GRUB ${VERSION})" |
---|
297 | exit 0 ;; |
---|
298 | --root-directory=*) |
---|
299 | rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; |
---|
300 | --grub-shell=*) |
---|
301 | grub_shell=`echo "$option" | sed 's/--grub-shell=//'` ;; |
---|
302 | --force-lba) |
---|
303 | force_lba="--force-lba" ;; |
---|
304 | --recheck) |
---|
305 | recheck=yes ;; |
---|
306 | --just-copy) |
---|
307 | justcopy=yes ;; |
---|
308 | # This is an undocumented feature... |
---|
309 | --debug) |
---|
310 | debug=yes ;; |
---|
311 | -*) |
---|
312 | echo "Unrecognized option \`$option'" 1>&2 |
---|
313 | usage |
---|
314 | exit 1 |
---|
315 | ;; |
---|
316 | *) |
---|
317 | if test "x$install_device" != x; then |
---|
318 | echo "More than one install_devices?" 1>&2 |
---|
319 | usage |
---|
320 | exit 1 |
---|
321 | fi |
---|
322 | install_device="${option}" ;; |
---|
323 | esac |
---|
324 | done |
---|
325 | |
---|
326 | # If the debugging feature is enabled, print commands. |
---|
327 | if test $debug = yes; then |
---|
328 | set -x |
---|
329 | fi |
---|
330 | |
---|
331 | # Initialize these directories here, since ROOTDIR was initialized. |
---|
332 | case "$host_os" in |
---|
333 | netbsd*) |
---|
334 | # Because /boot is used for the boot block in NetBSD, use /grub |
---|
335 | # instead of /boot/grub. |
---|
336 | grub_prefix=/grub |
---|
337 | bootdir=${rootdir} |
---|
338 | ;; |
---|
339 | *) |
---|
340 | # Use /boot/grub by default. |
---|
341 | bootdir=${rootdir}/boot |
---|
342 | ;; |
---|
343 | esac |
---|
344 | |
---|
345 | grubdir=${bootdir}/grub |
---|
346 | device_map=${grubdir}/device.map |
---|
347 | |
---|
348 | # if they just want the images copied, copy the images and then exit |
---|
349 | if test $justcopy = yes; then |
---|
350 | copy_images |
---|
351 | exit 0 |
---|
352 | fi |
---|
353 | |
---|
354 | if test "x$install_device" = x; then |
---|
355 | echo "install_device not specified." 1>&2 |
---|
356 | usage |
---|
357 | exit 1 |
---|
358 | fi |
---|
359 | |
---|
360 | # Check if GRUB is installed |
---|
361 | if test -f "$grub_shell"; then |
---|
362 | : |
---|
363 | else |
---|
364 | echo "${grub_shell}: Not found." 1>&2 |
---|
365 | exit 1 |
---|
366 | fi |
---|
367 | |
---|
368 | if test -f "$pkgdatadir/stage1"; then |
---|
369 | : |
---|
370 | else |
---|
371 | echo "${pkgdatadir}/stage1: Not found." 1>&2 |
---|
372 | exit 1 |
---|
373 | fi |
---|
374 | |
---|
375 | if test -f "$pkgdatadir/stage2"; then |
---|
376 | : |
---|
377 | else |
---|
378 | echo "${pkgdatadir}/stage2: Not found." 1>&2 |
---|
379 | exit 1 |
---|
380 | fi |
---|
381 | |
---|
382 | # Don't check for *stage1_5, because it is not fatal even if any |
---|
383 | # Stage 1.5 does not exist. |
---|
384 | |
---|
385 | # Create the GRUB directory if it is not present. |
---|
386 | test -d "$bootdir" || mkdir "$bootdir" || exit 1 |
---|
387 | test -d "$grubdir" || mkdir "$grubdir" || exit 1 |
---|
388 | |
---|
389 | copy_images |
---|
390 | |
---|
391 | # If --recheck is specified, remove the device map, if present. |
---|
392 | if test $recheck = yes; then |
---|
393 | rm -f $device_map |
---|
394 | fi |
---|
395 | |
---|
396 | # Create the device map file if it is not present. |
---|
397 | if test -f "$device_map"; then |
---|
398 | : |
---|
399 | else |
---|
400 | # Create a safe temporary file. |
---|
401 | test -n "$mklog" && log_file=`$mklog` |
---|
402 | |
---|
403 | # Before all invocations of the grub shell, call sync to make sure |
---|
404 | # the raw device is in sync with any bufferring in filesystems. |
---|
405 | sync |
---|
406 | |
---|
407 | $grub_shell --batch --device-map=$device_map <<EOF >$log_file |
---|
408 | quit |
---|
409 | EOF |
---|
410 | if grep "Error [0-9]*: " $log_file >/dev/null; then |
---|
411 | cat $log_file 1>&2 |
---|
412 | exit 1 |
---|
413 | fi |
---|
414 | |
---|
415 | rm -f $log_file |
---|
416 | fi |
---|
417 | |
---|
418 | # Make sure that there is no duplicated entry. |
---|
419 | tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \ |
---|
420 | | sort | uniq -d | sed -n 1p` |
---|
421 | if test -n "$tmp"; then |
---|
422 | echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2 |
---|
423 | exit 1 |
---|
424 | fi |
---|
425 | |
---|
426 | # Check for INSTALL_DEVICE. |
---|
427 | case "$install_device" in |
---|
428 | /dev/*) |
---|
429 | install_drive=`convert "$install_device"` |
---|
430 | # I don't know why, but some shells wouldn't die if exit is |
---|
431 | # called in a function. |
---|
432 | if test "x$install_drive" = x; then |
---|
433 | exit 1 |
---|
434 | fi ;; |
---|
435 | \([hf]d[0-9]*\)) |
---|
436 | install_drive="$install_device" ;; |
---|
437 | *) |
---|
438 | echo "Format of install_device not recognized." 1>&2 |
---|
439 | usage |
---|
440 | exit 1 ;; |
---|
441 | esac |
---|
442 | |
---|
443 | # Get the root drive. |
---|
444 | root_device=`find_device ${rootdir}` |
---|
445 | bootdir_device=`find_device ${bootdir}` |
---|
446 | |
---|
447 | # Check if the boot directory is in the same device as the root directory. |
---|
448 | if test "x$root_device" != "x$bootdir_device"; then |
---|
449 | # Perhaps the user has a separate boot partition. |
---|
450 | root_device=$bootdir_device |
---|
451 | grub_prefix="/grub" |
---|
452 | fi |
---|
453 | |
---|
454 | # Convert the root device to a GRUB drive. |
---|
455 | root_drive=`convert "$root_device"` |
---|
456 | if test "x$root_drive" = x; then |
---|
457 | exit 1 |
---|
458 | fi |
---|
459 | |
---|
460 | # Check if the root directory exists in the same device as the grub |
---|
461 | # directory. |
---|
462 | grubdir_device=`find_device ${grubdir}` |
---|
463 | |
---|
464 | if test "x$grubdir_device" != "x$root_device"; then |
---|
465 | # For now, cannot deal with this situation. |
---|
466 | cat <<EOF 1>&2 |
---|
467 | You must set the root directory by the option --root-directory, because |
---|
468 | $grubdir does not exist in the root device $root_device. |
---|
469 | EOF |
---|
470 | exit 1 |
---|
471 | fi |
---|
472 | |
---|
473 | # Make sure that GRUB reads the same images as the host OS. |
---|
474 | test -n "$mkimg" && img_file=`$mkimg` |
---|
475 | test -n "$mklog" && log_file=`$mklog` |
---|
476 | |
---|
477 | for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do |
---|
478 | count=5 |
---|
479 | tmp=`echo $file | sed "s|^${grubdir}|${grub_prefix}|"` |
---|
480 | while test $count -gt 0; do |
---|
481 | $grub_shell --batch --device-map=$device_map <<EOF >$log_file |
---|
482 | dump ${root_drive}${tmp} ${img_file} |
---|
483 | quit |
---|
484 | EOF |
---|
485 | if grep "Error [0-9]*: " $log_file >/dev/null; then |
---|
486 | : |
---|
487 | elif cmp $file $img_file >/dev/null; then |
---|
488 | break |
---|
489 | fi |
---|
490 | sleep 1 |
---|
491 | count=`expr $count - 1` |
---|
492 | done |
---|
493 | if test $count -eq 0; then |
---|
494 | echo "The file $file not read correctly." 1>&2 |
---|
495 | exit 1 |
---|
496 | fi |
---|
497 | done |
---|
498 | |
---|
499 | rm -f $img_file |
---|
500 | rm -f $log_file |
---|
501 | |
---|
502 | # Create a safe temporary file. |
---|
503 | test -n "$mklog" && log_file=`$mklog` |
---|
504 | |
---|
505 | # Before all invocations of the grub shell, call sync to make sure |
---|
506 | # the raw device is in sync with any bufferring in filesystems. |
---|
507 | sync |
---|
508 | |
---|
509 | # Now perform the installation. |
---|
510 | $grub_shell --batch --device-map=$device_map <<EOF >$log_file |
---|
511 | root $root_drive |
---|
512 | setup $force_lba --stage2=$grubdir/stage2 --prefix=$grub_prefix $install_drive |
---|
513 | quit |
---|
514 | EOF |
---|
515 | |
---|
516 | if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then |
---|
517 | cat $log_file 1>&2 |
---|
518 | exit 1 |
---|
519 | fi |
---|
520 | |
---|
521 | rm -f $log_file |
---|
522 | |
---|
523 | # Prompt the user to check if the device map is correct. |
---|
524 | echo "Installation finished. No error reported." |
---|
525 | echo "This is the contents of the device map $device_map." |
---|
526 | echo "Check if this is correct or not. If any of the lines is incorrect," |
---|
527 | echo "fix it and re-run the script \`grub-install'." |
---|
528 | echo |
---|
529 | |
---|
530 | cat $device_map |
---|
531 | |
---|
532 | # Bye. |
---|
533 | exit 0 |
---|