2009-11-14 Robert Millan <rmh.grub@aybabtu.com>

* conf/i386-coreboot.rmk (grub_mkrescue_SOURCES): Replace
        `util/i386/coreboot/grub-mkrescue.in' with `util/grub-mkrescue.in'.
        * conf/i386-pc.rmk (grub_mkrescue_SOURCES): Replace
        `util/i386/pc/grub-mkrescue.in' with `util/grub-mkrescue.in'.
        (bin_SCRIPTS): Add `grub-mkfloppy'.
        (grub_mkfloppy_SOURCES): New variable.

        * util/grub-mkrescue.in: New file.
        * util/i386/pc/grub-mkfloppy.in: New file.

        * util/i386/coreboot/grub-mkrescue.in: Remove.
        * util/i386/pc/grub-mkrescue.in: Remove.
This commit is contained in:
Robert Millan 2009-11-14 18:38:11 +00:00
parent 2e035eb9ba
commit fc2208b0ef
6 changed files with 194 additions and 241 deletions

View file

@ -1,3 +1,18 @@
2009-11-14 Robert Millan <rmh.grub@aybabtu.com>
* conf/i386-coreboot.rmk (grub_mkrescue_SOURCES): Replace
`util/i386/coreboot/grub-mkrescue.in' with `util/grub-mkrescue.in'.
* conf/i386-pc.rmk (grub_mkrescue_SOURCES): Replace
`util/i386/pc/grub-mkrescue.in' with `util/grub-mkrescue.in'.
(bin_SCRIPTS): Add `grub-mkfloppy'.
(grub_mkfloppy_SOURCES): New variable.
* util/grub-mkrescue.in: New file.
* util/i386/pc/grub-mkfloppy.in: New file.
* util/i386/coreboot/grub-mkrescue.in: Remove.
* util/i386/pc/grub-mkrescue.in: Remove.
2009-11-13 Robert Millan <rmh.grub@aybabtu.com> 2009-11-13 Robert Millan <rmh.grub@aybabtu.com>
* include/grub/multiboot.h (struct grub_multiboot_header): Move * include/grub/multiboot.h (struct grub_multiboot_header): Move

View file

@ -153,7 +153,7 @@ sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in grub_install_SOURCES = util/grub-install.in
bin_SCRIPTS += grub-mkrescue bin_SCRIPTS += grub-mkrescue
grub_mkrescue_SOURCES = util/i386/coreboot/grub-mkrescue.in grub_mkrescue_SOURCES = util/grub-mkrescue.in
# Modules. # Modules.
pkglib_MODULES = linux.mod multiboot.mod \ pkglib_MODULES = linux.mod multiboot.mod \

View file

@ -168,15 +168,14 @@ grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \
grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB) grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB)
endif endif
# Scripts. sbin_SCRIPTS += grub-install
sbin_SCRIPTS = grub-install
bin_SCRIPTS = grub-mkrescue
# For grub-install.
grub_install_SOURCES = util/grub-install.in grub_install_SOURCES = util/grub-install.in
# For grub-mkrescue. bin_SCRIPTS += grub-mkrescue
grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in grub_mkrescue_SOURCES = util/grub-mkrescue.in
bin_SCRIPTS += grub-mkfloppy
grub_mkfloppy_SOURCES = util/i386/pc/grub-mkfloppy.in
pkglib_MODULES = biosdisk.mod chain.mod \ pkglib_MODULES = biosdisk.mod chain.mod \
multiboot.mod reboot.mod halt.mod \ multiboot.mod reboot.mod halt.mod \

151
util/grub-mkrescue.in Normal file
View file

@ -0,0 +1,151 @@
#! /bin/sh -e
# Make GRUB rescue image
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
#
# GRUB 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 3 of the License, or
# (at your option) any later version.
#
# GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables.
transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
target_cpu=@target_cpu@
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
grub_mkisofs="grub-mkisofs"
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] SOURCE...
Make GRUB rescue image.
-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--output=FILE save output in FILE
$0 generates a bootable rescue image with specified source files or directories.
Report bugs to <bug-grub@gnu.org>.
EOF
}
# Check the arguments.
for option in "$@"; do
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
*)
source="${source} ${option}" ;;
esac
done
iso9660_dir=`mktemp -d`
mkdir -p ${iso9660_dir}/boot/grub
for platform in pc coreboot ; do
input_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-${platform}
if test -e ${input_dir} ; then
mkdir -p ${iso9660_dir}/boot/grub/${target_cpu}-${platform}
for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \
${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \
${input_dir}/handler.lst ${input_dir}/parttool.lst; do
if test -f "$file"; then
cp -f "$file" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/
fi
done
fi
done
# build coreboot core.img
if test -e ${coreboot_dir} ; then
memdisk_img=`mktemp`
memdisk_dir=`mktemp -d`
mkdir -p ${memdisk_dir}/boot/grub
# obtain date-based UUID
iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00)
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
search --fs-uuid --set ${iso_uuid}
set prefix=(\${root})/boot/grub/${target_cpu}-coreboot
EOF
(for i in ${modules} ; do
echo "insmod $i"
done ; \
echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir}
grub-mkelfimage -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
memdisk tar search iso9660 configfile sh \
ata at_keyboard
rm -f ${memdisk_img}
grub_mkisofs="${grub_mkisofs} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
fi
if [ "${source}" != "" ] ; then
for d in ${source}; do
echo "Processing $d"
cp -dpRl "${d}" ${iso9660_dir}/
done
fi
# build eltorito core.img
if test -e ${pc_dir} ; then
core_img=`mktemp`
grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
memdisk tar search iso9660 configfile sh \
biosdisk
cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
rm -f ${core_img}
modules="$(cat ${pc_dir}/partmap.lst) ${modules}"
(for i in ${modules} ; do
echo "insmod $i"
done ; \
echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
grub_mkisofs="${grub_mkisofs} -b boot/grub/i386-pc/eltorito.img -boot-info-table"
fi
# build iso image
${grub_mkisofs} -o ${output_image} -r -J ${iso9660_dir}
rm -rf ${iso9660_dir}
exit 0

View file

@ -1,7 +1,7 @@
#! /bin/sh -e #! /bin/sh -e
# Make GRUB rescue image # Make GRUB rescue floppy
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. # Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
# #
# GRUB is free software: you can redistribute it and/or modify # GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -30,26 +30,19 @@ target_cpu=@target_cpu@
platform=@platform@ platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
grub_mkisofs=${bindir}/`echo grub-mkisofs | sed ${transform}`
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
usage () { usage () {
cat <<EOF cat <<EOF
Usage: $0 [OPTION] output_image Usage: $0 [OPTION] output_image
Make GRUB rescue image. Make GRUB rescue floppy.
-h, --help print this message and exit -h, --help print this message and exit
-v, --version print the version information and exit -v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES --modules=MODULES pre-load specified modules MODULES
--overlay=DIR overlay directory DIR in the memdisk image --output=FILE save output in FILE
(may be specified multiple times)
--pkglibdir=DIR use images from directory DIR instead of ${pkglibdir}
--grub-mkimage=FILE use FILE as grub-mkimage
--grub-mkisofs=FILE use FILE as grub-mkisofs
$0 generates a bootable rescue image. $0 generates a bootable rescue floppy.
Report bugs to <bug-grub@gnu.org>. Report bugs to <bug-grub@gnu.org>.
EOF EOF
@ -68,14 +61,8 @@ for option in "$@"; do
exit 0 ;; exit 0 ;;
--modules=*) --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;; modules=`echo "$option" | sed 's/--modules=//'` ;;
--overlay=*) --output=*)
overlay=${overlay}${overlay:+ }`echo "$option" | sed 's/--overlay=//'` ;; output_image=`echo "$option" | sed 's/--output=//'` ;;
--pkglibdir=*)
input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-mkisofs=*)
grub_mkisofs=`echo "$option" | sed 's/--grub-mkisofs=//'` ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage
@ -96,53 +83,34 @@ if test "x$output_image" = x; then
exit 1 exit 1
fi fi
memdisk_dir=`mktemp -d` aux_dir=`mktemp -d`
iso9660_dir=`mktemp -d` mkdir -p ${aux_dir}/boot/grub
mkdir -p ${memdisk_dir}/boot/grub ${iso9660_dir}/boot/grub
for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \ for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \
${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \
${input_dir}/handler.lst ${input_dir}/parttool.lst; do ${input_dir}/handler.lst ${input_dir}/parttool.lst; do
if test -f "$file"; then if test -f "$file"; then
cp -f "$file" ${iso9660_dir}/boot/grub/ cp -f "$file" ${aux_dir}/boot/grub/
fi fi
done done
# obtain date-based UUID modules="$(cat ${input_dir}/partmap.lst) ${modules}"
iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00) for i in ${modules} ; do
echo "insmod $i"
# first-stage grub.cfg done > ${aux_dir}/boot/grub/grub.cfg
cat << EOF >> ${memdisk_dir}/boot/grub/grub.cfg
search --fs-uuid --set ${iso_uuid}
set prefix=(\${root})/boot/grub
source /boot/grub/grub.cfg
EOF
# build memdisk # build memdisk
memdisk_img=`mktemp` memdisk_img=`mktemp`
tar -C ${memdisk_dir} -cf ${memdisk_img} boot tar -C ${aux_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir} rm -rf ${aux_dir}
# build core.img # build core.img
mkdir -p ${iso9660_dir}/boot/grub core_img=`mktemp`
${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \ grub-mkimage -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar biosdisk
at_keyboard memdisk tar ata search iso9660 configfile sh
rm -f ${memdisk_img} rm -f ${memdisk_img}
for d in ${overlay}; do # build floppy image
echo "Overlaying $d" cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${output_image}
cp -dpR "${d}"/* "${iso9660_dir}"/ rm -f ${core_img}
done
# second-stage grub.cfg
modules="`cat ${input_dir}/partmap.lst` ${modules}"
for i in ${modules} ; do
echo "insmod $i"
done > ${iso9660_dir}/boot/grub/grub.cfg
# build iso image
${grub_mkisofs} \
--modification-date=$(echo ${iso_uuid} | sed -e s/-//g) \
-o ${output_image} -r -J ${iso9660_dir}
exit 0 exit 0

View file

@ -1,180 +0,0 @@
#! /bin/sh -e
# Make GRUB rescue image
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
#
# GRUB 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 3 of the License, or
# (at your option) any later version.
#
# GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables.
transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] output_image
Make GRUB rescue image.
-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--overlay=DIR overlay directory DIR in the memdisk image
(may be specified multiple times)
--pkglibdir=DIR use images from directory DIR instead of ${pkglibdir}
--grub-mkimage=FILE use FILE as grub-mkimage
--image-type=TYPE select floppy or cdrom (default)
--emulation=TYPE select El Torito boot emulation type floppy
or none (default) (cdrom only)
$0 generates a bootable rescue image of the specified type.
Report bugs to <bug-grub@gnu.org>.
EOF
}
image_type=cdrom
input_dir=${pkglibdir}
emulation=none
# Check the arguments.
for option in "$@"; do
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--overlay=*)
overlay=${overlay}${overlay:+ }`echo "$option" | sed 's/--overlay=//'` ;;
--pkglibdir=*)
input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--image-type=*)
image_type=`echo "$option" | sed 's/--image-type=//'`
case "$image_type" in
floppy|cdrom) ;;
*)
echo "Unknown image type \`$image_type'" 1>&2
exit 1 ;;
esac ;;
--emulation=*)
emulation=`echo "$option" | sed 's/--emulation=//'`
case "$emulation" in
floppy|none) ;;
*)
echo "Unknown emulation type \`$emulation'" 1>&2
exit 1 ;;
esac ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
*)
if test "x$output_image" != x; then
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
fi
output_image="${option}" ;;
esac
done
if test "x$output_image" = x; then
usage
exit 1
fi
aux_dir=`mktemp -d`
mkdir -p ${aux_dir}/boot/grub
for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \
${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \
${input_dir}/handler.lst ${input_dir}/parttool.lst; do
if test -f "$file"; then
cp -f "$file" ${aux_dir}/boot/grub/
fi
done
modules="biosdisk `cat ${input_dir}/partmap.lst` ${modules}"
for i in ${modules} ; do
echo "insmod $i"
done > ${aux_dir}/boot/grub/grub.cfg
for d in ${overlay}; do
echo "Overlaying $d"
cp -dpR "${d}"/* "${aux_dir}"/
done
if [ "x${image_type}" = xfloppy -o "x${emulation}" = xfloppy ] ; then
# build memdisk
memdisk_img=`mktemp`
tar -C ${aux_dir} -cf ${memdisk_img} boot
rm -rf ${aux_dir}
# build core.img
core_img=`mktemp`
${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar
rm -f ${memdisk_img}
# build floppy image
if [ "x${image_type}" = xcdrom ] ; then
floppy_dir=`mktemp -d`
floppy_img=${floppy_dir}/grub_floppy.img
else
floppy_img=${output_image}
fi
cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${floppy_img}
rm -f ${core_img}
if [ "x${image_type}" = xcdrom ] ; then
# build iso image
genisoimage -b grub_floppy.img \
-o ${output_image} -r -J ${floppy_dir}
rm -rf ${floppy_dir}
fi
else
# build core.img
core_img=`mktemp`
${grub_mkimage} -d ${input_dir}/ -o ${core_img} biosdisk iso9660
# build grub_eltorito image
cat ${input_dir}/cdboot.img ${core_img} > ${aux_dir}/boot/grub/grub_eltorito
rm -f ${core_img}
# build iso image
genisoimage -b boot/grub/grub_eltorito \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-o ${output_image} -r -J ${aux_dir}
rm -rf ${aux_dir}
fi
exit 0