Imported Debian patch 3.4-9 debian/3.4-9
authorBdale Garbee <bdale@gag.com>
Mon, 29 Nov 2004 09:38:12 +0000 (02:38 -0700)
committerBdale Garbee <bdale@gag.com>
Tue, 20 May 2008 05:09:33 +0000 (23:09 -0600)
16 files changed:
Make.defaults
choosers/simple.c
choosers/textmenu.c
debian/README.elilo [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/elilo.8 [new file with mode: 0644]
debian/elilo.sh [new file with mode: 0644]
debian/eliloalt.8 [new file with mode: 0644]
debian/postinst [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/sys2ansi.pl [new file with mode: 0644]
elilo.c

index 523f0fc70f420be172391fadbb508eb1c8a84efc..8037303f2a9133e24ba5e679c8642eca119c2cae 100644 (file)
@@ -96,8 +96,7 @@ CFLAGS += -DCONFIG_CHOOSER_TEXTMENU
 endif
 
 ifeq ($(ARCH),ia64)
-  prefix       = 
-  prefix       = /opt/gcc3.1/bin/
+  prefix       = /usr/bin/
   CC           = $(prefix)gcc
   AS           = $(prefix)as
   LD           = $(prefix)ld
@@ -120,8 +119,8 @@ endif
 CFLAGS += -mfixed-range=f32-f127
 else
  ifeq ($(ARCH),ia32)
-  prefix       = 
-  CC           = $(prefix)gcc3
+  prefix       = /usr/bin/
+  CC           = $(prefix)gcc
   AS           = $(prefix)as
   LD           = $(prefix)ld
   AR           = $(prefix)ar
index 9b0725e4b8264712d56e8f329b0fcf836696707c..31bbe4ccc05911938e53884b24a0a22e81d61b17 100644 (file)
@@ -303,14 +303,14 @@ restart:
         * if no match is found, the args and initrd arguments may
         * still be modified by global options in the config file.
         */
-       ret = find_label(argv[index], kname, args, initrd_name);
+       ret = find_label((index < argc) ? argv[index] : NULL, kname, args, initrd_name);
 
        /*
         * not found, so assume first argument is kernel name and
         * not label name 
         */
        if (ret == -1) {
-               if (argv[index]) 
+               if ((index < argc) && argv[index])
                        StrCpy(kname, argv[index]);
                else
                        StrCpy(kname, elilo_opt.default_kernel);
@@ -347,6 +347,7 @@ restart:
                if (ret != 0) {
                        elilo_opt.prompt = 1;
                        elilo_opt.timeout =  ELILO_TIMEOUT_INFINITY;
+                       elilo_opt.initrd[0] = CHAR_NULL;
                        goto restart;
                }
        }
index 9379b0e2034e7691709a609b8dde2635c08a1359..a8067b4b5496b49e344b6369c9f710734416b072 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "elilo.h"
 
-#define MAX_LABELS     16
+#define MAX_LABELS     64
 #define MSGBUFLEN      4096
 
 static UINT8 msgbuf[MSGBUFLEN];
@@ -414,14 +414,14 @@ restart:
        if (label[0])
                ret = find_label(label, kname, args, initrd_name);
        else
-               ret = find_label(argv[index], kname, args, initrd_name);
+               ret = find_label((index < argc) ? argv[index] : NULL, kname, args, initrd_name);
 
        /*
         * not found, so assume first argument is kernel name and
         * not label name 
         */
        if (ret == -1) {
-               if (argv[index]) 
+               if ((index < argc) && argv[index])
                        StrCpy(kname, argv[index]);
                else
                        StrCpy(kname, elilo_opt.default_kernel);
@@ -460,6 +460,7 @@ restart:
                if (ret != 0) {
                        elilo_opt.prompt = 1;
                        elilo_opt.timeout =  ELILO_TIMEOUT_INFINITY;
+                       elilo_opt.initrd[0] = CHAR_NULL;
                        goto restart;
                }
        }
diff --git a/debian/README.elilo b/debian/README.elilo
new file mode 100644 (file)
index 0000000..499bb4b
--- /dev/null
@@ -0,0 +1,106 @@
+
+                        /usr/sbin/elilo documentation
+
+There are two parts to elilo:
+
+/usr/lib/elilo/elilo.efi   The bootloader itself.
+/usr/sbin/elilo            Utility to install/update a bootload configuration.
+
+This document describes /usr/sbin/elilo; for information on elilo.efi, or
+the configuration file format, please refer to /usr/doc/elilo/elilo.txt.
+
+
+elilo option summary:
+
+  -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 elilo more verbose
+      --debug                print boring junk only useful for debugging
+  -h, --help                 display this help and exit
+  -V, --version              output version information and exit
+
+
+The primary function of elilo is to copy files necessary for booting
+Debian GNU/Linux from the main filesystem to a subdirectory /EFI/debian
+on the boot partition.  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 Debian GNU/Linux on power up.
+
+It is important to note that elilo will recreate the /EFI/debian
+directory on your boot partition every time it is run, so any local
+changes you might have made under that direcotry will be lost.  The
+intention of elilo is to hide the boot partition from the user; the
+partition is not normally mounted so the user is unlikely to make local
+modifications.
+
+elilo does various checks on the partition (e.g. must pass dosfsck, must
+be a partition rather than a whole disk, must not be mounted, etc.)
+before overwriting it.  Invoking it with --format will run mkdosfs on
+the partition; this is generally not advisable, if the partition may be
+shared with other operating systems.
+
+
+/etc/elilo.conf generation:
+
+This is generally only used during system installation.  Typically elilo.conf
+will already exist, and is not modified by elilo.  To generate a new config
+file, you must specify --autoconf, along with any of the other auto
+configuration options necessary to override defaults.  Defaults are given
+in the option summary above.
+
+
+Invoking efibootmgr:
+
+--efiboot will cause elilo to run efibootmgr and create a default boot entry
+in the EFI Boot Manager menu called "Debian GNU/Linux".  Any other entries
+of that name are assumed to be left over from some previous installation and
+are deleted.  If the descriptions for the first two boot mansger entries
+start with strings "floppy" and "CD" or "DVD", then the new boot entry
+is created as the third entry, so that the system will still boot
+exchangeable media first by default.
+
+
+elilo.conf extensions:
+
+elilo requires a couple of extra parameters in elilo.conf that elio.efi does
+not currently support.  They are:
+
+install=<path to elilo.efi>  # default /usr/lib/elilo/elilo.efi
+boot=<boot partition>        # /dev/sda1
+
+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.
+
+
+Boot partition creation:
+
+Once the /EFI/debian directory has been created, elilo copies various
+files to it.  These include elilo.efi, elilo.conf, and certain kernel
+and ramdisk images referenced by elilo.conf.  elilo.conf is modified as
+it is copied, to comment out the install= and boot= lines so as not to
+confuse elilo.efi, and to prefix any file paths with /EFI/debian.  All
+kernel and initrd images that are referenced via standard UNIX paths are
+copied to the boot partition, so that elilo.efi can find them easily.
+Any paths containing a ':' are assumed to be EFI device paths, and as
+such are not copied.  Device path names depend on features of elilo.efi,
+but a typical path might be "scsi1:/vmlinux-2.4.7".  It is hoped that
+eventually a sufficiently robust device path naming scheme will be
+devised, and then devices paths will be used throughout, and it will no
+longer be necessary to copy images to the boot partition.
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..7f79b9d
--- /dev/null
@@ -0,0 +1,249 @@
+elilo (3.4-9) unstable; urgency=low
+
+  * patch from upstream to fix problems when wrong -C param is provided,
+    closes: #238434
+  * if the --autoconf option is used on an SGI Altix system, add 'relocatable' 
+    to the resulting elilo.conf as per request from Jesse Barnes
+  * make elilo.sh replace tabs with spaces when copying elilo.conf to the 
+    system partition, as tabs kill old elilo.efi versions, closes: #279646
+  * patch from upstream to enlarge max textmenu size, closes: #273745
+
+ -- Bdale Garbee <bdale@gag.com>  Mon, 29 Nov 2004 02:38:12 -0700
+
+elilo (3.4-7.sarge.1) testing; urgency=high
+
+  * build 3.4-8 in testing chroot for sarge
+  * update elilo.sh to know that efibootmgr can use /sys/firmware/efi/vars
+    as an alternative to /proc/efi/vars when used with 2.6 kernels
+  * urgency high since previous version fails to call efibootmgr with 
+    current 2.6 kernels
+
+ -- Bdale Garbee <bdale@gag.com>  Wed, 18 Aug 2004 09:09:32 -0600
+
+elilo (3.4-8) unstable; urgency=high
+
+  * update elilo.sh to know that efibootmgr can use /sys/firmware/efi/vars
+    as an alternative to /proc/efi/vars when used with 2.6 kernels
+  * urgency high since previous version fails to call efibootmgr with 
+    current 2.6 kernels
+
+ -- Bdale Garbee <bdale@gag.com>  Wed, 18 Aug 2004 09:04:39 -0600
+
+elilo (3.4-7) unstable; urgency=medium
+
+  * a patch in kernel 2.6.8-rc3 reverted in rc4 broke an NLS default we 
+    depended on.  This fix add options to the mount call in elilo.sh so we 
+    no longer care about the default, closes: #263484
+  * changes from David Weinehall to fix elilo.sh XSI:isms, closes: #256507
+
+ -- Bdale Garbee <bdale@gag.com>  Fri, 13 Aug 2004 17:16:07 -0600
+
+elilo (3.4-6) unstable; urgency=high
+
+  * patch from Jeff Bailey to ease use of devfs and non-devfs enabled kernels,
+    closes: #232259
+
+ -- Bdale Garbee <bdale@gag.com>  Sat, 14 Feb 2004 22:21:36 -0700
+
+elilo (3.4-5) unstable; urgency=high
+
+  * patch from Richard Hirst to allow elilo.sh to work with initrd kernels,
+    closes: #229016
+      - 'modprobe vfat' in case support isn't currently loaded
+      - include initrd= lines when generating a new .conf file, if
+        /etc/kernel-img.cong says do_initrd=yes
+      - when generating a new append= line, preserve only console=
+        from any existing kernel cmdline
+      - Add '-P' to 'df -k' calls, closes: #204423
+  * patch from Richard Hirst to avoid using the wrong initrd when elilo is
+    driven interactively, closes: #217595
+  * urgency set high because the d-i folk want this update in testing quickly
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 22 Jan 2004 09:34:16 -0700
+
+elilo (3.4-4) unstable; urgency=low
+
+  * add i386 to list of supported architectures, build depend on a suitably
+    new version of gnu-efi to allow that to work, and change priority from 
+    standard to optional so elilo isn't installed by default on i386
+  * stop forcing use of gcc-3.2
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 23 Oct 2003 22:19:51 -0600
+
+elilo (3.4-3) unstable; urgency=low
+
+  * minor patch from upstream to turn off a debugging output accidentally
+    left in the 3.4 release.
+
+ -- Bdale Garbee <bdale@gag.com>  Fri, 29 Aug 2003 21:35:46 -0600
+
+elilo (3.4-2) unstable; urgency=low
+
+  * force use of gcc-3.2, since latest gcc yields an elilo.efi that won't 
+    boot on at least some systems, closes: #207547
+
+ -- Bdale Garbee <bdale@gag.com>  Fri, 29 Aug 2003 11:34:00 -0600
+
+elilo (3.4-1) unstable; urgency=low
+
+  * new upstream version
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 21 Aug 2003 15:38:26 -0600
+
+elilo (3.3a-3) unstable; urgency=low
+
+  * update the elilo shell script to handle SmartArray device naming
+
+ -- Bdale Garbee <bdale@gag.com>  Wed,  7 May 2003 21:30:53 -0600
+
+elilo (3.3a-2) unstable; urgency=low
+
+  * apply patch from Richard Hirst to have the elilo shell script pay 
+    attention to /etc/kernel-img.conf if it exists.
+
+ -- Bdale Garbee <bdale@gag.com>  Wed,  5 Mar 2003 15:29:12 -0700
+
+elilo (3.3a-1) unstable; urgency=low
+
+  * new upstream version, closes: #165957, #136862
+  * patch to elilo shell script from Dann Frazier to warn user that --force 
+    is now deprecated, closes: #141994
+  * patch to elilo shell script and rules from Dann Frazier to allow -V 
+    option to return the complete version, closes: #142027
+  * patch to elilo shell script from Richard Hirst that fixes problem with
+    whitespace matching in elilo.conf, closes: #146125
+  * add sys2ansi.pl script to the textmenu_chooser example directory since it
+    helps with developing new menu and help screens, closes: #144266
+
+ -- Bdale Garbee <bdale@gag.com>  Tue, 29 Oct 2002 20:03:27 -0700
+
+elilo (3.2-2) unstable; urgency=high
+
+  * craft a reasonably complete elilo.8 man page from Richard's README.Debian
+    content
+  * craft a minimal eliloalt.8 man page that points to /usr/share/doc/elilo
+  * upload with high priority since ia64 b-f needs 3.2 or later in woody
+  * make elilo.efi not be marked executable since it isn't under Linux!
+
+ -- Bdale Garbee <bdale@gag.com>  Mon, 18 Mar 2002 16:22:26 -0700
+
+elilo (3.2-1) unstable; urgency=low
+
+  * new upstream version, merge updates made by Richard Hirst
+  * new /usr/sbin/elilo script, general cleanup, handles GPT tables,
+    puts everything under /EFI/debian subdir, adds boot manager entry
+    after floppy and CD/DVD entries, if they exist
+  * added new tool /usr/sbin/eliloalt, see /usr/share/docs/elilo
+  * updated installed docs to match new upstream source
+  * add postinst query on upgrade from pre-3.2 version offering to rewrite
+    EFI partition and update boot manager entry to reflect structure changes.
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 14 Mar 2002 10:53:42 -0700
+
+elilo (3.1-5) unstable; urgency=low
+
+  * ensure /proc is mounted for efiboot and autoconf options
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 15 Nov 2001 14:56:11 -0700
+
+elilo (3.1-4) unstable; urgency=low
+
+  * integrate changes made by Richard Hirst:
+  * elilo can now handle '/' as a path seperator, so no need to modify
+    paths in elilo.conf
+  * record partition contents in .elilofiles, and only prompt before
+    reformatting on next run if contents have changed
+
+ -- Bdale Garbee <bdale@gag.com>  Thu,  8 Nov 2001 10:20:03 -0700
+
+elilo (3.1-3) unstable; urgency=medium
+
+  * changes to elilo user space script from Richard Hirst to improve install
+    process on systems with serial consoles
+
+ -- Bdale Garbee <bdale@gag.com>  Mon, 29 Oct 2001 12:46:30 -0700
+
+elilo (3.1-2) unstable; urgency=low
+
+  * add dependency on dosfstools since /sbin/elilo uses it to (re)generate
+    the EFI partition
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 30 Aug 2001 10:27:47 -0600
+
+elilo (3.1-1) unstable; urgency=low
+
+  * new upstream version
+  * back out all Debian-specific changes I think are no longer relevant
+
+ -- Bdale Garbee <bdale@gag.com>  Tue, 21 Aug 2001 11:43:21 -0600
+
+elilo (3.0-8) unstable; urgency=low
+
+  * add dependency on efibootmgr, since the user-space elilo script now
+    knows how to use it to configure EFI's boot manager
+
+ -- Bdale Garbee <bdale@gag.com>  Fri, 10 Aug 2001 13:38:55 -0600
+
+elilo (3.0-7) unstable; urgency=low
+
+  * make the elilo script tolerant of the 'bootable' flag being set on the
+    EFI partition
+
+ -- Bdale Garbee <bdale@gag.com>  Thu,  9 Aug 2001 17:05:47 -0600
+
+elilo (3.0-6) unstable; urgency=low
+
+  * fold in patch from Richard Hirst implementing changes as follows:
+  *   added README.elilo for /usr/sbin/elilo script
+  *   verify boot partition is type EFI
+  *   don't copy files that appear to be specified via EFI device path
+      (i.e. if image= or initrd= contains a ':')
+  *   run efibootmgr if requested (b-f does request it)
+  *   check boot partition is big enough before reformatting
+  *   include vmlinuz.old entry in elilo.conf, incase kernel-image
+      expects it
+
+ -- Bdale Garbee <bdale@gag.com>  Wed,  8 Aug 2001 13:51:10 -0600
+
+elilo (3.0-5) unstable; urgency=low
+
+  * move elilo script from /sbin to /usr/sbin at Richard's request
+
+ -- Bdale Garbee <bdale@gag.com>  Fri,  3 Aug 2001 09:48:25 -0600
+
+elilo (3.0-4) unstable; urgency=low
+
+  * fix from Stephane for problem where argument string is modified by
+    the loader.
+  * fix from Stephane for problem discovered by Richard typing return 
+    with no text at the elilo boot prompt
+  * change priority from important to standard
+
+ -- Bdale Garbee <bdale@gag.com>  Mon, 30 Jul 2001 10:21:52 -0600
+
+elilo (3.0-3) unstable; urgency=low
+
+  * make /sbin/elilo executable
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 19 Jul 2001 22:33:47 -0600
+
+elilo (3.0-2) unstable; urgency=low
+
+  * fix for interactive use from linux-ia64 mailing list
+  * changes for recognising full device paths in elilo.conf from Richard
+    Hirst that may or may not be retained in the future.
+  * includes user-space elilo script used to create and populate EFI 
+    partitions during installations and updates
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 19 Jul 2001 15:43:59 -0600
+
+elilo (3.0-1) unstable; urgency=low
+
+  * Initial release of elilo package since upstream split source away from
+    the gnu-efi package.
+
+ -- Bdale Garbee <bdale@gag.com>  Tue, 10 Jul 2001 13:20:28 -0600
+
+Local variables:
+mode: debian-changelog
+End:
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..bf07c15
--- /dev/null
@@ -0,0 +1,13 @@
+Source: elilo
+Section: base
+Priority: optional
+Maintainer: Bdale Garbee <bdale@gag.com>
+Build-Depends: debhelper (>> 3.0.0), gnu-efi (>=3.0a-4)
+Standards-Version: 3.6.1.1
+
+Package: elilo
+Architecture: i386 ia64
+Depends: efibootmgr, dosfstools
+Description: Bootloader for systems using EFI-based firmware
+ This is the Linux bootloader for systems using the Intel EFI firmware
+ specification.  This includes all ia64 systems, and some ia32 systems.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..e8332f8
--- /dev/null
@@ -0,0 +1,20 @@
+This package was debianized by Bdale Garbee <bdale@gag.com> using sources
+obtained from
+
+       ftp://ftp.hpl.hp.com/pub/linux-ia64/
+
+Copyright:
+
+  Copyright (C) 1999-2002 Hewlett-Packard Co.
+      Contributed by David Mosberger <davidm@hpl.hp.com>.
+      Contributed by Stephane Eranian <eranian@hpl.hp.com>
+
+  Copyright (C) 1999-2000 VA Linux Systems
+      Contributed by Johannes Erdfelt <jerdfelt@valinux.com>.
+
+  Copyright (C) 2001 Silicon Graphics, Inc.
+      Contributed by Brent Casavant <bcasavan@sgi.com>
+
+elilo is distributed under the GNU Public License.  On a Debian system,
+the license can be found in /usr/share/common-licenses/GPL.  Or you may 
+contact the Free Software Foundation to obtain a copy.
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..11174f4
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib/elilo
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..af6dfdf
--- /dev/null
@@ -0,0 +1,5 @@
+README
+README.gnu-efi
+TODO
+docs/*.txt
+debian/README.elilo
diff --git a/debian/elilo.8 b/debian/elilo.8
new file mode 100644 (file)
index 0000000..5fd5782
--- /dev/null
@@ -0,0 +1,112 @@
+.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.
+.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
+Debian GNU/Linux from the main filesystem to a subdirectory /EFI/debian
+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 Debian GNU/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/debian/elilo.sh b/debian/elilo.sh
new file mode 100644 (file)
index 0000000..17368e6
--- /dev/null
@@ -0,0 +1,834 @@
+#! /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=##VERSION##
+DEBUG=0
+VERBOSE=0
+TMP="${TMPDIR:-/tmp}"
+TARGET=
+# Beware, /EFI/debian occurs with double backslashes in the script too
+# so change those as well as EFIROOT, if need be.
+EFIROOT=/EFI/debian
+export LC_COLLATE=C
+
+## catch signals, clean up junk in /tmp.
+trap "cleanup" 0
+trap "cleanup; exit 129" HUP
+trap "echo 1>&2 $SIGINT ; cleanup; exit 130" INT
+trap "cleanup; exit 131" QUIT
+trap "cleanup; exit 143" TERM
+
+## 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 ] &&
+       grep -E -qi "^(image|link)_in_boot *= *yes" /etc/kernel-img.conf; then
+    image=/boot/vmlinuz
+    initrdline=initrd=/boot/initrd.img
+    initrdoldline=initrd=/boot/initrd.img.old
+else
+    image=/vmlinuz
+    initrdline=initrd=/initrd.img
+    initrdoldline=initrd=/initrd.img.old
+fi
+if [ -f /etc/kernel-img.conf ] &&
+       ! grep -qi "^do_initrd *= *yes" /etc/kernel-img.conf; then
+    initrdline=
+    initrdoldline=
+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 [ -L "$boot" ] ; then
+       oldboot=$boot
+       boot=$(readlink -f $oldboot)
+       echo 1>&2 "$PRG: $oldboot is a symbolic link, using $boot instead"
+    fi
+    if [ ! -e "$boot" ] ; then
+       echo 1>&2 "$PRG: $boot: No such file or directory"
+       CONFERR=1
+    elif [ ! -b "$boot" ] && [ ! -f "$boot" ] ; then
+       echo 1>&2 "$PRG: $boot: Not a regular file or block device"
+       CONFERR=1
+    elif [ ! -w "$boot" ] || [ ! -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"
+           CONFERR=1
+           ;;
+       *sda)
+           echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of all data on $boot"
+           CONFERR=1
+           ;;
+       *disc)
+           echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of all data on $boot"
+           CONFERR=1
+           ;;
+    esac
+
+    ## now make sure its not something dumb like the root partition
+    ROOT="$(v=`df / 2> /dev/null | grep ^/dev/` ; echo ${v%%[ ]*})"
+    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"
+       CONFERR=1
+    elif [ "$boot" = "$BOOT" ] ; then
+       echo 1>&2 "$PRG:$ERR \`boot=$boot' would result in the destruction of the /boot filesystem"
+       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"
+       CONFERR=1
+    fi
+
+    if [ ! -e "$install" ] ; then
+       echo 1>&2 "$PRG: $install: No such file or directory"
+       CONFERR=1
+    elif [ ! -f "$install" ] ; then
+       echo 1>&2 "$PRG: $install: Not a regular file"
+       CONFERR=1
+    elif [ ! -r "$install" ] ; then
+       echo 1>&2 "$PRG: $install: Permission denied"
+       CONFERR=1
+    fi
+
+    if [ ! -e "$bootconf" ] ; then
+       echo 1>&2 "$PRG: $bootconf: No such file or directory"
+       CONFERR=1
+    elif [ ! -f "$bootconf" ] ; then
+       echo 1>&2 "$PRG: $bootconf: Not a regular file"
+       CONFERR=1
+    elif [ ! -r "$bootconf" ] ; then
+       echo 1>&2 "$PRG: $bootconf: Permission denied"
+       CONFERR=1
+    fi
+
+    if [ ! -d /proc/efi/vars ] && [ ! -d /sys/firmware/efi/vars ] && [ "$efiboot" = 1 ] ; then
+       echo 1>&2 "$PRG: no efi/vars under /proc or /sys/firmware, 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
+       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 codepage=437,iocharset=iso8859-1,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()
+{
+    BTFILE=elilo.efi
+    CFFILE=elilo.conf
+    imagefiles=`grep '^image[[:space:]]*=' $bootconf | \
+               sed 's/^image[[:space:]]*=[[:space:]]*//' | grep -v ':'`
+    initrdfiles=`grep '^[[:space:]]*initrd[[:space:]]*=' $bootconf | \
+               sed 's/.*=[[:space:]]*//' | grep -v ':'`
+
+    ## Point of no return, removing the old EFI/debian 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/debian on to
+    ## the front of any paths that don't contain colons (device paths),
+    ## and replace tabs with spaces.
+    sed -e "s|^boot[[:space:]]*=|# &|" -e "s|^install[[:space:]]*=|# &|" \
+       -e "s|\t| |g" \
+       -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
+           BOOTDISK="${boot%/*}/disc"
+           BOOTPART="${boot##*part}"
+       elif ckcciss "$boot" ; then
+           BOOTDISK="${boot%p[0-9]*}"
+           BOOTPART="${boot##*[a-z]}"
+       else
+           BOOTDISK="${boot%%[0-9]*}"
+           BOOTPART="${boot##*[a-z]}"
+       fi
+       if [ -z "$BOOTDISK" ] || [ -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 "Debian GNU/Linux"
+       for b in `efibootmgr | grep "Debian GNU/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 "Debian GNU/Linux" \
+               -l \\EFI\\debian\\elilo.efi -u -- elilo -C \\EFI\\debian\\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 "^console=" | 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
+" > "$TMPCONF" || return 1
+
+if [ -d /proc/sgi_sn ]
+then
+  # aha!  This is an SGI Altix, and they need the relocatable option.
+  echo "relocatable" >> "$TMPCONF" || return 1
+fi
+
+echo \
+"$append
+
+image=$image
+       label=$label
+       root=$root
+       read-only
+       $initrdline
+
+image=${image}.old
+       label=${label}OLD
+       root=$root
+       read-only
+       $initrdoldline
+" >> "$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()
+{
+    imagefiles=`grep '^image[[:space:]]*=' $bootconf | \
+               sed 's/^image[[:space:]]*=[[:space:]]*//' | grep -v ':'`
+    initrdfiles=`grep '^[[:space:]]*initrd[[:space:]]*=' $bootconf | \
+               sed 's/.*=[[:space:]]*//' | grep -v ':'`
+    bytesneeded=`cat $imagefiles $initrdfiles $install $bootconf 2>/dev/null | wc -c`
+    # convert to KB, allowing 5% overhead
+    kbneeded=$(( bytesneeded / 1024 + bytesneeded / 20480 ))
+    kbavailable=$(df -P -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
+       kbused=$(du -ks $TARGET/$EFIROOT | sed -n "s/[  ].*$//p")
+    else
+        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" ] && [ "$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
+
+# We need vfat support, so make sure it is loaded
+modprobe vfat >/dev/null 2>&1
+
+## elilo.conf autogeneration. MUST have secure mktemp to
+## avoid race conditions. Debian'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 ] && [ $(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/debian/eliloalt.8 b/debian/eliloalt.8
new file mode 100644 (file)
index 0000000..81bcdf6
--- /dev/null
@@ -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).  
diff --git a/debian/postinst b/debian/postinst
new file mode 100644 (file)
index 0000000..50b76ca
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh -e
+
+# don't bother with debconf for this, since very few systems are likely to
+# be affected by this upgrade, and it's a one-shot deal.  this postinst can
+# probably be safely removed for the woody+1 release.
+
+case "$1" in
+    configure)
+        # continue below
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+        exit 0
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 0
+    ;;
+esac
+
+if [ "$2" ] && dpkg --compare-versions $2 lt 3.2-1
+then
+  echo ""
+  echo "You appear to be upgrading from an old (pre-3.2) version of the elilo"
+  echo "package.  The structure of files in the EFI partition is different"
+  echo "now, and the EFI boot manager entry for Debian needs to be updated."
+  echo ""
+  echo "If you have not made any manual changes to the EFI partition content"
+  echo "that you want to preserve, we can reformat and reload that partition"
+  echo "for you, and rewrite the boot manager entry to be correct."
+  echo ""
+  echo "Do you want me to reformat and reload the EFI partition and write an"
+  echo -n "updated boot manager entry for you [Ny]? "
+
+  read answer
+  case "$answer" in
+    [Yy]*)
+       echo -n "Working... "
+       /usr/sbin/elilo --format --efiboot
+       echo "done."
+       ;;
+    *)
+       echo "No action taken.  See /usr/share/doc/elilo/* for more info."
+       ;;
+  esac
+  echo ""
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..1ddd0c5
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatability version to use.
+export DH_COMPAT=3
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+
+       touch configure-stamp
+
+build: configure-stamp build-stamp
+build-stamp:
+       dh_testdir
+
+       $(MAKE)
+
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       -$(MAKE) clean
+
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       cp elilo.efi debian/elilo/usr/lib/elilo/elilo.efi
+
+       # dynamically determine version string from changelog
+       sed s/'##VERSION##'/"`IFS=\"()\" read pkg ver other < \
+               debian/changelog && echo $$ver`"/ < debian/elilo.sh > \
+               debian/elilo/usr/sbin/elilo
+
+       chmod 0755 debian/elilo/usr/sbin/elilo
+       cp tools/eliloalt debian/elilo/usr/sbin/eliloalt
+       chmod 0755 debian/elilo/usr/sbin/eliloalt
+
+       chmod 0644 debian/elilo/usr/lib/elilo/elilo.efi
+
+binary-indep: build install
+
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installdocs
+       dh_installexamples examples/netboot examples/textmenu_chooser
+       cp debian/sys2ansi.pl \
+               debian/elilo/usr/share/doc/elilo/examples/textmenu_chooser/
+       dh_installmenu
+       dh_installcron
+       dh_installman debian/elilo.8 debian/eliloalt.8
+       dh_installinfo
+       dh_installchangelogs ChangeLog
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/sys2ansi.pl b/debian/sys2ansi.pl
new file mode 100644 (file)
index 0000000..ecf7b6b
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+# $Id: sys2ansi.pl,v 1.1 2002/10/29 22:35:52 bdale Exp $
+#
+# Perl script to convert a Syslinux-format screen to PC-ANSI
+# to display in a color xterm or on the Linux console
+#
+@ansicol = (0,4,2,6,1,5,3,7);
+
+$getting_file = 0;
+$enable = 1;
+
+while ( read(STDIN, $ch, 1) > 0 ) {
+    if ( $ch eq "\x1A" ) {     # <SUB> <Ctrl-Z> EOF
+       last;
+    } elsif ( $ch eq "\x0C" ) {        # <FF>  <Ctrl-L> Clear screen
+       print "\x1b[2J" if ( $enable && !$getting_file );
+    } elsif ( $ch eq "\x0F" ) {        # <SI>  <Ctrl-O> Attribute change
+       if ( !$getting_file ) {
+           if ( read(STDIN, $attr, 2) == 2 ) {
+               $attr = hex $attr;
+               if ( $enable ) {
+                   print "\x1b[0;";
+                   if ( $attr & 0x80 ) {
+                       print "5;";
+                       $attr &= ~0x80;
+                   }
+                   if ( $attr & 0x08 ) {
+                       print "1;";
+                       $attr &= ~0x08;
+                   }
+                   printf "%d;%dm",
+                   $ansicol[$attr >> 4] + 40, $ansicol[$attr & 7] + 30;
+               }
+           }
+       }
+    } elsif ( $ch eq "\x18" ) {        # <CAN> <Ctrl-X> Display image
+       # We can't display an image; pretend to be a text screen
+       # Ignore all input until end of line
+       $getting_file = 1;
+    } elsif ( (ord($ch) & ~07) == 0x10 ) { # Mode controls
+       $enable = (ord($ch) & 0x01); # Emulate the text screen
+    } elsif ( $ch eq "\x0D" ) {        # <CR>  <Ctrl-M> Carriage return
+       # Ignore
+    } elsif ( $ch eq "\x0A" ) { # <LF>  <Ctrl-J> Line feed
+       if ( $getting_file ) {
+           $getting_file = 0;
+       } else {
+           print $ch if ( $enable );
+       }
+    } elsif ( $ch eq "\x01" ) {        # <SOH>  <Ctrl-A> Prompt delimiter
+       # Ignore
+    } elsif ( $ch eq "\x02" ) {        # <STX>  <Ctrl-B> Menu delimiter
+       # Ignore
+    } else {
+       print $ch if ( $enable && !$getting_file );
+    }
+}
diff --git a/elilo.c b/elilo.c
index 0959c7133295c1a266589920e4f35ffab5ef8f9d..6ae687255e89f7552d7855679127d91774149cb6 100644 (file)
--- a/elilo.c
+++ b/elilo.c
@@ -564,7 +564,6 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *system_tab)
         * parse config file (verbose becomes visible if set)
         */
        ret = read_config(ptr, retry);
-       Print(L"read_config=%r\n", ret);
        /*
         * when the config file is not found, we fail only if:
         *      - the user did not specified interactive mode