2000-07-27 Gordon Matzigkeit <gord@fig.org>

* util/grub-image.in: Initial cut at a script for creating GRUB
	boot images.
	* util/Makefile.am (noinst_SCRIPTS): Added grub-image.
	* configure.in (AC_OUTPUT): Added util/grub-image.
This commit is contained in:
gord 2000-07-27 17:05:44 +00:00
parent 1e402724c6
commit ca924e1180
7 changed files with 1433 additions and 1100 deletions

View file

@ -1,3 +1,10 @@
2000-07-27 Gordon Matzigkeit <gord@fig.org>
* util/grub-image.in: Initial cut at a script for creating GRUB
boot images.
* util/Makefile.am (noinst_SCRIPTS): Added grub-image.
* configure.in (AC_OUTPUT): Added util/grub-image.
2000-07-27 Jochen Hoenicke <jochen@gnu.org> 2000-07-27 Jochen Hoenicke <jochen@gnu.org>
* stage2/asm.S (check_int13_extensions): Fixed the effect of * stage2/asm.S (check_int13_extensions): Fixed the effect of

View file

@ -27,36 +27,44 @@
/* Defined if an absolute indirect call/jump must NOT be prefixed with `*'. */ /* Defined if an absolute indirect call/jump must NOT be prefixed with `*'. */
#undef ABSOLUTE_WITHOUT_ASTERISK #undef ABSOLUTE_WITHOUT_ASTERISK
/* Define if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
/* Define if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H
/* Define if you have the <ncurses/curses.h> header file. */
#undef HAVE_NCURSES_CURSES_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION
/* Define if C symbols get an underscore after compilation */
#undef HAVE_ASM_USCORE
/* Define it to "addr32" or "addr32;" to make GAS happy */ /* Define it to "addr32" or "addr32;" to make GAS happy */
#undef ADDR32 #undef ADDR32
/* Define it to "data32" or "data32;" to make GAS happy */ /* Define it to "data32" or "data32;" to make GAS happy */
#undef DATA32 #undef DATA32
/* Define if C symbols get an underscore after compilation */
#undef HAVE_ASM_USCORE
/* Define if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
/* Define if you have the `curses' library (-lcurses). */
#undef HAVE_LIBCURSES
/* Define if you have the `ncurses' library (-lncurses). */
#undef HAVE_LIBNCURSES
/* Define if you have the `util' library (-lutil). */
#undef HAVE_LIBUTIL
/* Define if you have the <ncurses/curses.h> header file. */
#undef HAVE_NCURSES_CURSES_H
/* Define if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H
/* Define if opendisk() in -lutil can be used */ /* Define if opendisk() in -lutil can be used */
#undef HAVE_OPENDISK #undef HAVE_OPENDISK
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION

2236
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -488,4 +488,4 @@ AC_SUBST(NETBOOT_DRIVERS)
dnl Output. dnl Output.
AC_OUTPUT([Makefile stage1/Makefile stage2/Makefile docs/Makefile \ AC_OUTPUT([Makefile stage1/Makefile stage2/Makefile docs/Makefile \
debian/Makefile lib/Makefile util/Makefile grub/Makefile \ debian/Makefile lib/Makefile util/Makefile grub/Makefile \
netboot/Makefile util/grub-install]) netboot/Makefile util/grub-image util/grub-install])

View file

@ -1,5 +1,6 @@
bin_PROGRAMS = mbchk bin_PROGRAMS = mbchk
sbin_SCRIPTS = grub-install sbin_SCRIPTS = grub-install
noinst_SCRIPTS = grub-image
# XXX: Need to search for a header file in docs, because of multiboot.h. # XXX: Need to search for a header file in docs, because of multiboot.h.
AM_CFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/docs AM_CFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/docs

View file

@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.4a from Makefile.am # Makefile.in generated automatically by automake 1.4a from Makefile.am
# Copyright (C) 1994, 1995-9, 2000 Free Software Foundation, Inc. # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved. # with or without modifications, as long as this notice is preserved.
@ -31,6 +31,8 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
oldincludedir = /usr/include oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@
@ -55,8 +57,6 @@ POST_INSTALL = :
NORMAL_UNINSTALL = : NORMAL_UNINSTALL = :
PRE_UNINSTALL = : PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
@SET_MAKE@
host_alias = @host_alias@ host_alias = @host_alias@
host_triplet = @host@ host_triplet = @host@
AMDEP = @AMDEP@ AMDEP = @AMDEP@
@ -89,6 +89,7 @@ install_sh = @install_sh@
bin_PROGRAMS = mbchk bin_PROGRAMS = mbchk
sbin_SCRIPTS = grub-install sbin_SCRIPTS = grub-install
noinst_SCRIPTS = grub-image
# XXX: Need to search for a header file in docs, because of multiboot.h. # XXX: Need to search for a header file in docs, because of multiboot.h.
AM_CFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/docs AM_CFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/docs
@ -98,7 +99,7 @@ mbchk_LDADD = ../lib/libcommon.a
subdir = util subdir = util
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = grub-install CONFIG_CLEAN_FILES = grub-image grub-install
PROGRAMS = $(bin_PROGRAMS) PROGRAMS = $(bin_PROGRAMS)
@ -110,21 +111,20 @@ am_mbchk_OBJECTS = mbchk.o
mbchk_OBJECTS = $(am_mbchk_OBJECTS) mbchk_OBJECTS = $(am_mbchk_OBJECTS)
mbchk_DEPENDENCIES = ../lib/libcommon.a mbchk_DEPENDENCIES = ../lib/libcommon.a
mbchk_LDFLAGS = mbchk_LDFLAGS =
SCRIPTS = $(sbin_SCRIPTS) SCRIPTS = $(noinst_SCRIPTS) $(sbin_SCRIPTS)
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CCLD = $(CC) CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(mbchk_SOURCES) DIST_SOURCES = $(mbchk_SOURCES)
depcomp = $(SHELL) $(top_srcdir)/depcomp DIST_COMMON = Makefile.am Makefile.in grub-image.in grub-install.in
DEP_FILES = @AMDEP@ $(DEPDIR)/mbchk.Po
DIST_COMMON = Makefile.am Makefile.in grub-install.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best GZIP_ENV = --best
DEP_FILES = .deps/mbchk.P
SOURCES = $(mbchk_SOURCES) SOURCES = $(mbchk_SOURCES)
OBJECTS = $(am_mbchk_OBJECTS) OBJECTS = $(am_mbchk_OBJECTS)
@ -134,10 +134,12 @@ all: all-redirect
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu util/Makefile cd $(top_srcdir) && $(AUTOMAKE) --gnu util/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \ cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
grub-image: $(top_builddir)/config.status grub-image.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
grub-install: $(top_builddir)/config.status grub-install.in grub-install: $(top_builddir)/config.status grub-install.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
@ -204,6 +206,8 @@ uninstall-sbinSCRIPTS:
echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \ echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
rm -f $(DESTDIR)$(sbindir)/$$f; \ rm -f $(DESTDIR)$(sbindir)/$$f; \
done done
.c.o:
$(COMPILE) -c $<
tags: TAGS tags: TAGS
@ -214,7 +218,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
done | \ done | \
$(AWK) ' { files[$$0] = 1; } \ $(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \ END { for (i in files) print i; }'`; \
mkid -fID $$unique $(LISP) mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP) $(TAGS_FILES) $(LISP)
@ -238,40 +242,56 @@ distclean-tags:
maintainer-clean-tags: maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/mbchk.Po distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu util/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend: mostlyclean-depend:
clean-depend: clean-depend:
distclean-depend: distclean-depend:
-rm -rf $(DEPDIR) -rm -rf .deps
maintainer-clean-depend: maintainer-clean-depend:
@AMDEP@CCDEPMODE = @CCDEPMODE@ %.o: %.c
@echo '$(COMPILE) -c -o $@ $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
@-cp .deps/$(*D)/$(*F).pp .deps/$(*D)/$(*F).P; \
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*D)/$(*F).P; \
rm .deps/$(*D)/$(*F).pp
.c.o: %.lo: %.c
@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @echo '$(LTCOMPILE) -c -o $@ $<'; \
@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ $(LTCOMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
$(COMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< < .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) >> .deps/$(*D)/$(*F).P; \
rm -f .deps/$(*D)/$(*F).pp
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir) \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
info-am: info-am:
info: info-am info: info-am
dvi-am: dvi-am:
@ -308,7 +328,6 @@ distclean-generic:
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic: maintainer-clean-generic:
-rm -f Makefile.in
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic mostlyclean-tags mostlyclean-depend mostlyclean-generic
@ -338,8 +357,8 @@ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \ mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile uninstall-sbinSCRIPTS install-sbinSCRIPTS tags \ maintainer-clean-compile uninstall-sbinSCRIPTS install-sbinSCRIPTS tags \
mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
mostlyclean-depend distclean-depend clean-depend \ distdir mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend distdir info-am info dvi-am dvi check check-am \ maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \ installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \ install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all install-strip installdirs mostlyclean-generic \ all-redirect all-am all install-strip installdirs mostlyclean-generic \

138
util/grub-image.in Normal file
View file

@ -0,0 +1,138 @@
#! /bin/sh
# grub-image - Create a GRUB boot filesystem image and tarball
# Gordon Matzigkeit <gord@fig.org>, 2000-07-25
#
# Copyright (C) 2000 Free Software Foundation, Inc.
#
# This file 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.
prefix=@prefix@
exec_prefix=@exec_prefix@
sbindir=@sbindir@
datadir=@datadir@
PACKAGE=@PACKAGE@
host_cpu=@host_cpu@
host_os=@host_os@
host_vendor=@host_vendor@
context=${host_cpu}-${host_vendor}
pkgdatadir=${datadir}/${PACKAGE}/${context}
mke2fs=/sbin/mke2fs
progname=`echo "$0" | sed 's%^.*/%%'`
thisdir=`echo "$0" | sed 's%/[^/]*$%%'`
test "X$thisdir" = "X$0" && thisdir=.
# See if we were invoked from within the build directory, and if so,
# use the built files rather than the installed ones.
if test -f $thisdir/../stage2/stage2.c; then
grub_shell="$thisdir/../grub/grub"
stage1dir="$thisdir/../stage1"
stage2dir="$thisdir/../stage2"
else
grub_shell=${sbindir}/grub
stage1dir="$pkgdatadir"
stage2dir="$pkgdatadir"
fi
# Exit on any error.
set -e
# Get GRUB's version from the Grub shell, since we use the
# installed files.
VERSION=`$grub_shell --version | sed 's/^.* //'`
test "X$VERSION" != X
bootdir=${PACKAGE}-${VERSION}-${context}
image=$bootdir.ext2fs
# Create the tarball.
if test ! -f $bootdir.tar.gz; then
echo "# Creating \`$bootdir.tar.gz'"
mkdir -p $bootdir/boot/grub
cp -p $stage1dir/stage1 $stage2dir/*_stage1_5 $stage2dir/stage2 \
$bootdir/boot/grub
test ! -f menu.lst || cp -p menu.lst $bootdir/boot/grub
trap "rm -f $bootdir.tar.gz" 0
GZIP=-9 tar -zcf $bootdir.tar.gz $bootdir
trap '' 0
rm -rf $bootdir
fi
# Create a new filesystem image of the specified size.
if test ! -f $image; then
tarsize=`zcat $bootdir.tar.gz | wc -c`
# Add about 30% (20% overhead plus 10% breathing room), and convert
# to kilobytes. This factor was determined empirically.
SIZE=`expr $tarsize \* 130 / 100 / 1024`k
echo "# Creating $SIZE disk image \`$image'"
trap "rm -f $image" 0
dd if=/dev/zero of=$image bs=$SIZE count=1 >/dev/null
$mke2fs -F $image
trap '' 0
fi
# Attempt to mount the image.
echo "# Mounting \`$image'"
test -d $bootdir || mkdir $bootdir
case "$host_os" in
gnu*)
settrans -a $bootdir /hurd/ext2fs $image
umount="settrans -a $bootdir"
;;
linux*)
# This requires running as root, and using the loop device.
i=0
while test -e /dev/loop$i; do
if /sbin/losetup /dev/loop$i $image; then
break
fi
i=`expr $i + 1`
done
# Silly losetup doesn't report an error!
mount /dev/loop$i $bootdir
umount="umount $bootdir && /sbin/losetup -d /dev/loop$i && trap '' 0"
;;
*)
echo "$progname: Mounting \`$image' under \`$host_os' is not supported" 1>&2
exit 1
;;
esac
trap "$umount" 0
# Extract our tarball into the image, then unmount it.
echo "# Copying files into \`$image':"
tar -zxvf $bootdir.tar.gz
echo "# \`$image' usage:"
df $bootdir
eval $umount
rmdir $bootdir || :
# Use the GRUB shell to properly set up GRUB on the image.
echo "# Installing GRUB in \`$image'"
cat <<EOF | $grub_shell --batch --device-map=/dev/null
device (fd0) $image
root (fd0)
install /boot/grub/stage1 (fd0) /boot/grub/stage2
quit
EOF
exit 0