merge mainline into arm

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-05-11 10:24:24 +02:00
commit 8e71d87482
490 changed files with 29659 additions and 8612 deletions

View file

@ -220,9 +220,6 @@ xgetcwd (void)
#if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__GNU__)
#if (defined (__linux__) || \
!defined (HAVE_LIBZFS) || !defined (HAVE_LIBNVPAIR))
static pid_t
exec_pipe (char **argv, int *fd)
{
@ -243,6 +240,13 @@ exec_pipe (char **argv, int *fd)
else if (mdadm_pid == 0)
{
/* Child. */
/* Close fd's. */
#ifdef HAVE_DEVICE_MAPPER
dm_lib_release ();
#endif
grub_diskfilter_fini ();
/* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1);
@ -261,8 +265,6 @@ exec_pipe (char **argv, int *fd)
}
}
#endif
static char **
find_root_devices_from_poolname (char *poolname)
{
@ -660,14 +662,14 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
char *ptr;
*relroot = xmalloc (strlen (entries[i].enc_root) +
2 + strlen (dir));
ptr = stpcpy (*relroot, entries[i].enc_root);
ptr = grub_stpcpy (*relroot, entries[i].enc_root);
if (strlen (dir) > strlen (entries[i].enc_path))
{
while (ptr > *relroot && *(ptr - 1) == '/')
ptr--;
if (dir[strlen (entries[i].enc_path)] != '/')
*ptr++ = '/';
ptr = stpcpy (ptr, dir + strlen (entries[i].enc_path));
ptr = grub_stpcpy (ptr, dir + strlen (entries[i].enc_path));
}
*ptr = 0;
}
@ -1315,6 +1317,80 @@ grub_util_get_dev_abstraction (const char *os_dev)
return GRUB_DEV_ABSTRACTION_NONE;
}
#if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__GNU__)
static void
pull_lvm_by_command (const char *os_dev)
{
char *argv[6];
int fd;
pid_t pid;
FILE *mdadm;
char *buf = NULL;
size_t len = 0;
char *vgname;
const char *iptr;
char *optr;
if (strncmp (os_dev, "/dev/mapper/", sizeof ("/dev/mapper/") - 1)
!= 0)
return;
vgname = xmalloc (strlen (os_dev + sizeof ("/dev/mapper/") - 1) + 1);
for (iptr = os_dev + sizeof ("/dev/mapper/") - 1, optr = vgname; *iptr; )
if (*iptr != '-')
*optr++ = *iptr++;
else if (iptr[0] == '-' && iptr[1] == '-')
{
iptr += 2;
*optr++ = '-';
}
else
break;
*optr = '\0';
/* execvp has inconvenient types, hence the casts. None of these
strings will actually be modified. */
argv[0] = (char *) "vgs";
argv[1] = (char *) "--options";
argv[2] = (char *) "pv_name";
argv[3] = (char *) "--noheadings";
argv[4] = vgname;
argv[5] = NULL;
pid = exec_pipe (argv, &fd);
free (vgname);
if (!pid)
return;
/* Parent. Read mdadm's output. */
mdadm = fdopen (fd, "r");
if (! mdadm)
{
grub_util_warn (_("Unable to open stream from %s: %s"),
"vgs", strerror (errno));
goto out;
}
while (getline (&buf, &len, mdadm) > 0)
{
char *ptr;
for (ptr = buf; ptr < buf + 2 && *ptr == ' '; ptr++);
if (*ptr == '\0')
continue;
*(ptr + strlen (ptr) - 1) = '\0';
grub_util_pull_device (ptr);
}
out:
close (fd);
waitpid (pid, NULL, 0);
free (buf);
}
#endif
#ifdef __linux__
static char *
get_mdadm_uuid (const char *os_dev)
@ -1538,6 +1614,10 @@ grub_util_pull_device (const char *os_dev)
break;
case GRUB_DEV_ABSTRACTION_LVM:
#if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__GNU__)
pull_lvm_by_command (os_dev);
#endif
/* Fallthrough in case that lvm-tools are unavailable. */
case GRUB_DEV_ABSTRACTION_LUKS:
#ifdef HAVE_DEVICE_MAPPER
{
@ -1877,6 +1957,7 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st,
grub_util_info ("dm_tree_find_node failed");
goto devmapper_out;
}
reiterate:
node_uuid = dm_tree_node_get_uuid (node);
if (! node_uuid)
{
@ -1951,6 +2032,9 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st,
goto devmapper_out;
}
mapper_name = child_name;
*is_part = 1;
node = child;
goto reiterate;
devmapper_out:
if (! mapper_name && node)

View file

@ -289,10 +289,10 @@ cmd_cmp (char *src, char *dest)
+ strlen (entry->d_name));
destnew = xmalloc (strlen (dest) + sizeof ("/")
+ strlen (entry->d_name));
ptr = stpcpy (srcnew, src);
ptr = grub_stpcpy (srcnew, src);
*ptr++ = '/';
strcpy (ptr, entry->d_name);
ptr = stpcpy (destnew, dest);
ptr = grub_stpcpy (destnew, dest);
*ptr++ = '/';
strcpy (ptr, entry->d_name);

219
util/grub-glue-efi.c Normal file
View file

@ -0,0 +1,219 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2012,2013 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/>.
*/
#include <config.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <grub/term.h>
#include <grub/macho.h>
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <argp.h>
#include <unistd.h>
#include <errno.h>
#include "progname.h"
struct arguments
{
char *input32;
char *input64;
char *output;
int verbosity;
};
static struct argp_option options[] = {
{"input32", '3', N_("FILE"), 0,
N_("set input filename for 32-bit part."), 0},
{"input64", '6', N_("FILE"), 0,
N_("set input filename for 64-bit part."), 0},
{"output", 'o', N_("FILE"), 0,
N_("set output filename. Default is STDOUT"), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
{ 0, 0, 0, 0, 0, 0 }
};
static error_t
argp_parser (int key, char *arg, struct argp_state *state)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
struct arguments *arguments = state->input;
switch (key)
{
case '6':
arguments->input64 = xstrdup (arg);
break;
case '3':
arguments->input32 = xstrdup (arg);
break;
case 'o':
arguments->output = xstrdup (arg);
break;
case 'v':
arguments->verbosity++;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp argp = {
options, argp_parser, N_("[OPTIONS]"),
N_("Glue 32-bit and 64-binary into Apple fat one."),
NULL, NULL, NULL
};
static void
write_fat (FILE *in32, FILE *in64, FILE *out, const char *out_filename,
const char *name32, const char *name64)
{
struct grub_macho_fat_header head;
struct grub_macho_fat_arch arch32, arch64;
grub_uint32_t size32, size64;
char *buf;
fseek (in32, 0, SEEK_END);
size32 = ftell (in32);
fseek (in32, 0, SEEK_SET);
fseek (in64, 0, SEEK_END);
size64 = ftell (in64);
fseek (in64, 0, SEEK_SET);
head.magic = grub_cpu_to_le32_compile_time (GRUB_MACHO_FAT_EFI_MAGIC);
head.nfat_arch = grub_cpu_to_le32_compile_time (2);
arch32.cputype = grub_cpu_to_le32_compile_time (GRUB_MACHO_CPUTYPE_IA32);
arch32.cpusubtype = grub_cpu_to_le32_compile_time (3);
arch32.offset = grub_cpu_to_le32_compile_time (sizeof (head)
+ sizeof (arch32)
+ sizeof (arch64));
arch32.size = grub_cpu_to_le32 (size32);
arch32.align = 0;
arch64.cputype = grub_cpu_to_le32_compile_time (GRUB_MACHO_CPUTYPE_AMD64);
arch64.cpusubtype = grub_cpu_to_le32_compile_time (3);
arch64.offset = grub_cpu_to_le32 (sizeof (head) + sizeof (arch32)
+ sizeof (arch64) + size32);
arch64.size = grub_cpu_to_le32 (size64);
arch64.align = 0;
if (fwrite (&head, 1, sizeof (head), out) != sizeof (head)
|| fwrite (&arch32, 1, sizeof (arch32), out) != sizeof (arch32)
|| fwrite (&arch64, 1, sizeof (arch64), out) != sizeof (arch64))
{
if (out_filename)
grub_util_error ("cannot write to `%s': %s",
out_filename, strerror (errno));
else
grub_util_error ("cannot write to the stdout: %s", strerror (errno));
}
buf = xmalloc (size32);
if (fread (buf, 1, size32, in32) != size32)
grub_util_error (_("cannot read `%s': %s"), name32,
strerror (errno));
if (fwrite (buf, 1, size32, out) != size32)
{
if (out_filename)
grub_util_error ("cannot write to `%s': %s",
out_filename, strerror (errno));
else
grub_util_error ("cannot write to the stdout: %s", strerror (errno));
}
free (buf);
buf = xmalloc (size64);
if (fread (buf, 1, size64, in64) != size64)
grub_util_error (_("cannot read `%s': %s"), name64,
strerror (errno));
if (fwrite (buf, 1, size64, out) != size64)
{
if (out_filename)
grub_util_error ("cannot write to `%s': %s",
out_filename, strerror (errno));
else
grub_util_error ("cannot write to the stdout: %s", strerror (errno));
}
free (buf);
}
int
main (int argc, char *argv[])
{
FILE *in32, *in64, *out;
struct arguments arguments;
set_program_name (argv[0]);
/* Check for options. */
memset (&arguments, 0, sizeof (struct arguments));
if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
{
fprintf (stderr, "%s", _("Error in parsing command line arguments\n"));
exit(1);
}
if (!arguments.input32 || !arguments.input64)
{
fprintf (stderr, "%s", _("Missing input file\n"));
exit(1);
}
in32 = fopen (arguments.input32, "r");
if (!in32)
grub_util_error (_("cannot open `%s': %s"), arguments.input32,
strerror (errno));
in64 = fopen (arguments.input64, "r");
if (!in64)
grub_util_error (_("cannot open `%s': %s"), arguments.input64,
strerror (errno));
if (arguments.output)
out = fopen (arguments.output, "wb");
else
out = stdout;
if (!out)
{
grub_util_error (_("cannot open `%s': %s"), arguments.output ? : "stdout",
strerror (errno));
}
write_fat (in32, in64, out, arguments.output,
arguments.input32, arguments.input64);
fclose (in32);
fclose (in64);
if (out != stdout)
fclose (out);
return 0;
}

View file

@ -17,39 +17,19 @@
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
sbindir="@sbindir@"
bindir="@bindir@"
libdir="@libdir@"
sysconfdir="@sysconfdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
host_os=@host_os@
source_dir=
target=
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
localedir="@datadir@/locale"
self="`basename $0`"
grub_mkimage="${bindir}/@grub_mkimage@"
grub_probe="${sbindir}/@grub_probe@"
grub_editenv="${bindir}/@grub_editenv@"
grub_mkrelpath="${bindir}/@grub_mkrelpath@"
rootdir=
bootdir=
grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`"
modules=
install_device=
force_lba=
@ -74,8 +54,6 @@ fi
disk_module=unspecified
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage
# Print the usage.
usage () {
@ -86,8 +64,6 @@ usage () {
gettext "Install GRUB on your drive." ; echo
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help
dirmsg="$(gettext_printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
@ -96,9 +72,7 @@ usage () {
target_trans="$(gettext "TARGET")"
# TRANSLATORS: "current" refers to the platform user's currently running on
print_option_help "--target=$target_trans" "$(gettext "install GRUB for TARGET platform [default=current]")"
print_option_help "--directory=$(gettext "DIR")" "$(gettext "use GRUB images from DIR. Takes precedence over target")"
print_option_help "--grub-setup=$(gettext "FILE")" "$(gettext "use FILE as grub-setup")"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
print_option_help "--grub-mkrelpath=$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
print_option_help "--grub-probe=$(gettext "FILE")" "$(gettext "use FILE as grub-probe")"
# TRANSLATORS: "may break" doesn't just mean that option wouldn't have any
@ -142,14 +116,6 @@ do
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--force-file-id)
force_file_id=y ;;
@ -176,11 +142,6 @@ do
--efi-directory=*)
efidir="`echo "$option" | sed 's/--efi-directory=//'`" ;;
--directory | -d)
source_dir="`argument $option "$@"`"; shift;;
--directory=*)
source_dir="`echo "$option" | sed 's/--directory=//'`" ;;
--target)
target="`argument $option "$@"`"; shift;;
--target=*)
@ -196,11 +157,6 @@ do
--bootloader-id=*)
bootloader_id="`echo "$option" | sed 's/--bootloader-id=//'`" ;;
--grub-mkimage)
grub_mkimage="`argument $option "$@"`"; shift;;
--grub-mkimage=*)
grub_mkimage="`echo "$option" | sed 's/--grub-mkimage=//'`" ;;
--grub-mkrelpath)
grub_mkrelpath="`argument "$option" "$@"`"; shift;;
--grub-mkrelpath=*)
@ -264,7 +220,7 @@ do
esac
done
if [ x$source_dir = x ]; then
if [ x$source_directory = x ]; then
if [ x$target = x ]; then
case x"`uname -m`" in
x"powerpc"* | x"ppc"*)
@ -323,15 +279,15 @@ if [ x$source_dir = x ]; then
echo ;;
esac
fi
source_dir="${libdir}/@PACKAGE@/$target"
source_directory="${libdir}/@PACKAGE@/$target"
fi
if ! [ -d "$source_dir" ]; then
gettext_printf "%s doesn't exist. Please specify --target or --directory\\n" "$source_dir"
if ! [ -d "$source_directory" ]; then
gettext_printf "%s doesn't exist. Please specify --target or --directory\\n" "$source_directory"
exit 1
fi
. "${source_dir}"/modinfo.sh
. "${source_directory}"/modinfo.sh
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] ; then
if [ x$disk_module = xunspecified ]; then
@ -522,10 +478,10 @@ else
fi
# Copy the GRUB images to the GRUB directory.
grub_install_files "${source_dir}" "${grubdir}" "${grub_modinfo_target_cpu}-$grub_modinfo_platform" all
grub_install_files "${source_directory}" "${grubdir}" "${grub_modinfo_target_cpu}-$grub_modinfo_platform" all
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then
for file in "${source_dir}"/*.img "${source_dir}"/efiemu??.o; do
for file in "${source_directory}"/*.img "${source_directory}"/efiemu??.o; do
if test -f "$file"; then
cp -f "$file" "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" || exit 1
fi
@ -679,20 +635,21 @@ fi
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-raw ;;
mipsel-loongson) mkimage_target=mipsel-loongson-elf ;;
mips-qemu_mips | mipsel-qemu_mips) mkimage_target="${grub_modinfo_target_cpu}-${grub_modinfo_platform}"-elf ;;
*) mkimage_target="${grub_modinfo_target_cpu}-${grub_modinfo_platform}" ;;
esac
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
i386-efi | x86_64-efi) imgext=efi ;;
i386-efi | x86_64-efi | ia64-efi) imgext=efi ;;
mipsel-loongson | i386-coreboot | i386-multiboot | i386-ieee1275 \
| powerpc-ieee1275) imgext=elf ;;
| powerpc-ieee1275 | mips-qemu_mips | mipsel-qemu_mips) imgext=elf ;;
*) imgext=img ;;
esac
if [ x"$config_opt_file" = x ]; then
"$grub_mkimage" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
"$grub_mkimage" -d "${source_directory}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $grub_decompression_module $modules || exit 1
else
"$grub_mkimage" -c "${config_opt_file}" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
"$grub_mkimage" -c "${config_opt_file}" -d "${source_directory}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $grub_decompression_module $modules || exit 1
fi
# Backward-compatibility kludges
@ -703,9 +660,9 @@ elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-ieee1275" ]
elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-efi" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "x86_64-efi" ]; then
if [ x"$config_opt_file" = x ]; then
"$grub_mkimage" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $modules || exit 1
"$grub_mkimage" -d "${source_directory}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $grub_decompression_module $modules || exit 1
else
"$grub_mkimage" -c "${config_opt_file}" -d "${source_dir}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $modules || exit 1
"$grub_mkimage" -c "${config_opt_file}" -d "${source_directory}" -O "${mkimage_target}" --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $grub_decompression_module $modules || exit 1
fi
fi
@ -803,9 +760,21 @@ elif [ x"$grub_modinfo_platform" = xefi ]; then
fi
# Try to make this image bootable using the EFI Boot Manager, if available.
efibootmgr="`which efibootmgr`"
if test "$removable" = no && test -n "$efi_distributor" && \
test -n "$efibootmgr"; then
if test "$removable" = no; then
efibootmgr="`which efibootmgr`" || {
# TRANSLATORS: This message is shown when required executable `%s'
# isn't found
gettext_printf "%s: Not found.\n" "efibootmgr" 1>&2
exit 1
}
test -n "$efi_distributor" || {
gettext "EFI distributor id isn't specified." 1>&2
echo 1>&2
exit 1
}
# On Linux, we need the efivars kernel modules.
case "$host_os" in
linux*)

View file

@ -16,9 +16,42 @@ set -e
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
modules=
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst \
handler.lst video.lst crypto.lst terminal.lst"
grub_mkimage="${bindir}/@grub_mkimage@"
grub_compress_file () {
if [ "$compressor" != "" ] ; then
"$compressor" $compressor_opts "$1" > "$2"
else
cp -f "$1" "$2"
fi
}
grub_install_files () {
grub_install_files_source_directory="$1"
grub_install_files_target_directory="$2"
@ -42,7 +75,7 @@ grub_install_files () {
if [ x"$install_modules" = xall ]; then
for file in "${grub_install_files_source_directory}/"*.mod; do
cp -f "$file" "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
grub_compress_file "$file" "${grub_install_files_target_directory}"/"${grub_install_files_platform}/$(basename "$file")"
done
else
modules1=
@ -56,13 +89,13 @@ grub_install_files () {
modules2="$modules3"
done
for file in $(echo "$modules1" | sed 's, ,\n,g' |sort -u); do
cp -f "${grub_install_files_source_directory}/$file.mod" "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
grub_compress_file "${grub_install_files_source_directory}/$file.mod" "${grub_install_files_target_directory}"/"${grub_install_files_platform}/$file.mod"
done
fi
for file in ${pkglib_DATA} efiemu32.o efiemu64.o; do
if test -f "${grub_install_files_source_directory}/${file}"; then
cp -f "${grub_install_files_source_directory}/${file}" "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
grub_compress_file "${grub_install_files_source_directory}/${file}" "${grub_install_files_target_directory}"/"${grub_install_files_platform}/${file}"
fi
done
@ -78,49 +111,63 @@ grub_install_files () {
if [ x"$install_locales" = xall ]; then
for file in "${grub_install_files_source_directory}"/po/*.mo; do
if test -f "$file"; then
cp -f "$file" "${grub_install_files_target_directory}"/locale/
grub_compress_file "$file" "${grub_install_files_target_directory}"/locale/"$(basename "$file")"
fi
done
for dir in "${localedir}"/*; do
if test -f "$dir/LC_MESSAGES/@PACKAGE@.mo" && ! test -f "${grub_install_files_target_directory}"/locale/"${dir##*/}.mo"; then
cp -f "$dir/LC_MESSAGES/@PACKAGE@.mo" "${grub_install_files_target_directory}"/locale/"${dir##*/}.mo"
grub_compress_file "$dir/LC_MESSAGES/@PACKAGE@.mo" "${grub_install_files_target_directory}"/locale/"${dir##*/}.mo"
fi
done
else
for locale in $install_locales; do
if test -f "${grub_install_files_source_directory}"/po/$locale.mo; then
cp -f " "${grub_install_files_source_directory}"/po/$locale.mo" "${grub_install_files_target_directory}"/locale/$locale.mo
grub_compress_file "${grub_install_files_source_directory}"/po/locale.mo "${grub_install_files_target_directory}"/locale/$locale.mo
elif test -f "${localedir}/$locale/LC_MESSAGES/@PACKAGE@.mo"; then
cp -f "${localedir}/$locale/LC_MESSAGES/@PACKAGE@.mo" "${grub_install_files_target_directory}"/locale/$locale.mo
grub_compress_file "${localedir}/$locale/LC_MESSAGES/@PACKAGE@.mo" "${grub_install_files_target_directory}"/locale/$locale.mo
fi
done
fi
for theme in ${install_themes} ; do
if test -f "${pkgdatadir}"/themes/"${theme}"/theme.txt; then
mkdir -p "${grub_install_files_target_directory}"/themes/"${theme}"
cp "${pkgdatadir}"/themes/"${theme}"/* "${grub_install_files_target_directory}"/themes/"${theme}"
for file in "${pkgdatadir}"/themes/"${theme}"/*; do
grub_compress_file "$file" "${grub_install_files_target_directory}"/themes/"${theme}"/"$(basename "$file")"
done
fi
done
for font in ${install_fonts} ; do
if test -f "${pkgdatadir}"/"$font".pf2; then
mkdir -p "${grub_install_files_target_directory}"/fonts
cp "${pkgdatadir}"/"$font".pf2 "${grub_install_files_target_directory}"/fonts
grub_compress_file "${pkgdatadir}"/"$font".pf2 "${grub_install_files_target_directory}"/fonts/"$font".pf2
fi
done
}
grub_print_install_files_help () {
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies [default=all]")"
print_option_help "--themes=THEMES" "$(gettext_printf "install THEMES [default=%s]" "starfield")"
print_option_help "--fonts=FONTS" "$(gettext_printf "install FONTS [default=%s]" "unicode")"
print_option_help "--locales=LOCALES" "$(gettext_printf "install only LOCALES [default=all]")"
print_option_help "--compress[=no,xz,gz,lzo]" "$(gettext "compress GRUB files [optional]")"
# TRANSLATORS: platform here isn't identifier. It can be translated.
dir_msg="$(gettext_printf "use images and modules under DIR [default=%s/<platform>]" "${libdir}/@PACKAGE@")"
print_option_help "-d, --directory=$(gettext "DIR")" "$dir_msg"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
}
install_modules=all
install_themes=starfield
install_fonts=unicode
install_locales=all
compress=no
grub_decompression_module=""
compressor=""
compressor_opts=""
source_directory=""
argument () {
opt=$1
@ -133,6 +180,29 @@ argument () {
echo $1
}
grub_parse_compress () {
compress="$1"
case x"$compress" in
xno) ;;
xgz)
compressor=`which gzip || true`
grub_decompression_module="gzio"
compressor_opts="--best --stdout";;
xxz)
compressor=`which xz || true`
grub_decompression_module="xzio gcry_crc"
compressor_opts="--lzma2=dict=128KiB --check=none --stdout";;
xlzo)
compressor=`which lzop || true`
grub_decompression_module="lzopio adler32 gcry_crc"
compressor_opts="-9 -c";;
*)
gettext_printf "Unrecognized compression \`%s'\n" "$compress" 1>&2
usage
exit 1
esac
}
grub_process_install_options () {
option=$1
shift
@ -156,6 +226,33 @@ grub_process_install_options () {
install_locales=`argument $option "$@"`; grub_process_install_options_consumed=2; return ;;
--locales=*)
install_locales=`echo "$option" | sed 's/--locales=//'`; grub_process_install_options_consumed=1; return ;;
--compress)
grub_parse_compress `argument $option "$@"`; grub_process_install_options_consumed=2; return ;;
--compress=*)
grub_parse_compress `echo "${option}" | sed 's/--compress=//'`; grub_process_install_options_consumed=1; return ;;
--directory | -d)
source_directory=`argument $option "$@"`; grub_process_install_options_consumed=2 ;;
--directory=*)
source_directory=`echo "$option" | sed 's/--directory=//'` grub_process_install_options_consumed=1;;
# For backwards compatibility
--override-directory)
source_directory=`argument $option "$@"`; grub_process_install_options_consumed=2 ;;
--override-directory=*)
source_directory=`echo "$option" | sed 's/--override-directory=//'` grub_process_install_options_consumed=1;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; grub_process_install_options_consumed=2 ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'`;grub_process_install_options_consumed=1 ;;
--modules)
modules=`argument $option "$@"`; grub_process_install_options_consumed=2;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` grub_process_install_options_consumed=1;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
esac
}
export grub_decompression_module

View file

@ -42,6 +42,7 @@
#include <grub/efi/pe32.h>
#include <grub/uboot/image.h>
#include <grub/arm/reloc.h>
#include <grub/ia64/reloc.h>
#define _GNU_SOURCE 1
#include <argp.h>
@ -68,7 +69,8 @@ struct image_target_desc
int bigendian;
enum {
IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE,
IMAGE_I386_IEEE1275,
IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT
@ -335,6 +337,21 @@ struct image_target_desc image_targets[] =
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
},
{
.dirname = "sparc64-ieee1275",
.names = { "sparc64-ieee1275-cdcore", NULL },
.voidp_sizeof = 8,
.bigendian = 1,
.id = IMAGE_SPARC64_CDCORE,
.flags = PLATFORM_FLAGS_NONE,
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
},
{
.dirname = "sparc64-ieee1275",
.names = { "sparc64-ieee1275-aout", NULL },
@ -372,8 +389,7 @@ struct image_target_desc image_targets[] =
.voidp_sizeof = 4,
.bigendian = 1,
.id = IMAGE_MIPS_ARC,
.flags = (PLATFORM_FLAGS_DECOMPRESSORS
| PLATFORM_FLAGS_MODULES_BEFORE_KERNEL),
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
@ -385,6 +401,24 @@ struct image_target_desc image_targets[] =
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
.default_compression = COMPRESSION_NONE
},
{
.dirname = "mipsel-arc",
.names = {"mipsel-arc", NULL},
.voidp_sizeof = 4,
.bigendian = 0,
.id = IMAGE_MIPS_ARC,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
.decompressor_compressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE,
.decompressor_uncompressed_size = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE,
.decompressor_uncompressed_addr = GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_MIPSEL_ARC_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
.default_compression = COMPRESSION_NONE
},
{
.dirname = "mipsel-qemu_mips",
.names = { "mipsel-qemu_mips-elf", NULL },
@ -1062,6 +1096,7 @@ generate_image (const char *dir, const char *prefix,
break;
case IMAGE_SPARC64_AOUT:
case IMAGE_SPARC64_RAW:
case IMAGE_SPARC64_CDCORE:
case IMAGE_I386_IEEE1275:
case IMAGE_PPC:
case IMAGE_UBOOT:
@ -1244,10 +1279,10 @@ generate_image (const char *dir, const char *prefix,
o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
/* Do these really matter? */
o->stack_reserve_size = grub_host_to_target32 (0x10000);
o->stack_commit_size = grub_host_to_target32 (0x10000);
o->heap_reserve_size = grub_host_to_target32 (0x10000);
o->heap_commit_size = grub_host_to_target32 (0x10000);
o->stack_reserve_size = grub_host_to_target64 (0x10000);
o->stack_commit_size = grub_host_to_target64 (0x10000);
o->heap_reserve_size = grub_host_to_target64 (0x10000);
o->heap_commit_size = grub_host_to_target64 (0x10000);
o->num_data_directories
= grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
@ -1402,6 +1437,8 @@ generate_image (const char *dir, const char *prefix,
free (boot_path);
}
break;
case IMAGE_SPARC64_CDCORE:
break;
case IMAGE_YEELOONG_FLASH:
case IMAGE_FULOONG2F_FLASH:
{
@ -1581,22 +1618,23 @@ generate_image (const char *dir, const char *prefix,
program_size = ALIGN_ADDR (core_size);
if (comp == COMPRESSION_NONE)
target_addr = (image_target->link_addr
- total_module_size - decompress_size);
target_addr = (image_target->link_addr - decompress_size);
else
target_addr = (image_target->link_addr
- ALIGN_UP(total_module_size + core_size, 1048576)
- (1 << 20));
target_addr = ALIGN_UP (image_target->link_addr
+ kernel_size + total_module_size, 32);
ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section));
grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section));
head = (void *) ecoff_img;
section = (void *) (head + 1);
head->magic = grub_host_to_target16 (0x160);
head->magic = image_target->bigendian ? grub_host_to_target16 (0x160)
: grub_host_to_target16 (0x166);
head->nsec = grub_host_to_target16 (1);
head->time = grub_host_to_target32 (0);
head->opt = grub_host_to_target16 (0x38);
head->flags = grub_host_to_target16 (0x207);
head->flags = image_target->bigendian
? grub_host_to_target16 (0x207)
: grub_host_to_target16 (0x103);
head->magic2 = grub_host_to_target16 (0x107);
head->textsize = grub_host_to_target32 (program_size);
head->entry = grub_host_to_target32 (target_addr);
@ -1606,6 +1644,11 @@ generate_image (const char *dir, const char *prefix,
section->vaddr = grub_host_to_target32 (target_addr);
section->size = grub_host_to_target32 (program_size);
section->file_offset = grub_host_to_target32 (sizeof (*head) + sizeof (*section));
if (!image_target->bigendian)
{
section->paddr = grub_host_to_target32 (0xaa60);
section->flags = grub_host_to_target32 (0x20);
}
memcpy (section + 1, core_img, core_size);
free (core_img);
core_img = ecoff_img;
@ -1788,7 +1831,9 @@ static struct argp_option options[] = {
{"memdisk", 'm', N_("FILE"), 0,
/* TRANSLATORS: "memdisk" here isn't an identifier, it can be translated.
"embed" is a verb (command description). "*/
N_("embed FILE as a memdisk image"), 0},
N_("embed FILE as a memdisk image\n"
"Implies `-p (memdisk)/boot/grub' but prefix can be overridden by "
"later options"), 0},
/* TRANSLATORS: "embed" is a verb (command description). "*/
{"config", 'c', N_("FILE"), 0, N_("embed FILE as an early config"), 0},
/* TRANSLATORS: "embed" is a verb (command description). "*/
@ -1797,7 +1842,7 @@ static struct argp_option options[] = {
{"note", 'n', 0, 0, N_("add NOTE segment for CHRP IEEE1275"), 0},
{"output", 'o', N_("FILE"), 0, N_("output a generated image to FILE [default=stdout]"), 0},
{"format", 'O', N_("FORMAT"), 0, 0, 0},
{"compression", 'C', "(xz|none|auto)", 0, N_("choose the compression to use"), 0},
{"compression", 'C', "(xz|none|auto)", 0, N_("choose the compression to use for core image"), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
{ 0, 0, 0, 0, 0, 0 }
};

View file

@ -119,7 +119,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info)
== STT_FUNC)
{
*jptr = sym->st_value;
*jptr = grub_host_to_target64 (sym->st_value);
sym->st_value = (char *) jptr - (char *) jumpers + jumpers_addr;
jptr++;
*jptr = 0;
@ -145,8 +145,8 @@ SUFFIX (get_symbol_address) (Elf_Ehdr *e, Elf_Shdr *s, Elf_Word i,
Elf_Sym *sym;
sym = (Elf_Sym *) ((char *) e
+ grub_target_to_host32 (s->sh_offset)
+ i * grub_target_to_host32 (s->sh_entsize));
+ grub_target_to_host (s->sh_offset)
+ i * grub_target_to_host (s->sh_entsize));
return sym->st_value;
}
@ -155,7 +155,7 @@ static Elf_Addr *
SUFFIX (get_target_address) (Elf_Ehdr *e, Elf_Shdr *s, Elf_Addr offset,
struct image_target_desc *image_target)
{
return (Elf_Addr *) ((char *) e + grub_target_to_host32 (s->sh_offset) + offset);
return (Elf_Addr *) ((char *) e + grub_target_to_host (s->sh_offset) + offset);
}
#ifdef MKIMAGE_ELF64
@ -184,128 +184,6 @@ SUFFIX (count_funcs) (Elf_Ehdr *e, Elf_Shdr *symtab_section,
}
#endif
#ifdef MKIMAGE_ELF64
struct unaligned_uint32
{
grub_uint32_t val;
} __attribute__ ((packed));
#define MASK20 ((1 << 20) - 1)
#define MASK19 ((1 << 19) - 1)
#define MASK3 (~(grub_addr_t) 3)
static void
add_value_to_slot_20b (grub_addr_t addr, grub_uint32_t value)
{
struct unaligned_uint32 *p;
switch (addr & 3)
{
case 0:
p = (struct unaligned_uint32 *) ((addr & MASK3) + 2);
p->val = ((((((p->val >> 2) & MASK20) + value) & MASK20) << 2)
| (p->val & ~(MASK20 << 2)));
break;
case 1:
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & MASK3) + 7);
p->val = ((((((p->val >> 3) & MASK20) + value) & MASK20) << 3)
| (p->val & ~(MASK20 << 3)));
break;
case 2:
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & MASK3) + 12);
p->val = ((((((p->val >> 4) & MASK20) + value) & MASK20) << 4)
| (p->val & ~(MASK20 << 4)));
break;
}
}
#define MASKF21 ( ((1 << 23) - 1) & ~((1 << 7) | (1 << 8)) )
static grub_uint32_t
add_value_to_slot_21_real (grub_uint32_t a, grub_uint32_t value)
{
grub_uint32_t high, mid, low, c;
low = (a & 0x00007f);
mid = (a & 0x7fc000) >> 7;
high = (a & 0x003e00) << 7;
c = (low | mid | high) + value;
return (c & 0x7f) | ((c << 7) & 0x7fc000) | ((c >> 7) & 0x0003e00); //0x003e00
}
static void
add_value_to_slot_21 (grub_addr_t addr, grub_uint32_t value)
{
struct unaligned_uint32 *p;
switch (addr & 3)
{
case 0:
p = (struct unaligned_uint32 *) ((addr & MASK3) + 2);
p->val = ((add_value_to_slot_21_real (((p->val >> 2) & MASKF21), value) & MASKF21) << 2) | (p->val & ~(MASKF21 << 2));
break;
case 1:
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & MASK3) + 7);
p->val = ((add_value_to_slot_21_real (((p->val >> 3) & MASKF21), value) & MASKF21) << 3) | (p->val & ~(MASKF21 << 3));
break;
case 2:
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & MASK3) + 12);
p->val = ((add_value_to_slot_21_real (((p->val >> 4) & MASKF21), value) & MASKF21) << 4) | (p->val & ~(MASKF21 << 4));
break;
}
}
struct ia64_kernel_trampoline
{
/* nop.m */
grub_uint8_t nop[5];
/* movl r15 = addr*/
grub_uint8_t addr_hi[6];
grub_uint8_t e0;
grub_uint8_t addr_lo[4];
grub_uint8_t jump[0x20];
};
static grub_uint8_t nopm[5] =
{
/* [MLX] nop.m 0x0 */
0x05, 0x00, 0x00, 0x00, 0x01
};
static grub_uint8_t jump[0x20] =
{
/* [MMI] add r15=r15,r1;; */
0x0b, 0x78, 0x3c, 0x02, 0x00, 0x20,
/* ld8 r16=[r15],8 */
0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0,
/* mov r14=r1;; */
0x01, 0x08, 0x00, 0x84,
/* [MIB] ld8 r1=[r15] */
0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,
/* mov b6=r16 */
0x60, 0x80, 0x04, 0x80, 0x03, 0x00,
/* br.few b6;; */
0x60, 0x00, 0x80, 0x00
};
static void
make_trampoline (struct ia64_kernel_trampoline *tr, grub_uint64_t addr)
{
grub_memcpy (tr->nop, nopm, sizeof (tr->nop));
tr->addr_hi[0] = ((addr & 0xc00000) >> 16);
tr->addr_hi[1] = (addr >> 24) & 0xff;
tr->addr_hi[2] = (addr >> 32) & 0xff;
tr->addr_hi[3] = (addr >> 40) & 0xff;
tr->addr_hi[4] = (addr >> 48) & 0xff;
tr->addr_hi[5] = (addr >> 56) & 0xff;
tr->e0 = 0xe0;
tr->addr_lo[0] = ((addr & 0x000f) << 4) | 0x01;
tr->addr_lo[1] = (((addr & 0x0070) >> 4) | ((addr & 0x070000) >> 11)
| ((addr & 0x200000) >> 17));
tr->addr_lo[2] = ((addr & 0x1f80) >> 5) | ((addr & 0x180000) >> 19);
tr->addr_lo[3] = ((addr & 0xe000) >> 13) | 0x60;
grub_memcpy (tr->jump, jump, sizeof (tr->jump));
}
#endif
/* Deal with relocation information. This function relocates addresses
within the virtual address space starting from 0. So only relative
addresses can be fully resolved. Absolute addresses must be relocated
@ -322,8 +200,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
Elf_Half i;
Elf_Shdr *s;
#ifdef MKIMAGE_ELF64
struct ia64_kernel_trampoline *tr = (void *) (pe_target + tramp_off);
struct grub_ia64_trampoline *tr = (void *) (pe_target + tramp_off);
grub_uint64_t *gpptr = (void *) (pe_target + got_off);
#define MASK19 ((1 << 19) - 1)
#endif
for (i = 0, s = sections;
@ -354,9 +233,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
strtab + grub_target_to_host32 (s->sh_name),
strtab + grub_target_to_host32 (target_section->sh_name));
rtab_size = grub_target_to_host32 (s->sh_size);
r_size = grub_target_to_host32 (s->sh_entsize);
rtab_offset = grub_target_to_host32 (s->sh_offset);
rtab_size = grub_target_to_host (s->sh_size);
r_size = grub_target_to_host (s->sh_entsize);
rtab_offset = grub_target_to_host (s->sh_offset);
num_rs = rtab_size / r_size;
for (j = 0, r = (Elf_Rela *) ((char *) e + rtab_offset);
@ -377,7 +256,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
ELF_R_SYM (info), image_target);
addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
r->r_addend : 0;
grub_target_to_host (r->r_addend) : 0;
switch (image_target->elf_target)
{
@ -463,14 +342,14 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case R_IA64_PCREL21B:
{
grub_uint64_t noff;
make_trampoline (tr, addend + sym_addr);
grub_ia64_make_trampoline (tr, addend + sym_addr);
noff = ((char *) tr - (char *) pe_target
- target_section_addr - (offset & ~3)) >> 4;
tr++;
if (noff & ~MASK19)
grub_util_error ("trampoline offset too big (%"
PRIxGRUB_UINT64_T ")", noff);
add_value_to_slot_20b ((grub_addr_t) target, noff);
grub_ia64_add_value_to_slot_20b ((grub_addr_t) target, noff);
}
break;
@ -480,8 +359,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
Elf_Sym *sym;
sym = (Elf_Sym *) ((char *) e
+ grub_target_to_host32 (symtab_section->sh_offset)
+ ELF_R_SYM (info) * grub_target_to_host32 (symtab_section->sh_entsize));
+ grub_target_to_host (symtab_section->sh_offset)
+ ELF_R_SYM (info) * grub_target_to_host (symtab_section->sh_entsize));
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
sym_addr = grub_target_to_host64 (*(grub_uint64_t *) (pe_target
+ sym->st_value
@ -489,15 +368,15 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
}
case R_IA64_LTOFF_FPTR22:
*gpptr = grub_host_to_target64 (addend + sym_addr);
add_value_to_slot_21 ((grub_addr_t) target,
(char *) gpptr - (char *) pe_target
+ image_target->vaddr_offset);
grub_ia64_add_value_to_slot_21 ((grub_addr_t) target,
(char *) gpptr - (char *) pe_target
+ image_target->vaddr_offset);
gpptr++;
break;
case R_IA64_GPREL22:
add_value_to_slot_21 ((grub_addr_t) target,
addend + sym_addr);
grub_ia64_add_value_to_slot_21 ((grub_addr_t) target,
addend + sym_addr);
break;
case R_IA64_PCREL64LSB:
*target = grub_host_to_target64 (grub_target_to_host64 (*target)
@ -516,7 +395,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
+ addend + sym_addr);
grub_util_info ("relocating a direct entry to 0x%"
PRIxGRUB_UINT64_T " at the offset 0x%llx",
*target, (unsigned long long) offset);
grub_target_to_host64 (*target),
(unsigned long long) offset);
break;
/* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
@ -702,8 +582,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
for (i = 0, s = sections; i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if ((s->sh_type == grub_cpu_to_le32 (SHT_REL)) ||
(s->sh_type == grub_cpu_to_le32 (SHT_RELA)))
if ((grub_target_to_host32 (s->sh_type) == SHT_REL) ||
(grub_target_to_host32 (s->sh_type) == SHT_RELA))
{
Elf_Rel *r;
Elf_Word rtab_size, r_size, num_rs;
@ -714,9 +594,9 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
grub_util_info ("translating the relocation section %s",
strtab + grub_le_to_cpu32 (s->sh_name));
rtab_size = grub_le_to_cpu32 (s->sh_size);
r_size = grub_le_to_cpu32 (s->sh_entsize);
rtab_offset = grub_le_to_cpu32 (s->sh_offset);
rtab_size = grub_target_to_host (s->sh_size);
r_size = grub_target_to_host (s->sh_entsize);
rtab_offset = grub_target_to_host (s->sh_offset);
num_rs = rtab_size / r_size;
section_address = section_addresses[grub_le_to_cpu32 (s->sh_info)];
@ -728,8 +608,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
Elf_Addr info;
Elf_Addr offset;
offset = grub_le_to_cpu32 (r->r_offset);
info = grub_le_to_cpu32 (r->r_info);
offset = grub_target_to_host (r->r_offset);
info = grub_target_to_host (r->r_info);
/* Necessary to relocate only absolute addresses. */
switch (image_target->elf_target)
@ -1119,7 +999,7 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
*kernel_sz = ALIGN_UP (*kernel_sz, 16);
grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
tramp *= sizeof (struct ia64_kernel_trampoline);
tramp *= sizeof (struct grub_ia64_trampoline);
ia64_toff = *kernel_sz;
*kernel_sz += ALIGN_UP (tramp, 16);

View file

@ -250,7 +250,7 @@ static grub_uint8_t linux_to_usb_map[128] = {
/* 0x52 */ GRUB_KEYBOARD_KEY_NUMDOT, GRUB_KEYBOARD_KEY_NUMDOT,
/* 0x54 */ 0, 0,
/* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11,
/* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0,
/* 0x58 */ GRUB_KEYBOARD_KEY_F12, GRUB_KEYBOARD_KEY_JP_RO,
/* 0x5a */ 0, 0,
/* 0x5c */ 0, 0,
/* 0x5e */ 0, 0,
@ -261,7 +261,14 @@ static grub_uint8_t linux_to_usb_map[128] = {
/* 0x68 */ GRUB_KEYBOARD_KEY_PPAGE, GRUB_KEYBOARD_KEY_LEFT,
/* 0x6a */ GRUB_KEYBOARD_KEY_RIGHT, GRUB_KEYBOARD_KEY_END,
/* 0x6c */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_NPAGE,
/* 0x6e */ GRUB_KEYBOARD_KEY_INSERT, GRUB_KEYBOARD_KEY_DELETE
/* 0x6e */ GRUB_KEYBOARD_KEY_INSERT, GRUB_KEYBOARD_KEY_DELETE,
/* 0x70 */ 0, 0,
/* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO,
/* 0x74 */ 0, 0,
/* 0x76 */ 0, 0,
/* 0x78 */ 0, 0,
/* 0x7a */ 0, 0,
/* 0x7c */ GRUB_KEYBOARD_KEY_JP_YEN,
};
static void

View file

@ -15,23 +15,8 @@
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_os=@host_os@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
grub_mkimage="${bindir}/@grub_mkimage@"
rootdir=/srv/tftp
modules=
@ -48,11 +33,6 @@ efi32_dir="${libdir}/@PACKAGE@/i386-efi"
efi64_dir="${libdir}/@PACKAGE@/x86_64-efi"
itanium_dir="${libdir}/@PACKAGE@/ia64-efi"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage
# Print the usage.
usage () {
@ -60,15 +40,9 @@ usage () {
gettext; echo "Install GRUB on your drive."; echo
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help
print_option_help "--net-directory=$(gettext "DIR")" "$(gettext "root directory of TFTP server")"
print_option_help "--subdir=$(gettext "DIR")" "$(gettext "relative subdirectory on network server")"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
# TRANSLATORS: platform here isn't identifier. It can be translated.
dir_msg="$(gettext_printf "use images and modules under DIR [default=%s/<platform>]" "${libdir}/@PACKAGE@")"
print_option_help "-d, --directory=$(gettext "DIR")" "$dir_msg"
echo
gettext_printf "%s copies GRUB images into net_directory/subdir/target_cpu-platform\n" "$self"
echo
@ -91,14 +65,6 @@ do
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--net-directory)
rootdir=`argument $option "$@"`; shift;;
@ -110,11 +76,6 @@ do
--subdir=*)
subdir=`echo "$option" | sed 's/--subdir=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
# This is an undocumented feature...
--debug)
debug=yes ;;
@ -123,11 +84,6 @@ do
--debug-image=*)
debug_image=`echo "$option" | sed 's/--debug-image=//'` ;;
--directory | -d)
source_directory=`argument $option "$@"`; shift ;;
--directory=*)
source_directory=`echo "$option" | sed 's/--directory=//'` ;;
-*)
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
usage
@ -191,7 +147,7 @@ process_input_dir ()
source ${subdir}/grub.cfg
EOF
"$grub_mkimage" ${config_opt} -d "${input_dir}" -O ${mkimage_target} "--output=${grubdir}/core.$ext" "--prefix=$prefix" $modules $netmodules tftp || exit 1
"$grub_mkimage" ${config_opt} -d "${input_dir}" -O ${mkimage_target} "--output=${grubdir}/core.$ext" "--prefix=$prefix" $modules $grub_decompression_module $netmodules tftp || exit 1
# TRANSLATORS: First %s is replaced by platform name. Second one by filename.
gettext_printf "Netboot directory for %s created. Configure your DHCP server to point to %s\n" "${platform}" "${subdir}/${platform}/core.$ext"
}

View file

@ -1,3 +1,4 @@
#!/bin/sh
# Make GRUB rescue image
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
@ -17,22 +18,6 @@
# Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
self=`basename $0`
multiboot_dir="${libdir}/@PACKAGE@/i386-multiboot"
coreboot_dir="${libdir}/@PACKAGE@/i386-coreboot"
qemu_dir="${libdir}/@PACKAGE@/i386-qemu"
@ -40,22 +25,27 @@ mipsel_qemu_dir="${libdir}/@PACKAGE@/mipsel-qemu_mips"
loongson_dir="${libdir}/@PACKAGE@/mipsel-loongson"
mips_qemu_dir="${libdir}/@PACKAGE@/mips-qemu_mips"
pc_dir="${libdir}/@PACKAGE@/i386-pc"
i386_ieee1275_dir="${libdir}/@PACKAGE@/i386-ieee1275"
efi32_dir="${libdir}/@PACKAGE@/i386-efi"
efi64_dir="${libdir}/@PACKAGE@/x86_64-efi"
ia64_dir="${libdir}/@PACKAGE@/ia64-efi"
sparc64_dir="${libdir}/@PACKAGE@/sparc64-ieee1275"
arcs_dir="${libdir}/@PACKAGE@/mips-arc"
arc_dir="${libdir}/@PACKAGE@/mipsel-arc"
ppc_dir="${libdir}/@PACKAGE@/powerpc-ieee1275"
rom_directory=
override_dir=
grub_mkimage="${bindir}/@grub_mkimage@"
grub_render_label="${bindir}/@grub_render_label@"
grub_glue_efi="${bindir}/@grub_glue_efi@"
label_font="${pkgdatadir}/unicode.pf2"
label_color="black"
label_bgcolor="white"
product_name="${PACKAGE_NAME}"
product_version="${PACKAGE_VERSION}"
xorriso=xorriso
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
localedir="@datadir@/locale"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage
# Print the usage.
usage () {
@ -65,15 +55,20 @@ usage () {
echo
filetrans="$(gettext FILE)"
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "-o, --output=$filetrans" "$(gettext "save output in FILE [required]")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help
print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies on bootable media")"
print_option_help "--rom-directory=$(gettext "DIR")" "$(gettext "save ROM images in DIR [optional]")"
# TRANSLATORS: xorriso is a program for creating ISOs and burning CDs
print_option_help "--xorriso=$filetrans" "$(gettext "use FILE as xorriso [optional]")"
print_option_help "--grub-mkimage=$filetrans" "$(gettext "use FILE as grub-mkimage")"
print_option_help "--grub-glue-efi=$filetrans" "$(gettext "use FILE as grub-glue-efi")"
print_option_help "--grub-render-label=$filetrans" "$(gettext "use FILE as grub-render-label")"
print_option_help "--label-font=$filetrans" "$(gettext "use FILE as font for label")"
print_option_help "--label-color=$(gettext "COLOR")" "$(gettext "use COLOR for label")"
print_option_help "--label-bgcolor=$(gettext "COLOR")" "$(gettext "use COLOR for label background")"
print_option_help "--product-name=$(gettext "STRING")" "$(gettext "use STRING as product name")"
print_option_help "--product-version=$(gettext "STRING")" "$(gettext "use STRING as product version")"
print_option_help "--sparc-boot" "$(gettext "enable sparc boot. Disables HFS+, APM, ARCS and boot as disk image for i386-pc")"
print_option_help "--arcs-boot" "$(gettext "enable ARCS (big-endian mips machines, mostly SGI) boot. Disables HFS+, APM, sparc64 and boot as disk image for i386-pc")"
echo
gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "xorriso -as mkisofs -help" "$self" | grub_fmt
echo
@ -83,6 +78,9 @@ usage () {
gettext "Mail xorriso support requests to <bug-xorriso@gnu.org>."; echo
}
system_area=auto
mkimage_extra_arg=
# Check the arguments.
while test $# -gt 0
do
@ -99,14 +97,6 @@ do
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output)
output_image=`argument $option "$@"`; shift ;;
@ -119,22 +109,51 @@ do
rom_directory=`echo "$option" | sed 's/--rom-directory=//'` ;;
# Intentionally undocumented
--override-directory)
override_dir=`argument $option "$@"`
shift
PATH=${override_dir}:$PATH
export PATH
;;
--override-directory=*)
override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
PATH=${override_dir}:$PATH
export PATH
;;
--grub-mkimage-extra)
mkimage_extra_arg="$mkimage_extra_arg `argument $option "$@"`"; shift ;;
--grub-mkimage-extra=*)
mkimage_extra_arg="$mkimage_extra_arg `echo "$option" | sed 's/--grub-mkimage-extra=//'`" ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--sparc-boot)
system_area=sparc64 ;;
--arcs-boot)
system_area=arcs ;;
--product-name)
product_name=`argument $option "$@"`; shift ;;
--product-name=*)
product_name=`echo "$option" | sed 's/--product-name=//'` ;;
--product-version)
product_version=`argument $option "$@"`; shift ;;
--product-version=*)
product_version=`echo "$option" | sed 's/--product-version=//'` ;;
--grub-glue-efi)
grub_glue_efi=`argument $option "$@"`; shift ;;
--grub-glue-efi=*)
grub_glue_efi=`echo "$option" | sed 's/--grub-glue-efi=//'` ;;
--grub-render-label)
grub_render_label=`argument $option "$@"`; shift ;;
--grub-render-label=*)
grub_render_label=`echo "$option" | sed 's/--grub-render-label=//'` ;;
--label-font)
label_font=`argument $option "$@"`; shift ;;
--label-font=*)
label_font=`echo "$option" | sed 's/--label-font=//'` ;;
--label-color)
label_color=`argument $option "$@"`; shift ;;
--label-color=*)
label_color=`echo "$option" | sed 's/--label-color=//'` ;;
--label-bgcolor)
label_bgcolor=`argument $option "$@"`; shift ;;
--label-bgcolor=*)
label_bgcolor=`echo "$option" | sed 's/--label-bgcolor=//'` ;;
--xorriso)
xorriso=`argument $option "$@"`; shift ;;
@ -163,6 +182,7 @@ fi
iso9660_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
mkdir -p ${iso9660_dir}/boot/grub
mkdir -p ${iso9660_dir}/boot/grub/roms
process_input_dir ()
{
@ -179,9 +199,7 @@ make_image ()
gettext_printf "Enabling %s support ...\n" "$2"
memdisk_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
memdisk_dir="`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
mkdir -p "${memdisk_dir}/boot/grub"
load_cfg="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`"
(cat << EOF
search --fs-uuid --set=root ${iso_uuid}
@ -189,18 +207,38 @@ set prefix=(\${root})/boot/grub
EOF
for i in $(cat "${source_directory}/partmap.lst") ${modules} ; do
echo "insmod $i"
done ; \
echo "source \$prefix/grub.cfg") \
> "${memdisk_dir}/boot/grub/grub.cfg"
done ; ) > "${load_cfg}"
(cd "${memdisk_dir}"; tar -cf - boot) > "${memdisk_img}"
rm -rf "${memdisk_dir}"
"$grub_mkimage" -O ${platform} -d "${source_directory}" -m "${memdisk_img}" -o "$3" --prefix='(memdisk)/boot/grub' \
search iso9660 configfile normal memdisk tar $4
rm -rf "${memdisk_img}"
"$grub_mkimage" -O ${platform} -d "${source_directory}" -c "${load_cfg}" -o "$3" \
$grub_decompression_module search iso9660 $4
rm -rf "${load_cfg}"
}
if [ "${override_dir}" = "" ] ; then
make_image_fwdisk ()
{
source_directory="$1"
platform=$2
if ! test -e "${source_directory}"; then
return;
fi
gettext_printf "Enabling %s support ...\n" "$2"
"$grub_mkimage" -O ${platform} -d "${source_directory}" -p '()/boot/grub' -o "$3" \
$grub_decompression_module iso9660 $4
}
if [ "${source_directory}" = "" ] ; then
if [ "$system_area" = auto ]; then
if test -e "${pc_dir}" || test -e "${ppc_dir}" \
|| test -e "${efi32_dir}" || test -e "${efi64_dir}"; then
system_area=common;
elif test -e "${sparc64_dir}" ; then
system_area=sparc64;
elif test -e "${arcs_dir}" ; then
system_area=arcs;
fi
fi
if test -e "${multiboot_dir}" ; then
process_input_dir "${multiboot_dir}" i386-multiboot
fi
@ -213,6 +251,9 @@ if [ "${override_dir}" = "" ] ; then
if test -e "${pc_dir}" ; then
process_input_dir "${pc_dir}" i386-pc
fi
if test -e "${i386_ieee1275_dir}" ; then
process_input_dir "${i386_ieee1275_dir}" i386-ieee1275
fi
if test -e "${efi32_dir}" ; then
process_input_dir "${efi32_dir}" i386-efi
fi
@ -231,9 +272,21 @@ if [ "${override_dir}" = "" ] ; then
if test -e "${loongson_dir}" ; then
process_input_dir "${loongson_dir}" mipsel-loongson
fi
if test -e "${ppc_dir}" ; then
process_input_dir "${ppc_dir}" powerpc-ieee1275
fi
if test -e "${sparc64_dir}" ; then
process_input_dir "${sparc64_dir}" sparc64-ieee1275
fi
if test -e "${arcs_dir}" ; then
process_input_dir "${arcs_dir}" mips-arc
fi
if test -e "${arc_dir}" ; then
process_input_dir "${arc_dir}" mipsel-arc
fi
else
. "${override_dir}"/modinfo.sh
process_input_dir "${override_dir}" ${grub_modinfo_target_cpu}-${grub_modinfo_platform}
. "${source_directory}"/modinfo.sh
process_input_dir "${source_directory}" ${grub_modinfo_target_cpu}-${grub_modinfo_platform}
multiboot_dir=
pc_dir=
efi32_dir=
@ -244,17 +297,27 @@ else
mipsel_qemu_dir=
mips_qemu_dir=
loongson_dir=
ppc_dir=
i386_ieee1275_dir=
sparc64_dir=
arcs_dir=
arc_dir=
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
i386-multiboot) multiboot_dir="${override_dir}" ;;
i386-coreboot) coreboot_dir="${override_dir}" ;;
i386-qemu) qemu_dir="${override_dir}" ;;
i386-pc) pc_dir="${override_dir}" ;;
i386-efi) efi32_dir="${override_dir}" ;;
x86_64-efi) efi64_dir="${override_dir}" ;;
ia64-efi) ia64_dir="${override_dir}" ;;
mipsel-qemu_mips) mipsel_qemu_dir="${override_dir}" ;;
mipsel-loongson) loongson_dir="${override_dir}" ;;
mips-qemu_mips) mips_qemu_dir="${override_dir}" ;;
i386-multiboot) multiboot_dir="${source_directory}" ;;
i386-coreboot) coreboot_dir="${source_directory}" ;;
i386-qemu) qemu_dir="${source_directory}" ;;
i386-pc) pc_dir="${source_directory}"; system_area=common;;
i386-efi) efi32_dir="${source_directory}"; system_area=common ;;
x86_64-efi) efi64_dir="${source_directory}"; system_area=common ;;
ia64-efi) ia64_dir="${source_directory}" ;;
mipsel-qemu_mips) mipsel_qemu_dir="${source_directory}" ;;
mipsel-loongson) loongson_dir="${source_directory}" ;;
mips-qemu_mips) mips_qemu_dir="${source_directory}" ;;
powerpc-ieee1275) ppc_dir="${source_directory}"; system_area=common ;;
sparc64-ieee1275) sparc64_dir="${source_directory}"; system_area=sparc64 ;;
mips-arc) arcs_dir="${source_directory}"; system_area=arcs ;;
mipsel-arc) arc_dir="${source_directory}" ;;
i386-ieee1275) i386_ieee1275_dir="${source_directory}" ;;
esac
fi
@ -273,20 +336,34 @@ if test -e "${pc_dir}" ; then
done ;) > "${load_cfg}"
"$grub_mkimage" -O i386-pc -d "${pc_dir}/" -o "${core_img}" -c "$load_cfg" --prefix=/boot/grub \
iso9660 biosdisk
$grub_decompression_module iso9660 biosdisk
cat "${pc_dir}/cdboot.img" "${core_img}" > "${iso9660_dir}/boot/grub/i386-pc/eltorito.img"
embed_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
cat "${pc_dir}/boot.img" "${core_img}" > "${embed_img}"
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table"
if [ "$system_area" = common ]; then
if "${xorriso}" -as mkisofs -help 2>&1 | fgrep "grub2-boot-info" >/dev/null; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} --grub2-boot-info --grub2-mbr ${pc_dir}/boot_hybrid.img"
else
gettext "Your xorriso doesn't support \`--grub2-boot-info'. Some features are disabled. Please use xorriso 1.2.9 or later."
echo
sysarea_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
cat "${pc_dir}/boot.img" "${core_img}" > "${sysarea_img}"
if [ "$(wc -c "${sysarea_img}" | awk '{ print $1; }')" -gt 32768 ]; then
gettext "Your xorriso doesn't support \`--grub2-boot-info'. Your core image is too big. Boot as disk is disabled. Please use xorriso 1.2.9 or later."
echo
else
grub_mkisofs_arguments="${grub_mkisofs_arguments} -G ${sysarea_img}"
fi
fi
fi
rm -f "${core_img}"
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-info-table \
--embedded-boot ${embed_img}"
fi
# build multiboot core.img
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "pata ahci at_keyboard"
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/grub/i386-multiboot/core.elf" "pata ahci at_keyboard"
make_image_fwdisk "${i386_ieee1275_dir}" i386-ieee1275 "${iso9660_dir}/boot/grub/ofwx86.elf" ""
if test -e "${efi64_dir}" || test -e "${efi32_dir}" || test -e "${ia64_dir}"; then
efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
@ -303,48 +380,116 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}" || test -e "${ia64_dir}"; th
cp "${efi_dir}"/efi/boot/bootia32.efi "${efi_dir}"/efi/boot/boot.efi
fi
if [ -e "${efi_dir}"/efi/boot/bootx64.efi ] || [ -e "${efi_dir}"/efi/boot/bootia32.efi ]; then
mkdir -p "${iso9660_dir}"/System/Library/CoreServices
fi
if [ -e "${efi_dir}"/efi/boot/bootx64.efi ] && [ -e "${efi_dir}"/efi/boot/bootia32.efi ]; then
"$grub_glue_efi" -6 "${efi_dir}"/efi/boot/bootx64.efi -3 "${efi_dir}"/efi/boot/bootia32.efi -o "${iso9660_dir}"/System/Library/CoreServices/boot.efi
elif [ -e "${efi_dir}"/efi/boot/bootx64.efi ]; then
cp "${efi_dir}"/efi/boot/bootx64.efi "${iso9660_dir}"/System/Library/CoreServices/boot.efi
elif [ -e "${efi_dir}"/efi/boot/bootia32.efi ]; then
cp "${efi_dir}"/efi/boot/bootia32.efi "${iso9660_dir}"/System/Library/CoreServices/boot.efi
fi
mformat -C -f 2880 -L 16 -i "${iso9660_dir}"/efi.img ::
mcopy -s -i "${iso9660_dir}"/efi.img ${efi_dir}/efi ::/
rm -rf ${efi_dir}
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img"
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img -efi-boot-part --efi-boot-image"
fi
make_image "${mipsel_qemu_dir}" mipsel-qemu_mips-elf "${iso9660_dir}/boot/mipsel-qemu_mips.elf" "pata"
if [ -e "${iso9660_dir}/boot/mipsel-qemu_mips.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/mipsel-qemu_mips.elf" "${rom_directory}/mipsel-qemu_mips.elf"
make_image_fwdisk "${ppc_dir}" powerpc-ieee1275 "${iso9660_dir}/boot/grub/powerpc-ieee1275/core.elf" ""
if [ -e "${iso9660_dir}"/System/Library/CoreServices/boot.efi ] || [ -e "${iso9660_dir}/boot/grub/powerpc-ieee1275/core.elf" ]; then
mkdir -p "${iso9660_dir}"/System/Library/CoreServices
touch "${iso9660_dir}/mach_kernel"
cat > "${iso9660_dir}/System/Library/CoreServices/SystemVersion.plist" <<EOF
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string></string>
<key>ProductName</key>
<string>${product_name}</string>
<key>ProductVersion</key>
<string>${product_version}</string>
</dict>
</plist>
EOF
"$grub_render_label" -f "$label_font" -b "$label_bgcolor" -c "$label_color" -t "${product_name} ${product_version}" -o "${iso9660_dir}/System/Library/CoreServices/.disk_label"
echo "${product_name} ${product_version}" > "${iso9660_dir}/System/Library/CoreServices/.disk_label.contentDetails"
if [ "$system_area" = common ]; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfsplus -apm-block-size 2048 -hfsplus-file-creator-type chrp tbxj /System/Library/CoreServices/.disk_label"
fi
fi
make_image "${loongson_dir}" mipsel-loongson-elf "${iso9660_dir}/boot/mipsel-loongson.elf" "pata -C xz"
if [ -e "${iso9660_dir}/boot/mipsel-loongson.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/mipsel-loongson.elf" "${rom_directory}/mipsel-loongson.elf"
fi
make_image "${loongson_dir}" mipsel-yeeloong-flash "${iso9660_dir}/boot/mipsel-yeeloong.bin" "pata -C xz"
if [ -e "${iso9660_dir}/boot/mipsel-yeeloong.bin" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/mipsel-yeeloong.bin" "${rom_directory}/mipsel-yeeloong.bin"
if [ -e "${iso9660_dir}/boot/grub/powerpc-ieee1275/core.elf" ] ; then
cp "${ppc_dir}/grub.chrp" "${iso9660_dir}"/System/Library/CoreServices/BootX
mkdir -p "${iso9660_dir}"/ppc/chrp
cp "${ppc_dir}/bootinfo.txt" "${iso9660_dir}"/ppc/bootinfo.txt
grub_mkisofs_arguments="${grub_mkisofs_arguments} /System/Library/CoreServices/grub.elf=${iso9660_dir}/boot/grub/powerpc-ieee1275/core.elf /boot/grub/powerpc.elf=${iso9660_dir}/boot/grub/powerpc-ieee1275/core.elf"
# FIXME: add PreP
if [ "$system_area" = common ]; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfsplus-file-creator-type chrp tbxi /System/Library/CoreServices/BootX -hfs-bless-by p /System/Library/CoreServices"
fi
grub_mkisofs_arguments="${grub_mkisofs_arguments} -sysid PPC"
fi
make_image "${loongson_dir}" mipsel-fuloong2f-flash "${iso9660_dir}/boot/mipsel-fuloong2f.bin" "pata -C xz"
if [ -e "${iso9660_dir}/boot/mipsel-fulong.bin" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/mipsel-fulong.bin" "${rom_directory}/mipsel-fulong.bin"
if [ -e "${iso9660_dir}"/System/Library/CoreServices/boot.efi ] && [ "$system_area" = common ]; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} -hfs-bless-by i /System/Library/CoreServices/boot.efi"
fi
make_image "${mips_qemu_dir}" mips-qemu_mips-elf "${iso9660_dir}/boot/mips-qemu_mips.elf" "pata"
if [ -e "${iso9660_dir}/boot/mips-qemu_mips.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/mips-qemu_mips.elf" "${rom_directory}/mips-qemu_mips.elf"
make_image_fwdisk "${sparc64_dir}" sparc64-ieee1275-cdcore "${iso9660_dir}/boot/grub/sparc64-ieee1275/core.img" ""
if [ -e "${iso9660_dir}"/boot/grub/sparc64-ieee1275/core.img ] && [ "$system_area" = sparc64 ]; then
sysarea_img="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
dd if=/dev/zero count=1 bs=512 | cat - "${sparc64_dir}"/cdboot.img > "$sysarea_img"
grub_mkisofs_arguments="${grub_mkisofs_arguments} -G $sysarea_img -B , --grub2-sparc-core /boot/grub/sparc64-ieee1275/core.img"
fi
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "pata at_keyboard"
if [ -e "${iso9660_dir}/boot/qemu.img" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/qemu.img" "${rom_directory}/qemu.img"
make_image_fwdisk "${arcs_dir}" mips-arc "${iso9660_dir}/boot/grub/mips-arc/core.img" ""
if [ -e "${iso9660_dir}/boot/grub/mips-arc/core.img" ]; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} /boot/grub/mips-arc/grub=${iso9660_dir}/boot/grub/mips-arc/core.img /boot/grub/mips-arc/sashARCS=${iso9660_dir}/boot/grub/mips-arc/core.img /boot/grub/mips-arc/sash=${iso9660_dir}/boot/grub/mips-arc/core.img"
fi
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "pata ahci at_keyboard"
if [ -e "${iso9660_dir}/boot/coreboot.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/coreboot.elf" "${rom_directory}/coreboot.elf"
if [ -e "${iso9660_dir}/boot/grub/mips-arc/core.img" ] && [ "$system_area" = arcs ]; then
grub_mkisofs_arguments="${grub_mkisofs_arguments} -mips-boot /boot/grub/mips-arc/sashARCS -mips-boot /boot/grub/mips-arc/sash -mips-boot /boot/grub/mips-arc/grub"
fi
make_image_fwdisk "${arc_dir}" mipsel-arc "${iso9660_dir}/boot/grub/arc.exe" ""
make_image "${mipsel_qemu_dir}" mipsel-qemu_mips-elf "${iso9660_dir}/boot/grub/roms/mipsel-qemu_mips.elf" "pata"
if [ -e "${iso9660_dir}/boot/grub/roms/mipsel-qemu_mips.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/roms/mipsel-qemu_mips.elf" "${rom_directory}/mipsel-qemu_mips.elf"
fi
make_image "${loongson_dir}" mipsel-loongson-elf "${iso9660_dir}/boot/grub/loongson.elf" "pata -C xz"
if [ -e "${iso9660_dir}/boot/grub/loongson.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/loongson.elf" "${rom_directory}/mipsel-loongson.elf"
fi
make_image "${loongson_dir}" mipsel-yeeloong-flash "${iso9660_dir}/boot/grub/roms/mipsel-yeeloong.bin" "pata -C xz"
if [ -e "${iso9660_dir}/boot/grub/roms/mipsel-yeeloong.bin" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/roms/mipsel-yeeloong.bin" "${rom_directory}/mipsel-yeeloong.bin"
fi
make_image "${loongson_dir}" mipsel-fuloong2f-flash "${iso9660_dir}/boot/grub/roms/mipsel-fuloong2f.bin" "pata -C xz"
if [ -e "${iso9660_dir}/boot/grub/roms/mipsel-fulong.bin" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/roms/mipsel-fulong.bin" "${rom_directory}/mipsel-fulong.bin"
fi
make_image "${mips_qemu_dir}" mips-qemu_mips-elf "${iso9660_dir}/boot/grub/roms/mips-qemu_mips.elf" "pata"
if [ -e "${iso9660_dir}/boot/grub/roms/mips-qemu_mips.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/roms/mips-qemu_mips.elf" "${rom_directory}/mips-qemu_mips.elf"
fi
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/grub/roms/qemu.img" "pata at_keyboard"
if [ -e "${iso9660_dir}/boot/grub/roms/qemu.img" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/roms/qemu.img" "${rom_directory}/qemu.img"
fi
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/grub/roms/coreboot.elf" "pata ahci at_keyboard"
if [ -e "${iso9660_dir}/boot/grub/roms/coreboot.elf" ] && [ -d "${rom_directory}" ]; then
cp "${iso9660_dir}/boot/grub/roms/coreboot.elf" "${rom_directory}/coreboot.elf"
fi
# build iso image
"${xorriso}" -as mkisofs -graft-points ${grub_mkisofs_arguments} --protective-msdos-label -o "${output_image}" -r "${iso9660_dir}" --sort-weight 0 / --sort-weight 1 /boot ${source}
rm -rf "${iso9660_dir}"
rm -f "${embed_img}"
rm -f "${sysarea_img}"
exit 0

View file

@ -18,32 +18,10 @@
# Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
source_directory=
compression=auto
format=
grub_mkimage="${bindir}/@grub_mkimage@"
source=
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage
# Print the usage.
usage () {
@ -52,18 +30,12 @@ usage () {
gettext "Generate a standalone image (containing all modules) in the selected format"
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")"
# TRANSLATORS: platform here isn't identifier. It can be translated.
dir_msg="$(gettext_printf "use images and modules under DIR [default=%s/<platform>]" "${libdir}/@PACKAGE@")"
print_option_help "-d, --directory=$(gettext "DIR")" "$dir_msg"
print_option_help "-O, --format=$(gettext "FORMAT")" "$(gettext "generate an image in FORMAT")"; echo
print_option_help "" "$(gettext "available formats:") $formats"
echo
print_option_help "-C, --compression=(xz|none|auto)" "$(gettext "choose the compression to use")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
print_option_help "-C, --compression=(xz|none|auto)" "$(gettext "choose the compression to use for core image")"
grub_print_install_files_help
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
echo
gettext "Report bugs to <bug-grub@gnu.org>."; echo
}
@ -84,30 +56,12 @@ do
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output)
output_image=`argument $option "$@"`; shift ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
--directory | -d)
source_directory=`argument $option "$@"`; shift ;;
--directory=*)
source_directory=`echo "$option" | sed 's/--directory=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--compression | -C)
compression=`argument $option "$@"`; shift ;;
--compression=*)
@ -170,7 +124,7 @@ memdisk_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
(cd "${memdisk_dir}"; tar -cf - * $source) > "${memdisk_img}"
rm -rf "${memdisk_dir}"
"$grub_mkimage" -O "${format}" -C "$compression" -d "${source_directory}" -m "${memdisk_img}" -o "$output_image" --prefix='(memdisk)/boot/grub' memdisk tar $modules
"$grub_mkimage" -O "${format}" -C "$compression" -d "${source_directory}" -m "${memdisk_img}" -o "$output_image" --prefix='(memdisk)/boot/grub' memdisk tar $grub_decompression_module $modules
rm -rf "${memdisk_img}"
exit 0

View file

@ -499,7 +499,7 @@ probe (const char *path, char **device_names, char delim)
{
char *tmp = xmalloc (strlen (ofpath) + sizeof ("ieee1275/"));
char *p;
p = stpcpy (tmp, "ieee1275/");
p = grub_stpcpy (tmp, "ieee1275/");
strcpy (p, ofpath);
printf ("--hint-ieee1275='");
print_full_name (tmp, dev);
@ -616,7 +616,7 @@ probe (const char *path, char **device_names, char delim)
{
char *tmp = xmalloc (strlen (ofpath) + sizeof ("ieee1275/"));
char *p;
p = stpcpy (tmp, "ieee1275/");
p = grub_stpcpy (tmp, "ieee1275/");
strcpy (p, ofpath);
print_full_name (tmp, dev);
free (tmp);

View file

@ -46,8 +46,6 @@ export TEXTDOMAINDIR="@localedir@"
usage () {
gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir"
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
@ -129,17 +127,14 @@ fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
# Restore saved_entry if it was set by previous version
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^prev_saved_entry=//p'`
if [ "$prev_saved_entry" ]; then
$grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
else
# We need some non-empty value for prev_saved_entry so that GRUB will
# recognise that grub-reboot has been used and restore the previous
# saved entry. "0" is the same as an empty value, i.e. the first menu
# entry.
$grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
$grub_editenv ${grubdir}/grubenv set saved_entry="$prev_saved_entry"
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
fi
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
$grub_editenv ${grubdir}/grubenv set next_entry="$entry"
# Bye.
exit 0

324
util/grub-render-label.c Normal file
View file

@ -0,0 +1,324 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2012,2013 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/>.
*/
#include <config.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <grub/term.h>
#include <grub/font.h>
#include <grub/gfxmenu_view.h>
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <argp.h>
#include <unistd.h>
#include <errno.h>
#include "progname.h"
struct arguments
{
char *input;
char *text;
char *output;
char *font;
grub_video_rgba_color_t fgcolor;
grub_video_rgba_color_t bgcolor;
int verbosity;
};
static struct argp_option options[] = {
{"input", 'i', N_("FILE"), 0,
N_("read text from FILE."), 0},
{"color", 'c', N_("COLOR"), 0,
N_("use COLOR for text"), 0},
{"bgcolor", 'b', N_("COLOR"), 0,
N_("use COLOR for background"), 0},
{"text", 't', N_("STRING"), 0,
N_("set the label to render."), 0},
{"output", 'o', N_("FILE"), 0,
N_("set output filename. Default is STDOUT"), 0},
{"font", 'f', N_("FILE"), 0,
N_("use FILE as font (PF2)."), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
{ 0, 0, 0, 0, 0, 0 }
};
#include <grub/err.h>
#include <grub/types.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/video.h>
#include <grub/video_fb.h>
static error_t
argp_parser (int key, char *arg, struct argp_state *state)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
struct arguments *arguments = state->input;
grub_err_t err;
switch (key)
{
case 'i':
arguments->input = xstrdup (arg);
break;
case 'b':
err = grub_video_parse_color (arg, &arguments->bgcolor);
if (err)
grub_util_error (_("invalid color specification `%s'"), arg);
break;
case 'c':
err = grub_video_parse_color (arg, &arguments->fgcolor);
if (err)
grub_util_error (_("invalid color specification `%s'"), arg);
break;
case 'f':
arguments->font = xstrdup (arg);
break;
case 't':
arguments->text = xstrdup (arg);
break;
case 'o':
arguments->output = xstrdup (arg);
break;
case 'v':
arguments->verbosity++;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
void grub_hostfs_init (void);
void grub_host_init (void);
struct header
{
grub_uint8_t magic;
grub_uint16_t width;
grub_uint16_t height;
} __attribute__ ((packed));
static struct argp argp = {
options, argp_parser, N_("[OPTIONS]"),
N_("Render Apple .disk_label."),
NULL, NULL, NULL
};
static struct grub_video_palette_data ieee1275_palette[256];
int
main (int argc, char *argv[])
{
FILE *out;
char *text;
char *fontfull;
struct arguments arguments;
grub_font_t font;
int width, height;
struct header head;
const grub_uint8_t vals[] = { 0xff, 0xda, 0xb3, 0x87, 0x54, 0x00 };
const grub_uint8_t vals2[] = { 0xf3, 0xe7, 0xcd, 0xc0, 0xa5, 0x96,
0x77, 0x66, 0x3f, 0x27 };
int i, j, k, cptr = 0;
grub_uint8_t bg, fg;
struct grub_video_mode_info mode_info;
for (i = 0; i < 256; i++)
ieee1275_palette[i].a = 0xff;
for (i = 0; i < 6; i++)
for (j = 0; j < 6; j++)
for (k = 0; k < 6; k++)
{
ieee1275_palette[cptr].r = vals[i];
ieee1275_palette[cptr].g = vals[j];
ieee1275_palette[cptr].b = vals[k];
ieee1275_palette[cptr].a = 0xff;
cptr++;
}
cptr--;
for (i = 0; i < 10; i++)
{
ieee1275_palette[cptr].r = vals2[i];
ieee1275_palette[cptr].g = 0;
ieee1275_palette[cptr].b = 0;
ieee1275_palette[cptr].a = 0xff;
cptr++;
}
for (i = 0; i < 10; i++)
{
ieee1275_palette[cptr].r = 0;
ieee1275_palette[cptr].g = vals2[i];
ieee1275_palette[cptr].b = 0;
ieee1275_palette[cptr].a = 0xff;
cptr++;
}
for (i = 0; i < 10; i++)
{
ieee1275_palette[cptr].r = 0;
ieee1275_palette[cptr].g = 0;
ieee1275_palette[cptr].b = vals2[i];
ieee1275_palette[cptr].a = 0xff;
cptr++;
}
for (i = 0; i < 10; i++)
{
ieee1275_palette[cptr].r = vals2[i];
ieee1275_palette[cptr].g = vals2[i];
ieee1275_palette[cptr].b = vals2[i];
ieee1275_palette[cptr].a = 0xff;
cptr++;
}
ieee1275_palette[cptr].r = 0;
ieee1275_palette[cptr].g = 0;
ieee1275_palette[cptr].b = 0;
ieee1275_palette[cptr].a = 0xff;
set_program_name (argv[0]);
grub_util_init_nls ();
/* Check for options. */
memset (&arguments, 0, sizeof (struct arguments));
arguments.bgcolor.red = 0xff;
arguments.bgcolor.green = 0xff;
arguments.bgcolor.blue = 0xff;
arguments.bgcolor.alpha = 0xff;
arguments.fgcolor.red = 0x00;
arguments.fgcolor.green = 0x00;
arguments.fgcolor.blue = 0x00;
arguments.fgcolor.alpha = 0xff;
if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
{
fprintf (stderr, "%s", _("Error in parsing command line arguments\n"));
exit(1);
}
if ((!arguments.input && !arguments.text) || !arguments.font)
{
fprintf (stderr, "%s", _("Missing arguments\n"));
exit(1);
}
if (arguments.text)
text = arguments.text;
else
{
FILE *in = fopen (arguments.input, "r");
size_t s;
if (!in)
grub_util_error (_("cannot open `%s': %s"), arguments.input,
strerror (errno));
fseek (in, 0, SEEK_END);
s = ftell (in);
fseek (in, 0, SEEK_SET);
text = xmalloc (s + 1);
if (fread (text, 1, s, in) != s)
grub_util_error (_("cannot read `%s': %s"), arguments.input,
strerror (errno));
text[s] = 0;
fclose (in);
}
if (arguments.output)
out = fopen (arguments.output, "wb");
else
out = stdout;
if (!out)
{
grub_util_error (_("cannot open `%s': %s"), arguments.output ? : "stdout",
strerror (errno));
}
fontfull = canonicalize_file_name (arguments.font);
if (!fontfull)
{
grub_util_error (_("cannot open `%s': %s"), arguments.font,
strerror (errno));
}
fontfull = xasprintf ("(host)/%s", fontfull);
grub_init_all ();
grub_hostfs_init ();
grub_host_init ();
grub_font_loader_init ();
font = grub_font_load (fontfull);
if (!font)
{
grub_util_error (_("cannot open `%s': %s"), arguments.font,
grub_errmsg);
}
width = grub_font_get_string_width (font, text) + 10;
height = grub_font_get_height (font);
mode_info.width = width;
mode_info.height = height;
mode_info.pitch = width;
mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
mode_info.bpp = 8;
mode_info.bytes_per_pixel = 1;
mode_info.number_of_colors = 256;
grub_video_capture_start (&mode_info, ieee1275_palette,
ARRAY_SIZE (ieee1275_palette));
fg = grub_video_map_rgb (arguments.fgcolor.red,
arguments.fgcolor.green,
arguments.fgcolor.blue);
bg = grub_video_map_rgb (arguments.bgcolor.red,
arguments.bgcolor.green,
arguments.bgcolor.blue);
grub_memset (grub_video_capture_get_framebuffer (), bg, height * width);
grub_font_draw_string (text, font, fg,
5, grub_font_get_ascent (font));
head.magic = 1;
head.width = grub_cpu_to_be16 (width);
head.height = grub_cpu_to_be16 (height);
fwrite (&head, 1, sizeof (head), out);
fwrite (grub_video_capture_get_framebuffer (), 1, width * height, out);
grub_video_capture_end ();
if (out != stdout)
fclose (out);
return 0;
}

View file

@ -130,6 +130,7 @@ fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
$grub_editenv ${grubdir}/grubenv unset next_entry
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
# Bye.

View file

@ -51,13 +51,25 @@ if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
set default="${GRUB_DEFAULT_BUTTON}"
elif [ "\${next_entry}" ] ; then
set default="\${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="${GRUB_DEFAULT}"
fi
EOF
else
cat <<EOF
set default="${GRUB_DEFAULT}"
if [ "\${next_entry}" ] ; then
set default="\${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="${GRUB_DEFAULT}"
fi
EOF
fi
cat <<EOF

View file

@ -195,7 +195,7 @@ EOF
if [ "x$is_first_entry" = xtrue ]; then
cat << EOF
menuentry '$(echo "$OS" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
EOF
save_default_entry | grub_add_tab
printf '%s\n' "${prepare_boot_cache}"
@ -210,7 +210,7 @@ EOF
cat << EOF
}
EOF
echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
is_first_entry=false
fi
title="${LLABEL} $onstr"
@ -231,7 +231,7 @@ EOF
}
EOF
if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"

View file

@ -324,11 +324,11 @@ vendor_is_ATA(const char *path)
}
static void
check_sas (char *sysfs_path, int *tgt)
check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
{
char *ed = strstr (sysfs_path, "end_device");
char *p, *q, *path;
char phy[16];
char phy[21];
int fd;
size_t path_size;
@ -348,16 +348,25 @@ check_sas (char *sysfs_path, int *tgt)
+ sizeof ("%s/sas_device/%s/phy_identifier"));
path = xmalloc (path_size);
snprintf (path, path_size, "%s/sas_device/%s/phy_identifier", p, ed);
fd = open (path, O_RDONLY);
if (fd < 0)
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
memset (phy, 0, sizeof (phy));
read (fd, phy, sizeof (phy));
read (fd, phy, sizeof (phy) - 1);
close (fd);
sscanf (phy, "%d", tgt);
snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed);
fd = open (path, O_RDONLY);
if (fd < 0)
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
memset (phy, 0, sizeof (phy));
read (fd, phy, sizeof (phy) - 1);
sscanf (phy, "%lx", sas_address);
free (path);
free (p);
close (fd);
@ -370,13 +379,14 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
{
const char *p, *digit_string, *disk_name;
int host, bus, tgt, lun;
unsigned long int sas_address;
char *sysfs_path, disk[MAX_DISK_CAT - sizeof ("/fp@0,0")];
char *of_path;
sysfs_path = block_device_get_sysfs_path_and_link(devicenode);
p = get_basename (sysfs_path);
sscanf(p, "%d:%d:%d:%d", &host, &bus, &tgt, &lun);
check_sas (sysfs_path, &tgt);
check_sas (sysfs_path, &tgt, &sas_address);
if (vendor_is_ATA(sysfs_path))
{
@ -417,18 +427,52 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
}
else
{
if (*digit_string == '\0')
{
snprintf(disk, sizeof (disk), "/%s@%x,%d", disk_name, tgt, lun);
}
else
{
int part;
if (lun == 0)
{
int sas_id = 0;
sas_id = bus << 16 | tgt << 8 | lun;
sscanf(digit_string, "%d", &part);
snprintf(disk, sizeof (disk),
"/%s@%x,%d:%c", disk_name, tgt, lun, 'a' + (part - 1));
}
if (*digit_string == '\0')
{
snprintf(disk, sizeof (disk), "/sas/%s@%x", disk_name, sas_id);
}
else
{
int part;
sscanf(digit_string, "%d", &part);
snprintf(disk, sizeof (disk),
"/sas/%s@%x:%c", disk_name, sas_id, 'a' + (part - 1));
}
}
else
{
char *lunstr;
int lunpart[4];
lunstr = xmalloc (20);
lunpart[0] = (lun >> 8) & 0xff;
lunpart[1] = lun & 0xff;
lunpart[2] = (lun >> 24) & 0xff;
lunpart[3] = (lun >> 16) & 0xff;
sprintf(lunstr, "%02x%02x%02x%02x00000000", lunpart[0], lunpart[1], lunpart[2], lunpart[3]);
long int longlun = atol(lunstr);
if (*digit_string == '\0')
{
snprintf(disk, sizeof (disk), "/sas/%s@%lx,%lu", disk_name, sas_address, longlun);
}
else
{
int part;
sscanf(digit_string, "%d", &part);
snprintf(disk, sizeof (disk),
"/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1));
}
}
}
strcat(of_path, disk);
return of_path;

View file

@ -488,6 +488,12 @@ for src in sorted (os.listdir (os.path.join (indir, "src"))):
fw.close ()
continue
f = codecs.open (infile, "r", "utf-8")
if src == "types.h":
fw.write (f.read ().replace ("float f;", "").replace ("double g;", ""))
f.close ()
fw.close ()
continue
fw.write (f.read ())
f.close ()
fw.close ()

View file

@ -1,146 +0,0 @@
#! /bin/sh
set -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.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
input_dir="${libdir}/@PACKAGE@/powerpc-ieee1275"
datarootdir="@datarootdir@"
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
grub_mkimage="${bindir}/@grub_mkimage@"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage
# Print the usage.
usage () {
gettext_printf "Usage: %s [OPTION] SOURCE...\n" "$self"
gettext "Make GRUB CD-ROM, disk, pendrive and floppy bootable image."; echo
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
echo
gettext_printf "%s generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of \`%s'\n" "genisoimage -help" "$self" | grub_fmt
echo
gettext "Report bugs to <bug-grub@gnu.org>."; echo
}
argument () {
opt=$1
shift
if test $# -eq 0; then
gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
exit 1
fi
echo $1
}
source=
output_image=
# Check the arguments.
while test $# -gt 0
do
option=$1
shift
case "$option" in
-h | --help)
usage
exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--override-directory)
input_dir=`argument $option "$@"`; shift ;;
--override-directory=*)
input_dir=`echo "$option" | sed 's/--override-directory=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
-o | --output)
output_image=`argument $option "$@"`; shift ;;
--output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;;
--rom-directory=*)
;;
--rom-directory)
shift ;;
*)
source="${source} ${option} $@"; break ;;
esac
done
if test "x$output_image" = x; then
usage
exit 1
fi
if [ "x${modules}" = "x" ] ; then
modules=`cd ${input_dir}/ && ls *.mod`
fi
map_file=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
cat >${map_file} <<EOF
# EXTN XLate CREATOR TYPE Comment
grub.img Raw 'UNIX' 'tbxi' "bootstrap"
EOF
iso_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
boot_dir=${iso_dir}/boot/grub
mkdir ${iso_dir}/boot
mkdir ${boot_dir}
core_img=${boot_dir}/grub.img
${grub_mkimage} -O powerpc-ieee1275 -n -d ${input_dir}/ -o ${core_img} ${modules}
genisoimage -graft-points -hfs -part -no-desktop -r -J -o ${output_image} \
-map ${map_file} -hfs-bless ${boot_dir} -chrp-boot -sysid PPC \
${iso_dir} ${source}
rm -rf ${iso_dir}
rm -f ${map_file}
exit 0