#!/bin/sh set -e . /usr/share/debconf/confmodule db_capb backup log() { logger -t elilo-installer "$@" } error() { log "error: $@" } info() { log "info: $@" } if [ -f /etc/mtab ]; then MTAB=/etc/mtab else MTAB=/proc/mounts fi # detect which is the root partition: /target rootfs=`grep ' /target ' $MTAB |cut -d' ' -f1 -s` # Find all partitions with fat filesystems and the boot flag set. May be # enough just to look for one of those. OTOH, elilo will convert any # partition you give it to FAT... Also translates /dev/discs paths in to # real /dev/scsi (or ide) paths. rm -f /tmp/efi_boot.list /usr/lib/partconf/find-partitions --flag boot | while read part fs size; do case $fs in fat16|fat32) echo "$part" >> /tmp/efi_boot.list ;; esac done bootpart_priority=medium default_bootpart= if [ -s /tmp/efi_boot.list ]; then for d in `cat /tmp/efi_boot.list`; do d=`mapdevfs $d` if [ -n "$BOOTPARTS" ]; then BOOTPARTS="$BOOTPARTS, $d" bootpart_priority=critical else default_bootpart=$d BOOTPARTS=$d fi done else db_capb db_input critical elilo-installer/no-bootpart db_go || true exit 1 fi rm -f /tmp/efi_boot.list db_subst elilo-installer/bootpart BOOTPARTS $BOOTPARTS db_fget elilo-installer/bootpart seen if [ "$RET" = false ]; then db_set elilo-installer/bootpart "$default_bootpart" fi db_input "$bootpart_priority" elilo-installer/bootpart || true db_go || exit 10 db_get elilo-installer/bootpart bootpart=$RET rootfs=`mapdevfs $rootfs` # Write out elilo.conf # TODO: this template doesn't have the right text; need a different template # for the progress bar title. db_progress START 0 2 debian-installer/elilo-installer/title db_progress INFO elilo-installer/progress_installing if ! apt-install elilo ; then info "Calling 'apt-install elilo' failed" # Hm, unable to install elilo into /target/, what should we do? db_input critical elilo-installer/apt-install-failed || [ $? -eq 30 ] if ! db_go; then db_progress STOP exit 10 # back up to menu fi db_get elilo-installer/apt-install-failed if [ true != "$RET" ] ; then db_progress STOP exit 1 fi fi db_progress STEP 1 db_subst elilo-installer/progress_running bootdev "$bootpart" db_progress INFO elilo-installer/progress_running ## efibootmgr, which is called by elilo, needs this if [ ! -f /proc/efivars ] && [ ! -d /sys/firmware/efi/vars ] ; then if ! modprobe efivars ; then log "Couldn't load efivars module - is it statically linked?" fi fi ## efi variables (needed by efibootmgr) are exported via proc in 2.4, ## or via sysfs in 2.6. Make sure sysfs is mounted if it needs to be. ## We should probably also make sure proc is mounted, since whatever is ## mounting /proc today may not always do so in the future. sysmount=0 if grep -q sysfs /proc/filesystems ; then if [ ! -d /target/sys ] ; then error "/target/sys does not exist" fi ## check to see if sysfs is already mounted in the target if ! grep '^sysfs ' /proc/mounts | cut -d' ' -f2 | grep -q '^/target/sys$' ; then if mount sysfs /target/sys -t sysfs ; then sysmount=1 else log "Couldn't mount sysfs, continuing in case its not needed" fi fi fi errcode=0 chroot /target /usr/sbin/elilo --autoconf --boot $bootpart \ --root $rootfs --efiboot || errcode=$? ## umount sysfs if we mounted it above if [ $sysmount -eq 1 ]; then if ! umount /target/sys; then log "Couldn't umount sysfs, continuing in case that's ok" fi fi if [ "$errcode" = 0 ] ; then info "Boot loader successfully installed into EFI partition" else db_subst elilo-installer/failed ERRCODE "$errcode" db_input critical elilo-installer/failed || [ $? -eq 30 ] db_progress STOP db_go || exit 10 # back up exit 1 fi db_progress STEP 1 db_progress STOP sed 's/do_bootloader = no/do_bootloader = yes/' < /target/etc/kernel-img.conf > /target/etc/kernel-img.conf.$$ mv /target/etc/kernel-img.conf.$$ /target/etc/kernel-img.conf exit 0