merge with Trunk
This commit is contained in:
commit
a239a5e9cc
8 changed files with 198 additions and 58 deletions
|
@ -30,6 +30,12 @@
|
|||
# define DEV_CYGDRIVE_MAJOR 98
|
||||
#endif
|
||||
|
||||
#ifdef __GNU__
|
||||
#include <hurd.h>
|
||||
#include <hurd/lookup.h>
|
||||
#include <hurd/fs.h>
|
||||
#endif
|
||||
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/hostdisk.h>
|
||||
#include <grub/util/getroot.h>
|
||||
|
@ -378,8 +384,65 @@ find_cygwin_root_device (const char *path, dev_t dev)
|
|||
char *
|
||||
grub_guess_root_device (const char *dir)
|
||||
{
|
||||
struct stat st;
|
||||
char *os_dev;
|
||||
#ifdef __GNU__
|
||||
file_t file;
|
||||
mach_port_t *ports;
|
||||
int *ints;
|
||||
loff_t *offsets;
|
||||
char *data;
|
||||
error_t err;
|
||||
mach_msg_type_number_t num_ports = 0, num_ints = 0, num_offsets = 0, data_len = 0;
|
||||
size_t name_len;
|
||||
|
||||
file = file_name_lookup (dir, 0, 0);
|
||||
if (file == MACH_PORT_NULL)
|
||||
return 0;
|
||||
|
||||
err = file_get_storage_info (file,
|
||||
&ports, &num_ports,
|
||||
&ints, &num_ints,
|
||||
&offsets, &num_offsets,
|
||||
&data, &data_len);
|
||||
|
||||
if (num_ints < 1)
|
||||
grub_util_error ("Storage info for `%s' does not include type", dir);
|
||||
if (ints[0] != STORAGE_DEVICE)
|
||||
grub_util_error ("Filesystem of `%s' is not stored on local disk", dir);
|
||||
|
||||
if (num_ints < 5)
|
||||
grub_util_error ("Storage info for `%s' does not include name", dir);
|
||||
name_len = ints[4];
|
||||
if (name_len < data_len)
|
||||
grub_util_error ("Bogus name length for storage info for `%s'", dir);
|
||||
if (data[name_len - 1] != '\0')
|
||||
grub_util_error ("Storage name for `%s' not NUL-terminated", dir);
|
||||
|
||||
os_dev = xmalloc (strlen ("/dev/") + data_len);
|
||||
memcpy (os_dev, "/dev/", strlen ("/dev/"));
|
||||
memcpy (os_dev + strlen ("/dev/"), data, data_len);
|
||||
|
||||
if (ports && num_ports > 0)
|
||||
{
|
||||
mach_msg_type_number_t i;
|
||||
for (i = 0; i < num_ports; i++)
|
||||
{
|
||||
mach_port_t port = ports[i];
|
||||
if (port != MACH_PORT_NULL)
|
||||
mach_port_deallocate (mach_task_self(), port);
|
||||
}
|
||||
munmap ((caddr_t) ports, num_ports * sizeof (*ports));
|
||||
}
|
||||
|
||||
if (ints && num_ints > 0)
|
||||
munmap ((caddr_t) ints, num_ints * sizeof (*ints));
|
||||
if (offsets && num_offsets > 0)
|
||||
munmap ((caddr_t) offsets, num_offsets * sizeof (*offsets));
|
||||
if (data && data_len > 0)
|
||||
munmap (data, data_len);
|
||||
mach_port_deallocate (mach_task_self (), file);
|
||||
#else /* !__GNU__ */
|
||||
struct stat st;
|
||||
|
||||
if (stat (dir, &st) < 0)
|
||||
grub_util_error ("Cannot stat `%s'", dir);
|
||||
|
@ -393,6 +456,7 @@ grub_guess_root_device (const char *dir)
|
|||
/* This might be truly slow, but is there any better way? */
|
||||
os_dev = find_root_device ("/dev", st.st_dev);
|
||||
#endif
|
||||
#endif /* !__GNU__ */
|
||||
|
||||
return os_dev;
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ PACKAGE_NAME=@PACKAGE_NAME@
|
|||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
target_cpu=@target_cpu@
|
||||
native_platform=@platform@
|
||||
|
||||
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.
|
||||
|
@ -42,7 +42,7 @@ 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
|
||||
--output=FILE save output in FILE [required]
|
||||
|
||||
$0 generates a bootable rescue image with specified source files or directories.
|
||||
|
||||
|
@ -63,6 +63,12 @@ for option in "$@"; do
|
|||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||
--output=*)
|
||||
output_image=`echo "$option" | sed 's/--output=//'` ;;
|
||||
# Intentionally undocumented
|
||||
--override-directory=*)
|
||||
override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
|
||||
PATH=${override_dir}:$PATH
|
||||
export PATH
|
||||
;;
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
|
@ -73,25 +79,49 @@ for option in "$@"; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [ "x${output_image}" = x ] ; then
|
||||
echo "output file must be given" >&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
process_input_dir ()
|
||||
{
|
||||
input_dir="$1"
|
||||
platform="$2"
|
||||
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
|
||||
}
|
||||
|
||||
if [ "${override_dir}" = "" ] ; then
|
||||
if test -e "${coreboot_dir}" ; then
|
||||
process_input_dir ${coreboot_dir} coreboot
|
||||
fi
|
||||
done
|
||||
if test -e "${pc_dir}" ; then
|
||||
process_input_dir ${pc_dir} pc
|
||||
fi
|
||||
else
|
||||
process_input_dir ${override_dir} ${native_platform}
|
||||
coreboot_dir=
|
||||
pc_dir=
|
||||
case "${native_platform}" in
|
||||
coreboot) coreboot_dir=${override_dir} ;;
|
||||
pc) pc_dir=${override_dir} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# build coreboot core.img
|
||||
if test -e ${coreboot_dir} ; then
|
||||
if test -e "${coreboot_dir}" ; then
|
||||
echo "Generates coreboot"
|
||||
memdisk_img=`mktemp`
|
||||
memdisk_dir=`mktemp -d`
|
||||
mkdir -p ${memdisk_dir}/boot/grub
|
||||
|
@ -115,18 +145,12 @@ EOF
|
|||
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
|
||||
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
|
||||
fi
|
||||
|
||||
# build eltorito core.img
|
||||
if test -e ${pc_dir} ; then
|
||||
if test -e "${pc_dir}" ; then
|
||||
echo "Generates eltorito"
|
||||
core_img=`mktemp`
|
||||
grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
|
||||
memdisk tar search iso9660 configfile sh \
|
||||
|
@ -141,11 +165,11 @@ if test -e ${pc_dir} ; then
|
|||
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"
|
||||
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -boot-info-table"
|
||||
fi
|
||||
|
||||
# build iso image
|
||||
${grub_mkisofs} -o ${output_image} -r -J ${iso9660_dir}
|
||||
grub-mkisofs ${grub_mkisofs_arguments} -o ${output_image} -r ${iso9660_dir} ${source}
|
||||
rm -rf ${iso9660_dir}
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -22,7 +22,8 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
||||
locale_prefix="/usr/share/locale" # TODO: dynamic with exec_prefix ?
|
||||
locale_dir=`echo /boot/grub/locale | sed ${transform}`
|
||||
grub_lang=`echo $LANG | cut -d _ -f 1`
|
||||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
|
@ -101,20 +102,12 @@ EOF
|
|||
;;
|
||||
esac
|
||||
|
||||
if test -e ${grub_prefix}/gettext.mod -a -d /usr/share/locale; then
|
||||
# Make the locales accesible
|
||||
prepare_grub_to_access_device `${grub_probe} --target=device ${locale_prefix}`
|
||||
lang=`get_locale_lang`
|
||||
grub_locale_prefix=`make_system_path_relative_to_its_root ${locale_prefix}`
|
||||
cat << EOF
|
||||
# Gettext variables and module
|
||||
set locale_prefix=${grub_locale_prefix}
|
||||
set lang=${lang}
|
||||
cat << EOF
|
||||
set locale_dir=${locale_dir}
|
||||
set lang=${grub_lang}
|
||||
insmod gettext
|
||||
EOF
|
||||
else
|
||||
echo "gettext module or /usr/share/locale is not available"
|
||||
fi
|
||||
|
||||
if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
|
||||
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
||||
|
|
|
@ -88,11 +88,16 @@ EOF
|
|||
LLABEL="${LONGNAME}"
|
||||
fi
|
||||
|
||||
if [ "${LROOT}" != "${LBOOT}" ]; then
|
||||
LKERNEL="${LKERNEL#/boot}"
|
||||
LINITRD="${LINITRD#/boot}"
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
menuentry "${LLABEL} (on ${DEVICE})" {
|
||||
EOF
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/")"
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
cat << EOF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue