1 |
#! /bin/sh |
#! /bin/sh |
2 |
|
|
3 |
# Install GRUB on your drive. |
# Install GRUB on your drive. |
4 |
# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
# Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. |
5 |
# |
# |
6 |
# This file is free software; you can redistribute it and/or modify it |
# This file is free software; you can redistribute it and/or modify it |
7 |
# under the terms of the GNU General Public License as published by |
# under the terms of the GNU General Public License as published by |
31 |
|
|
32 |
grub_shell=${sbindir}/grub |
grub_shell=${sbindir}/grub |
33 |
log_file=/tmp/grub-install.log.$$ |
log_file=/tmp/grub-install.log.$$ |
34 |
|
img_file=/tmp/grub-install.img.$$ |
35 |
rootdir= |
rootdir= |
36 |
grub_prefix=/boot/grub |
grub_prefix=/boot/grub |
37 |
|
|
42 |
|
|
43 |
# look for secure tempfile creation wrappers on this platform |
# look for secure tempfile creation wrappers on this platform |
44 |
if test -x /bin/tempfile; then |
if test -x /bin/tempfile; then |
45 |
mkstemp="/bin/tempfile --prefix=grub" |
mklog="/bin/tempfile --prefix=grub" |
46 |
|
mkimg="/bin/tempfile --prefix=grub" |
47 |
elif test -x /bin/mktemp; then |
elif test -x /bin/mktemp; then |
48 |
mkstemp="/bin/mktemp /tmp/grub-install.log.XXXXXX" |
mklog="/bin/mktemp /tmp/grub-install.log.XXXXXX" |
49 |
|
mkimg="/bin/mktemp /tmp/grub-install.img.XXXXXX" |
50 |
else |
else |
51 |
mkstemp="" |
mklog="" |
52 |
|
mkimg="" |
53 |
fi |
fi |
54 |
|
|
55 |
# Usage: usage |
# Usage: usage |
310 |
: |
: |
311 |
else |
else |
312 |
# Create a safe temporary file. |
# Create a safe temporary file. |
313 |
test -n "$mkstemp" && log_file=`$mkstemp` |
test -n "$mklog" && log_file=`$mklog` |
314 |
|
|
315 |
$grub_shell --batch --device-map=$device_map <<EOF >$log_file |
$grub_shell --batch --device-map=$device_map <<EOF >$log_file |
316 |
quit |
quit |
379 |
cp -f $file ${grubdir} || exit 1 |
cp -f $file ${grubdir} || exit 1 |
380 |
done |
done |
381 |
|
|
382 |
|
# Make sure that GRUB reads the same images as the host OS. |
383 |
|
test -n "$mkimg" && img_file=`$mkimg` |
384 |
|
test -n "$mklog" && log_file=`$mklog` |
385 |
|
|
386 |
|
for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do |
387 |
|
count=5 |
388 |
|
tmp=`echo $file | sed "s|^${grubdir}|${grub_prefix}|"` |
389 |
|
while test $count -gt 0; do |
390 |
|
$grub_shell --batch --device-map=$device_map <<EOF >$log_file |
391 |
|
dump ${root_drive}${tmp} ${img_file} |
392 |
|
quit |
393 |
|
EOF |
394 |
|
if grep "Error [0-9]*: " $log_file >/dev/null; then |
395 |
|
: |
396 |
|
elif cmp $file $img_file >/dev/null; then |
397 |
|
break |
398 |
|
fi |
399 |
|
sleep 1 |
400 |
|
count=`expr $count - 1` |
401 |
|
done |
402 |
|
if test $count -eq 0; then |
403 |
|
echo "The file $file not read correctly." 1>&2 |
404 |
|
exit 1 |
405 |
|
fi |
406 |
|
done |
407 |
|
|
408 |
|
rm -f $img_file |
409 |
|
rm -f $log_file |
410 |
|
|
411 |
# Create a safe temporary file. |
# Create a safe temporary file. |
412 |
test -n "$mkstemp" && log_file=`$mkstemp` |
test -n "$mklog" && log_file=`$mklog` |
413 |
|
|
414 |
# Now perform the installation. |
# Now perform the installation. |
415 |
$grub_shell --batch --device-map=$device_map <<EOF >$log_file |
$grub_shell --batch --device-map=$device_map <<EOF >$log_file |