#!/bin/sh set -e . /usr/share/debconf/confmodule 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` rootfs=`mapdevfs $rootfs` defaultbootdev=`echo $rootfs |sed 's/[0-9]\+$//'` db_fget arcboot/boot_device seen [ "$RET" = true ] || db_set arcboot/boot_device "$defaultbootdev" db_input high arcboot/boot_device || [ $? -eq 30 ] db_go || true db_get arcboot/boot_device bootdev=$RET [ "$bootdev" != '' ] || bootdev=$defaultbootdev # Use a serial console if current default console is a serial port. # default console is last listed defconsole=$(sed -e 's/.*console=/console=/' /proc/cmdline) if echo "${defconsole}" | grep -q console=ttyS; then defconsole=$(echo "${defconsole}" | sed -e 's/[[:space:]].*//') PORT=$(echo "${defconsole}" | sed -e 's%^console=ttyS%%' -e 's%,.*%%') SPEED=$(echo "${defconsole}" | sed -e 's%^console=ttyS[0-9]\+,*%%' -e 's%[[:space:]].*%%') SERIAL="${PORT}" if [ "${SPEED}" != '' ]; then SERIAL="${SERIAL},${SPEED}" fi db_subst arcboot-installer/serial-console PORT "ttyS${PORT}" db_subst arcboot-installer/serial-console SPEED "${SPEED}" db_input medium arcboot-installer/serial-console || [ $? -eq 30 ] db_go || true fi # write out arcboot.conf { echo 'label=Linux' echo ' image=/vmlinux' echo ' initrd=/initrd.img' if [ "${SERIAL}" ]; then echo " append=\"root=${rootfs} console=ttyS${SERIAL}\"" else echo " append=\"root=${rootfs}\"" fi } > /target/etc/arcboot.conf # Install arcboot only after arcboot.conf is created since the arcboot # postinst fails in a chroot. # # HACK ALERT! # The arcboot postinst wants to read $bootdev from debconf _in the chroot_, # which is still empty. We ignore the resulting apt-install error and do the # install ourself. If apt-install fails for a different reason, we are lost. # # mount proc since arcboot needs it to find out the subarchitecture mount -t proc proc /target/proc set +e apt-install arcboot chroot /target /usr/sbin/arcboot $bootdev set -e umount /target/proc #if ! apt-install arcboot; then # log "Calling 'apt-install arcboot' failed" # # What to do now? # db_input critical arcboot-installer/apt-install-failed || [$? -eq 30] # db_go # db_get # if [ true != "$RET" ] ; then # exit 1 # fi #fi # Fill the necessary PROM variables that will need to be set before the # system can be booted. bootmin=$((`echo $bootdev |sed 's+/dev/sd++' |tr [a-h] [0-7]` * 16)) bootdev=`grep "^\ \+8\ \+$bootmin\ \+" /proc/partitions | sed -e "s/ \+/ /g" | cut -d " " -f5` scsi_info=$(readlink /sys/block/$bootdev/device | sed 's/.*\///') BOOTBUS=`echo $scsi_info | cut -d: -f2` BOOTID=`echo $scsi_info | cut -d: -f3` BOOTLUN=`echo $scsi_info | cut -d: -f4` rootmin=`echo $rootfs |sed 's+/dev/sd.++'` rootdev=`grep "^\ \+8\ \+$rootmin\ \+" /proc/partitions | sed -e "s/ \+/ /g" | cut -d " " -f5` rootdev=$(echo $rootdev | sed 's/[0-9]\+$//') scsi_info=$(readlink /sys/block/$rootdev/device | sed 's/.*\///') ROOTBUS=`echo $scsi_info | cut -d: -f2` ROOTID=`echo $scsi_info | cut -d: -f3` ROOTLUN=`echo $scsi_info | cut -d: -f4` ROOTPART=$(($rootmin - 1)) db_subst arcboot-installer/prom-variables BOOTBUS "${BOOTBUS}" db_subst arcboot-installer/prom-variables BOOTID "${BOOTID}" db_subst arcboot-installer/prom-variables BOOTLUN "${BOOTLUN}" db_subst arcboot-installer/prom-variables ROOTBUS "${ROOTBUS}" db_subst arcboot-installer/prom-variables ROOTID "${ROOTID}" db_subst arcboot-installer/prom-variables ROOTLUN "${ROOTLUN}" db_subst arcboot-installer/prom-variables ROOTPART "${ROOTPART}" db_input high arcboot-installer/prom-variables || [ $? -eq 30 ] db_go || true