| 1 |
#! /bin/sh -e |
| 2 |
|
| 3 |
. /usr/share/debconf/confmodule |
| 4 |
|
| 5 |
. /usr/share/grub-installer/functions.sh |
| 6 |
|
| 7 |
db_progress START 0 2 grub-installer/progress/title |
| 8 |
db_progress INFO grub-installer/progress/step_bootdev |
| 9 |
|
| 10 |
# If we're installing grub-efi, it wants /sys mounted in the |
| 11 |
# target. Maybe /proc too, and definitely the efivars fs. Should be |
| 12 |
# harmless if we're not using it. |
| 13 |
mountvirtfs proc /target/proc |
| 14 |
mountvirtfs sysfs /target/sys |
| 15 |
modprobe efivarfs >/dev/null 2>&1 || true |
| 16 |
mountvirtfs efivarfs /target/sys/firmware/efi/efivars non-fatal |
| 17 |
if [ -e /target/boot/efi ]; then |
| 18 |
chroot /target mount /boot/efi && on_exit "umount /target/boot/efi" || true |
| 19 |
fi |
| 20 |
|
| 21 |
db_input critical grub-installer/bootdev |
| 22 |
if ! db_go; then |
| 23 |
# back up to menu |
| 24 |
db_progress STOP |
| 25 |
exit 10 |
| 26 |
fi |
| 27 |
|
| 28 |
db_get grub-installer/bootdev |
| 29 |
bootdev="$RET" |
| 30 |
if echo "$bootdev" | grep -qv '('; then |
| 31 |
mappedbootdev="$(mapdevfs "$bootdev")" || true |
| 32 |
if [ "$mappedbootdev" ]; then |
| 33 |
bootdev="$mappedbootdev" |
| 34 |
fi |
| 35 |
fi |
| 36 |
|
| 37 |
db_progress STEP 1 |
| 38 |
db_subst grub-installer/progress/step_install_loader BOOTDEV "$bootdev" |
| 39 |
db_progress INFO grub-installer/progress/step_install_loader |
| 40 |
|
| 41 |
update_mtab |
| 42 |
|
| 43 |
grub_install_params= |
| 44 |
if ! is_floppy "$bootdev"; then |
| 45 |
grub_install_params="$grub_install_params --no-floppy" |
| 46 |
fi |
| 47 |
|
| 48 |
if chroot /target grub-install --version | grep -q 'GNU GRUB 0'; then |
| 49 |
grub_install_params="$grub_install_params --recheck" |
| 50 |
fi |
| 51 |
|
| 52 |
if ! log-output -t grub-installer chroot /target grub-install $grub_install_params "$bootdev"; then |
| 53 |
db_subst grub-installer/grub-install-failed BOOTDEV "$bootdev" |
| 54 |
db_input critical grub-installer/grub-install-failed || true |
| 55 |
db_go || true |
| 56 |
db_progress STOP |
| 57 |
exit 1 |
| 58 |
fi |
| 59 |
|
| 60 |
db_progress STEP 1 |
| 61 |
db_progress STOP |