diff options
author | Aron Griffis <agriffis@gentoo.org> | 2004-01-23 16:21:47 +0000 |
---|---|---|
committer | Aron Griffis <agriffis@gentoo.org> | 2004-01-23 16:21:47 +0000 |
commit | a8f691090e1120962929099a4d77eb2a068f477f (patch) | |
tree | be242ca3ca6de5083499b6cc009995a212f12eae /sys-boot | |
parent | New ebuild for elilo, stolen from Mandrake and Debian (diff) | |
download | gentoo-2-a8f691090e1120962929099a4d77eb2a068f477f.tar.gz gentoo-2-a8f691090e1120962929099a4d77eb2a068f477f.tar.bz2 gentoo-2-a8f691090e1120962929099a4d77eb2a068f477f.zip |
New ebuild for elilo, stolen from Mandrake and Debian
Diffstat (limited to 'sys-boot')
-rw-r--r-- | sys-boot/elilo/ChangeLog | 11 | ||||
-rw-r--r-- | sys-boot/elilo/Manifest | 3 | ||||
-rw-r--r-- | sys-boot/elilo/elilo-3.4.ebuild | 59 | ||||
-rw-r--r-- | sys-boot/elilo/files/digest-elilo-3.4 | 1 | ||||
-rw-r--r-- | sys-boot/elilo/files/elilo-3.3a-devscheme.patch | 124 | ||||
-rw-r--r-- | sys-boot/elilo/files/elilo-3.4 | 804 | ||||
-rw-r--r-- | sys-boot/elilo/files/elilo-3.4-makefile.patch | 8 | ||||
-rw-r--r-- | sys-boot/elilo/files/elilo.8-3.4 | 113 | ||||
-rw-r--r-- | sys-boot/elilo/files/eliloalt.8-3.4 | 20 |
9 files changed, 1142 insertions, 1 deletions
diff --git a/sys-boot/elilo/ChangeLog b/sys-boot/elilo/ChangeLog new file mode 100644 index 000000000000..b6b70fb2ff39 --- /dev/null +++ b/sys-boot/elilo/ChangeLog @@ -0,0 +1,11 @@ +# ChangeLog for sys-boot/elilo +# Copyright 2000-2004 Gentoo Technologies, Inc.; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/sys-boot/elilo/ChangeLog,v 1.1 2004/01/23 16:21:39 agriffis Exp $ + +*elilo-3.4 (23 Jan 2004) + + 23 Jan 2004; <agriffis@gentoo.org> elilo-3.4.ebuild, + files/elilo-3.3a-devscheme.patch, files/elilo-3.4, + files/elilo-3.4-makefile.patch, files/elilo.8-3.4, files/eliloalt.8-3.4: + New ebuild for elilo, stolen from Mandrake and Debian + diff --git a/sys-boot/elilo/Manifest b/sys-boot/elilo/Manifest index 265ee8f9cfc5..097d314787c1 100644 --- a/sys-boot/elilo/Manifest +++ b/sys-boot/elilo/Manifest @@ -1,4 +1,5 @@ -MD5 cda6670281bd5d3ba667d35e1edd3049 elilo-3.4.ebuild 1762 +MD5 170751d8049b2c371326f017bea65442 elilo-3.4.ebuild 1750 +MD5 783b45fdac0028728f23e9f1b8ffea8b ChangeLog 478 MD5 2b2d58955c4ad612fee3bcf9b977bc41 files/elilo-3.4-makefile.patch 338 MD5 85650d47a2950be23774d73205b19e97 files/digest-elilo-3.4 61 MD5 c41337651da1c5b597609856146438ec files/elilo-3.4 22707 diff --git a/sys-boot/elilo/elilo-3.4.ebuild b/sys-boot/elilo/elilo-3.4.ebuild new file mode 100644 index 000000000000..72a3cc12ede8 --- /dev/null +++ b/sys-boot/elilo/elilo-3.4.ebuild @@ -0,0 +1,59 @@ +# Copyright 1999-2004 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-boot/elilo/elilo-3.4.ebuild,v 1.1 2004/01/23 16:21:39 agriffis Exp $ + +DESCRIPTION="Linux boot loader for EFI-based systems such as IA-64" +HOMEPAGE="http://developer.intel.com/technology/efi" +SRC_URI="ftp://ftp.hpl.hp.com/pub/linux-ia64/${P}.tar.gz" +KEYWORDS="~ia64" +SLOT="0" +LICENSE="GPL-2" +IUSE="" + +# gnu-efi contains only static libs, so there's no run-time dep on it +DEPEND=">=gnu-efi-3.0" +RDEPEND="sys-boot/efibootmgr" + +src_unpack() { + unpack ${A} && cd ${S} || die "failed to unpack" + epatch ${FILESDIR}/elilo-3.4-makefile.patch || die "epatch failed" + epatch ${FILESDIR}/elilo-3.3a-devscheme.patch || die "epatch failed" +} + +src_compile() { + local iarch + case $ARCH in + ia64) iarch=ia64 ;; + x86) iarch=ia32 ;; # for cross-compiling? + *) die "unknown architecture: $ARCH" ;; + esac + + # "prefix" on the next line specifies where to find gcc, as, ld, + # etc. It's not the usual meaning of "prefix". By blanking it we + # allow PATH to be searched. + emake -j1 prefix= CC="${CC}" ARCH=${iarch} || die "emake failed" + + # unversion the man-pages and Debian's elilo script + cp ${FILESDIR}/elilo.8-${PV} elilo.8 + cp ${FILESDIR}/eliloalt.8-${PV} eliloalt.8 + cp ${FILESDIR}/elilo-${PV} elilo +} + +src_install() { + dodir /usr/lib/elilo || die + dodir /usr/sbin || die + + # install the efi executable in a known location + install -m755 elilo.efi ${D}/usr/lib/elilo || die + + # install eliloalt + install -m755 tools/eliloalt ${D}/usr/sbin || die + doman eliloalt.8 || die + + # text docs + dodoc docs/* + + # install the debian elilo script + install -m755 elilo ${D}/usr/sbin || die + doman elilo.8 || die +} diff --git a/sys-boot/elilo/files/digest-elilo-3.4 b/sys-boot/elilo/files/digest-elilo-3.4 new file mode 100644 index 000000000000..6c9603e2135d --- /dev/null +++ b/sys-boot/elilo/files/digest-elilo-3.4 @@ -0,0 +1 @@ +MD5 e7357929dfca29436d35ad6386fc051c elilo-3.4.tar.gz 316518 diff --git a/sys-boot/elilo/files/elilo-3.3a-devscheme.patch b/sys-boot/elilo/files/elilo-3.3a-devscheme.patch new file mode 100644 index 000000000000..3d8f0c42f55d --- /dev/null +++ b/sys-boot/elilo/files/elilo-3.3a-devscheme.patch @@ -0,0 +1,124 @@ +--- elilo-3.3a/devschemes/simple.c.devscheme 2002-09-16 20:51:52.000000000 +0200 ++++ elilo-3.3a/devschemes/simple.c 2003-05-26 15:05:13.000000000 +0200 +@@ -38,52 +38,50 @@ typedef struct { + } devices_types_t; + + +-static UINT32 atapi_count, scsi_count, net_count; ++static UINT32 cdrom_count, hd_count, net_count; + + static INTN +-atapi_device(device_t *dev, EFI_DEVICE_PATH *dp) ++network_device(device_t *dev, EFI_DEVICE_PATH *dp) + { +- //ATAPI_DEVICE_PATH *atapi = (ATAPI_DEVICE_PATH *)dp; ++ //MAC_ADDR_DEVICE_PATH *mac = (MAC_ADDR_DEVICE_PATH *)dp; + +- dev->name[0] = L'a'; +- dev->name[1] = L't'; +- dev->name[2] = L'a'; +- dev->name[3] = L'p'; +- dev->name[4] = L'i'; ++ dev->name[0] = L'n'; ++ dev->name[1] = L'e'; ++ dev->name[2] = L't'; + +- SPrint(dev->name+5,FILEOPS_DEVNAME_MAXLEN-5-1, L"%d", atapi_count); +- atapi_count++; ++ SPrint(dev->name+3,FILEOPS_DEVNAME_MAXLEN-3-1, L"%d", net_count); ++ net_count++; + + return 0; + } + + static INTN +-scsi_device(device_t *dev, EFI_DEVICE_PATH *dp) ++harddrive_device(device_t *dev, EFI_DEVICE_PATH *dp) + { + //SCSI_DEVICE_PATH *scsi = (SCSI_DEVICE_PATH *)dp; + +- dev->name[0] = L's'; +- dev->name[1] = L'c'; +- dev->name[2] = L's'; +- dev->name[3] = L'i'; ++ dev->name[0] = L'h'; ++ dev->name[1] = L'd'; + +- SPrint(dev->name+4, FILEOPS_DEVNAME_MAXLEN-4-1, L"%d", scsi_count); +- scsi_count++; ++ SPrint(dev->name+2, FILEOPS_DEVNAME_MAXLEN-2-1, L"%d", hd_count); ++ hd_count++; + + return 0; + } + + static INTN +-network_device(device_t *dev, EFI_DEVICE_PATH *dp) ++cdrom_device(device_t *dev, EFI_DEVICE_PATH *dp) + { + //MAC_ADDR_DEVICE_PATH *mac = (MAC_ADDR_DEVICE_PATH *)dp; + +- dev->name[0] = L'n'; +- dev->name[1] = L'e'; +- dev->name[2] = L't'; ++ dev->name[0] = L'c'; ++ dev->name[1] = L'd'; ++ dev->name[2] = L'r'; ++ dev->name[3] = L'o'; ++ dev->name[4] = L'm'; + +- SPrint(dev->name+3, FILEOPS_DEVNAME_MAXLEN-3-1, L"%d", net_count); +- net_count++; ++ SPrint(dev->name+5, FILEOPS_DEVNAME_MAXLEN-5-1, L"%d", cdrom_count); ++ cdrom_count++; + + return 0; + } +@@ -92,9 +90,12 @@ network_device(device_t *dev, EFI_DEVICE + * what we are looking for in the device path + */ + static devices_types_t dev_types[]={ +- { MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, atapi_device}, +- { MESSAGING_DEVICE_PATH, MSG_SCSI_DP, scsi_device}, ++ // { MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, atapi_device}, ++ // { MESSAGING_DEVICE_PATH, MSG_SCSI_DP, scsi_device}, + { MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, network_device}, ++ { MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, harddrive_device}, ++ { MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, cdrom_device}, ++ // { MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, network_device}, + { 0, 0 , NULL} + }; + +@@ -121,6 +122,7 @@ simple_scheme(device_t *tab, UINTN n) + + for(i=0; i < n; i++) { + dp = DevicePathFromHandle(tab[i].dev); ++ Print(L"New Dev :"); + if (dp == NULL) { + ERR_PRT((L"cannot get device path for device %d", i)); + continue; +@@ -128,6 +130,7 @@ simple_scheme(device_t *tab, UINTN n) + dp1 = dp = UnpackDevicePath(dp); + + while (!IsDevicePathEnd(dp)) { ++ Print(L"(%d,%d) ",DevicePathType(dp),DevicePathSubType(dp) ); + p = dev_types; + while (p->type) { + if ( p->type == DevicePathType(dp) +@@ -135,6 +138,8 @@ simple_scheme(device_t *tab, UINTN n) + (*p->device_func)(tab+i, dp); + goto done; + } ++ // if (DevicePathType(dp) == MEDIA_DEVICE_PATH) Print(L"Unknown : %d : %d\n", DevicePathType(dp) , DevicePathSubType(dp) ); ++ + + p++; + } +@@ -142,6 +147,7 @@ simple_scheme(device_t *tab, UINTN n) + } + done: + FreePool(dp1); ++ Print(L"\n"); + } + return 0; + } diff --git a/sys-boot/elilo/files/elilo-3.4 b/sys-boot/elilo/files/elilo-3.4 new file mode 100644 index 000000000000..08bbb03527f4 --- /dev/null +++ b/sys-boot/elilo/files/elilo-3.4 @@ -0,0 +1,804 @@ +#! /bin/sh + +############################################################################### +## +## elilo installs efi bootloader onto a bootstrap partition (based on ybin) +## Copyright (C) 2001 Ethan Benson +## +## This program is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License +## as published by the Free Software Foundation; either version 2 +## of the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## +############################################################################### + +PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" +## allow to run out of /target in boot-floppies +if [ -n "$PATH_PREFIX" ] ; then + PATH="${PATH}:${PATH_PREFIX}/sbin:${PATH_PREFIX}/bin:${PATH_PREFIX}/usr/sbin:${PATH_PREFIX}/usr/bin:${PATH_PREFIX}/usr/local/sbin:${PATH_PREFIX}/usr/local/bin" +fi +PRG="${0##*/}" +SIGINT="$PRG: Interrupt caught ... exiting" +VERSION=3.4-4 +DEBUG=0 +VERBOSE=0 +TMP="${TMPDIR:-/tmp}" +TARGET= +# Beware, /EFI/gentoo occurs with double backslashes in the script too +# so change those as well as EFIROOT, if need be. +EFIROOT=/EFI/gentoo +export LC_COLLATE=C + +## catch signals, clean up junk in /tmp. +trap "cleanup" 0 +trap "cleanup; exit 129" 1 +trap "echo 1>&2 $SIGINT ; cleanup; exit 130" 2 +trap "cleanup; exit 131" 3 +trap "cleanup; exit 143" 15 + +## define default config file +CONF=/etc/elilo.conf +bootconf=$CONF +ERR=" Error in $CONF:" + +## define default configuration +boot=unconfigured + +## allow default to work on packaged and non-packaged elilo. +if [ -f /usr/local/lib/elilo/elilo.efi ] ; then + install=/usr/local/lib/elilo/elilo.efi +elif [ -f /usr/lib/elilo/elilo.efi ] ; then + install=/usr/lib/elilo/elilo.efi +fi + +## defaults +efiboot=0 +autoconf=0 +fstype=vfat +umountproc=0 + +## elilo autoconf defaults +label=Linux +timeout=20 +root=/dev/sda3 + +# image default is controlled by /etc/kernel-img.conf, if it exists +if [ -f /etc/kernel-img.conf ] && + egrep -q "^(image|link)_in_boot *= *yes" /etc/kernel-img.conf; then + image=/boot/vmlinuz +else + image=/vmlinuz +fi + +## make fake `id' if its missing, outputs 0 since if its missing we +## are probably running on boot floppies and thus are root. +if (command -v id > /dev/null 2>&1) ; then + true +else + id() + { + echo 0 + } +fi + +## --version output +version() +{ +echo \ +"$PRG $VERSION +Written by Richard Hirst, based on work by Ethan Benson + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." +} + +## --help output. +usage() +{ +echo \ +"Usage: $PRG [OPTION]... +Update/install bootloader onto a bootstrap partition. + + -b, --boot set bootstrap partition device [ -b /dev/sda1 ] + -i, --install pathname to the actual bootloader binary + default: /usr/{local/}lib/elilo/elilo.efi + -C, --config use alternate configuration file [ -C config_file ] + --autoconf auto-generate a /etc/elilo.conf + --efiboot elilo auto configuration: create an efi boot + manager entry for elilo + --timeout elilo auto configuration: sets the time elilo + will wait for user input before booting default + image default: 20 (2 seconds) + --image elilo auto configuration: sets the path to the + kernel image. default: /vmlinuz + --label elilo auto configuration: sets the image label + default: Linux + --root elilo auto configuration: sets the root device + default: /dev/sda3 + --format create a new FAT filesystem on the boot partition + -v, --verbose make $PRG more verbose + --debug print boring junk only useful for debugging + -h, --help display this help and exit + -V, --version output version information and exit" +} + +## we have to do some things differently with a retarded devfs name. +ckdevfs() +{ + case "$1" in + /dev/ide/*|/dev/scsi/*|/dev/discs/*) + return 0 + ;; + *) + return 1 + ;; + esac +} + +## the SmartArray RAID controllers use /dev/cciss/c0d0p1 kinds of names... +ckcciss() +{ + case "$1" in + /dev/cciss/*) + return 0 + ;; + *) + return 1 + ;; + esac +} + + +## configuration file parsing. FIXME: need a method which can parse +## image= sections. +parseconf() +{ +case "$1" in + str) + v=`grep "^$2[\ ,=]" "$CONF"` ; echo "${v#*=}" + ;; + flag) + grep "^$2\>" "$CONF" > /dev/null && echo 0 || echo 1 + ;; + ck) + grep "^$2[\ ,=]" "$CONF" > /dev/null && echo 0 || echo 1 + ;; +esac +} + +## check for existence of a configuration file, and make sure we have +## read permission. +confexist() +{ + if [ ! -e "$CONF" ] ; then + echo 1>&2 "$PRG: $CONF: No such file or directory" + return 1 + elif [ ! -f "$CONF" ] ; then + echo 1>&2 "$PRG: $CONF: Not a regular file" + return 1 + elif [ ! -r "$CONF" ] ; then + echo 1>&2 "$PRG: $CONF: Permission denied" + return 1 + else + return 0 + fi +} + +## check to make sure the configuration file is sane and correct. +## maybe this is an insane ammount of error checking, but I want to +## make sure (hopefully) nothing unexpected ever happens. and i just +## like useful errors from programs. every error just marks an error +## variable so we give the user as much info as possible before we +## abandon ship. +checkconf() +{ + if [ ! -e "$boot" ] ; then + echo 1>&2 "$PRG: $boot: No such file or directory" + local CONFERR=1 + elif [ ! -b "$boot" -a ! -f "$boot" ] ; then + echo 1>&2 "$PRG: $boot: Not a regular file or block device" + local CONFERR=1 + elif [ ! -w "$boot" -o ! -r "$boot" ] ; then + echo 1>&2 "$PRG: $boot: Permission denied" + CONFERR=1 + fi + + ## sanity check, make sure boot=bootstrap and not something dumb + ## like /dev/hda + case "$boot" in + *hda) + echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of all data on $boot" + local CONFERR=1 + ;; + *sda) + echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of all data on $boot" + local CONFERR=1 + ;; + *disc) + echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of all data on $boot" + local CONFERR=1 + ;; + esac + + ## now make sure its not something dumb like the root partition + local ROOT="$(v=`df / 2> /dev/null | grep ^/dev/` ; echo ${v%%[ ]*})" + local BOOT="$(v=`df /boot 2> /dev/null | grep ^/dev/` ; echo ${v%%[ ]*})" + if [ "$boot" = "$ROOT" ] ; then + echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of the root filesystem" + local CONFERR=1 + elif [ "$boot" = "$BOOT" ] ; then + echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of the /boot filesystem" + local CONFERR=1 + fi + + ## Make sure boot is not already mounted + mount | grep "^$boot " > /dev/null + if [ $? = 0 ] ; then + echo 1>&2 "$PRG: $boot appears to be mounted" + local CONFERR=1 + fi + + if [ ! -e "$install" ] ; then + echo 1>&2 "$PRG: $install: No such file or directory" + local CONFERR=1 + elif [ ! -f "$install" ] ; then + echo 1>&2 "$PRG: $install: Not a regular file" + local CONFERR=1 + elif [ ! -r "$install" ] ; then + echo 1>&2 "$PRG: $install: Permission denied" + local CONFERR=1 + fi + + if [ ! -e "$bootconf" ] ; then + echo 1>&2 "$PRG: $bootconf: No such file or directory" + local CONFERR=1 + elif [ ! -f "$bootconf" ] ; then + echo 1>&2 "$PRG: $bootconf: Not a regular file" + local CONFERR=1 + elif [ ! -r "$bootconf" ] ; then + echo 1>&2 "$PRG: $bootconf: Permission denied" + local CONFERR=1 + fi + + if [ ! -d /proc/efi/vars -a "$efiboot" = 1 ] ; then + echo 1>&2 "$PRG: /proc/efi/vars not available, boot menu not updated" + efiboot=0 + fi + + if [ "$efiboot" = 1 ] ; then + ## see if efibootmgr exists and is executable + if (command -v efibootmgr > /dev/null 2>&1) ; then + [ -x `command -v efibootmgr` ] || MISSING=1 ; else MISSING=1 + fi + + if [ "$MISSING" = 1 ] ; then + efiboot=0 + echo 1>&2 "$PRG: Warning: \`efibootmgr' could not be found, boot menu not updated" + fi + + if [ -f "$boot" ] ; then + echo 1>&2 "$PRG: $boot is a regular file, disabling boot menu update" + efiboot=0 + fi + fi + + if [ "$CONFERR" = 1 ] ; then + return 1 + else + return 0 + fi +} + + +mnt() +{ + ## we can even create bootstrap filesystem images directly if you + ## ever wanted too. + if [ -f "$boot" ] ; then + local loop=",loop" + fi + + if [ -e "$TMP/bootstrap.$$" ] ; then + echo 1>&2 "$PRG: $TMP/bootstrap.$$ exists, aborting." + return 1 + fi + + mkdir -m 700 "$TMP/bootstrap.$$" + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: Could not create mountpoint directory, aborting." + return 1 + fi + + mount | grep "^$boot " > /dev/null + if [ $? = 0 ] ; then + echo 1>&2 "$PRG: $boot appears to be mounted! aborting." + return 1 + fi + + [ "$VERBOSE" = 1 ] && echo "$PRG: Mounting $boot..." + mount -t "$fstype" -o rw,noexec,umask=077$loop "$boot" "$TMP/bootstrap.$$" + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured mounting $boot" + return 1 + fi + + TARGET="$TMP/bootstrap.$$" + return 0 +} + +copyfiles() +{ + local BTFILE=elilo.efi + local CFFILE=elilo.conf + local imagefiles=`grep '^image[[:space:]]*=' $bootconf | \ + sed 's/^image[[:space:]]*=[[:space:]]*//' | grep -v ':'` + local initrdfiles=`grep '^[[:space:]]*initrd[[:space:]]*=' $bootconf | \ + sed 's/.*=[[:space:]]*//' | grep -v ':'` + + ## Point of no return, removing the old EFI/gentoo tree + rm -rf $TARGET/$EFIROOT + if [ $? != 0 ]; then + echo 2>&1 "$PRG: Failed to delete old boot files, aborting" + return 1 + fi + mkdir -p $TARGET/$EFIROOT + + ## Add a README to warn that this tree is deleted every time elilo is run + echo -ne "\ +This directory tree is managed by /usr/sbin/elilo, and is deleted and\n\ +recreated every time elilo runs. Any local changes will be lost.\n\ +" > $TARGET/$EFIROOT/README.TXT + + ## this is probably insecure on modern filesystems, but i think + ## safe on crippled hfs/dosfs. + [ "$VERBOSE" = 1 ] && echo "$PRG: Installing primary bootstrap $install onto $boot..." + cp -f "$install" "$TARGET/$EFIROOT/$BTFILE" + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured while writing to $boot" + return 1 + fi + + [ "$VERBOSE" = 1 ] && echo "$PRG: Installing $bootconf on $boot..." + ## we comment out boot= and install=, because they are only really + ## needed in the /etc/elilo.conf file, and elilo.efi currently + ## doesn't understand them. We also need to add /EFI/gentoo on to + ## the front of any paths that don't contain colons (device paths). + sed -e "s|^boot[[:space:]]*=|# &|" -e "s|^install[[:space:]]*=|# &|" \ + -e "s|\(^image[[:space:]]*=[[:space:]]*\)\([^:]*\)$|\1$EFIROOT\2|" \ + -e "s|\(^[[:space:]]*initrd[[:space:]]*=[[:space:]]*\)\([^:]*\)$|\1$EFIROOT\2|" \ + < "$bootconf" > "$TARGET/$EFIROOT/$CFFILE" + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured while writing to $boot" + return 1 + fi + + [ "$DEBUG" = 1 ] && echo "----" && cat "$TARGET/$EFIROOT/$CFFILE" && echo "----" + + for i in $imagefiles $initrdfiles; do + [ "$VERBOSE" = 1 ] && echo "$PRG: Installing $i on $boot..." + if [ -f $i ]; then + mkdir -p `dirname "$TARGET/$EFIROOT/$i"` + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured creating directory `dirname $EFIROOT/$i` on $boot" + return 1 + fi + cp -f "$i" "$TARGET/$EFIROOT/$i" + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured writing $i to $boot" + return 1 + fi + else + echo "$PRG: Warning: $i not found" + fi + done + + sync ; sync + + ## update the boot-device variable in EFI. + if [ "$efiboot" = 1 ] ; then + [ "$VERBOSE" = 1 ] && echo "$PRG: Updating EFI boot-device variable..." + efiquiet="-q" + [ "$VERBOSE" = 1 ] && efiquiet="" + if ckdevfs "$boot" ; then + local BOOTDISK="${boot%/*}/disc" + local BOOTPART="${boot##*part}" + elif ckcciss "$boot" ; then + local BOOTDISK="${boot%p[0-9]*}" + local BOOTPART="${boot##*[a-z]}" + else + local BOOTDISK="${boot%%[0-9]*}" + local BOOTPART="${boot##*[a-z]}" + fi + if [ -z "$BOOTDISK" -o -z "$BOOTPART" ] ; then + echo 2>&1 "$PRG: Could not determine boot disk, aborting..." + return 1 + fi + + [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: boot-disk = $BOOTDISK" + [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: boot-partition = $BOOTPART" + # delete other entries with name "Gentoo Linux" + for b in `efibootmgr | grep "Gentoo Linux" | awk '{print substr($1,5,4) }'`; do + efibootmgr $efiquiet -b $b -B + done + # Add a new entry for this installation + efibootmgr $efiquiet -c -d $BOOTDISK -p $BOOTPART -w -L "Gentoo Linux" \ + -l \\EFI\\gentoo\\elilo.efi -u -- elilo -C \\EFI\\gentoo\\elilo.conf + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured while updating boot menu, we'll ignore it" + fi + # Now, if 2nd and 3rd boot entries are for floppy and CD/DVD, + # move them up to 1st and 2nd, making our entry the 3rd. + bootorder=$(efibootmgr | sed -n 's/^BootOrder: \(.*\)$/\1/p') + boot1st=$(echo $bootorder | sed -n "s/\(....\).*$/\1/p") + boot2nd=$(echo $bootorder | sed -n "s/....,\(....\).*$/\1/p") + boot3rd=$(echo $bootorder | sed -n "s/....,....,\(....\).*$/\1/p") + boot456=$(echo $bootorder | sed -n "s/....,....,....\(.*\).*$/\1/p") + name2nd=$(efibootmgr | sed -n "s/^Boot$boot2nd[\*] \(.*\)$/\1/p") + name3rd=$(efibootmgr | sed -n "s/^Boot$boot3rd[\*] \(.*\)$/\1/p") + name23="@$name2nd@$name3rd" + if ( echo $name23 | grep -qi "@floppy" ); then + if ( echo $name23 | grep -qi "@cd") || ( echo $name23 | grep -qi "@dvd"); then + efibootmgr $efiquiet -o $boot2nd,$boot3rd,$boot1st$boot456 + fi + fi + fi + + return 0 +} + +## mkefifs function. +mkefifs() +{ + mount | grep "^$boot\>" > /dev/null + if [ $? = 0 ] ; then + echo 1>&2 "$PRG: $boot appears to be mounted! aborting." + return 1 + fi + + if (command -v mkdosfs > /dev/null 2>&1) ; then + [ -x `command -v mkdosfs` ] || FAIL=1 ; else FAIL=1 ; fi + if [ "$FAIL" = 1 ] ; then + echo 1>&2 "$PRG: mkdosfs is not installed or cannot be found" + return 1 + fi + + [ "$VERBOSE" = 1 ] && echo "$PRG: Creating DOS filesystem on $boot..." + mkdosfs -n bootstrap "$boot" > /dev/null + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: DOS filesystem creation failed!" + return 1 + fi + return 0 +} + +mkconf() +{ +## defaults for this are defined at the beginning of the script with +## other variables. + +# We want to create an append= line from the current /proc/cmdline, +# so things like console=ttyS0 get picked up automatically. +# We also want to filter out bits of cmdline we are not interested in. + +if [ -f /proc/cmdline ]; then + cmdline=`cat /proc/cmdline` +else + echo 1>&2 "$PRG: Warning: couldn't read /proc/cmdline, may need to add append=... to elilo.conf" + cmdline="" +fi + +append=`echo $cmdline | tr ' ' '\n' | grep -v "^BOOT_IMAGE=" | grep -v "^root=" | grep -v "^ro$" | tr '\n' ' '` +if [ ! -z "$append" ]; then append="append=\"$append\""; fi + +echo \ +"## elilo configuration file generated by elilo $VERSION + +install=$install +boot=$boot +delay=$timeout +default=$label +$append + +image=$image + label=$label + root=$root + read-only + +image=${image}.old + label=${label}OLD + root=$root + read-only +" > "$TMPCONF" || return 1 + + ## Copy the new elilo.conf to /etc + if [ -f $CONF ]; then + echo 1>&2 "$PRG: backing up existing $CONF as ${CONF}-" + rm -f ${CONF}- + mv $CONF ${CONF}- + fi + cp -f "$TMPCONF" "$CONF" + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured while writing to $conf" + return 1 + fi + +return 0 +} + +# check partition will be big enough for all we want to add to it + +chkspace() +{ + local imagefiles=`grep '^image[[:space:]]*=' $bootconf | \ + sed 's/^image[[:space:]]*=[[:space:]]*//' | grep -v ':'` + local initrdfiles=`grep '^[[:space:]]*initrd[[:space:]]*=' $bootconf | \ + sed 's/.*=[[:space:]]*//' | grep -v ':'` + local bytesneeded=`cat $imagefiles $initrdfiles $install $bootconf 2>/dev/null | wc -c` + # convert to KB, allowing 5% overhead + local kbneeded=$(( bytesneeded / 1024 + bytesneeded / 20480 )) + local kbavailable=$(df -k $TARGET | sed -n "s|^$boot[[:space:]]\+[0-9]\+[[:space:]]\+[0-9]\+[[:space:]]\+\([0-9]\+\).*$|\1|p") + if [ -z $kbavailable ]; then + echo 2>&1 "$PRG: unable to determine space on $boot, aborting" + return 1 + fi + if [ -d $TARGET/$EFIROOT ]; then + local kbused=$(du -ks $TARGET/$EFIROOT | sed -n "s/[ ].*$//p") + else + local kbused=0 + fi + [ "$VERBOSE" = 1 ] && echo "$PRG: ${kbneeded}KB needed, ${kbavailable}KB free, ${kbused}KB to reuse" + kbavailable=$(( kbavailable + kbused )) + if [ "$kbavailable" -lt "$kbneeded" ] ; then + echo 1>&2 "$PRG: Insufficient space on $boot, need ${kbneeded}KB, only ${kbavailable}KB available" + return 1 + fi +return 0 +} + + +## take out the trash. +cleanup() +{ + if [ -n "$TARGET" ]; then + TARGET= + [ "$VERBOSE" = 1 ] && echo "$PRG: Unmounting $boot" + umount "$boot" + [ $? != 0 ] && echo 2>&1 "$PRG: Warning, failed to unmount $TARGET" + fi + if [ -n "$TMPCONF" ] ; then rm -f "$TMPCONF" ; fi + if [ -d "$TMP/bootstrap.$$" ] ; then rmdir "$TMP/bootstrap.$$" ; fi + if [ "$umountproc" = 1 ] ; then umount /proc ; fi + return 0 +} + +########## +## Main ## +########## + +## absurdly bloated case statement to parse command line options. +if [ $# != 0 ] ; then + while true ; do + case "$1" in + -V|--version) + version + exit 0 + ;; + -h|--help) + usage + exit 0 + ;; + --debug) + DEBUG=1 + shift + ;; + -v|--verbose) + VERBOSE=1 + shift + ;; + --force) + # allow --force for now, boot-floppies 3.0.20 and + # systemconfigurator use that instead of --format + echo 1>&2 "$PRG: Warning: --force is now deprecated. Use --for\mat." + echo 1>&2 "Try \`$PRG --help' for more information." + FORMAT=yes + shift + ;; + --format) + FORMAT=yes + shift + ;; + --autoconf) + autoconf=1 + shift + ;; + -b|--boot) + if [ -n "$2" ] ; then + boot="$2" + ARGBT=1 + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + -i|--install) + if [ -n "$2" ] ; then + install="$2" + ARGBF=1 + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + -C|--config) + if [ -n "$2" ] ; then + CONF="$2" + bootconf="$2" + ERR=" Error in $CONF:" + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + --efiboot) + efiboot=1 + ARGNV=1 + shift + ;; + --timeout) + if [ -n "$2" ] ; then + timeout="$2" + bootconf=auto + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + --image) + if [ -n "$2" ] ; then + image="$2" + bootconf=auto + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + --label) + if [ -n "$2" ] ; then + label="$2" + bootconf=auto + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + --root) + if [ -n "$2" ] ; then + root="$2" + bootconf=auto + shift 2 + else + echo 1>&2 "$PRG: option requires an argument $1" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + fi + ;; + "") + break + ;; + *) + echo 1>&2 "$PRG: unrecognized option \`$1'" + echo 1>&2 "Try \`$PRG --help' for more information." + exit 1 + ;; + esac + done +fi + +## check that are root +if [ `id -u` != 0 ] ; then + echo 1>&2 "$PRG: requires root privileges, go away." + exit 1 +fi + +## check that autoconf options are only specified with --autoconf +if [ "$bootconf" = "auto" -a "$autoconf" = "0" ] ; then + echo 1>&2 "$PRG: Auto-config options specified without --autoconf." + exit 1; +fi + +## check that specified config file exists, unless we are to generate it, +## which case we assume all options are done on the command line. +if [ "$autoconf" = "0" ] ; then + confexist || exit 1 +fi + +## /proc is needed to parse /proc/partitions, etc. +if [ ! -f /proc/uptime ]; then + [ "$VERBOSE" = 1 ] && echo "$PRG: Mounting /proc..." + mount -t proc proc /proc 2> /dev/null + if [ $? != 0 ]; then + echo 1>&2 "$PRG: Failed to mount /proc, aborting." + exit 1 + fi + umountproc=1 +fi + +## elilo.conf autogeneration. MUST have secure mktemp to +## avoid race conditions. GNU's mktemp qualifies. +if [ "$autoconf" = "1" ] ; then + TMPCONF=`mktemp -q "$TMP/$PRG.XXXXXX"` + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: Could not create temporary file, aborting." + exit 1 + fi + mkconf + if [ $? != 0 ] ; then + echo 1>&2 "$PRG: An error occured generating elilo.conf, aborting." + exit 1 + fi + + bootconf="$TMPCONF" +fi + +## Checks if each option was defined on the command line, and if so +## don't read it from the configuration file. this avoids +## configuration options from being set null, as well as command line +## options from being clobbered. +[ "$ARGBT" != 1 -a $(parseconf ck boot) = 0 ] && boot=`parseconf str boot` + +## ffs!! rtfm! foad! +if [ "$boot" = unconfigured ] ; then + echo 1>&2 "$PRG: You must specify the device for the bootstrap partition. (ie: -b /dev/hdaX)" + echo 1>&2 "$PRG: Try \`$PRG --help' for more information." + exit 1 +fi + +## validate configuration for sanity. +checkconf || exit 1 + +if [ "$FORMAT" = "yes" ]; then + mkefifs || exit 1 +fi + +[ "$VERBOSE" = 1 ] && echo "$PRG: Checking filesystem on $boot..." +dosfsck $boot > /dev/null +if [ $? != 0 ]; then + echo 1>&2 "$PRG: Filesystem on $boot is corrupt, please fix that and rerun $PRG." + exit 1 +fi + +mnt || exit 1 +chkspace || exit 1 +copyfiles || exit 1 + +umount $TARGET +if [ $? != 0 ]; then + echo 1>&2 "$PRG: Failed to unmount $boot" + exit 1 +fi +TARGET= + +[ "$VERBOSE" = 1 ] && echo "$PRG: Installation complete." + +exit 0 diff --git a/sys-boot/elilo/files/elilo-3.4-makefile.patch b/sys-boot/elilo/files/elilo-3.4-makefile.patch new file mode 100644 index 000000000000..2a315c0352f6 --- /dev/null +++ b/sys-boot/elilo/files/elilo-3.4-makefile.patch @@ -0,0 +1,8 @@ +--- elilo-3.4/Make.defaults.makefile 2002-10-08 20:50:27.000000000 +0200 ++++ elilo-3.4/Make.defaults 2003-05-26 14:59:04.000000000 +0200 +@@ -123,3 +121,5 @@ + OBJCOPY = $(prefix)objcopy + endif + endif ++ ++CFLAGS += $(shell if $(CC) -fno-merge-constants -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-fno-merge-constants"; fi) diff --git a/sys-boot/elilo/files/elilo.8-3.4 b/sys-boot/elilo/files/elilo.8-3.4 new file mode 100644 index 000000000000..a88dcec3d015 --- /dev/null +++ b/sys-boot/elilo/files/elilo.8-3.4 @@ -0,0 +1,113 @@ +.TH ELILO 8 "18 Mar 2002" +.SH NAME +elilo \- install EFI boot loader +.SH SYNOPSIS +.B elilo +.RI [ options ] +.SH DESCRIPTION +This manual page documents briefly the +.B elilo +command, which was written specifically for the Debian distribution to +simplify configuring and using the elilo.efi bootloader. The command works +equally on Gentoo Linux. +.sp +There are two parts to elilo, the bootloader itself and this utility which +installs or updates a bootload configuration. +.sp +The primary function of elilo is to copy files necessary for booting +Gentoo Linux from the main filesystem to a subdirectory /EFI/gentoo +on the boot partition. These include elilo.efi, elilo.conf, and the kernel +and ramdisk images referenced by elilo.conf. +.sp +In addition, elilo can create a default +configuration file, /etc/elilo.conf, and can invoke efibootmgr to create +an entry in the EFI Boot Manager menu such that a system will autoboot +in to Gentoo Linux on power up. +.sp +.B elilo +requires a couple of extra parameters in elilo.conf that elio.efi does +not currently support. +These are needed so that a normal run of elilo with no parameters can find +the elilo.efi binary and boot partition in order to rebuild it. +They are: +.sp +install=<path to elilo.efi> +.br +boot=<boot partition> +.sp +.SH OPTIONS +This program follows the usual GNU command line syntax, with long +options starting with two dashes (`-'). +.TP +.B \-b, \-\-boot +set bootstrap partition device [ -b /dev/sda1 ] +.TP +.B \-i, \-\-install +pathname to the actual bootloader binary, +default: /usr/{local/}lib/elilo/elilo.efi +.TP +.B \-C, \-\-config +use alternate configuration file [ -C config_file ] +.TP +.B \-\-autoconf +auto-generate a /etc/elilo.conf. Typically only used during system +installation. In normal use, an elilo.conf file already exists and will not +be modified by elilo. +.TP +.B \-\-efiboot +elilo auto configuration: create an efi boot manager entry for elilo. This +option requires that the +.B efibootmgr +package also be installed. +.TP +.B \-\-timeout +elilo auto configuration: sets the time elilo +will wait for user input before booting default +image default: 20 (2 seconds) +.TP +.B \-\-image +elilo auto configuration: sets the path to the +kernel image. default: /vmlinuz +.TP +.B \-\-label +elilo auto configuration: sets the image label +default: Linux +.TP +.B \-\-root +elilo auto configuration: sets the root device default: /dev/sda3 +.TP +.B \-\-format +create a new FAT filesystem on the boot partition. Use this cautiously if +you have more than one operating system installed, and they may be sharing +the same EFI partition! +.TP +.B \-v, \-\-verbose +make elilo more verbose +.TP +.B \-\-debug +print boring junk only useful for debugging +.TP +.B \-h, \-\-help +display this help and exit +.TP +.B \-V, \-\-version +output version information and exit +.SH FILES +.I /etc/elilo.conf +.br +.I /usr/lib/elilo/elilo.efi +.SH SEE ALSO +.BR efibootmgr (8) +.sp +Additional information about +.B elilo +is available in the /usr/share/doc/elilo directory. +.SH AUTHOR +The +.B elilo +program and this manual page were written by +Richard Hirst <rhirst@linuxcare.com> and Bdale Garbee <bdale@gag.com> +as additions to the +.B elilo +bootloader package from Stephane Eranian <eranian@hpl.hp.com> +for the Debian GNU/Linux system (but may be used by others). diff --git a/sys-boot/elilo/files/eliloalt.8-3.4 b/sys-boot/elilo/files/eliloalt.8-3.4 new file mode 100644 index 000000000000..81bcdf6e80a8 --- /dev/null +++ b/sys-boot/elilo/files/eliloalt.8-3.4 @@ -0,0 +1,20 @@ +.TH ELILOALT 8 "18 Mar 2002" +.SH NAME +eliloalt \- manipulate elilo alternate +.SH SYNOPSIS +.B eliloalt +.RI [ options ] +.SH DESCRIPTION +The +.B eliloalt +command makes it possible to coerce elilo to boot an alternate +kernel configuration one time only, as when engaging in kernel development or +debugging. +.sp +.SH SEE ALSO +Additional information about +.B eliloalt +is available in the /usr/share/doc/elilo directory. +.SH AUTHOR +This manual page was written by Bdale Garbee <bdale@gag.com> +for the Debian GNU/Linux system (but may be used by others). |