mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
Anpassung der Pfadangaben für GRUB.
Überflüssige Dateien entfernt. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@287 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
24
lfs/grub
24
lfs/grub
@@ -83,18 +83,18 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
|
||||
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
|
||||
|
||||
# Patch SuSE 10.2
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-0.97-path-patch
|
||||
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/SuSE10.2/use_ferror.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-R
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/bad-assert-sideeffect
|
||||
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/SuSE10.2/grub-gfxmenu-v8.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-0.97-devicemap.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-linux-setup-fix
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/fix-uninitialized
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/force-LBA-off.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-0.97-initrdaddr.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-0.97-protexec.patch
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/SuSE10.2/grub-path-cfg.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-0.97-path-patch
|
||||
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/grub-0.97/use_ferror.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-R
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/bad-assert-sideeffect
|
||||
cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/grub-0.97/grub-gfxmenu-v8.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-0.97-devicemap.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-linux-setup-fix
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/fix-uninitialized
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/force-LBA-off.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-0.97-initrdaddr.diff
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-0.97-protexec.patch
|
||||
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-0.97/grub-path-cfg.diff
|
||||
|
||||
cd $(DIR_APP) && perl -pi -e 's,/usr/lib/grub/i386-pc,/usr/share/grub/i386-pc,' docs/grub.texi
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
--- grub-0.97/stage2/builtins.c.orig 2005-02-15 22:58:23.000000000 +0100
|
||||
+++ grub-0.97/stage2/builtins.c 2006-04-19 16:26:33.000000000 +0200
|
||||
@@ -455,6 +455,10 @@ chainloader_func (char *arg, int flags)
|
||||
*((unsigned long *) (BOOTSEC_LOCATION + BOOTSEC_BPB_HIDDEN_SECTORS))
|
||||
= part_start;
|
||||
|
||||
+ /* if a new device was specified, make sure DX is passed correctly */
|
||||
+ if ('(' == *file)
|
||||
+ set_device(file);
|
||||
+
|
||||
errnum = ERR_NONE;
|
||||
|
||||
return 0;
|
||||
@@ -1,160 +0,0 @@
|
||||
--- grub-0.96/netboot/main.c
|
||||
+++ grub-0.96/netboot/main.c
|
||||
@@ -54,9 +54,9 @@
|
||||
|
||||
static int vendorext_isvalid;
|
||||
static unsigned long netmask;
|
||||
-static struct bootpd_t bootp_data;
|
||||
+struct bootpd_t bootp_data;
|
||||
static unsigned long xid;
|
||||
-static unsigned char *end_of_rfc1533 = NULL;
|
||||
+unsigned char *end_of_rfc1533 = NULL;
|
||||
|
||||
#ifndef NO_DHCP_SUPPORT
|
||||
#endif /* NO_DHCP_SUPPORT */
|
||||
--- grub-0.96/stage2/disk_io.c
|
||||
+++ grub-0.96/stage2/disk_io.c
|
||||
@@ -128,7 +128,7 @@
|
||||
int filemax;
|
||||
|
||||
static inline unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+grub_log2 (unsigned long word)
|
||||
{
|
||||
asm volatile ("bsfl %1,%0"
|
||||
: "=r" (word)
|
||||
@@ -140,7 +140,7 @@
|
||||
rawread (int drive, int sector, int byte_offset, int byte_len, char *buf)
|
||||
{
|
||||
int slen, sectors_per_vtrack;
|
||||
- int sector_size_bits = log2 (buf_geom.sector_size);
|
||||
+ int sector_size_bits = grub_log2 (buf_geom.sector_size);
|
||||
|
||||
if (byte_len <= 0)
|
||||
return 1;
|
||||
@@ -163,7 +163,7 @@
|
||||
}
|
||||
buf_drive = drive;
|
||||
buf_track = -1;
|
||||
- sector_size_bits = log2 (buf_geom.sector_size);
|
||||
+ sector_size_bits = grub_log2 (buf_geom.sector_size);
|
||||
}
|
||||
|
||||
/* Make sure that SECTOR is valid. */
|
||||
--- grub-0.96/stage2/fsys_ext2fs.c
|
||||
+++ grub-0.96/stage2/fsys_ext2fs.c
|
||||
@@ -193,7 +193,7 @@
|
||||
|
||||
|
||||
/* ext2/super.c */
|
||||
-#define log2(n) ffz(~(n))
|
||||
+#define grub_log2(n) ffz(~(n))
|
||||
|
||||
#define EXT2_SUPER_MAGIC 0xEF53 /* include/linux/ext2_fs.h */
|
||||
#define EXT2_ROOT_INO 2 /* include/linux/ext2_fs.h */
|
||||
@@ -216,7 +216,7 @@
|
||||
|
||||
/* linux/ext2_fs.h */
|
||||
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
|
||||
-#define EXT2_ADDR_PER_BLOCK_BITS(s) (log2(EXT2_ADDR_PER_BLOCK(s)))
|
||||
+#define EXT2_ADDR_PER_BLOCK_BITS(s) (grub_log2(EXT2_ADDR_PER_BLOCK(s)))
|
||||
|
||||
/* linux/ext2_fs.h */
|
||||
#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
|
||||
@@ -537,7 +537,7 @@
|
||||
|
||||
/* look up an inode */
|
||||
group_id = (current_ino - 1) / (SUPERBLOCK->s_inodes_per_group);
|
||||
- group_desc = group_id >> log2 (EXT2_DESC_PER_BLOCK (SUPERBLOCK));
|
||||
+ group_desc = group_id >> grub_log2 (EXT2_DESC_PER_BLOCK (SUPERBLOCK));
|
||||
desc = group_id & (EXT2_DESC_PER_BLOCK (SUPERBLOCK) - 1);
|
||||
#ifdef E2DEBUG
|
||||
printf ("ipg=%d, dpb=%d\n", SUPERBLOCK->s_inodes_per_group,
|
||||
@@ -553,7 +553,7 @@
|
||||
gdp = GROUP_DESC;
|
||||
ino_blk = gdp[desc].bg_inode_table +
|
||||
(((current_ino - 1) % (SUPERBLOCK->s_inodes_per_group))
|
||||
- >> log2 (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)));
|
||||
+ >> grub_log2 (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)));
|
||||
#ifdef E2DEBUG
|
||||
printf ("inode table fsblock=%d\n", ino_blk);
|
||||
#endif /* E2DEBUG */
|
||||
--- grub-0.96/stage2/fsys_fat.c
|
||||
+++ grub-0.96/stage2/fsys_fat.c
|
||||
@@ -55,7 +55,7 @@
|
||||
#define FAT_CACHE_SIZE 2048
|
||||
|
||||
static __inline__ unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+grub_log2 (unsigned long word)
|
||||
{
|
||||
__asm__ ("bsfl %1,%0"
|
||||
: "=r" (word)
|
||||
@@ -84,9 +84,9 @@
|
||||
if (bpb.sects_per_clust == 0)
|
||||
return 0;
|
||||
|
||||
- FAT_SUPER->sectsize_bits = log2 (FAT_CVT_U16 (bpb.bytes_per_sect));
|
||||
+ FAT_SUPER->sectsize_bits = grub_log2 (FAT_CVT_U16 (bpb.bytes_per_sect));
|
||||
FAT_SUPER->clustsize_bits
|
||||
- = FAT_SUPER->sectsize_bits + log2 (bpb.sects_per_clust);
|
||||
+ = FAT_SUPER->sectsize_bits + grub_log2 (bpb.sects_per_clust);
|
||||
|
||||
/* Fill in info about super block */
|
||||
FAT_SUPER->num_sectors = FAT_CVT_U16 (bpb.short_sectors)
|
||||
--- grub-0.96/stage2/fsys_iso9660.c
|
||||
+++ grub-0.96/stage2/fsys_iso9660.c
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
|
||||
static inline unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+grub_log2 (unsigned long word)
|
||||
{
|
||||
asm volatile ("bsfl %1,%0"
|
||||
: "=r" (word)
|
||||
@@ -68,7 +68,7 @@
|
||||
static int
|
||||
iso9660_devread (int sector, int byte_offset, int byte_len, char *buf)
|
||||
{
|
||||
- unsigned short sector_size_lg2 = log2(buf_geom.sector_size);
|
||||
+ unsigned short sector_size_lg2 = grub_log2(buf_geom.sector_size);
|
||||
|
||||
/*
|
||||
* We have to use own devread() function since BIOS return wrong geometry
|
||||
--- grub-0.96/stage2/fsys_reiserfs.c
|
||||
+++ grub-0.96/stage2/fsys_reiserfs.c
|
||||
@@ -367,7 +367,7 @@
|
||||
|
||||
|
||||
static __inline__ unsigned long
|
||||
-log2 (unsigned long word)
|
||||
+grub_log2 (unsigned long word)
|
||||
{
|
||||
__asm__ ("bsfl %1,%0"
|
||||
: "=r" (word)
|
||||
@@ -609,7 +609,7 @@
|
||||
|
||||
INFO->version = super.s_version;
|
||||
INFO->blocksize = super.s_blocksize;
|
||||
- INFO->fullblocksize_shift = log2 (super.s_blocksize);
|
||||
+ INFO->fullblocksize_shift = grub_log2 (super.s_blocksize);
|
||||
INFO->blocksize_shift = INFO->fullblocksize_shift - SECTOR_BITS;
|
||||
INFO->cached_slots =
|
||||
(FSYSREISER_CACHE_SIZE >> INFO->fullblocksize_shift) - 1;
|
||||
--- grub-0.96/stage2/iso9660.h
|
||||
+++ grub-0.96/stage2/iso9660.h
|
||||
@@ -73,11 +73,11 @@
|
||||
|
||||
typedef struct __iso_16bit {
|
||||
u_int16_t l, b;
|
||||
-} iso_16bit_t __attribute__ ((packed));
|
||||
+} iso_16bit_t;
|
||||
|
||||
typedef struct __iso_32bit {
|
||||
u_int32_t l, b;
|
||||
-} iso_32bit_t __attribute__ ((packed));
|
||||
+} iso_32bit_t;
|
||||
|
||||
typedef u_int8_t iso_date_t[7];
|
||||
|
||||
Binary file not shown.
@@ -1,384 +0,0 @@
|
||||
#
|
||||
# spec file for package grub (Version 0.97)
|
||||
#
|
||||
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# This file and all modifications and additions to the pristine
|
||||
# package are under the same license as the package itself.
|
||||
#
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
# norootforbuild
|
||||
# usedforbuild aaa_base acl attr audit-libs autoconf automake bash bind-libs bind-utils binutils bison bzip2 coreutils cpio cpp cpp41 cracklib cvs cyrus-sasl db diffutils e2fsprogs file filesystem fillup findutils flex gawk gcc gcc41 gdbm gdbm-devel gettext gettext-devel glibc glibc-devel glibc-locale gpm grep groff gzip info insserv klogd less libacl libattr libcom_err libgcc41 libltdl libmudflap41 libnscd libstdc++41 libtool libvolume_id libxcrypt libzio m4 make man mktemp module-init-tools ncurses ncurses-devel net-tools netcfg openldap2-client openssl pam pam-modules patch perl permissions popt procinfo procps psmisc pwdutils rcs readline rpm sed strace sysvinit tar tcpd texinfo timezone unzip util-linux vim zlib zlib-devel
|
||||
|
||||
# Commandline:
|
||||
Name: grub
|
||||
%ifarch x86_64
|
||||
BuildRequires: gcc41-32bit glibc-devel-32bit ncurses-32bit ncurses-devel-32bit
|
||||
%endif
|
||||
License: GPL
|
||||
Group: System/Boot
|
||||
Version: 0.97
|
||||
Release: 22
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
Source1: installgrub
|
||||
Source2: grubonce
|
||||
Patch0: %{name}-%{version}-path-patch
|
||||
Patch1: use_ferror.diff
|
||||
Patch2: grub-R
|
||||
Patch3: bad-assert-sideeffect
|
||||
Patch4: %{name}-gfxmenu-v8.diff
|
||||
Patch5: reiser-unpack
|
||||
Patch6: chainloader-devicefix
|
||||
Patch7: %{name}-%{version}-devicemap.diff
|
||||
Patch8: grub-linux-setup-fix
|
||||
Patch9: fix-uninitialized
|
||||
Patch10: force-LBA-off.diff
|
||||
Patch11: gcc4-diff
|
||||
Patch12: %{name}-%{version}-initrdaddr.diff
|
||||
Patch20: stage2-dir-callback.diff
|
||||
Patch21: stage2-wildcard.diff
|
||||
Patch22: stage2-wildcard-zerowidth.diff
|
||||
Patch23: stage2-wildcard-doc.diff
|
||||
Patch24: grub-%{version}-protexec.patch
|
||||
URL: http://www.gnu.org/software/grub/grub.en.html
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
Summary: Grand Unified Boot Loader
|
||||
PreReq: fileutils sh-utils
|
||||
|
||||
%description
|
||||
GNU GRUB is a multiboot boot loader. It was derived from GRUB. It is an
|
||||
attempt to produce a boot loader for IBM PC-compatible machines that
|
||||
has both the ability to be friendly to beginning or otherwise
|
||||
nontechnically interested users and the flexibility to help experts in
|
||||
diverse environments. It is compatible with Free/Net/OpenBSD and Linux.
|
||||
It supports Win 9x/NT and OS/2 via chainloaders. It has a menu
|
||||
interface and a command line interface.
|
||||
|
||||
|
||||
|
||||
Authors:
|
||||
--------
|
||||
Alessandro Rubini <rubini@gnu.org>
|
||||
Chip Salzenberg <chip@valinux.com>
|
||||
Edmund GRIMLEY EVANS <edmundo@rano.demon.co.uk>
|
||||
Edward Killips <ekillips@triton.net>
|
||||
Gordon Matzigkeit <gord@fig.org>
|
||||
Jochen Hoenicke <jochen@gnu.org>
|
||||
Khimenko Victor <grub@khim.sch57.msk.ru>
|
||||
Klaus Reichl <Klaus.Reichl@alcatel.at>
|
||||
Michael Hohmuth <hohmuth@innocent.com>
|
||||
OKUJI Yoshinori <okuji@gnu.org>
|
||||
Pavel Roskin <proski@gnu.org>
|
||||
|
||||
%debug_package
|
||||
%prep
|
||||
%setup
|
||||
rm -f acconfig.h || true
|
||||
%patch -p1 -E
|
||||
%patch1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
# Disable the wildcard feature
|
||||
#%patch20 -p1
|
||||
#%patch21 -p1
|
||||
#%patch22 -p1
|
||||
#%patch23 -p1
|
||||
%patch24 -p1
|
||||
|
||||
%build
|
||||
perl -pi -e 's,/usr/share/grub/i386-pc,/usr/lib/grub,' docs/grub.texi
|
||||
%{?suse_update_config:%{suse_update_config -l -f . }}
|
||||
autoreconf --force --install
|
||||
%ifarch x86_64
|
||||
EXTRACFLAGS=' -fno-strict-aliasing -minline-all-stringops -m32 -fno-asynchronous-unwind-tables '
|
||||
%else
|
||||
EXTRACFLAGS=' -fno-strict-aliasing -minline-all-stringops'
|
||||
%endif
|
||||
CFLAGS="$RPM_OPT_FLAGS -Os -DNDEBUG -W -Wall -Wpointer-arith $EXTRACFLAGS" ./configure \
|
||||
--prefix=/usr --infodir=%{_infodir} --mandir=%{_mandir} --datadir=/usr/lib \
|
||||
--disable-auto-linux-mem-opt --enable-diskless \
|
||||
--enable-{3c50{3,7},3c5{0,2}9,3c595,3c90x,cs89x0,davicom,depca,eepro{,100},epic100} \
|
||||
--enable-{exos205,lance,ne,ne2100,ni{50,52,65}00,ns8390} \
|
||||
--enable-{rtl8139,sk-g16,smc9000,tiara,tulip,via-rhine,w89c840,wd}
|
||||
make
|
||||
(cd stage2; mv nbgrub pxegrub ..)
|
||||
mv stage2/stage2{,.netboot}
|
||||
make clean
|
||||
CFLAGS="$RPM_OPT_FLAGS -Os -DNDEBUG -W -Wall -Wpointer-arith $EXTRACFLAGS" ./configure \
|
||||
--prefix=/usr --infodir=%{_infodir} --mandir=%{_mandir} --datadir=/usr/lib \
|
||||
--disable-auto-linux-mem-opt
|
||||
make
|
||||
|
||||
%install
|
||||
[ "$RPM_BUILD_ROOT" != "" -a -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
|
||||
make -k DESTDIR=$RPM_BUILD_ROOT install
|
||||
mkdir -p $RPM_BUILD_ROOT/boot/grub
|
||||
ln -sfn . $RPM_BUILD_ROOT/boot/boot
|
||||
(cd $RPM_BUILD_ROOT/usr/lib/grub && mv *-suse/* . && rmdir *-suse) >/dev/null 2>&1 || true
|
||||
cp -p {nb,pxe}grub stage2/stage2{,.netboot} $RPM_BUILD_ROOT/usr/lib/grub
|
||||
cp -p %{SOURCE2} $RPM_BUILD_ROOT/usr/sbin/.
|
||||
# This fine script used to do everything at once, which
|
||||
# isn't necessary any more with Yast2 support.
|
||||
# Kept only for reference and historical reasons.
|
||||
# install -o root -g root -m 744 %{SOURCE1} /usr/sbin
|
||||
# grub-terminfo is irrelevant to us
|
||||
rm -f $RPM_BUILD_ROOT/usr/sbin/grub-terminfo
|
||||
rm -f $RPM_BUILD_ROOT/usr/share/man/man8/grub-terminfo*
|
||||
|
||||
%clean
|
||||
[ "$RPM_BUILD_ROOT" != "" -a -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
|
||||
|
||||
%preun
|
||||
%install_info --delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
|
||||
%install_info --delete --info-dir=%{_infodir} %{_infodir}/multiboot.info.gz
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc BUGS NEWS TODO README THANKS AUTHORS INSTALL ChangeLog COPYING
|
||||
%docdir %{_infodir}
|
||||
%docdir %{_mandir}
|
||||
%docdir /usr/share/doc/packages/grub
|
||||
%dir /boot/grub
|
||||
/usr/bin/mbchk
|
||||
%{_infodir}/grub*.gz
|
||||
%{_infodir}/multiboot.info.gz
|
||||
%{_mandir}/man1/mbchk.1.gz
|
||||
%{_mandir}/man8/grub-install.8.gz
|
||||
%{_mandir}/man8/grub.8.gz
|
||||
%{_mandir}/man8/grub-md5-crypt.8.gz
|
||||
/usr/sbin/grub
|
||||
/usr/sbin/grubonce
|
||||
/usr/sbin/grub-set-default
|
||||
/usr/sbin/grub-install
|
||||
/usr/sbin/grub-md5-crypt
|
||||
#/usr/sbin/installgrub
|
||||
%dir /boot/boot
|
||||
/usr/lib/grub
|
||||
|
||||
%post
|
||||
# should anything go wrong the system will remain bootable :
|
||||
[ -e /boot/grub/stage2 ] && mv /boot/grub/stage2{,.old}
|
||||
# copy especially stage2 over, because it will be modified in-place !
|
||||
cp -p /usr/lib/grub/*stage1* /boot/grub 2>/dev/null || true
|
||||
cp -p /usr/lib/grub/*/*stage1* /boot/grub 2>/dev/null || true
|
||||
#special hack for #46843
|
||||
dd if=/usr/lib/grub/stage2 of=/boot/grub/stage2 bs=256k
|
||||
sync
|
||||
# command sequence to update-install stage1/stage2.
|
||||
# leave everything else alone !
|
||||
[ -e /etc/grub.conf ] && /usr/sbin/grub --batch < /etc/grub.conf >/dev/null 2>&1
|
||||
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
|
||||
%install_info --info-dir=%{_infodir} %{_infodir}/multiboot.info.gz
|
||||
exit 0
|
||||
|
||||
%changelog -n grub
|
||||
* Fri Aug 25 2006 - snwint@suse.de
|
||||
- needs gcc41-32bit
|
||||
* Thu Aug 24 2006 - snwint@suse.de
|
||||
- support latest gfxmenu
|
||||
* Mon Jul 17 2006 - snwint@suse.de
|
||||
- extended gfxmenu interface to pass options for 'module' lines (#160066)
|
||||
- merged various gfxmenu patch fragments into one patch
|
||||
* Thu Apr 20 2006 - duwe@suse.de
|
||||
- fix incorrect DL contents e.g. on chainloader (fd0)+1
|
||||
(Bug #158072)
|
||||
- initialize array in intel netcard probe (Bug #144171)
|
||||
* Wed Jan 25 2006 - mls@suse.de
|
||||
- converted neededforbuild to BuildRequires
|
||||
* Thu Nov 24 2005 - snwint@suse.de
|
||||
- support latest gfxboot
|
||||
* Thu Nov 10 2005 - duwe@suse.de
|
||||
- update to 0.97
|
||||
* Fri Sep 09 2005 - coolo@suse.de
|
||||
- make grubonce shutup
|
||||
* Fri Sep 02 2005 - duwe@suse.de
|
||||
- Make grubonce work with the new 0.96 savedefault,
|
||||
(fixing bug #95082, and by coincidence 99185 along the way, too)
|
||||
* Fri Jun 10 2005 - ro@suse.de
|
||||
- fix variable type in last change
|
||||
* Thu Jun 09 2005 - ro@suse.de
|
||||
- fix gfx display (stackptr diff) (thanks to Steffen)
|
||||
* Fri Apr 29 2005 - duwe@suse.de
|
||||
- update to 0.96
|
||||
- "grubonce" no handled differently
|
||||
- re-do gcc4 fix (cleaner now)
|
||||
- dropped rare NICs sis900 and natsemi in the process,
|
||||
update from etherboot pending anyways.
|
||||
* Sat Apr 09 2005 - aj@suse.de
|
||||
- Compile with GCC4.
|
||||
* Wed Mar 02 2005 - duwe@suse.de
|
||||
- force cache reloading after "embed", for
|
||||
the "setup" shortcut. This fixes Bug #66454
|
||||
* Fri Feb 18 2005 - agruen@suse.de
|
||||
- Disable the wildcard feature.
|
||||
* Sun Feb 06 2005 - ro@suse.de
|
||||
- fix build on i386
|
||||
- use RPM_OPT_FLAGS
|
||||
* Sat Feb 05 2005 - ro@suse.de
|
||||
- use PROT_EXEC (from grub bug-tracking system)
|
||||
* Fri Jan 28 2005 - snwint@suse.de
|
||||
- updated gfxboot patch
|
||||
* Wed Oct 06 2004 - sf@suse.de
|
||||
- dd stage2 instead of copying it (#46843)
|
||||
* Fri Oct 01 2004 - max@suse.de
|
||||
- Added ncurses-devel-32bit and ncurses-devel-32bit to
|
||||
neededforbuild to make history and command completion work
|
||||
on x86_64 [Bug #46577].
|
||||
* Thu Sep 30 2004 - duwe@suse.de
|
||||
- try to defragment stage2 if it resides on reiserfs.
|
||||
This should fix sporadic failures we see.
|
||||
* Thu Sep 30 2004 - agruen@suse.de
|
||||
- Wildcard feature:
|
||||
+ stage2-wildcard-zerowidth.diff: Allow zero-width matches (so
|
||||
that the asterisk in wildcard matches has the usual file glob
|
||||
sematics).
|
||||
+ stage2-wildcard-doc.diff: Document the wildcard feature.
|
||||
* Tue Sep 21 2004 - duwe@suse.de
|
||||
- removed one ill side effect of assert(), most likely
|
||||
fixing blocker #44520
|
||||
* Tue Sep 07 2004 - duwe@suse.de
|
||||
- added "grubonce" script to demonstrate & ease "savedefault --once"
|
||||
* Mon Sep 06 2004 - agruen@suse.de
|
||||
- Fix usage of wrong variable in wildcard code.
|
||||
* Sun Aug 22 2004 - agruen@suse.de
|
||||
- stage2-dir-callback.diff: Make the dir command more flexible,
|
||||
and clean up a bit.
|
||||
- stage2-wildcard.diff: Implement wildcard menu entries.
|
||||
* Mon Jul 26 2004 - duwe@suse.de
|
||||
- update to the latest version, 0.95
|
||||
* Thu May 13 2004 - duwe@suse.de
|
||||
- added -fno-strict-aliasing to CFLAGS, as suggested
|
||||
per autobuild.
|
||||
* Thu May 13 2004 - duwe@suse.de
|
||||
- fix at least Bugs #32351,#36460,#34576,#38774 and #27486,
|
||||
maybe also #35262
|
||||
* Fri Mar 05 2004 - duwe@suse.de
|
||||
- fix bug #35352, the initrd patch only seemed to have gone into
|
||||
0.94, the semantics differ slightly :-(
|
||||
* Mon Mar 01 2004 - duwe@suse.de
|
||||
- quick fix for changed --datadir in 0.94,
|
||||
detected by automated build checks.
|
||||
* Mon Mar 01 2004 - duwe@suse.de
|
||||
- upgrade to 0.94
|
||||
- integrate iso9660 FS
|
||||
- network booting temporarily disabled
|
||||
* Wed Jan 14 2004 - snwint@suse.de
|
||||
- understand new gfxboot file format
|
||||
* Sat Jan 10 2004 - adrian@suse.de
|
||||
- add %%defattr
|
||||
* Thu Aug 28 2003 - snwint@suse.de
|
||||
- graphics patch had been accidentally disabled
|
||||
* Thu Aug 14 2003 - duwe@suse.de
|
||||
- another graphics consolidation, to allow
|
||||
modular maintenance
|
||||
* Thu Jul 31 2003 - duwe@suse.de
|
||||
- reconsolidated graphics patches
|
||||
- fix for machines with > 1GB of mem
|
||||
(thanks to Karsten Keil for reporting/finding this)
|
||||
- fix for hardware RAID device naming scheme
|
||||
* Tue May 27 2003 - snwint@suse.de
|
||||
- no graphics menu if 'savedefault --once' is used (#25356)
|
||||
* Wed May 21 2003 - mmj@suse.de
|
||||
- Don't package grub-terminfo
|
||||
* Sat Mar 08 2003 - snwint@suse.de
|
||||
- no graphics menu if 'hiddenmenu' is used (#23538)
|
||||
* Thu Mar 06 2003 - kukuk@suse.de
|
||||
- Remove not used cyrus-sasl from neededforbuild
|
||||
* Wed Feb 19 2003 - duwe@suse.de
|
||||
- use -minline-all-stringops to work around broken gcc
|
||||
* Tue Feb 11 2003 - ro@suse.de
|
||||
- combine the two postinstalls
|
||||
* Mon Feb 10 2003 - mmj@suse.de
|
||||
- Use %%install_info macros [#23420]
|
||||
* Mon Feb 10 2003 - snwint@suse.de
|
||||
- fixed evil bug in graphics patch
|
||||
* Mon Feb 10 2003 - duwe@suse.de
|
||||
- Now build network and non-network stage2 (Blocker #23502 )
|
||||
- #19984 considered fixed now, too
|
||||
* Sun Feb 09 2003 - snwint@suse.de
|
||||
- updated graphics patch
|
||||
* Thu Feb 06 2003 - duwe@suse.de
|
||||
- update to 0.93 version
|
||||
- patches rediffed accordingly
|
||||
- gfx patches consolidated
|
||||
- made patch to force LBA off (untested)
|
||||
* Thu Jan 16 2003 - nadvornik@suse.cz
|
||||
- fixed the 'valid preprocessing token' error
|
||||
* Thu Nov 28 2002 - duwe@suse.de
|
||||
- added an "important" security fix ;-)
|
||||
passwd not working along with gfxmenu is now
|
||||
made obvious and warned about.
|
||||
- made grub compile with gcc-3.3 and hopefully up.
|
||||
* Thu Nov 14 2002 - duwe@suse.de
|
||||
(candidate to PUTONFTP -- please test)
|
||||
- imported totally rewritten memory layout
|
||||
handling from CVS. This should work around the
|
||||
broken nforce chipsets.
|
||||
- made device.map more robust:
|
||||
* use /boot/grub/device.map by default if it exists
|
||||
* erroneous lines are now skipped, and don't lead to
|
||||
no device.map at all any more.
|
||||
* Thu Oct 10 2002 - kukuk@suse.de
|
||||
- remove requires from bootsplash
|
||||
* Wed Sep 11 2002 - adrian@suse.de
|
||||
- remove PreReq to itself
|
||||
* Tue Sep 10 2002 - duwe@suse.de
|
||||
- added --disable-auto-linux-mem-opt to ./configure options.
|
||||
This prevents grub from arbitrarily adding "mem=" to kernel opts.
|
||||
This anachronism was necessary for some 2.2 Linux kernels, and
|
||||
breaks on MXT machines (#19288).
|
||||
* Fri Sep 06 2002 - duwe@suse.de
|
||||
- added "lilo -R" feature on strong popular demand (#18538)
|
||||
* Tue Sep 03 2002 - snwint@suse.de
|
||||
- fixed Requires
|
||||
* Tue Aug 27 2002 - snwint@suse.de
|
||||
- graphics: free some memory before loading kernel (#18291)
|
||||
* Mon Aug 26 2002 - sf@suse.de
|
||||
- add glibc-devel-32bit to compile on x86_64
|
||||
* Thu Aug 22 2002 - sf@suse.de
|
||||
- added x86_64
|
||||
- compile with -m32 -fno-unwind-asynchronous-tables on x86_64
|
||||
* Tue Aug 20 2002 - mmj@suse.de
|
||||
- Correct PreReq
|
||||
* Wed Jul 24 2002 - duwe@suse.de
|
||||
- converted to safe update scheme using /etc/grub.conf
|
||||
*stage* are now copied from /usr/lib/grub [FHS compliant]
|
||||
to /boot/grub and remain functioning after uninstall.
|
||||
Now configurable with next Yast2; remove previous versions
|
||||
with "rpm -e", from here on "rpm -U" simply works.
|
||||
- grub shell & friends moved to /usr/sbin
|
||||
(you already have that functionality w/ GRUB even before
|
||||
the kernel is booted, save for a mounted root FS)
|
||||
* Thu Jul 18 2002 - snwint@suse.de
|
||||
- basic graphics patch
|
||||
* Thu Jun 20 2002 - stepan@suse.de
|
||||
- update to 0.92 (bugfix release)
|
||||
* Thu Apr 04 2002 - pthomas@suse.de
|
||||
- Fixed to build with new autoconf/automake.
|
||||
* Fri Feb 01 2002 - pthomas@suse.de
|
||||
- Update to 0.91
|
||||
- Clean up spec file.
|
||||
- Handle the chase of /boot not being on its own partition correctly.
|
||||
* Mon Mar 19 2001 - tw@suse.de
|
||||
- switched to grub 0.5.96.1 so the patch of device.c is no longer needed
|
||||
- build --recheck into the installgrub-script
|
||||
* Mon Jan 15 2001 - tw@suse.de
|
||||
- Don't install the stage bootloaders in /usr/share as FHS
|
||||
prohibits doing so.
|
||||
- Because the stage-bootloaders are not in /usr/share, they have
|
||||
to be copied by "grub-install".
|
||||
- Added a new script to ./util "installgrub", which automatically
|
||||
searches the most common partition-types, the kernels and the initrds
|
||||
and installs the bootmanager without action by the user.
|
||||
- There was a bug in ./lib/device.c, that causes a DISK WRITE ERROR.
|
||||
It is fixed now. (Only a O_RDONLY needed to be changed to O_RDRW)
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Keep this sort of configurable for the future.
|
||||
$GRUBDIR="/boot/grub";
|
||||
|
||||
# Parse the menu file, and see if we can get a match for a maybe given arg.
|
||||
open(MENU, "<$GRUBDIR/menu.lst") || die "no menu.lst in $GRUBDIR";
|
||||
$gotit = 0;
|
||||
$titleno = -1;
|
||||
$global_default = undef;
|
||||
while(<MENU>) {
|
||||
m,\s*default\s+(.+), && $titleno == -1 && ($global_default = $1);
|
||||
next unless m,\s*title\s+(.*),i;
|
||||
$title_name = $1;
|
||||
$titleno++;
|
||||
|
||||
if (@ARGV > 0) {
|
||||
# Argument may be entirely numerical, in which case it is an index,
|
||||
# or a perl RE that leads to the first title matching.
|
||||
if (( $ARGV[0] =~ m,[0-9]+, && $titleno eq $ARGV[0] ) ||
|
||||
( $ARGV[0] !~ m,[0-9]+, && $title_name =~ m,$ARGV[0],i) ) {
|
||||
$gotit = 1;
|
||||
last;
|
||||
}
|
||||
} else {
|
||||
print "$titleno: $title_name\n";
|
||||
}
|
||||
}
|
||||
close(MENU);
|
||||
|
||||
print "Warning: you haven't set a global default!\n" if !defined($global_default);
|
||||
|
||||
# Without a command line argument, we have now listet the titles and are done.
|
||||
exit 0 if @ARGV < 1;
|
||||
|
||||
# Else the user wants to write the default file. We have better found a match!
|
||||
if ($gotit > 0) {
|
||||
print "Warning: your global default is 'saved'; changing default permanently!"
|
||||
if $global_default eq "saved";
|
||||
|
||||
print "Using entry #$titleno: $title_name\n";
|
||||
|
||||
# set the magic one-time flag
|
||||
$titleno |= 0x4000;
|
||||
|
||||
open(DEFFILE, ">$GRUBDIR/default") ||
|
||||
die "Cannot open default file for writing";
|
||||
$buf = $titleno . "\0" . "\n" x 9;
|
||||
syswrite(DEFFILE, $buf, 10);
|
||||
close(DEFFILE);
|
||||
|
||||
exit 0;
|
||||
} else {
|
||||
print $ARGV[0] . " not found in $GRUBDIR/menu.lst\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
@@ -1,477 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# installgrub
|
||||
#
|
||||
# Program to automatically install GNU/GrUB under Linux
|
||||
#
|
||||
# Copyright: (c) SuSE GmbH, Nuernberg, Germany
|
||||
#
|
||||
# Authors: Thorsten Wandersmann <tw@suse.de>
|
||||
# Philipp Thomas <pthomas@suse.de>
|
||||
#
|
||||
# $Id: installgrub,v 0.15 2002/01/22 18:06:14 pthomas Exp $
|
||||
#
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_see
|
||||
#
|
||||
# Synopsis: funct_see
|
||||
#
|
||||
# Description: sets -x
|
||||
|
||||
function funct_see () {
|
||||
set -x
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_help
|
||||
#
|
||||
# Synopsis: funct_help help
|
||||
# funct_help "message"
|
||||
#
|
||||
# Description: funct_help will print out the help for the programm if
|
||||
# the keyword "help" is passed to it and will exit with "0".
|
||||
# In other cases it will print out the "message" as error, print
|
||||
# out the help and then exit with "1".
|
||||
|
||||
function funct_help () {
|
||||
if [ "$1" = "help" ]; then
|
||||
funct_print_help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "WARNING: $1"
|
||||
echo ""
|
||||
funct_print_help
|
||||
exit 1
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_print_help
|
||||
#
|
||||
# Synopsis: funct_help
|
||||
#
|
||||
# Description: funct_print_help only prints out the helpscreen and then
|
||||
# returns.
|
||||
#
|
||||
|
||||
function funct_print_help () {
|
||||
funct_version
|
||||
echo ""
|
||||
echo "NAME: installgrub"
|
||||
echo "Synopsis: $0 help"
|
||||
echo " $0 ide|scsi [debug]"
|
||||
echo " $0 version"
|
||||
echo "Description:"
|
||||
echo "$0 will install grub on your system and, hopefully, will correctly"
|
||||
echo "find all things needed."
|
||||
echo "Usage: help - will print out this screen"
|
||||
echo " ide|scsi - GRUB enumerates all drives, ide and scsi, beginning"
|
||||
echo " with '0', just like the BIOS will report them."
|
||||
echo " What it does not regard is SCSI/IDE boot order."
|
||||
echo " If you have SCSI and IDE hard disks installed,"
|
||||
echo " GRUB will start enumeration with the SCSI drives."
|
||||
echo " So in order to correctly install GRUB, you"
|
||||
echo " have to tell it whether booting starts with IDE"
|
||||
echo " or SCSI"
|
||||
echo " debug - causes a lot of messages to be written to"
|
||||
echo " /var/log/installgrub.msg"
|
||||
echo " version - prints out the version"
|
||||
echo ""
|
||||
echo "Send bugreports to 'pthomas@suse.de'"
|
||||
echo ""
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_version
|
||||
#
|
||||
# Synopsios: funct_version
|
||||
#
|
||||
# Description: Extract version info from RCS tag.
|
||||
#
|
||||
|
||||
function funct_version () {
|
||||
|
||||
VERSION=`cat $0 | grep "^#.*Id" | gawk '{print $4" checked in on "$5}'`
|
||||
echo "This is 'installgrub' version $VERSION."
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_entry
|
||||
#
|
||||
# Description: Prepare an entry
|
||||
#
|
||||
|
||||
function funct_entry() {
|
||||
DESCR=$1
|
||||
O_ROOT=`echo $CASE | cut -d"-" -f2`
|
||||
O_ROOT_NR=`echo $O_ROOT | cut -c 9-10`
|
||||
O_ROOT_HD=`echo $O_ROOT | cut -c 1-8`
|
||||
G_O_HD=`grep $O_ROOT_HD /boot/grub/device.map | cut -c 2-4`
|
||||
G_O_NR=`expr $O_ROOT_NR - 1`
|
||||
G_O="($G_O_HD,$G_O_NR)"
|
||||
|
||||
ENTRY="$ENTRY\n\n# Entry -- $DESCR\ntitle $DESCR on $O_ROOT\nroot $G_O\nmakeaktive\nchainloader +1"
|
||||
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_options
|
||||
#
|
||||
# Description: Sort the options given at the command-line.
|
||||
#
|
||||
|
||||
function funct_options() {
|
||||
|
||||
if [ "$1" = "debug" -o "$2" = "debug" ]; then
|
||||
DEB="yes"
|
||||
fi
|
||||
|
||||
if [ "$1" = "help" -o "$2" = "help" ]; then
|
||||
funct_help help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "version" -o "$2" = "version" ]; then
|
||||
funct_version
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "scsi" -o "$2" = "scsi" ]; then
|
||||
DEVICE="scsi"
|
||||
fi
|
||||
|
||||
if [ "$1" = "ide" -o "$2" = "ide" ]; then
|
||||
DEVICE="ide"
|
||||
fi
|
||||
|
||||
test "$DEVICE" || funct_help "No device specified"
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_parts
|
||||
#
|
||||
# Synopsis: funct_parts
|
||||
#
|
||||
# Descriptiuon: Searches the root-partition for GrUB (the Partition
|
||||
# that inhabits /boot) and the Linux Root Partition.
|
||||
#
|
||||
|
||||
function funct_parts () {
|
||||
|
||||
L_BOOT=`grep "[[:space:]]/boot[[:space:]]" /etc/fstab | cut -d" " -f1`
|
||||
L_ROOT=`grep "[[:space:]]/[[:space:]]" /etc/fstab | cut -d" " -f1`
|
||||
|
||||
test -d "/boot" -a -z "$L_BOOT" && BOOT="d"
|
||||
test -L "/boot" -a -z "$L_BOOT" && BOOT="l"
|
||||
|
||||
case "$BOOT" in
|
||||
d)
|
||||
L_BOOT="$L_ROOT"
|
||||
;;
|
||||
l)
|
||||
BO_LINK=`ls -l /boot | gawk '{sub(/\/$/, "");print $NF}'`
|
||||
L_BOOT=`grep "[[:space:]]$BO_LINK[[:space:]]" /etc/fstab | gawk '{print $1}'`
|
||||
test "$L_BOOT" || L_BOOT="$L_ROOT"
|
||||
;;
|
||||
*)
|
||||
test -e "/boot" || \
|
||||
funct_help \
|
||||
"No /boot found! If you use another Directory, please make a Link."
|
||||
;;
|
||||
esac
|
||||
|
||||
L_BOOT_NR=`echo $L_BOOT | cut -c 9-10`
|
||||
L_BOOT_HD=`echo $L_BOOT | cut -c 1-8`
|
||||
G_ROOT_HD=`grep $L_BOOT_HD /boot/grub/device.map | cut -c 2-4`
|
||||
G_ROOT_NR=`expr $L_BOOT_NR - 1`
|
||||
G_ROOT="($G_ROOT_HD,$G_ROOT_NR)"
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_ide
|
||||
#
|
||||
# Synopsis: funct_ide
|
||||
#
|
||||
# Description: Serches the first IDE-HD-Drive.
|
||||
#
|
||||
|
||||
function funct_ide () {
|
||||
|
||||
FDISK=`sfdisk -l | grep "^Disk" | grep "/dev/hd" | cut -c 6-13`
|
||||
COUNTER=0
|
||||
|
||||
for i in $FDISK; do
|
||||
eval FDISK_$COUNTER="$i"
|
||||
COUNTER=`expr $COUNTER + 1`
|
||||
done
|
||||
|
||||
echo $FDISK_0
|
||||
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name funct_ginst
|
||||
#
|
||||
# Synopsis: funct_ginst
|
||||
#
|
||||
# Description: "Installs" GrUB, that means, generates the /boot/grub/device.map
|
||||
# file.
|
||||
#
|
||||
|
||||
function funct_ginst () {
|
||||
|
||||
|
||||
case "$DEVICE" in
|
||||
scsi)
|
||||
grub-install --recheck --root-directory=/boot /dev/sda
|
||||
;;
|
||||
ide)
|
||||
IDE=`funct_ide`
|
||||
grub-install --recheck --root-directory=/boot $IDE
|
||||
;;
|
||||
esac
|
||||
# Seems, that the documentation is not right anymore. IDE seems to be
|
||||
# always the first disk in grub. So its better to always do IDE as
|
||||
# first boot in mix-systems. So you can say, use always (hd0)
|
||||
I_ROOT="hd0"
|
||||
# This is kind of a test.
|
||||
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_oses
|
||||
#
|
||||
# Synopsis:
|
||||
#
|
||||
# Description: Searches all partitions and add those found to the menu
|
||||
#
|
||||
|
||||
function funct_oses () {
|
||||
|
||||
KERNELS=`file /boot/* | grep Kernel | cut -d":" -f1 | cut -d"/" -f3`
|
||||
|
||||
for i in $KERNELS; do
|
||||
INITRD=""
|
||||
INITRD_FILE=""
|
||||
|
||||
SUFFIX=`echo $i | gawk 'BEGIN {FS="vmlinuz"}{print $2}'`
|
||||
|
||||
test -e /boot/initrd && INITRD_FILE="initrd"
|
||||
test -e "/boot/initrd$SUFFIX" && INITRD_FILE="initrd$SUFFIX"
|
||||
|
||||
test "$INITRD_FILE" && INITRD="initrd /$INITRD_FILE"
|
||||
test "$INITRD" || INITRD_FILE="<no initrd found>"
|
||||
|
||||
ENTRY="$ENTRY\n\n# Entry -- $i with initrd: $INITRD_FILE\ntitle Linux on $L_ROOT -- \"$i\", \"$INITRD_FILE\", \"$G_ROOT\"\nroot $G_ROOT\nkernel /$i root=$L_ROOT\n$INITRD"
|
||||
done
|
||||
|
||||
PARTITIONS=`sfdisk -d | grep "^/dev" | gawk 'BEGIN {FIELDWIDTHS = "10 37 2"}{print $3"-"$1}'`
|
||||
|
||||
for CASE in $PARTITIONS; do
|
||||
case "$CASE" in
|
||||
"1-"* | "4-"* | "6-"* | "b-"* | "c-"* | "e-"* | "1-"* | \
|
||||
"11-"* | "14-"* | "16-"* | "1b-"* | "1c-"* | "1e-"* | \
|
||||
"24-"* | "c1-"* | "c4-"* | "c6-"* | "e1-"* | "e3-"* )
|
||||
funct_entry "DOS/Win"
|
||||
;;
|
||||
"7-"* | "17-"* | "84-"* )
|
||||
funct_entry "OS/2"
|
||||
;;
|
||||
"a-"* )
|
||||
funct_entry "OS/2 BootManager"
|
||||
;;
|
||||
"17-"* | "84-"* )
|
||||
funct_entry "WinNT"
|
||||
;;
|
||||
"82-"* )
|
||||
SWAPP=`echo $CASE | cut -d"-" -f2`
|
||||
SWAPT=`mount $SWAPP /tmp 2>&1 | grep swapspace ;
|
||||
umount /tmp 2>/dev/null`
|
||||
test "$SWAPT" || funct_entry "Solaris or SWAP !!!" ;;
|
||||
esac
|
||||
done
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_build
|
||||
#
|
||||
# Synopsis: funct_build
|
||||
#
|
||||
# Description: Builds the menu.lst file.
|
||||
#
|
||||
|
||||
function funct_build () {
|
||||
DATE=`date`
|
||||
ENTRY="# Automatic generated on $DATE\ntimeout 30\ndefault 0\ncolor green/light-gray black/cyan"
|
||||
funct_oses
|
||||
ENTRY="$ENTRY\n\n# Automatic End\n# Inserting Menu.own\n\n"
|
||||
|
||||
test -e /boot/grub/menu.lst && cp /boot/grub/menu.lst /boot/grub/menu.old
|
||||
echo -e "$ENTRY" > /boot/grub/menu.lst
|
||||
test -e /boot/grub/menu.own && cat /boot/grub/menu.own >> /boot/grub/menu.lst
|
||||
ENTRY="$ENTRY\n\n# Inserting Menu.own end\n\n# Have a lot of fun ..."
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Name: funct_write
|
||||
#
|
||||
# Synopsis: funct_write
|
||||
#
|
||||
# Description: Writes GrUB to MBR
|
||||
#
|
||||
# Notice: Because of "EOF" there is no format.
|
||||
#
|
||||
|
||||
function funct_write () {
|
||||
|
||||
grub << EOF
|
||||
root $G_ROOT
|
||||
install /boot/grub/stage1 d ($I_ROOT) ($I_ROOT)1+16 p $G_ROOT/boot/grub/stage2 /boot/grub/menu.lst
|
||||
quit
|
||||
EOF
|
||||
|
||||
return
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# This is the Main-Programm ;-)
|
||||
#
|
||||
|
||||
|
||||
test "$1" = "see" -o "$2" = "see" -o "$3" = "see" && funct_see
|
||||
|
||||
funct_options $1 $2
|
||||
funct_ginst
|
||||
funct_parts
|
||||
funct_build
|
||||
funct_write
|
||||
|
||||
exit 0
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# End Of INSTALLGRUB
|
||||
#
|
||||
# $Log: installgrub,v $
|
||||
# Revision 0.15 2002/01/22 18:06:14 pthomas
|
||||
# - Output bugreport address in help, not in version.
|
||||
# - Reformat help output a bit.
|
||||
#
|
||||
# Revision 0.14 2002/01/22 18:00:02 pthomas
|
||||
# Correct typo.
|
||||
#
|
||||
# Revision 0.13 2002/01/22 14:58:14 pthomas
|
||||
# Correct spelling and comments.
|
||||
# Change bugreport address to pthomas@suse.de
|
||||
#
|
||||
# Revision 0.12 2000/12/19 12:14:46 root
|
||||
# - fixed the version information in help
|
||||
# - rewrote the part, the scripts looks for the patitions.
|
||||
# that means, now its a case, and all partitions will go throug it.
|
||||
# - droped funct_debug its useless now.
|
||||
#
|
||||
# Revision 0.11 2000/09/23 13:19:40 root
|
||||
# found kind of a bug
|
||||
# the manuel of grub says, that your hd-order depends on the bios.
|
||||
# that means: is the first thing to boot ide or scsi.
|
||||
# well in single-systems this do nithing, but it seems, that
|
||||
# against the manuel, the ide-drive is always the first one in grub.
|
||||
# even if the bios says something else.
|
||||
# so i got an error to boot from scsi. after booting in bios from scsi
|
||||
# all went well.
|
||||
#
|
||||
# Revision 0.10 2000/09/23 12:05:06 root
|
||||
# did a fix for scsi ide mix-systems
|
||||
# rerun grub-install with an existing device.map can couse nothing.
|
||||
# so if a hd is added, it could be, that it will not be found.
|
||||
# better to remove the file first and then run grub-install
|
||||
#
|
||||
# Revision 0.9 2000/09/23 11:06:27 root
|
||||
# enterd the possibility to have an menu.own file.
|
||||
# menu.own will be appand below the automatic entrys.
|
||||
# old menu.lst will be saved to menu.old
|
||||
#
|
||||
# Revision 0.8 2000/09/23 08:33:29 root
|
||||
# make os/2 and nt detection ready.
|
||||
# build in detection of /boot, if /boot is not SuSE-Standard
|
||||
# fixed initrd-Entry
|
||||
# todo: description fixing of the functions
|
||||
# will rebuild the detection of the OSes -> going throug all partitions
|
||||
# and than go through a case.
|
||||
#
|
||||
# Revision 0.7 2000/09/18 11:53:22 root
|
||||
# fixed debug-messages
|
||||
# added option see for set -x
|
||||
# todo: correct the descriptions of the functions
|
||||
#
|
||||
# Revision 0.6 2000/09/18 07:22:59 root
|
||||
# minor bug fixed
|
||||
#
|
||||
# Revision 0.5 2000/09/18 07:18:55 root
|
||||
# made it nicer
|
||||
# mor functions, structure for other OS
|
||||
# all kernels, with different initrds
|
||||
#
|
||||
# Revision 0.4 2000/09/15 13:42:26 root
|
||||
# minor bug fixed
|
||||
#
|
||||
# Revision 0.3 2000/09/15 13:37:02 root
|
||||
# First Version that really installs grub, but only linux
|
||||
#
|
||||
# Revision 0.2 2000/09/15 12:16:12 root
|
||||
# ok, now it works as i wanted it
|
||||
#
|
||||
# Revision 0.1 2000/09/15 11:54:37 root
|
||||
# First little try, only for testing.
|
||||
# It will do nothing, because GrUB is disabled in this version.
|
||||
# Lets see if the idea is working.
|
||||
#
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
--- grub-0.95/stage2/filesys.h.orig 2004-05-14 21:36:43.000000000 +0200
|
||||
+++ grub-0.95/stage2/filesys.h 2004-09-30 17:16:20.741176364 +0200
|
||||
@@ -73,6 +73,16 @@
|
||||
int reiserfs_read (char *buf, int len);
|
||||
int reiserfs_dir (char *dirname);
|
||||
int reiserfs_embed (int *start_sector, int needed_sectors);
|
||||
+#if defined(__linux__) && defined (GRUB_UTIL)
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <sys/ioctl.h>
|
||||
+#include <sys/statfs.h>
|
||||
+#include <fcntl.h>
|
||||
+/* from <linux/reiserfs_fs.h> */
|
||||
+#define REISERFS_SUPER_MAGIC 0x52654973
|
||||
+#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
|
||||
+#endif
|
||||
#else
|
||||
#define FSYS_REISERFS_NUM 0
|
||||
#endif
|
||||
--- grub-0.95/stage2/builtins.c.orig 2004-05-14 21:30:52.000000000 +0200
|
||||
+++ grub-0.95/stage2/builtins.c 2004-09-30 17:18:52.342818812 +0200
|
||||
@@ -1807,9 +1807,23 @@
|
||||
#ifdef GRUB_UTIL
|
||||
else if (grub_memcmp ("--stage2=", arg, sizeof ("--stage2=") - 1) == 0)
|
||||
{
|
||||
+ int fd;
|
||||
stage2_os_file = arg + sizeof ("--stage2=") - 1;
|
||||
arg = skip_to (0, arg);
|
||||
nul_terminate (stage2_os_file);
|
||||
+
|
||||
+#if defined(__linux__) && defined (FSYS_REISERFS)
|
||||
+ if ((fd=open(stage2_os_file, O_RDONLY)) >= 0)
|
||||
+ {
|
||||
+ struct statfs buf;
|
||||
+ /* see if the file sits on a reiserfs,
|
||||
+ and try do defragment it if so. */
|
||||
+ fstatfs(fd, &buf);
|
||||
+ if (buf.f_type == REISERFS_SUPER_MAGIC)
|
||||
+ ioctl (fd, REISERFS_IOC_UNPACK, 1);
|
||||
+ }
|
||||
+#endif /* __linux__ && FSYS_REISERFS */
|
||||
+
|
||||
}
|
||||
#endif /* GRUB_UTIL */
|
||||
else
|
||||
@@ -1,708 +0,0 @@
|
||||
Index: grub-0.95/stage2/fsys_jfs.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_jfs.c
|
||||
+++ grub-0.95/stage2/fsys_jfs.c
|
||||
@@ -270,7 +270,7 @@ jfs_read (char *buf, int len)
|
||||
}
|
||||
|
||||
int
|
||||
-jfs_dir (char *dirname)
|
||||
+jfs_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
char *ptr, *rest, ch;
|
||||
ldtentry_t *de;
|
||||
@@ -357,12 +357,9 @@ jfs_dir (char *dirname)
|
||||
|
||||
cmp = (!*dirname) ? -1 : substring (dirname, namebuf);
|
||||
#ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/'
|
||||
- && cmp <= 0) {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
- print_a_completion (namebuf);
|
||||
- } else
|
||||
+ if (handle && ch != '/' && cmp <= 0)
|
||||
+ handle (namebuf);
|
||||
+ else
|
||||
#endif
|
||||
if (cmp == 0) {
|
||||
parent_inum = inum;
|
||||
@@ -372,9 +369,6 @@ jfs_dir (char *dirname)
|
||||
}
|
||||
de = next_dentry ();
|
||||
if (de == NULL) {
|
||||
- if (print_possibilities < 0)
|
||||
- return 1;
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
*rest = ch;
|
||||
return 0;
|
||||
Index: grub-0.95/stage2/fsys_minix.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_minix.c
|
||||
+++ grub-0.95/stage2/fsys_minix.c
|
||||
@@ -294,7 +294,7 @@ minix_read (char *buf, int len)
|
||||
inode of the file we were trying to look up
|
||||
side effects: none yet */
|
||||
int
|
||||
-minix_dir (char *dirname)
|
||||
+minix_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
int current_ino = MINIX_ROOT_INO; /* start at the root */
|
||||
int updir_ino = current_ino; /* the parent of the current directory */
|
||||
@@ -457,18 +457,9 @@ minix_dir (char *dirname)
|
||||
give up */
|
||||
if (loc >= INODE->i_size)
|
||||
{
|
||||
- if (print_possibilities < 0)
|
||||
- {
|
||||
-#if 0
|
||||
- putchar ('\n');
|
||||
-#endif
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- errnum = ERR_FILE_NOT_FOUND;
|
||||
- *rest = ch;
|
||||
- }
|
||||
- return (print_possibilities < 0);
|
||||
+ errnum = ERR_FILE_NOT_FOUND;
|
||||
+ *rest = ch;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/* else, find the (logical) block component of our location */
|
||||
@@ -510,20 +501,15 @@ minix_dir (char *dirname)
|
||||
str_chk = substring (dirname, dp->name);
|
||||
|
||||
# ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/'
|
||||
- && (!*dirname || str_chk <= 0))
|
||||
- {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
- print_a_completion (dp->name);
|
||||
- }
|
||||
+ if (handle && ch != '/' && (!*dirname || str_chk <= 0))
|
||||
+ handle (dp->name);
|
||||
# endif
|
||||
|
||||
dp->name[namelen] = saved_c;
|
||||
}
|
||||
|
||||
}
|
||||
- while (!dp->inode || (str_chk || (print_possibilities && ch != '/')));
|
||||
+ while (!dp->inode || (str_chk || (handle && ch != '/')));
|
||||
|
||||
current_ino = dp->inode;
|
||||
*(dirname = rest) = ch;
|
||||
Index: grub-0.95/stage2/fsys_reiserfs.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_reiserfs.c
|
||||
+++ grub-0.95/stage2/fsys_reiserfs.c
|
||||
@@ -991,7 +991,7 @@ reiserfs_read (char *buf, int len)
|
||||
* the size of the file.
|
||||
*/
|
||||
int
|
||||
-reiserfs_dir (char *dirname)
|
||||
+reiserfs_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
struct reiserfs_de_head *de_head;
|
||||
char *rest, ch;
|
||||
@@ -1123,7 +1123,7 @@ reiserfs_dir (char *dirname)
|
||||
*rest = 0;
|
||||
|
||||
# ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/')
|
||||
+ if (handle && ch != '/')
|
||||
do_possibilities = 1;
|
||||
# endif /* ! STAGE1_5 */
|
||||
|
||||
@@ -1170,10 +1170,8 @@ reiserfs_dir (char *dirname)
|
||||
{
|
||||
if (cmp <= 0)
|
||||
{
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
*name_end = 0;
|
||||
- print_a_completion (filename);
|
||||
+ handle (filename);
|
||||
*name_end = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1189,12 +1187,6 @@ reiserfs_dir (char *dirname)
|
||||
num_entries--;
|
||||
}
|
||||
}
|
||||
-
|
||||
-# ifndef STAGE1_5
|
||||
- if (print_possibilities < 0)
|
||||
- return 1;
|
||||
-# endif /* ! STAGE1_5 */
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
*rest = ch;
|
||||
return 0;
|
||||
Index: grub-0.95/stage2/fsys_iso9660.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_iso9660.c
|
||||
+++ grub-0.95/stage2/fsys_iso9660.c
|
||||
@@ -133,7 +133,7 @@ iso9660_mount (void)
|
||||
}
|
||||
|
||||
int
|
||||
-iso9660_dir (char *dirname)
|
||||
+iso9660_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
struct iso_directory_record *idr;
|
||||
RR_ptr_t rr_ptr;
|
||||
@@ -346,7 +346,7 @@ iso9660_dir (char *dirname)
|
||||
if (name_len >= pathlen
|
||||
&& !memcmp(name, dirname, pathlen))
|
||||
{
|
||||
- if (dirname[pathlen] == '/' || !print_possibilities)
|
||||
+ if (dirname[pathlen] == '/' || !handle)
|
||||
{
|
||||
/*
|
||||
* DIRNAME is directory component of pathname,
|
||||
@@ -377,11 +377,9 @@ iso9660_dir (char *dirname)
|
||||
else /* Completion */
|
||||
{
|
||||
#ifndef STAGE1_5
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
memcpy(NAME_BUF, name, name_len);
|
||||
NAME_BUF[name_len] = '\0';
|
||||
- print_a_completion (NAME_BUF);
|
||||
+ handle (NAME_BUF);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -390,7 +388,7 @@ iso9660_dir (char *dirname)
|
||||
size -= ISO_SECTOR_SIZE;
|
||||
} /* size>0 */
|
||||
|
||||
- if (dirname[pathlen] == '/' || print_possibilities >= 0)
|
||||
+ if (dirname[pathlen] == '/' || handle)
|
||||
{
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
return 0;
|
||||
Index: grub-0.95/stage2/fsys_fat.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_fat.c
|
||||
+++ grub-0.95/stage2/fsys_fat.c
|
||||
@@ -286,7 +286,7 @@ fat_read (char *buf, int len)
|
||||
}
|
||||
|
||||
int
|
||||
-fat_dir (char *dirname)
|
||||
+fat_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
char *rest, ch, dir_buf[FAT_DIRENTRY_LENGTH];
|
||||
char *filename = (char *) NAME_BUF;
|
||||
@@ -342,7 +342,7 @@ fat_dir (char *dirname)
|
||||
*rest = 0;
|
||||
|
||||
# ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/')
|
||||
+ if (handle && ch != '/')
|
||||
do_possibilities = 1;
|
||||
# endif
|
||||
|
||||
@@ -353,16 +353,6 @@ fat_dir (char *dirname)
|
||||
{
|
||||
if (!errnum)
|
||||
{
|
||||
-# ifndef STAGE1_5
|
||||
- if (print_possibilities < 0)
|
||||
- {
|
||||
-#if 0
|
||||
- putchar ('\n');
|
||||
-#endif
|
||||
- return 1;
|
||||
- }
|
||||
-# endif /* STAGE1_5 */
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
*rest = ch;
|
||||
}
|
||||
@@ -457,11 +447,7 @@ fat_dir (char *dirname)
|
||||
{
|
||||
print_filename:
|
||||
if (substring (dirname, filename) <= 0)
|
||||
- {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
- print_a_completion (filename);
|
||||
- }
|
||||
+ handle (filename);
|
||||
continue;
|
||||
}
|
||||
# endif /* STAGE1_5 */
|
||||
Index: grub-0.95/stage2/filesys.h
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/filesys.h
|
||||
+++ grub-0.95/stage2/filesys.h
|
||||
@@ -24,7 +24,7 @@
|
||||
#define FSYS_FFS_NUM 1
|
||||
int ffs_mount (void);
|
||||
int ffs_read (char *buf, int len);
|
||||
-int ffs_dir (char *dirname);
|
||||
+int ffs_dir (char *dirname, void (*handle)(char *));
|
||||
int ffs_embed (int *start_sector, int needed_sectors);
|
||||
#else
|
||||
#define FSYS_FFS_NUM 0
|
||||
@@ -34,7 +34,7 @@ int ffs_embed (int *start_sector, int ne
|
||||
#define FSYS_UFS2_NUM 1
|
||||
int ufs2_mount (void);
|
||||
int ufs2_read (char *buf, int len);
|
||||
-int ufs2_dir (char *dirname);
|
||||
+int ufs2_dir (char *dirname, void (*handle)(char *));
|
||||
int ufs2_embed (int *start_sector, int needed_sectors);
|
||||
#else
|
||||
#define FSYS_UFS2_NUM 0
|
||||
@@ -44,7 +44,7 @@ int ufs2_embed (int *start_sector, int n
|
||||
#define FSYS_FAT_NUM 1
|
||||
int fat_mount (void);
|
||||
int fat_read (char *buf, int len);
|
||||
-int fat_dir (char *dirname);
|
||||
+int fat_dir (char *dirname, void (*handle)(char *));
|
||||
#else
|
||||
#define FSYS_FAT_NUM 0
|
||||
#endif
|
||||
@@ -53,7 +53,7 @@ int fat_dir (char *dirname);
|
||||
#define FSYS_EXT2FS_NUM 1
|
||||
int ext2fs_mount (void);
|
||||
int ext2fs_read (char *buf, int len);
|
||||
-int ext2fs_dir (char *dirname);
|
||||
+int ext2fs_dir (char *dirname, void (*handle)(char *));
|
||||
#else
|
||||
#define FSYS_EXT2FS_NUM 0
|
||||
#endif
|
||||
@@ -62,7 +62,7 @@ int ext2fs_dir (char *dirname);
|
||||
#define FSYS_MINIX_NUM 1
|
||||
int minix_mount (void);
|
||||
int minix_read (char *buf, int len);
|
||||
-int minix_dir (char *dirname);
|
||||
+int minix_dir (char *dirname, void (*handle)(char *));
|
||||
#else
|
||||
#define FSYS_MINIX_NUM 0
|
||||
#endif
|
||||
@@ -71,7 +71,7 @@ int minix_dir (char *dirname);
|
||||
#define FSYS_REISERFS_NUM 1
|
||||
int reiserfs_mount (void);
|
||||
int reiserfs_read (char *buf, int len);
|
||||
-int reiserfs_dir (char *dirname);
|
||||
+int reiserfs_dir (char *dirname, void (*handle)(char *));
|
||||
int reiserfs_embed (int *start_sector, int needed_sectors);
|
||||
#else
|
||||
#define FSYS_REISERFS_NUM 0
|
||||
@@ -81,7 +81,7 @@ int reiserfs_embed (int *start_sector, i
|
||||
#define FSYS_VSTAFS_NUM 1
|
||||
int vstafs_mount (void);
|
||||
int vstafs_read (char *buf, int len);
|
||||
-int vstafs_dir (char *dirname);
|
||||
+int vstafs_dir (char *dirname, void (*handle)(char *));
|
||||
#else
|
||||
#define FSYS_VSTAFS_NUM 0
|
||||
#endif
|
||||
@@ -90,7 +90,7 @@ int vstafs_dir (char *dirname);
|
||||
#define FSYS_JFS_NUM 1
|
||||
int jfs_mount (void);
|
||||
int jfs_read (char *buf, int len);
|
||||
-int jfs_dir (char *dirname);
|
||||
+int jfs_dir (char *dirname, void (*handle)(char *));
|
||||
int jfs_embed (int *start_sector, int needed_sectors);
|
||||
#else
|
||||
#define FSYS_JFS_NUM 0
|
||||
@@ -100,7 +100,7 @@ int jfs_embed (int *start_sector, int ne
|
||||
#define FSYS_XFS_NUM 1
|
||||
int xfs_mount (void);
|
||||
int xfs_read (char *buf, int len);
|
||||
-int xfs_dir (char *dirname);
|
||||
+int xfs_dir (char *dirname, void (*handle)(char *));
|
||||
#else
|
||||
#define FSYS_XFS_NUM 0
|
||||
#endif
|
||||
@@ -109,7 +109,7 @@ int xfs_dir (char *dirname);
|
||||
#define FSYS_TFTP_NUM 1
|
||||
int tftp_mount (void);
|
||||
int tftp_read (char *buf, int len);
|
||||
-int tftp_dir (char *dirname);
|
||||
+int tftp_dir (char *dirname, void (*handle)(char *));
|
||||
void tftp_close (void);
|
||||
#else
|
||||
#define FSYS_TFTP_NUM 0
|
||||
@@ -119,7 +119,7 @@ void tftp_close (void);
|
||||
#define FSYS_ISO9660_NUM 1
|
||||
int iso9660_mount (void);
|
||||
int iso9660_read (char *buf, int len);
|
||||
-int iso9660_dir (char *dirname);
|
||||
+int iso9660_dir (char *dirname, void (*handle)(char *));
|
||||
#else
|
||||
#define FSYS_ISO9660_NUM 0
|
||||
#endif
|
||||
@@ -150,16 +150,10 @@ struct fsys_entry
|
||||
char *name;
|
||||
int (*mount_func) (void);
|
||||
int (*read_func) (char *buf, int len);
|
||||
- int (*dir_func) (char *dirname);
|
||||
+ int (*dir_func) (char *dirname, void (*print_one)(char *));
|
||||
void (*close_func) (void);
|
||||
int (*embed_func) (int *start_sector, int needed_sectors);
|
||||
};
|
||||
|
||||
-#ifdef STAGE1_5
|
||||
-# define print_possibilities 0
|
||||
-#else
|
||||
-extern int print_possibilities;
|
||||
-#endif
|
||||
-
|
||||
extern int fsmax;
|
||||
extern struct fsys_entry fsys_table[NUM_FSYS + 1];
|
||||
Index: grub-0.95/stage2/fsys_ext2fs.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_ext2fs.c
|
||||
+++ grub-0.95/stage2/fsys_ext2fs.c
|
||||
@@ -491,7 +491,7 @@ int ext2_is_fast_symlink (void)
|
||||
* side effects: messes up GROUP_DESC buffer area
|
||||
*/
|
||||
int
|
||||
-ext2fs_dir (char *dirname)
|
||||
+ext2fs_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
int current_ino = EXT2_ROOT_INO; /* start at the root */
|
||||
int updir_ino = current_ino; /* the parent of the current directory */
|
||||
@@ -517,7 +517,6 @@ ext2fs_dir (char *dirname)
|
||||
#ifdef E2DEBUG
|
||||
unsigned char *i;
|
||||
#endif /* E2DEBUG */
|
||||
-
|
||||
/* loop invariants:
|
||||
current_ino = inode to lookup
|
||||
dirname = pointer to filename component we are cur looking up within
|
||||
@@ -709,18 +708,9 @@ ext2fs_dir (char *dirname)
|
||||
give up */
|
||||
if (loc >= INODE->i_size)
|
||||
{
|
||||
- if (print_possibilities < 0)
|
||||
- {
|
||||
-# if 0
|
||||
- putchar ('\n');
|
||||
-# endif
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- errnum = ERR_FILE_NOT_FOUND;
|
||||
- *rest = ch;
|
||||
- }
|
||||
- return (print_possibilities < 0);
|
||||
+ errnum = ERR_FILE_NOT_FOUND;
|
||||
+ *rest = ch;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/* else, find the (logical) block component of our location */
|
||||
@@ -761,20 +751,15 @@ ext2fs_dir (char *dirname)
|
||||
str_chk = substring (dirname, dp->name);
|
||||
|
||||
# ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/'
|
||||
- && (!*dirname || str_chk <= 0))
|
||||
- {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
- print_a_completion (dp->name);
|
||||
- }
|
||||
+ if (handle && ch != '/' && (!*dirname || str_chk <= 0))
|
||||
+ handle (dp->name);
|
||||
# endif
|
||||
|
||||
dp->name[dp->name_len] = saved_c;
|
||||
}
|
||||
|
||||
}
|
||||
- while (!dp->inode || (str_chk || (print_possibilities && ch != '/')));
|
||||
+ while (!dp->inode || (str_chk || (handle && ch != '/')));
|
||||
|
||||
current_ino = dp->inode;
|
||||
*(dirname = rest) = ch;
|
||||
Index: grub-0.95/stage2/fsys_ffs.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_ffs.c
|
||||
+++ grub-0.95/stage2/fsys_ffs.c
|
||||
@@ -180,7 +180,7 @@ ffs_read (char *buf, int len)
|
||||
|
||||
|
||||
int
|
||||
-ffs_dir (char *dirname)
|
||||
+ffs_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
char *rest, ch;
|
||||
int block, off, loc, map, ino = ROOTINO;
|
||||
@@ -236,13 +236,6 @@ loop:
|
||||
{
|
||||
if (loc >= INODE->i_size)
|
||||
{
|
||||
-#if 0
|
||||
- putchar ('\n');
|
||||
-#endif
|
||||
-
|
||||
- if (print_possibilities < 0)
|
||||
- return 1;
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
*rest = ch;
|
||||
return 0;
|
||||
@@ -267,18 +260,13 @@ loop:
|
||||
loc += dp->d_reclen;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
- if (dp->d_ino && print_possibilities && ch != '/'
|
||||
+ if (dp->d_ino && handle && ch != '/'
|
||||
&& (!*dirname || substring (dirname, dp->d_name) <= 0))
|
||||
- {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
-
|
||||
- print_a_completion (dp->d_name);
|
||||
- }
|
||||
+ handle (dp->d_name);
|
||||
#endif /* STAGE1_5 */
|
||||
}
|
||||
while (!dp->d_ino || (substring (dirname, dp->d_name) != 0
|
||||
- || (print_possibilities && ch != '/')));
|
||||
+ || (handle && ch != '/')));
|
||||
|
||||
/* only get here if we have a matching directory entry */
|
||||
|
||||
Index: grub-0.95/stage2/fsys_vstafs.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_vstafs.c
|
||||
+++ grub-0.95/stage2/fsys_vstafs.c
|
||||
@@ -115,7 +115,7 @@ vstafs_nextdir (void)
|
||||
}
|
||||
|
||||
int
|
||||
-vstafs_dir (char *dirname)
|
||||
+vstafs_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
char *fn, ch;
|
||||
struct dir_entry *d;
|
||||
@@ -146,14 +146,9 @@ vstafs_dir (char *dirname)
|
||||
continue;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/'
|
||||
+ if (handle && ch != '/'
|
||||
&& (! *dirname || strcmp (dirname, d->name) <= 0))
|
||||
- {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
-
|
||||
- printf (" %s", d->name);
|
||||
- }
|
||||
+ handle(d->name);
|
||||
#endif
|
||||
if (! grub_strcmp (dirname, d->name))
|
||||
{
|
||||
@@ -168,12 +163,6 @@ vstafs_dir (char *dirname)
|
||||
*(dirname = fn) = ch;
|
||||
if (! d)
|
||||
{
|
||||
- if (print_possibilities < 0)
|
||||
- {
|
||||
- putchar ('\n');
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
return 0;
|
||||
}
|
||||
Index: grub-0.95/stage2/fsys_ufs2.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_ufs2.c
|
||||
+++ grub-0.95/stage2/fsys_ufs2.c
|
||||
@@ -204,7 +204,7 @@ ufs2_read (char *buf, int len)
|
||||
}
|
||||
|
||||
int
|
||||
-ufs2_dir (char *dirname)
|
||||
+ufs2_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
char *rest, ch;
|
||||
int block, off, loc, ino = ROOTINO;
|
||||
@@ -261,9 +261,6 @@ loop:
|
||||
{
|
||||
if (loc >= INODE_UFS2->di_size)
|
||||
{
|
||||
- if (print_possibilities < 0)
|
||||
- return 1;
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
*rest = ch;
|
||||
return 0;
|
||||
@@ -288,18 +285,13 @@ loop:
|
||||
loc += dp->d_reclen;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
- if (dp->d_ino && print_possibilities && ch != '/'
|
||||
+ if (dp->d_ino && handle && ch != '/'
|
||||
&& (!*dirname || substring (dirname, dp->d_name) <= 0))
|
||||
- {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
-
|
||||
- print_a_completion (dp->d_name);
|
||||
- }
|
||||
+ handle (dp->d_name);
|
||||
#endif /* STAGE1_5 */
|
||||
}
|
||||
while (!dp->d_ino || (substring (dirname, dp->d_name) != 0
|
||||
- || (print_possibilities && ch != '/')));
|
||||
+ || (handle && ch != '/')));
|
||||
|
||||
/* only get here if we have a matching directory entry */
|
||||
|
||||
Index: grub-0.95/stage2/disk_io.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/disk_io.c
|
||||
+++ grub-0.95/stage2/disk_io.c
|
||||
@@ -36,7 +36,6 @@ void (*disk_read_hook) (int, int, int) =
|
||||
void (*disk_read_func) (int, int, int) = NULL;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
-int print_possibilities;
|
||||
|
||||
static int do_completion;
|
||||
static int unique;
|
||||
@@ -1479,7 +1478,7 @@ print_completions (int is_filename, int
|
||||
if (! is_completion)
|
||||
grub_printf (" Possible files are:");
|
||||
|
||||
- dir (buf);
|
||||
+ dir (buf, print_a_completion);
|
||||
|
||||
if (is_completion && *unique_string)
|
||||
{
|
||||
@@ -1498,7 +1497,7 @@ print_completions (int is_filename, int
|
||||
*ptr = '/';
|
||||
*(ptr + 1) = 0;
|
||||
|
||||
- dir (buf);
|
||||
+ dir (buf, print_a_completion);
|
||||
|
||||
/* Restore the original unique value. */
|
||||
unique = 1;
|
||||
@@ -1626,12 +1625,7 @@ grub_open (char *filename)
|
||||
if (!errnum && fsys_type == NUM_FSYS)
|
||||
errnum = ERR_FSYS_MOUNT;
|
||||
|
||||
-# ifndef STAGE1_5
|
||||
- /* set "dir" function to open a file */
|
||||
- print_possibilities = 0;
|
||||
-# endif
|
||||
-
|
||||
- if (!errnum && (*(fsys_table[fsys_type].dir_func)) (filename))
|
||||
+ if (!errnum && (*(fsys_table[fsys_type].dir_func)) (filename, NULL))
|
||||
{
|
||||
#ifndef NO_DECOMPRESSION
|
||||
return gunzip_test_header ();
|
||||
@@ -1752,7 +1746,7 @@ grub_seek (int offset)
|
||||
}
|
||||
|
||||
int
|
||||
-dir (char *dirname)
|
||||
+dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
#ifndef NO_DECOMPRESSION
|
||||
compressed_file = 0;
|
||||
@@ -1761,19 +1755,18 @@ dir (char *dirname)
|
||||
if (!(dirname = setup_part (dirname)))
|
||||
return 0;
|
||||
|
||||
+ errnum = 0;
|
||||
if (*dirname != '/')
|
||||
errnum = ERR_BAD_FILENAME;
|
||||
-
|
||||
- if (fsys_type == NUM_FSYS)
|
||||
+ else if (fsys_type == NUM_FSYS)
|
||||
errnum = ERR_FSYS_MOUNT;
|
||||
-
|
||||
- if (errnum)
|
||||
- return 0;
|
||||
-
|
||||
- /* set "dir" function to list completions */
|
||||
- print_possibilities = 1;
|
||||
-
|
||||
- return (*(fsys_table[fsys_type].dir_func)) (dirname);
|
||||
+ else
|
||||
+ {
|
||||
+ fsys_table[fsys_type].dir_func (dirname, handle);
|
||||
+ if (errnum == ERR_FILE_NOT_FOUND)
|
||||
+ errnum = 0;
|
||||
+ }
|
||||
+ return errnum == 0;
|
||||
}
|
||||
#endif /* STAGE1_5 */
|
||||
|
||||
Index: grub-0.95/stage2/fsys_xfs.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/fsys_xfs.c
|
||||
+++ grub-0.95/stage2/fsys_xfs.c
|
||||
@@ -534,7 +534,7 @@ xfs_read (char *buf, int len)
|
||||
}
|
||||
|
||||
int
|
||||
-xfs_dir (char *dirname)
|
||||
+xfs_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
xfs_ino_t ino, parent_ino, new_ino;
|
||||
xfs_fsize_t di_size;
|
||||
@@ -595,11 +595,9 @@ xfs_dir (char *dirname)
|
||||
for (;;) {
|
||||
cmp = (!*dirname) ? -1 : substring (dirname, name);
|
||||
#ifndef STAGE1_5
|
||||
- if (print_possibilities && ch != '/' && cmp <= 0) {
|
||||
- if (print_possibilities > 0)
|
||||
- print_possibilities = -print_possibilities;
|
||||
- print_a_completion (name);
|
||||
- } else
|
||||
+ if (handle && ch != '/' && cmp <= 0)
|
||||
+ handle (name);
|
||||
+ else
|
||||
#endif
|
||||
if (cmp == 0) {
|
||||
parent_ino = ino;
|
||||
@@ -610,9 +608,6 @@ xfs_dir (char *dirname)
|
||||
}
|
||||
name = next_dentry (&new_ino);
|
||||
if (name == NULL) {
|
||||
- if (print_possibilities < 0)
|
||||
- return 1;
|
||||
-
|
||||
errnum = ERR_FILE_NOT_FOUND;
|
||||
*rest = ch;
|
||||
return 0;
|
||||
Index: grub-0.95/netboot/fsys_tftp.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/netboot/fsys_tftp.c
|
||||
+++ grub-0.95/netboot/fsys_tftp.c
|
||||
@@ -409,7 +409,7 @@ tftp_read (char *addr, int size)
|
||||
/* Check if the file DIRNAME really exists. Get the size and save it in
|
||||
FILEMAX. */
|
||||
int
|
||||
-tftp_dir (char *dirname)
|
||||
+tftp_dir (char *dirname, void (*handle)(char *))
|
||||
{
|
||||
int ch;
|
||||
|
||||
@@ -418,7 +418,7 @@ tftp_dir (char *dirname)
|
||||
#endif
|
||||
|
||||
/* In TFTP, there is no way to know what files exist. */
|
||||
- if (print_possibilities)
|
||||
+ if (handle)
|
||||
return 1;
|
||||
|
||||
/* Don't know the size yet. */
|
||||
@@ -1,55 +0,0 @@
|
||||
Index: grub-0.95/docs/grub.texi
|
||||
===================================================================
|
||||
--- grub-0.95.orig/docs/grub.texi
|
||||
+++ grub-0.95/docs/grub.texi
|
||||
@@ -1933,6 +1933,7 @@ These commands can only be used in the m
|
||||
* gfxmenu:: Use graphical menu interface
|
||||
* timeout:: Set the timeout
|
||||
* title:: Start a menu entry
|
||||
+* wildcard:: Define a wildcard boot entry
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -2001,6 +2002,42 @@ the line, starting with the first non-sp
|
||||
@end deffn
|
||||
|
||||
|
||||
+@node wildcard
|
||||
+@subsection wildcard
|
||||
+
|
||||
+@deffn Command wildcard pathname
|
||||
+Treat this boot entry as a wildcard entry: The
|
||||
+wildcard, title, kernel, and initrd commands (see @ref{Menu-specific
|
||||
+commands} and @ref{Command-line and menu entry commands}) each have an
|
||||
+asterisk (*) in their value. A filename match is performed on the
|
||||
+@var{pathname} of the wildcard command. For each match, the entire boot
|
||||
+entry is duplicated. The part of the filename whcih matches the asterisk
|
||||
+in the wildcard command replaces the asterisks in the title, kernel, and
|
||||
+initrd commands. For example, with the files vmlinuz-2.6.5-1 and
|
||||
+vmlinuz-2.6.8-8 below (hd0,7)/boot, the following entry in the stage 2
|
||||
+configuration file:
|
||||
+
|
||||
+@example
|
||||
+title Linux-*
|
||||
+ wildcard (hd0,7)/boot/vmlinuz-*
|
||||
+ kernel (hd0,7)/boot/vmlinuz-* root=/dev/hda8
|
||||
+ initrd (hd0,7)/boot/initrd-*
|
||||
+@end example
|
||||
+
|
||||
+would expand as follows:
|
||||
+
|
||||
+@example
|
||||
+title Linux-2.6.5-1
|
||||
+ wildcard (hd0,7)/boot/vmlinuz-2.6.5-1
|
||||
+ kernel (hd0,7)/boot/vmlinuz-2.6.5-1 root=/dev/hda8
|
||||
+ initrd (hd0,7)/boot/initrd-2.6.5-1
|
||||
+title Linux-2.6.8-8
|
||||
+ wildcard (hd0,7)/boot/vmlinuz-2.6.8-8
|
||||
+ kernel (hd0,7)/boot/vmlinuz-2.6.8-8 root=/dev/hda8
|
||||
+ initrd (hd0,7)/boot/initrd-2.6.8-8
|
||||
+@end example
|
||||
+@end deffn
|
||||
+
|
||||
@node General commands
|
||||
@section The list of general commands
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
Index: grub-0.95/stage2/stage2.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/stage2.c
|
||||
+++ grub-0.95/stage2/stage2.c
|
||||
@@ -1264,11 +1264,11 @@ wildcard_handler(char *name)
|
||||
p = name + grub_strlen (name) - grub_strlen (wildcard_suffix);
|
||||
/* [n .. p) is the part matching the asterisk */
|
||||
|
||||
- if (p <= n || grub_strcmp (p, wildcard_suffix) != 0)
|
||||
- return; /* zero-length match or suffix mismatch */
|
||||
+ if (p < n || grub_strcmp (p, wildcard_suffix) != 0)
|
||||
+ return; /* suffix mismatch */
|
||||
|
||||
/* store this match */
|
||||
- if (p - n + 2 > sizeof (wildcard_matches) -
|
||||
+ if (p - n + 1 > sizeof (wildcard_matches) -
|
||||
(end_wildcard_matches - wildcard_matches))
|
||||
return; /* out of space */
|
||||
while (n < p)
|
||||
@@ -1279,7 +1279,7 @@ wildcard_handler(char *name)
|
||||
/* Wildcard expand the GLOB argument. Return NULL upon failure, or
|
||||
a list of 0-terminated expansions, terminated by a zero-length string. */
|
||||
char *
|
||||
-wildcard (char *glob)
|
||||
+wildcard (char *glob, int *len)
|
||||
{
|
||||
char path[128], *p;
|
||||
int ret;
|
||||
@@ -1324,25 +1324,25 @@ wildcard (char *glob)
|
||||
wildcard_prefix[grub_strlen (wildcard_prefix)] = '*';
|
||||
if (!ret)
|
||||
return NULL;
|
||||
- *end_wildcard_matches++ = 0;
|
||||
+ *len = end_wildcard_matches - wildcard_matches;
|
||||
return wildcard_matches;
|
||||
}
|
||||
|
||||
#define skip(str) ((str) + grub_strlen (str) + 1)
|
||||
|
||||
-static void inplace_sort (char *str);
|
||||
+static void inplace_sort (char *str, int len);
|
||||
|
||||
static void
|
||||
-inplace_sort (char *str)
|
||||
+inplace_sort (char *str, int len)
|
||||
{
|
||||
int m, n = 0;
|
||||
- char *s, *t, *x;
|
||||
+ char *s, *t;
|
||||
|
||||
- for (s = str; *s; s = skip (s))
|
||||
- n++;
|
||||
-
|
||||
/* we use x as temporary storage */
|
||||
- x = s + 1;
|
||||
+ char *x = str + len;
|
||||
+
|
||||
+ for (s = str; s < x; s = skip (s))
|
||||
+ n++;
|
||||
|
||||
for (; n >= 2; n--)
|
||||
{
|
||||
@@ -1368,6 +1368,8 @@ inplace_sort (char *str)
|
||||
}
|
||||
}
|
||||
|
||||
+#undef skip
|
||||
+
|
||||
static int this_config_len (const char *config);
|
||||
static int
|
||||
this_config_len (const char *config)
|
||||
@@ -1468,16 +1470,16 @@ cmain (void)
|
||||
}
|
||||
if (*w == 0 && (*c == ' ' || *c == '\t' || *c == '='))
|
||||
{
|
||||
- int len;
|
||||
+ int len, wlen;
|
||||
|
||||
/* This is a wildcard command. Advance to the argument. */
|
||||
while (*c == ' ' || *c == '\t' || *c == '=')
|
||||
c++;
|
||||
|
||||
/* Expand wildcard entry. */
|
||||
- w = wildcard (c);
|
||||
+ w = wildcard (c, &wlen);
|
||||
if (w)
|
||||
- inplace_sort (w);
|
||||
+ inplace_sort (w, wlen);
|
||||
|
||||
/* Remove the wildcard command from the command section;
|
||||
it has no meaning beyond the wildcard expansion just
|
||||
@@ -1487,7 +1489,7 @@ cmain (void)
|
||||
config_len - (command - config_entries));
|
||||
config_len -= len;
|
||||
|
||||
- while (w && *w)
|
||||
+ while (w && wlen)
|
||||
{
|
||||
/* Insert expansion before the wildcard entry in the
|
||||
list of entry names. */
|
||||
@@ -1511,6 +1513,7 @@ cmain (void)
|
||||
config_len += len;
|
||||
|
||||
num_entries++;
|
||||
+ wlen -= grub_strlen (w) + 1;
|
||||
w += grub_strlen (w) + 1;
|
||||
}
|
||||
|
||||
Index: grub-0.95/stage2/shared.h
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/shared.h
|
||||
+++ grub-0.95/stage2/shared.h
|
||||
@@ -1012,7 +1012,7 @@ void grub_close (void);
|
||||
int dir (char *dirname, void (*handle)(char *));
|
||||
|
||||
/* Wildcard expand the last pathname component of GLOB. */
|
||||
-char *wildcard (char *glob);
|
||||
+char *wildcard (char *glob, int *len);
|
||||
|
||||
int set_bootdev (int hdbias);
|
||||
|
||||
@@ -1,403 +0,0 @@
|
||||
Index: grub-0.95/stage2/shared.h
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/shared.h
|
||||
+++ grub-0.95/stage2/shared.h
|
||||
@@ -1008,9 +1008,11 @@ int grub_seek (int offset);
|
||||
/* Close a file. */
|
||||
void grub_close (void);
|
||||
|
||||
-/* List the contents of the directory that was opened with GRUB_OPEN,
|
||||
- printing all completions. */
|
||||
-int dir (char *dirname);
|
||||
+/* List the contents of DIRECTORY. */
|
||||
+int dir (char *dirname, void (*handle)(char *));
|
||||
+
|
||||
+/* Wildcard expand the last pathname component of GLOB. */
|
||||
+char *wildcard (char *glob);
|
||||
|
||||
int set_bootdev (int hdbias);
|
||||
|
||||
Index: grub-0.95/stage2/stage2.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/stage2.c
|
||||
+++ grub-0.95/stage2/stage2.c
|
||||
@@ -1240,6 +1240,192 @@ get_line_from_config (char *cmdline, int
|
||||
}
|
||||
|
||||
|
||||
+char *wildcard_prefix, *wildcard_suffix;
|
||||
+char wildcard_matches[1024], *end_wildcard_matches;
|
||||
+
|
||||
+static void wildcard_handler(char *name);
|
||||
+
|
||||
+/* Match one directory entry against the current wildcard. If the entry
|
||||
+ matches, store it in WILDCARD_MATCHES. Silently ignore entries that
|
||||
+ don't fit into WILDCARD_MATCHES anymore. */
|
||||
+static void
|
||||
+wildcard_handler(char *name)
|
||||
+{
|
||||
+ char *n = name, *p = wildcard_prefix;
|
||||
+
|
||||
+ while (*p && *p == *n)
|
||||
+ {
|
||||
+ p++;
|
||||
+ n++;
|
||||
+ }
|
||||
+ if (*p)
|
||||
+ return; /* prefix mismatch */
|
||||
+
|
||||
+ p = name + grub_strlen (name) - grub_strlen (wildcard_suffix);
|
||||
+ /* [n .. p) is the part matching the asterisk */
|
||||
+
|
||||
+ if (p <= n || grub_strcmp (p, wildcard_suffix) != 0)
|
||||
+ return; /* zero-length match or suffix mismatch */
|
||||
+
|
||||
+ /* store this match */
|
||||
+ if (p - n + 2 > sizeof (wildcard_matches) -
|
||||
+ (end_wildcard_matches - wildcard_matches))
|
||||
+ return; /* out of space */
|
||||
+ while (n < p)
|
||||
+ *end_wildcard_matches++ = *n++;
|
||||
+ *end_wildcard_matches++ = 0;
|
||||
+}
|
||||
+
|
||||
+/* Wildcard expand the GLOB argument. Return NULL upon failure, or
|
||||
+ a list of 0-terminated expansions, terminated by a zero-length string. */
|
||||
+char *
|
||||
+wildcard (char *glob)
|
||||
+{
|
||||
+ char path[128], *p;
|
||||
+ int ret;
|
||||
+
|
||||
+ end_wildcard_matches = wildcard_matches;
|
||||
+ if (grub_strlen (glob) + 1 > sizeof (path)) {
|
||||
+ errnum = ERR_FILELENGTH;
|
||||
+ return NULL; /* cannot handle pathnames this long */
|
||||
+ }
|
||||
+ grub_strcpy (path, glob);
|
||||
+ p = path;
|
||||
+ while (*p)
|
||||
+ p++;
|
||||
+ wildcard_suffix = p;
|
||||
+ while (p > path && *p != '/')
|
||||
+ p--;
|
||||
+ if (*p != '/')
|
||||
+ {
|
||||
+ errnum = ERR_BAD_FILETYPE;
|
||||
+ return NULL; /* Cannot wildcard device names */
|
||||
+ }
|
||||
+ *(++p) = 0;
|
||||
+ wildcard_prefix = glob + (p - path);
|
||||
+ for (p = wildcard_prefix;; p++)
|
||||
+ {
|
||||
+ if (*p == 0)
|
||||
+ {
|
||||
+ /* We cannot do exact matches: this cannot be represented in the
|
||||
+ result list. */
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ else if (*p == '*')
|
||||
+ {
|
||||
+ *p++ = 0;
|
||||
+ wildcard_suffix = p;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ret = dir (path, wildcard_handler);
|
||||
+ /* restore original argument */
|
||||
+ wildcard_prefix[grub_strlen (wildcard_prefix)] = '*';
|
||||
+ if (!ret)
|
||||
+ return NULL;
|
||||
+ *end_wildcard_matches++ = 0;
|
||||
+ return wildcard_matches;
|
||||
+}
|
||||
+
|
||||
+#define skip(str) ((str) + grub_strlen (str) + 1)
|
||||
+
|
||||
+static void inplace_sort (char *str);
|
||||
+
|
||||
+static void
|
||||
+inplace_sort (char *str)
|
||||
+{
|
||||
+ int m, n = 0;
|
||||
+ char *s, *t, *x;
|
||||
+
|
||||
+ for (s = str; *s; s = skip (s))
|
||||
+ n++;
|
||||
+
|
||||
+ /* we use x as temporary storage */
|
||||
+ x = s + 1;
|
||||
+
|
||||
+ for (; n >= 2; n--)
|
||||
+ {
|
||||
+ s = str;
|
||||
+ t = skip (s);
|
||||
+
|
||||
+ for (m = n; m >= 2; m--)
|
||||
+ {
|
||||
+ if (grub_strcmp (s, t) > 0)
|
||||
+ {
|
||||
+ int ls = skip (s) - s;
|
||||
+ int lt = skip (t) - t;
|
||||
+
|
||||
+ memcpy (x, s, ls);
|
||||
+ grub_memmove (s + ls, s + lt, t - (s + ls));
|
||||
+ memcpy (s, t, lt);
|
||||
+ t = t + lt - ls;
|
||||
+ memcpy (t, x, ls);
|
||||
+ }
|
||||
+ s = t;
|
||||
+ t = skip (t);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int this_config_len (const char *config);
|
||||
+static int
|
||||
+this_config_len (const char *config)
|
||||
+{
|
||||
+ const char *c = config;
|
||||
+ while (*c)
|
||||
+ {
|
||||
+ while (*c)
|
||||
+ c++;
|
||||
+ c++;
|
||||
+ }
|
||||
+ c++;
|
||||
+ return c - config;
|
||||
+}
|
||||
+
|
||||
+static const char * expand_asterisks (const char *str, int *len,
|
||||
+ const char *subst);
|
||||
+
|
||||
+/* Expand all asterisks (*) in a menu entry or commands section with its
|
||||
+ substitution. Use a backslash as escape character. */
|
||||
+static const char *
|
||||
+expand_asterisks (const char *str, int *len, const char *subst)
|
||||
+{
|
||||
+ static char buffer[1024];
|
||||
+ char *b = buffer, escaped = 0;
|
||||
+ const char *end = str + *len;
|
||||
+
|
||||
+ while (str < end)
|
||||
+ {
|
||||
+ if (*str == '*' && !escaped)
|
||||
+ {
|
||||
+ if (b - buffer + grub_strlen (subst) > sizeof (buffer))
|
||||
+ {
|
||||
+ errnum = ERR_FILELENGTH;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ grub_strcpy (b, subst);
|
||||
+ b += grub_strlen (subst);
|
||||
+ }
|
||||
+ else if (*str == '\\' && !escaped)
|
||||
+ escaped = 1;
|
||||
+ else
|
||||
+ {
|
||||
+ escaped = 0;
|
||||
+ if (b - buffer + 1 > sizeof (buffer))
|
||||
+ {
|
||||
+ errnum = ERR_FILELENGTH;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ *b++ = *str;
|
||||
+ }
|
||||
+ str++;
|
||||
+ }
|
||||
+ *len = b - buffer;
|
||||
+
|
||||
+ return buffer;
|
||||
+}
|
||||
+
|
||||
/* This is the starting function in C. */
|
||||
void
|
||||
cmain (void)
|
||||
@@ -1260,6 +1446,96 @@ cmain (void)
|
||||
init_config ();
|
||||
}
|
||||
|
||||
+ auto void expand_wildcard_entries (void);
|
||||
+ void expand_wildcard_entries (void)
|
||||
+ {
|
||||
+ char *config_entry = config_entries;
|
||||
+ char *menu_entry = menu_entries;
|
||||
+
|
||||
+ while (*menu_entry)
|
||||
+ {
|
||||
+ char *command = config_entry;
|
||||
+
|
||||
+ do
|
||||
+ {
|
||||
+ char *c = command;
|
||||
+ const char *w = "wildcard";
|
||||
+
|
||||
+ while (*w && *c == *w)
|
||||
+ {
|
||||
+ c++;
|
||||
+ w++;
|
||||
+ }
|
||||
+ if (*w == 0 && (*c == ' ' || *c == '\t' || *c == '='))
|
||||
+ {
|
||||
+ int len;
|
||||
+
|
||||
+ /* This is a wildcard command. Advance to the argument. */
|
||||
+ while (*c == ' ' || *c == '\t' || *c == '=')
|
||||
+ c++;
|
||||
+
|
||||
+ /* Expand wildcard entry. */
|
||||
+ w = wildcard (c);
|
||||
+ if (w)
|
||||
+ inplace_sort (w);
|
||||
+
|
||||
+ /* Remove the wildcard command from the command section;
|
||||
+ it has no meaning beyond the wildcard expansion just
|
||||
+ performed. */
|
||||
+ len = grub_strlen (command) + 1;
|
||||
+ grub_memmove (command, command + len,
|
||||
+ config_len - (command - config_entries));
|
||||
+ config_len -= len;
|
||||
+
|
||||
+ while (w && *w)
|
||||
+ {
|
||||
+ /* Insert expansion before the wildcard entry in the
|
||||
+ list of entry names. */
|
||||
+ len = grub_strlen (menu_entry) + 1;
|
||||
+ const char *x = expand_asterisks (menu_entry, &len, w);
|
||||
+ grub_memmove (menu_entry + len, menu_entry,
|
||||
+ menu_len - (menu_entry - menu_entries));
|
||||
+ memcpy (menu_entry, x, len);
|
||||
+ menu_entry += len;
|
||||
+ menu_len += len;
|
||||
+
|
||||
+ /* Insert expansion before the wildcard command section
|
||||
+ in the list of command sections. */
|
||||
+ len = this_config_len (config_entry);
|
||||
+ x = expand_asterisks (config_entry, &len, w);
|
||||
+ grub_memmove (config_entry + len, config_entry,
|
||||
+ config_len - (config_entry -
|
||||
+ config_entries));
|
||||
+ memcpy (config_entry, x, len);
|
||||
+ config_entry += len;
|
||||
+ config_len += len;
|
||||
+
|
||||
+ num_entries++;
|
||||
+ w += grub_strlen (w) + 1;
|
||||
+ }
|
||||
+
|
||||
+ /* Remove the wildcard command section; it has just
|
||||
+ been expanded. */
|
||||
+ len = grub_strlen (menu_entry) + 1;
|
||||
+ grub_memmove (menu_entry, menu_entry + len,
|
||||
+ menu_len - (menu_entry - menu_entries));
|
||||
+ menu_len -= len;
|
||||
+
|
||||
+ len = this_config_len(config_entry);
|
||||
+ grub_memmove (config_entry, config_entry + len,
|
||||
+ config_len - (config_entry - config_entries));
|
||||
+ config_len -= len;
|
||||
+
|
||||
+ num_entries--;
|
||||
+ }
|
||||
+ command += grub_strlen (command) + 1;
|
||||
+ }
|
||||
+ while (*command);
|
||||
+ menu_entry += grub_strlen (menu_entry) + 1;
|
||||
+ config_entry += this_config_len(config_entry);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Initialize the environment for restarting Stage 2. */
|
||||
grub_setjmp (restart_env);
|
||||
|
||||
@@ -1379,8 +1655,16 @@ cmain (void)
|
||||
config_len = prev_config_len;
|
||||
}
|
||||
|
||||
+ if (is_preset)
|
||||
+ close_preset_menu ();
|
||||
+ else
|
||||
+ grub_close ();
|
||||
+
|
||||
menu_entries[menu_len++] = 0;
|
||||
config_entries[config_len++] = 0;
|
||||
+
|
||||
+ expand_wildcard_entries();
|
||||
+
|
||||
grub_memmove (config_entries + config_len, menu_entries,
|
||||
menu_len);
|
||||
menu_entries = config_entries + config_len;
|
||||
@@ -1395,11 +1679,6 @@ cmain (void)
|
||||
else
|
||||
default_entry = fallback_entry;
|
||||
}
|
||||
-
|
||||
- if (is_preset)
|
||||
- close_preset_menu ();
|
||||
- else
|
||||
- grub_close ();
|
||||
}
|
||||
while (is_preset);
|
||||
}
|
||||
Index: grub-0.95/stage2/builtins.c
|
||||
===================================================================
|
||||
--- grub-0.95.orig/stage2/builtins.c
|
||||
+++ grub-0.95/stage2/builtins.c
|
||||
@@ -4831,6 +4831,49 @@ static struct builtin builtin_vbeprobe =
|
||||
};
|
||||
|
||||
|
||||
+/* wildcard */
|
||||
+ static int
|
||||
+wildcard_func (char *arg, int flags)
|
||||
+{
|
||||
+#ifdef DEBUG_WILDCARD
|
||||
+ char *w = wildcard (arg);
|
||||
+
|
||||
+ if (w)
|
||||
+ {
|
||||
+ while (*w)
|
||||
+ {
|
||||
+ grub_printf("%s ", w);
|
||||
+ w += strlen (w) + 1;
|
||||
+ }
|
||||
+ grub_printf("\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+ else
|
||||
+ print_error();
|
||||
+#endif
|
||||
+
|
||||
+ /* This special command is interpreted in the config file parser. */
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct builtin builtin_wildcard =
|
||||
+ {
|
||||
+ "wildcard",
|
||||
+ wildcard_func,
|
||||
+#ifndef DEBUG_WILDCARD
|
||||
+ BUILTIN_MENU,
|
||||
+#else
|
||||
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
|
||||
+ "wildcard GLOB",
|
||||
+ "Declare this menu entry as a wildcard entry. GLOB is a path containing"
|
||||
+ " one asterisk. All files matching this expression are looked up; the"
|
||||
+ " menu entry is duplicated for each match with asterisks in other"
|
||||
+ " commands replaced by the string matching the asterisk in the wildcard"
|
||||
+ " command."
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+
|
||||
/* The table of builtin commands. Sorted in dictionary order. */
|
||||
struct builtin *builtin_table[] =
|
||||
{
|
||||
@@ -4920,5 +4963,6 @@ struct builtin *builtin_table[] =
|
||||
&builtin_unhide,
|
||||
&builtin_uppermem,
|
||||
&builtin_vbeprobe,
|
||||
+ &builtin_wildcard,
|
||||
0
|
||||
};
|
||||
Reference in New Issue
Block a user