live-build/helpers/lh_binary_yaboot

282 lines
6.9 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:50 +00:00
#!/bin/sh
# lh_binary_yaboot(1) - installs yaboot into binary
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.
set -e
2007-09-23 08:05:11 +00:00
# Including common functions
LH_BASE="${LH_BASE:-/usr/share/live-helper}"
for FUNCTION in "${LH_BASE}"/functions/*.sh
2007-09-23 08:04:50 +00:00
do
2007-09-23 08:05:11 +00:00
. "${FUNCTION}"
2007-09-23 08:04:50 +00:00
done
2007-09-23 08:05:11 +00:00
# Setting static variables
2007-09-23 08:04:50 +00:00
DESCRIPTION="installs yaboot into binary"
HELP=""
USAGE="${PROGRAM} [--force]"
Arguments "${@}"
# Reading configuration files
2007-09-23 08:04:52 +00:00
Read_conffile config/common
2007-09-23 08:04:50 +00:00
Read_conffile config/bootstrap
Read_conffile config/chroot
2007-09-23 08:04:52 +00:00
Read_conffile config/binary
Read_conffile config/source
2007-09-23 08:05:18 +00:00
Read_conffile "${LH_CONFIG}"
2007-09-23 08:04:50 +00:00
Set_defaults
2007-09-23 08:05:17 +00:00
if [ "${LH_BOOTLOADER}" != "yaboot" ]
2007-09-23 08:04:50 +00:00
then
exit 0
fi
2007-09-23 08:05:11 +00:00
Echo_message "Begin installing yaboot..."
2007-09-23 08:04:50 +00:00
# Requiring stage file
Require_stagefile .stage/bootstrap
# Checking stage file
Check_stagefile .stage/binary_yaboot
2007-09-23 08:05:13 +00:00
# Checking yaboot templates
Check_templates yaboot
2007-09-23 08:04:50 +00:00
# Checking lock file
Check_lockfile .lock
# Creating lock file
Create_lockfile .lock
2007-09-23 08:05:13 +00:00
# Check architecture
Check_architecture powerpc ppc64
2007-09-23 08:05:09 +00:00
2007-09-23 08:04:51 +00:00
# Checking depends
Check_package chroot/usr/lib/yaboot/yaboot yaboot
2007-09-23 08:04:50 +00:00
2007-09-23 08:05:15 +00:00
# Restoring cache
Restore_cache cache/packages_binary
2007-09-23 08:04:51 +00:00
# Installing depends
Install_package
2007-09-23 08:04:50 +00:00
2007-09-23 08:05:14 +00:00
# Local functions
Yaboot_live_entry ()
{
LABEL="${1}"
KERNEL="${2}"
INITRD="${3}"
APPEND="${4}"
DIRECTORY="/`basename ${DESTDIR_LIVE}`"
LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
LINUX_LIVE="${LINUX_LIVE}\tlabel=${LABEL}\n"
LINUX_LIVE="${LINUX_LIVE}\tinitrd=${DIRECTORY}/${INITRD}\n"
2007-09-23 08:05:17 +00:00
LINUX_LIVE="${LINUX_LIVE}\tappend=\"boot=${INITFS} LH_BOOTAPPEND ${APPEND}\"\n"
2007-09-23 08:05:14 +00:00
LINUX_LIVE="${LINUX_LIVE}\tinitrd-size=10240\n"
}
Yaboot_install_entry ()
{
LABEL="${1}"
KERNEL="${2}"
INITRD="${3}"
APPEND="${4}"
DIRECTORY="/`basename ${DESTDIR_LIVE}`"
2007-09-23 08:05:17 +00:00
if [ "${LH_DISTRIBUTION}" != "etch" ] && [ "${LABEL}" != "rescue" ] && [ "${LABEL}" != "rescuegui" ]
2007-09-23 08:05:14 +00:00
then
APPEND="${APPEND} quiet"
fi
LINUX_INSTALL="${LINUX_INSTALL}\nimage=${DIRECTORY}/${KERNEL}\n"
LINUX_INSTALL="${LINUX_INSTALL}\tlabel=${LABEL}\n"
LINUX_INSTALL="${LINUX_INSTALL}\tinitrd=${DIRECTORY}/${INITRD}\n"
2007-09-23 08:05:17 +00:00
LINUX_INSTALL="${LINUX_INSTALL}\tappend=\"LH_BOOTAPPEND ${APPEND} --\"\n"
2007-09-23 08:05:14 +00:00
LINUX_INSTALL="${LINUX_INSTALL}\tinitrd-size=10240\n"
}
2007-09-23 08:04:52 +00:00
case "${LH_INITRAMFS}" in
casper)
INITFS="casper"
;;
live-initramfs)
INITFS="live"
;;
esac
2007-09-23 08:04:50 +00:00
# Setting destination directory
2007-09-23 08:05:17 +00:00
case "${LH_BINARY_IMAGES}" in
2007-09-23 08:04:50 +00:00
iso)
2007-09-23 08:05:14 +00:00
case "${LH_INITRAMFS}" in
casper)
DESTDIR_LIVE="binary/casper"
;;
live-initramfs)
DESTDIR_LIVE="binary/live"
;;
esac
2007-09-23 08:05:12 +00:00
DESTDIR_INSTALL="binary/install"
2007-09-23 08:04:50 +00:00
;;
2007-09-23 08:05:11 +00:00
net|tar|usb-hdd)
2007-09-23 08:05:14 +00:00
Echo_error "not yet supported, aborting (FIXME)."
exit 1
2007-09-23 08:04:50 +00:00
;;
esac
2007-09-23 08:05:14 +00:00
Check_multiarchitecture
2007-09-23 08:04:50 +00:00
# Creating directory
2007-09-23 08:05:12 +00:00
mkdir -p "${DESTDIR_LIVE}"
2007-09-23 08:04:50 +00:00
# Setting boot parameters
2007-09-23 08:05:17 +00:00
if [ -n "${LH_ENCRYPTION}" ]
2007-09-23 08:04:50 +00:00
then
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="${LH_BOOTAPPEND} encryption=${LH_ENCRYPTION}"
2007-09-23 08:04:50 +00:00
fi
2007-09-23 08:05:17 +00:00
if [ -n "${LH_USERNAME}" ]
2007-09-23 08:04:50 +00:00
then
2007-09-23 08:05:09 +00:00
case "${LH_INITRAMFS}" in
casper)
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="${LH_BOOTAPPEND} username=${LH_USERNAME}"
2007-09-23 08:05:09 +00:00
;;
live-initramfs)
2007-09-23 08:05:17 +00:00
if [ "${LH_USERNAME}" != "user" ]
2007-09-23 08:05:09 +00:00
then
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="${LH_BOOTAPPEND} username=${LH_USERNAME}"
2007-09-23 08:05:09 +00:00
fi
;;
esac
2007-09-23 08:04:50 +00:00
fi
2007-09-23 08:05:17 +00:00
if [ -n "${LH_HOSTNAME}" ]
2007-09-23 08:04:50 +00:00
then
2007-09-23 08:05:11 +00:00
case "${LH_INITRAMFS}" in
2007-09-23 08:05:09 +00:00
casper)
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="${LH_BOOTAPPEND} hostname=${LH_HOSTNAME}"
2007-09-23 08:05:09 +00:00
;;
live-initramfs)
2007-09-23 08:05:17 +00:00
if [ "${LH_HOSTNAME}" != "debian" ]
2007-09-23 08:05:09 +00:00
then
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="${LH_BOOTAPPEND} hostname=${LH_HOSTNAME}"
2007-09-23 08:05:09 +00:00
fi
;;
esac
2007-09-23 08:04:50 +00:00
fi
2007-09-23 08:05:17 +00:00
if [ "${LH_UNION_FILESYSTEM}" != "unionfs" ]
2007-09-23 08:05:13 +00:00
then
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="${LH_BOOTAPPEND} union=${LH_UNION_FILESYSTEM}"
2007-09-23 08:05:13 +00:00
fi
2007-09-23 08:05:17 +00:00
LH_BOOTAPPEND="`echo ${LH_BOOTAPPEND} | sed -e 's/ //'`"
2007-09-23 08:04:50 +00:00
2007-09-23 08:05:12 +00:00
# Parameters are listed at: linux/Documentation/kernel-parameters.txt
2007-09-23 08:05:14 +00:00
FAILSAFE="noapic noapm nodma nomce nolapic nosmp vga=ofonly"
2007-09-23 08:05:12 +00:00
2007-09-23 08:04:50 +00:00
# Assembling kernel configuration
2007-09-23 08:05:14 +00:00
# Default entries
2007-09-23 08:05:17 +00:00
DEFAULT_FLAVOUR="`echo ${LH_LINUX_FLAVOURS} | awk '{ print $1 }'`"
2007-09-23 08:05:14 +00:00
DEFAULT_KERNEL="`basename chroot/boot/vmlinux-*${DEFAULT_FLAVOUR}`"
DEFAULT_INITRD="initrd.img-`echo ${DEFAULT_KERNEL} | sed -e 's/vmlinux-//'`"
Yaboot_live_entry "live" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}"
Yaboot_live_entry "live-failsafe" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}" "${FAILSAFE}"
2007-09-23 08:05:17 +00:00
if [ "`echo ${LH_LINUX_FLAVOURS} | wc -w`" -gt "1" ]
2007-09-23 08:04:50 +00:00
then
2007-09-23 08:05:14 +00:00
for KERNEL in chroot/boot/vmlinux-*
2007-09-23 08:04:50 +00:00
do
2007-09-23 08:05:14 +00:00
KERNEL_IMAGE="`basename ${KERNEL}`"
KERNEL_VERSION="`echo ${KERNEL_IMAGE} | sed -e 's/vmlinux-//'`"
INITRD="initrd.img-${KERNEL_VERSION}"
Yaboot_live_entry "live-${KERNEL_VERSION}" "${KERNEL_IMAGE}" "${INITRD}"
Yaboot_live_entry "live-${KERNEL_VERSION}-failsafe" "${KERNEL_IMAGE}" "${INITRD}" "${FAILSAFE}"
2007-09-23 08:04:50 +00:00
done
fi
2007-09-23 08:05:17 +00:00
LINUX_LIVE="`/bin/echo ${LINUX_LIVE} | sed -e 's/binary//g' -e 's#//#/#g'`"
2007-09-23 08:04:50 +00:00
2007-09-23 08:05:12 +00:00
# Assembling debian-installer configuration
2007-09-23 08:05:17 +00:00
if [ "${LH_DEBIAN_INSTALLER}" != "disabled" ]
2007-09-23 08:05:12 +00:00
then
VMLINUZ_DI="vmlinuz"
INITRD_DI="initrd.gz"
2007-09-23 08:05:14 +00:00
APPEND_DI="vga=normal"
2007-09-23 08:05:12 +00:00
VMLINUZ_GI="gtk/vmlinuz"
INITRD_GI="gtk/initrd.gz"
2007-09-23 08:05:14 +00:00
APPEND_GI="video=vesa:ywrap,mtrr vga=788"
Yaboot_install_entry "linux" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
Yaboot_install_entry "install" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
Yaboot_install_entry "installgui" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
Yaboot_install_entry "expert" "${VMLINUZ_DI}" "${INITRD_DI}" "priority=low ${APPEND_DI}"
Yaboot_install_entry "expertgui" "${VMLINUZ_GI}" "${INITRD_GI}" "priority=low ${APPEND_GI}"
Yaboot_install_entry "rescue" "${VMLINUZ_DI}" "${INITRD_DI}" "rescue/enable=true ${APPEND_DI}"
Yaboot_install_entry "rescuegui" "${VMLINUZ_GI}" "${INITRD_GI}" "rescue/enable=true ${APPEND_GI}"
Yaboot_install_entry "auto" "${VMLINUZ_DI}" "${INITRD_DI}" "auto=true priority=critical ${APPEND_DI}"
Yaboot_install_entry "autogui" "${VMLINUZ_GI}" "${INITRD_GI}" "auto=true priority=critical ${APPEND_GI}"
2007-09-23 08:05:12 +00:00
fi
2007-09-23 08:05:17 +00:00
LINUX_INSTALL="`/bin/echo ${LINUX_INSTALL} | sed -e 's/binary//g' -e 's#//#/#g'`"
2007-09-23 08:05:12 +00:00
2007-09-23 08:05:17 +00:00
case "${LH_BINARY_IMAGES}" in
2007-09-23 08:05:14 +00:00
iso|usb-hdd)
2007-09-23 08:04:50 +00:00
# Copying yaboot
2007-09-23 08:05:12 +00:00
mkdir -p binary/yaboot
2007-09-23 08:05:15 +00:00
2007-09-23 08:05:17 +00:00
case "${LH_CHROOT_BUILD}" in
2007-09-23 08:05:15 +00:00
enabled)
cp chroot/usr/lib/yaboot/yaboot binary/yaboot
;;
disabled)
cp /usr/lib/yaboot/yaboot binary/yaboot
;;
esac
cp -r "${TEMPLATES}"/* binary/yaboot
2007-09-23 08:04:50 +00:00
2007-09-23 08:05:17 +00:00
if [ "${LH_BINARY_IMAGES}" = "usb-hdd" ]
2007-09-23 08:05:14 +00:00
then
mv binary/yaboot/yaboot.conf binary/yaboot/yaboot.conf.tmp
echo "root=/dev/ram" > binary/yaboot/yaboot.conf
cat binary/yaboot/yaboot.conf.tmp >> binary/yaboot/yaboot.conf
rm -f binary/yaboot/yaboot.conf.tmp
fi
2007-09-23 08:04:50 +00:00
# Configure yaboot templates
2007-09-23 08:05:14 +00:00
sed -i -e "s#LINUX_LIVE#${LINUX_LIVE}#" -e "s#LINUX_INSTALL#${LINUX_INSTALL}#" binary/yaboot/yaboot.conf
2007-09-23 08:05:17 +00:00
sed -i -e "s#LH_BOOTAPPEND#${LH_BOOTAPPEND}#" binary/yaboot/yaboot.conf
sed -i -e "s/LH_DATE/`date +%Y%m%d`/" -e "s/LH_VERSION/${VERSION}/" binary/yaboot/boot.msg
2007-09-23 08:04:50 +00:00
;;
esac
2007-09-23 08:05:15 +00:00
# Saving cache
Save_cache cache/packages_binary
2007-09-23 08:04:51 +00:00
# Removing depends
Remove_package
2007-09-23 08:04:50 +00:00
# Creating stage file
Create_stagefile .stage/binary_yaboot