Merge trunk

This commit is contained in:
Felix Zielcke 2009-11-16 21:53:32 +01:00
commit a8e24b11db
28 changed files with 1024 additions and 487 deletions

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
# Make GRUB rescue image
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
# Make GRUB rescue floppy
# 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
@ -30,26 +30,19 @@ target_cpu=@target_cpu@
platform=@platform@
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
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] output_image
Make GRUB rescue image.
Make GRUB rescue floppy.
-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
--grub-mkisofs=FILE use FILE as grub-mkisofs
--output=FILE save output in FILE
$0 generates a bootable rescue image.
$0 generates a bootable rescue floppy.
Report bugs to <bug-grub@gnu.org>.
EOF
@ -68,14 +61,8 @@ for option in "$@"; do
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=//'` ;;
--grub-mkisofs=*)
grub_mkisofs=`echo "$option" | sed 's/--grub-mkisofs=//'` ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
-*)
echo "Unrecognized option \`$option'" 1>&2
usage
@ -96,53 +83,34 @@ if test "x$output_image" = x; then
exit 1
fi
memdisk_dir=`mktemp -d`
iso9660_dir=`mktemp -d`
mkdir -p ${memdisk_dir}/boot/grub ${iso9660_dir}/boot/grub
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" ${iso9660_dir}/boot/grub/
cp -f "$file" ${aux_dir}/boot/grub/
fi
done
# obtain date-based UUID
iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00)
# first-stage 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
modules="$(cat ${input_dir}/partmap.lst) ${modules}"
for i in ${modules} ; do
echo "insmod $i"
done > ${aux_dir}/boot/grub/grub.cfg
# build memdisk
memdisk_img=`mktemp`
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir}
tar -C ${aux_dir} -cf ${memdisk_img} boot
rm -rf ${aux_dir}
# build core.img
mkdir -p ${iso9660_dir}/boot/grub
${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
at_keyboard memdisk tar ata search iso9660 configfile sh
core_img=`mktemp`
grub-mkimage -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar biosdisk
rm -f ${memdisk_img}
for d in ${overlay}; do
echo "Overlaying $d"
cp -dpR "${d}"/* "${iso9660_dir}"/
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}
# build floppy image
cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${output_image}
rm -f ${core_img}
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

View file

@ -22,7 +22,7 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
static char rcsid[] ="$Id: mkisofs.c,v 1.32 1999/03/07 21:48:49 eric Exp $";
const char *program_name = "grub-mkisofs";
#include <errno.h>
#include "config.h"
@ -195,6 +195,8 @@ struct ld_option
#define OPTION_NO_EMUL_BOOT 171
#define OPTION_ELTORITO_EMUL_FLOPPY 172
#define OPTION_VERSION 173
static const struct ld_option ld_options[] =
{
{ {"all-files", no_argument, NULL, 'a'},
@ -227,6 +229,10 @@ static const struct ld_option ld_options[] =
'f', NULL, "Follow symbolic links", ONE_DASH },
{ {"help", no_argument, NULL, OPTION_HELP},
'\0', NULL, "Print option help", ONE_DASH },
{ {"help", no_argument, NULL, OPTION_HELP},
'\0', NULL, "Print option help", TWO_DASHES },
{ {"version", no_argument, NULL, OPTION_VERSION},
'\0', NULL, "Print version information and exit", TWO_DASHES },
{ {"hide", required_argument, NULL, OPTION_I_HIDE},
'\0', "GLOBFILE", "Hide ISO9660/RR file" , ONE_DASH },
{ {"hide-joliet", required_argument, NULL, OPTION_J_HIDE},
@ -462,23 +468,12 @@ int goof = 0;
#endif
void usage(){
const char * program_name = "mkisofs";
#if 0
fprintf(stderr,"Usage:\n");
fprintf(stderr,
"mkisofs [-o outfile] [-R] [-V volid] [-v] [-a] \
[-T]\n [-l] [-d] [-V] [-D] [-L] [-p preparer]"
"[-P publisher] [ -A app_id ] [-z] \n \
[-b boot_image_name] [-c boot_catalog-name] \
[-x path -x path ...] path\n");
#endif
unsigned int i;
/* const char **targets, **pp;*/
fprintf (stderr, "Usage: %s [options] file...\n", program_name);
printf ("Usage: %s [options] file...\n", program_name);
fprintf (stderr, "Options:\n");
printf ("Options:\n");
for (i = 0; i < OPTION_COUNT; i++)
{
if (ld_options[i].doc != NULL)
@ -487,7 +482,7 @@ void usage(){
int len;
unsigned int j;
fprintf (stderr, " ");
printf (" ");
comma = FALSE;
len = 2;
@ -498,16 +493,16 @@ void usage(){
if (ld_options[j].shortopt != '\0'
&& ld_options[j].control != NO_HELP)
{
fprintf (stderr, "%s-%c", comma ? ", " : "", ld_options[j].shortopt);
printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt);
len += (comma ? 2 : 0) + 2;
if (ld_options[j].arg != NULL)
{
if (ld_options[j].opt.has_arg != optional_argument)
{
fprintf (stderr, " ");
putchar (' ');
++len;
}
fprintf (stderr, "%s", ld_options[j].arg);
printf ("%s", ld_options[j].arg);
len += strlen (ld_options[j].arg);
}
comma = TRUE;
@ -522,7 +517,7 @@ void usage(){
if (ld_options[j].opt.name != NULL
&& ld_options[j].control != NO_HELP)
{
fprintf (stderr, "%s-%s%s",
printf ("%s-%s%s",
comma ? ", " : "",
ld_options[j].control == TWO_DASHES ? "-" : "",
ld_options[j].opt.name);
@ -532,7 +527,7 @@ void usage(){
+ strlen (ld_options[j].opt.name));
if (ld_options[j].arg != NULL)
{
fprintf (stderr, " %s", ld_options[j].arg);
printf (" %s", ld_options[j].arg);
len += 1 + strlen (ld_options[j].arg);
}
comma = TRUE;
@ -543,14 +538,14 @@ void usage(){
if (len >= 30)
{
fprintf (stderr, "\n");
printf ("\n");
len = 0;
}
for (; len < 30; len++)
fputc (' ', stderr);
putchar (' ');
fprintf (stderr, "%s\n", ld_options[i].doc);
printf ("%s\n", ld_options[i].doc);
}
}
exit(1);
@ -886,6 +881,10 @@ int FDECL2(main, int, argc, char **, argv){
usage ();
exit (0);
break;
case OPTION_VERSION:
printf ("%s (%s %s)\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
exit (0);
break;
case OPTION_NOSPLIT_SL_COMPONENT:
split_SL_component = 0;
break;

View file

@ -213,7 +213,7 @@ int FDECL3(iso9660_file_length,
}
if(current_length < 30)
{
if( *pnt < 0 )
if( !isascii (*pnt))
{
*result++ = '_';
}
@ -281,7 +281,7 @@ int FDECL3(iso9660_file_length,
switch (*pnt)
{
default:
if( *pnt < 0 )
if( !isascii (*pnt) )
{
*result++ = '_';
}