Autodetect platform in grub-install but allow override.
* util/grub-install.in: Autodetect platform. Support --target and --directory. Read platform from modinfo.sh.
This commit is contained in:
parent
b913642798
commit
90cb2803d4
2 changed files with 142 additions and 93 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2012-02-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Autodetect platform in grub-install but allow override.
|
||||||
|
|
||||||
|
* util/grub-install.in: Autodetect platform. Support --target and
|
||||||
|
--directory. Read platform from modinfo.sh.
|
||||||
|
|
||||||
2012-02-27 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Support btrfs multi-volume probe.
|
Support btrfs multi-volume probe.
|
||||||
|
|
|
@ -29,10 +29,9 @@ sysconfdir="@sysconfdir@"
|
||||||
PACKAGE_NAME=@PACKAGE_NAME@
|
PACKAGE_NAME=@PACKAGE_NAME@
|
||||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||||
target_cpu=@target_cpu@
|
|
||||||
platform=@platform@
|
|
||||||
host_os=@host_os@
|
host_os=@host_os@
|
||||||
pkglibdir="${libdir}/@PACKAGE@/${target_cpu}-${platform}"
|
source_dir=
|
||||||
|
target=
|
||||||
datadir="@datadir@"
|
datadir="@datadir@"
|
||||||
if [ "x$pkgdatadir" = x ]; then
|
if [ "x$pkgdatadir" = x ]; then
|
||||||
pkgdatadir="${datadir}/@PACKAGE@"
|
pkgdatadir="${datadir}/@PACKAGE@"
|
||||||
|
@ -71,33 +70,24 @@ if test -z "$bootloader_id"; then
|
||||||
bootloader_id=grub
|
bootloader_id=grub
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
disk_module=unspecified
|
||||||
disk_module=biosdisk
|
|
||||||
elif [ "${platform}" = "ieee1275" ] || [ "${platform}" = "efi" ] ; then
|
|
||||||
disk_module=
|
|
||||||
else
|
|
||||||
disk_module=native
|
|
||||||
fi
|
|
||||||
|
|
||||||
. "${pkgdatadir}/grub-mkconfig_lib"
|
. "${pkgdatadir}/grub-mkconfig_lib"
|
||||||
|
|
||||||
# Usage: usage
|
# Usage: usage
|
||||||
# Print the usage.
|
# Print the usage.
|
||||||
usage () {
|
usage () {
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] \
|
gettext_printf "Usage: %s [OPTION] [INSTALL_DEVICE]" "$self"
|
||||||
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]; then
|
|
||||||
gettext_printf "Usage: %s [OPTION] INSTALL_DEVICE" "$self"
|
|
||||||
else
|
|
||||||
gettext_printf "Usage: %s [OPTION] [INSTALL_DEVICE]" "$self"
|
|
||||||
fi
|
|
||||||
echo
|
echo
|
||||||
gettext "Install GRUB on your drive." ; echo
|
gettext "Install GRUB on your drive." ; echo
|
||||||
echo
|
echo
|
||||||
printf " -h, --help %s\n" "$(gettext "print this message and exit")"
|
printf " -h, --help %s\n" "$(gettext "print this message and exit")"
|
||||||
printf " -v, --version %s\n" "$(gettext "print the version information and exit")"
|
printf " -v, --version %s\n" "$(gettext "print the version information and exit")"
|
||||||
printf " --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
|
printf " --modules=%-14s%s\n" "$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
|
||||||
dirmsg="$(printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
|
dirmsg="$(gettext_printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
|
||||||
printf " --boot-directory=%-7s%s\n" "$(gettext "DIR")" "$dirmsg"
|
printf " --boot-directory=%-7s%s\n" "$(gettext "DIR")" "$dirmsg"
|
||||||
|
printf " --target=%-15s%s\n" "$(gettext "TARGET")" "$(gettext "install GRUB for TARGET platform [default=current]")"
|
||||||
|
printf " --directory=%-12s%s\n" "$(gettext "DIR")" "$(gettext "use GRUB images from DIR. Takes precedence over target")"
|
||||||
printf " --grub-setup=%-11s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-setup")"
|
printf " --grub-setup=%-11s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-setup")"
|
||||||
printf " --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
|
printf " --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
|
||||||
printf " --grub-mkrelpath=%-7s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
|
printf " --grub-mkrelpath=%-7s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
|
||||||
|
@ -106,17 +96,10 @@ usage () {
|
||||||
printf " --recheck %s\n" "$(gettext "delete device map if it already exists")"
|
printf " --recheck %s\n" "$(gettext "delete device map if it already exists")"
|
||||||
printf " --force %s\n" "$(gettext "install even if problems are detected")"
|
printf " --force %s\n" "$(gettext "install even if problems are detected")"
|
||||||
printf " --force-file-id %s\n" "$(gettext "use ID file even if UUID is available")"
|
printf " --force-file-id %s\n" "$(gettext "use ID file even if UUID is available")"
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
printf " --disk-module=%-10s%s\n" "$(gettext "MODULE")" "$(gettext "disk module to use (biosdisk or native). Only available on BIOS target")"
|
||||||
printf " --disk-module=%-10s%s\n" "$(gettext "MODULE")" "$(gettext "disk module to use (biosdisk or native)")"
|
printf " --no-nvram %s\n" "$(gettext "don't update the \`boot-device' NVRAM variable. Only available on IEEE1275 targets.")"
|
||||||
fi
|
printf " --removable %s\n" "$(gettext "the installation device is removable. Only available on EFI.")"
|
||||||
if [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] ; then
|
printf " --bootloader-id=%-8s%s\n" "$(gettext "ID")" "$(gettext "the ID of bootloader. Only available on EFI.")"
|
||||||
printf " --no-nvram %s\n" "$(gettext "don't update the \`boot-device' NVRAM variable")"
|
|
||||||
fi
|
|
||||||
if [ "${platform}" = "efi" ]; then
|
|
||||||
|
|
||||||
printf " --removable %s\n" "$(gettext "the installation device is removable")"
|
|
||||||
printf " --bootloader-id=%-8s%s\n" "$(gettext "ID")" "$(gettext "the ID of bootloader.")"
|
|
||||||
fi
|
|
||||||
echo
|
echo
|
||||||
gettext "INSTALL_DEVICE must be system device filename.";echo
|
gettext "INSTALL_DEVICE must be system device filename.";echo
|
||||||
echo
|
echo
|
||||||
|
@ -180,6 +163,16 @@ do
|
||||||
--boot-directory=*)
|
--boot-directory=*)
|
||||||
bootdir="`echo "$option" | sed 's/--boot-directory=//'`" ;;
|
bootdir="`echo "$option" | sed 's/--boot-directory=//'`" ;;
|
||||||
|
|
||||||
|
--directory | -d)
|
||||||
|
source_dir="`argument $option "$@"`"; shift;;
|
||||||
|
--directory=*)
|
||||||
|
source_dir="`echo "$option" | sed 's/--directory=//'`" ;;
|
||||||
|
|
||||||
|
--target)
|
||||||
|
target="`argument $option "$@"`"; shift;;
|
||||||
|
--target=*)
|
||||||
|
target="`echo "$option" | sed 's/--target=//'`" ;;
|
||||||
|
|
||||||
--grub-setup)
|
--grub-setup)
|
||||||
grub_setup="`argument "$option" "$@"`"; shift;;
|
grub_setup="`argument "$option" "$@"`"; shift;;
|
||||||
--grub-setup=*)
|
--grub-setup=*)
|
||||||
|
@ -222,13 +215,11 @@ do
|
||||||
allow_floppy="--allow-floppy" ;;
|
allow_floppy="--allow-floppy" ;;
|
||||||
|
|
||||||
--disk-module)
|
--disk-module)
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
disk_module="`argument "$option" "$@"`"; shift;
|
||||||
disk_module="`argument "$option" "$@"`"; shift;
|
;;
|
||||||
fi ;;
|
|
||||||
--disk-module=*)
|
--disk-module=*)
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
disk_module="`echo "$option" | sed 's/--disk-module=//'`"
|
||||||
disk_module="`echo "$option" | sed 's/--disk-module=//'`"
|
;;
|
||||||
fi ;;
|
|
||||||
|
|
||||||
--no-nvram)
|
--no-nvram)
|
||||||
update_nvram=no ;;
|
update_nvram=no ;;
|
||||||
|
@ -260,26 +251,77 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if test "x$grub_setup" = x && [ "${target_cpu}-${platform}" = "i386-pc" ]; then
|
if [ x$source_dir = x ]; then
|
||||||
|
if [ x$target = x ]; then
|
||||||
|
case x"`uname -m`" in
|
||||||
|
x"powerpc"* | x"ppc"*)
|
||||||
|
target="powerpc-ieee1275";;
|
||||||
|
x"sparc"*)
|
||||||
|
target="sparc64-ieee1275";;
|
||||||
|
x"mips"*"el")
|
||||||
|
target="mipsel-loongson";;
|
||||||
|
x"mips"*)
|
||||||
|
target="mips-arc";;
|
||||||
|
x"ia64"*)
|
||||||
|
target="ia64-efi";;
|
||||||
|
x"x86_64"* | x"amd64"*)
|
||||||
|
if [ -d /sys/firmware/efi ]; then
|
||||||
|
target="x86_64-efi"
|
||||||
|
fi
|
||||||
|
target=i386-pc;;
|
||||||
|
x"i"?"86"*)
|
||||||
|
if [ -d /sys/firmware/efi ]; then
|
||||||
|
target="i386-efi"
|
||||||
|
fi
|
||||||
|
if [ -e /proc/device-tree ]; then
|
||||||
|
target="i386-ieee1275"
|
||||||
|
fi
|
||||||
|
target=i386-pc;;
|
||||||
|
*)
|
||||||
|
gettext "Unable to determine your platform. Use --target." ;
|
||||||
|
echo ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
source_dir="${libdir}/@PACKAGE@/$target"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -d "source_dir" ]; then
|
||||||
|
gettext_printf "%s doesn't seem to exist. Please specify --target or --directory\\n" "source_dir"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
. "${source_dir}"/modinfo.sh
|
||||||
|
|
||||||
|
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] ; then
|
||||||
|
if [ x$disk_module = xunspecified ]; then
|
||||||
|
disk_module=biosdisk
|
||||||
|
fi
|
||||||
|
elif [ "${grub_modinfo_platform}" = "ieee1275" ] || [ "${grub_modinfo_platform}" = "efi" ] ; then
|
||||||
|
disk_module=
|
||||||
|
else
|
||||||
|
disk_module=native
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x$grub_setup" = x && [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ]; then
|
||||||
grub_setup="${sbindir}/`echo grub-bios-setup | sed ${transform}`"
|
grub_setup="${sbindir}/`echo grub-bios-setup | sed ${transform}`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$grub_setup" = x && [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]; then
|
if test "x$grub_setup" = x && [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ]; then
|
||||||
grub_setup="${sbindir}/`echo grub-sparc64-setup | sed ${transform}`"
|
grub_setup="${sbindir}/`echo grub-sparc64-setup | sed ${transform}`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|
if test "x$install_device" = x && ([ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] \
|
||||||
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
|
|| [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ]); then
|
||||||
gettext "Install device isn't specified." 1>&2
|
gettext "Install device isn't specified." 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|
if ! ([ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] \
|
||||||
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] \
|
|| [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] \
|
||||||
|| [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] \
|
|| [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "powerpc-ieee1275" ] \
|
||||||
|| [ "${target_cpu}-${platform}" = "mips-arc" ]); then
|
|| [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "mips-arc" ]); then
|
||||||
install_device=
|
install_device=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -306,7 +348,7 @@ device_map="${grubdir}/device.map"
|
||||||
|
|
||||||
|
|
||||||
# Check if GRUB is installed.
|
# Check if GRUB is installed.
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then
|
||||||
set $grub_setup dummy
|
set $grub_setup dummy
|
||||||
if test -f "$1"; then
|
if test -f "$1"; then
|
||||||
:
|
:
|
||||||
|
@ -324,7 +366,7 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$platform" = xefi ]; then
|
if [ x"$grub_modinfo_platform" = xefi ]; then
|
||||||
# Find the EFI System Partition.
|
# Find the EFI System Partition.
|
||||||
efidir=
|
efidir=
|
||||||
if test -d "${bootdir}/efi"; then
|
if test -d "${bootdir}/efi"; then
|
||||||
|
@ -370,7 +412,7 @@ if [ x"$platform" = xefi ]; then
|
||||||
# from them. The image must always reside under /EFI/BOOT, and it
|
# from them. The image must always reside under /EFI/BOOT, and it
|
||||||
# must have a specific file name depending on the architecture.
|
# must have a specific file name depending on the architecture.
|
||||||
efi_distributor=BOOT
|
efi_distributor=BOOT
|
||||||
case "$target_cpu" in
|
case "$grub_modinfo_target_cpu" in
|
||||||
i386)
|
i386)
|
||||||
efi_file=BOOTIA32.EFI ;;
|
efi_file=BOOTIA32.EFI ;;
|
||||||
x86_64)
|
x86_64)
|
||||||
|
@ -384,7 +426,7 @@ if [ x"$platform" = xefi ]; then
|
||||||
else
|
else
|
||||||
# It is convenient for each architecture to have a different
|
# It is convenient for each architecture to have a different
|
||||||
# efi_file, so that different versions can be installed in parallel.
|
# efi_file, so that different versions can be installed in parallel.
|
||||||
case "$target_cpu" in
|
case "$grub_modinfo_target_cpu" in
|
||||||
i386)
|
i386)
|
||||||
efi_file=grubia32.efi ;;
|
efi_file=grubia32.efi ;;
|
||||||
x86_64)
|
x86_64)
|
||||||
|
@ -413,7 +455,7 @@ fi
|
||||||
|
|
||||||
# Create the GRUB directory if it is not present.
|
# Create the GRUB directory if it is not present.
|
||||||
mkdir -p "$grubdir" || exit 1
|
mkdir -p "$grubdir" || exit 1
|
||||||
mkdir -p "$grubdir/${target_cpu}-$platform" || exit 1
|
mkdir -p "$grubdir/${grub_modinfo_target_cpu}-$grub_modinfo_platform" || exit 1
|
||||||
|
|
||||||
# If --recheck is specified, remove the device map, if present.
|
# If --recheck is specified, remove the device map, if present.
|
||||||
if test $recheck = yes; then
|
if test $recheck = yes; then
|
||||||
|
@ -434,18 +476,18 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the GRUB images to the GRUB directory.
|
# Copy the GRUB images to the GRUB directory.
|
||||||
for file in "${grubdir}"/*.mod "${grubdir}"/*.lst "${grubdir}"/*.img "${grubdir}"/efiemu??.o "${grubdir}"/${target_cpu}-$platform/*.mod "${grubdir}"/${target_cpu}-$platform/*.lst "${grubdir}"/${target_cpu}-$platform/*.img "${grubdir}"/${target_cpu}-$platform/efiemu??.o; do
|
for file in "${grubdir}"/*.mod "${grubdir}"/*.lst "${grubdir}"/*.img "${grubdir}"/efiemu??.o "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/*.mod "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/*.lst "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/*.img "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/efiemu??.o; do
|
||||||
if test -f "$file" && [ "`basename $file`" != menu.lst ]; then
|
if test -f "$file" && [ "`basename $file`" != menu.lst ]; then
|
||||||
rm -f "$file" || exit 1
|
rm -f "$file" || exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
for file in "${pkglibdir}"/*.mod "${pkglibdir}"/*.lst; do
|
for file in "${source_dir}"/*.mod "${source_dir}"/*.lst; do
|
||||||
cp -f "$file" "${grubdir}/${target_cpu}-$platform" || exit 1
|
cp -f "$file" "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" || exit 1
|
||||||
done
|
done
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then
|
||||||
for file in "${pkglibdir}"/*.img "${pkglibdir}"/efiemu??.o; do
|
for file in "${source_dir}"/*.img "${source_dir}"/efiemu??.o; do
|
||||||
if test -f "$file"; then
|
if test -f "$file"; then
|
||||||
cp -f "$file" "${grubdir}/${target_cpu}-$platform" || exit 1
|
cp -f "$file" "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" || exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -468,7 +510,7 @@ if test -f "${pkgdatadir}"/unicode.pf2; then
|
||||||
cp "${pkgdatadir}"/unicode.pf2 "${grubdir}"/fonts
|
cp "${pkgdatadir}"/unicode.pf2 "${grubdir}"/fonts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_path_readable_by_grub "${grubdir}/${target_cpu}-$platform" || (echo "${grubdir}" not readable 1>&2 ; exit 1)
|
is_path_readable_by_grub "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" || (echo "${grubdir}" not readable 1>&2 ; exit 1)
|
||||||
|
|
||||||
# Write device to a variable so we don't have to traverse /dev every time.
|
# Write device to a variable so we don't have to traverse /dev every time.
|
||||||
grub_device="`"$grub_probe" --device-map="${device_map}" --target=device "${grubdir}"`" || exit 1
|
grub_device="`"$grub_probe" --device-map="${device_map}" --target=device "${grubdir}"`" || exit 1
|
||||||
|
@ -510,7 +552,7 @@ fi
|
||||||
|
|
||||||
if [ "x$disk_module" = xnative ]; then
|
if [ "x$disk_module" = xnative ]; then
|
||||||
disk_module="pata ahci ohci"
|
disk_module="pata ahci ohci"
|
||||||
if [ "x$target_cpu" = "xi386" ] || [ "x$target_cpu" = "xx86_64" ]; then
|
if [ "x$grub_modinfo_target_cpu" = "xi386" ] || [ "x$grub_modinfo_target_cpu" = "xx86_64" ]; then
|
||||||
disk_module="$disk_module uhci"
|
disk_module="$disk_module uhci"
|
||||||
fi
|
fi
|
||||||
disk_module="$disk_module usbms"
|
disk_module="$disk_module usbms"
|
||||||
|
@ -528,11 +570,11 @@ fi
|
||||||
prefix_drive=
|
prefix_drive=
|
||||||
config_opt=
|
config_opt=
|
||||||
|
|
||||||
rm -f "${grubdir}/${target_cpu}-$platform/load.cfg"
|
rm -f "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg"
|
||||||
|
|
||||||
if [ "x${debug_image}" != x ]; then
|
if [ "x${debug_image}" != x ]; then
|
||||||
echo "set debug='${debug_image}'" >> "${grubdir}/${target_cpu}-$platform/load.cfg"
|
echo "set debug='${debug_image}'" >> "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg"
|
||||||
config_opt="-c ${grubdir}/${target_cpu}-$platform/load.cfg "
|
config_opt="-c ${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x${devabstraction_module}" = "x" ] ; then
|
if [ "x${devabstraction_module}" = "x" ] ; then
|
||||||
|
@ -549,7 +591,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
||||||
# Strip partition number
|
# Strip partition number
|
||||||
grub_partition="`echo "${grub_drive}" | sed -e 's/^(\(\([^,\\\\]\|\\\\\\\\\|\\\\,\)*\)\(\(,[a-zA-Z0-9]*\)*\))$/\3/'`"
|
grub_partition="`echo "${grub_drive}" | sed -e 's/^(\(\([^,\\\\]\|\\\\\\\\\|\\\\,\)*\)\(\(,[a-zA-Z0-9]*\)*\))$/\3/'`"
|
||||||
grub_drive="`echo "${grub_drive}" | sed -e 's/^(\(\([^,\\\\]\|\\\\\\\\\|\\\\,\)*\)\(\(,[a-zA-Z0-9]*\)*\))$/\1/'`"
|
grub_drive="`echo "${grub_drive}" | sed -e 's/^(\(\([^,\\\\]\|\\\\\\\\\|\\\\,\)*\)\(\(,[a-zA-Z0-9]*\)*\))$/\1/'`"
|
||||||
if ([ "x$disk_module" != x ] && [ "x$disk_module" != xbiosdisk ]) || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${platform}" != x"ieee1275" ]); then
|
if ([ "x$disk_module" != x ] && [ "x$disk_module" != xbiosdisk ]) || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$grub_modinfo_platform" != xefi ] && [ "x$grub_modinfo_platform" != xpc ] && [ x"${grub_modinfo_platform}" != x"ieee1275" ]); then
|
||||||
# generic method (used on coreboot and ata mod)
|
# generic method (used on coreboot and ata mod)
|
||||||
uuid=
|
uuid=
|
||||||
if [ x"$force_file_id" != xy ]; then
|
if [ x"$force_file_id" != xy ]; then
|
||||||
|
@ -558,31 +600,31 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
||||||
|
|
||||||
if [ x"$disk_module" != x ] && [ x"$disk_module" != xbiosdisk ]; then
|
if [ x"$disk_module" != x ] && [ x"$disk_module" != xbiosdisk ]; then
|
||||||
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=baremetal_hints --device`"
|
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=baremetal_hints --device`"
|
||||||
elif [ x"$platform" = xpc ]; then
|
elif [ x"$grub_modinfo_platform" = xpc ]; then
|
||||||
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=bios_hints --device`"
|
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=bios_hints --device`"
|
||||||
elif [ x"$platform" = xefi ]; then
|
elif [ x"$grub_modinfo_platform" = xefi ]; then
|
||||||
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=efi_hints --device`"
|
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=efi_hints --device`"
|
||||||
elif [ x"$platform" = xieee1275 ]; then
|
elif [ x"$grub_modinfo_platform" = xieee1275 ]; then
|
||||||
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=ieee1275_hints --device`"
|
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=ieee1275_hints --device`"
|
||||||
elif [ x"$platform" = xloongson ] || [ x"$platform" = xqemu ] || [ x"$platform" = xcoreboot ] || [ x"$platform" = xmultiboot ] || [ x"$platform" = xqemu-mips ]; then
|
elif [ x"$grub_modinfo_platform" = xloongson ] || [ x"$grub_modinfo_platform" = xqemu ] || [ x"$grub_modinfo_platform" = xcoreboot ] || [ x"$grub_modinfo_platform" = xmultiboot ] || [ x"$grub_modinfo_platform" = xqemu-mips ]; then
|
||||||
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=baremetal_hints --device`"
|
hints="`echo "${grub_device}" | xargs "$grub_probe" --device-map="${device_map}" --target=baremetal_hints --device`"
|
||||||
else
|
else
|
||||||
gettext "No hints available for your platform. Expect reduced performance" 1>&2
|
gettext "No hints available for your grub_modinfo_platform. Expect reduced performance" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
hints=
|
hints=
|
||||||
fi
|
fi
|
||||||
if [ x"$uuid" != x ]; then
|
if [ x"$uuid" != x ]; then
|
||||||
echo "search.fs_uuid ${uuid} root $hints " >> "${grubdir}/${target_cpu}-$platform/load.cfg"
|
echo "search.fs_uuid ${uuid} root $hints " >> "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg"
|
||||||
search_module=search_fs_uuid
|
search_module=search_fs_uuid
|
||||||
else
|
else
|
||||||
mkdir -p "${grubdir}/uuid"
|
mkdir -p "${grubdir}/uuid"
|
||||||
file="`mktemp "${grubdir}/uuid/XXXXXXXXXXXXXXXXXXXXXXXXX"`"
|
file="`mktemp "${grubdir}/uuid/XXXXXXXXXXXXXXXXXXXXXXXXX"`"
|
||||||
relfile="`${grub_mkrelpath} "$file"`"
|
relfile="`${grub_mkrelpath} "$file"`"
|
||||||
echo "search.file '${relfile}' root $hints " >> "${grubdir}/${target_cpu}-$platform/load.cfg"
|
echo "search.file '${relfile}' root $hints " >> "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg"
|
||||||
search_module=search_fs_file
|
search_module=search_fs_file
|
||||||
fi
|
fi
|
||||||
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/${target_cpu}-$platform/load.cfg"
|
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg"
|
||||||
config_opt="-c ${grubdir}/${target_cpu}-$platform/load.cfg "
|
config_opt="-c ${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg "
|
||||||
modules="$modules $search_module"
|
modules="$modules $search_module"
|
||||||
else
|
else
|
||||||
# we need to hardcode the partition number in the core image's prefix.
|
# we need to hardcode the partition number in the core image's prefix.
|
||||||
|
@ -596,21 +638,21 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
||||||
else
|
else
|
||||||
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
|
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
|
||||||
for uuid in "`echo "${grub_device}" | xargs "${grub_probe}" --target=cryptodisk_uuid --device`"; do
|
for uuid in "`echo "${grub_device}" | xargs "${grub_probe}" --target=cryptodisk_uuid --device`"; do
|
||||||
echo "cryptomount -u $uuid" >> "${grubdir}/${target_cpu}-$platform/load.cfg"
|
echo "cryptomount -u $uuid" >> "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg"
|
||||||
done
|
done
|
||||||
config_opt="-c ${grubdir}/${target_cpu}-$platform/load.cfg "
|
config_opt="-c ${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/load.cfg "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prefix_drive=`"$grub_probe" --device-map="${device_map}" --target=drive --device "${grub_device}"` || exit 1
|
prefix_drive=`"$grub_probe" --device-map="${device_map}" --target=drive --device "${grub_device}"` || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${target_cpu}-${platform}" in
|
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
|
||||||
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-raw ;;
|
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-raw ;;
|
||||||
mipsel-loongson) mkimage_target=mipsel-loongson-elf ;;
|
mipsel-loongson) mkimage_target=mipsel-loongson-elf ;;
|
||||||
*) mkimage_target="${target_cpu}-${platform}" ;;
|
*) mkimage_target="${grub_modinfo_target_cpu}-${grub_modinfo_platform}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "${target_cpu}-${platform}" in
|
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
|
||||||
i386-efi | x86_64-efi) imgext=efi ;;
|
i386-efi | x86_64-efi) imgext=efi ;;
|
||||||
mipsel-loongson | i386-coreboot | i386-multiboot | i386-ieee1275 \
|
mipsel-loongson | i386-coreboot | i386-multiboot | i386-ieee1275 \
|
||||||
| powerpc-ieee1275) imgext=elf ;;
|
| powerpc-ieee1275) imgext=elf ;;
|
||||||
|
@ -618,24 +660,24 @@ case "${target_cpu}-${platform}" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
"$grub_mkimage" ${config_opt} -d "${pkglibdir}" -O ${mkimage_target} --output="${grubdir}/${target_cpu}-$platform/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
|
"$grub_mkimage" ${config_opt} -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
|
||||||
|
|
||||||
# Backward-compatibility kludges
|
# Backward-compatibility kludges
|
||||||
if [ "${target_cpu}-${platform}" = "mipsel-loongson" ]; then
|
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "mipsel-loongson" ]; then
|
||||||
cp "${grubdir}/${target_cpu}-$platform/core.${imgext}" "${bootdir}"/grub.elf
|
cp "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" "${bootdir}"/grub.elf
|
||||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-ieee1275" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "powerpc-ieee1275" ]; then
|
||||||
cp "${grubdir}/${target_cpu}-$platform/core.${imgext}" "${grubdir}/grub"
|
cp "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" "${grubdir}/grub"
|
||||||
elif [ "${target_cpu}-${platform}" = "i386-efi" ] || [ "${target_cpu}-${platform}" = "x86_64-efi" ]; then
|
elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-efi" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "x86_64-efi" ]; then
|
||||||
"$grub_mkimage" ${config_opt} -d "${pkglibdir}" -O ${mkimage_target} --output="${grubdir}/${target_cpu}-$platform/grub.efi" --prefix="" $modules || exit 1
|
"$grub_mkimage" ${config_opt} -d "${source_dir}" -O ${mkimage_target} --output="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/grub.efi" --prefix="" $modules || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Perform the platform-dependent install
|
# Perform the grub_modinfo_platform-dependent install
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then
|
||||||
# Now perform the installation.
|
# Now perform the installation.
|
||||||
"$grub_setup" ${allow_floppy} ${setup_verbose} ${setup_force} --directory="${grubdir}/${target_cpu}-$platform" \
|
"$grub_setup" ${allow_floppy} ${setup_verbose} ${setup_force} --directory="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" \
|
||||||
--device-map="${device_map}" "${install_device}" || exit 1
|
--device-map="${device_map}" "${install_device}" || exit 1
|
||||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-ieee1275" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "powerpc-ieee1275" ]; then
|
||||||
if [ x"$update_nvram" = xyes ]; then
|
if [ x"$update_nvram" = xyes ]; then
|
||||||
ofpathname="`which ofpathname`"
|
ofpathname="`which ofpathname`"
|
||||||
nvsetenv="`which nvsetenv`"
|
nvsetenv="`which nvsetenv`"
|
||||||
|
@ -662,10 +704,10 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla
|
||||||
}
|
}
|
||||||
|
|
||||||
# Point boot-device at the new grub install
|
# Point boot-device at the new grub install
|
||||||
boot_device="$ofpath:$partno,"`"$grub_mkrelpath" "${grubdir}/${target_cpu}-$platform/core.${imgext}" | sed 's,/,\\\\,g'`
|
boot_device="$ofpath:$partno,"`"$grub_mkrelpath" "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" | sed 's,/,\\\\,g'`
|
||||||
|
|
||||||
# If a install device is defined, copy the core.elf to PReP partition.
|
# If a install device is defined, copy the core.elf to PReP partition.
|
||||||
if [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] \
|
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "powerpc-ieee1275" ] \
|
||||||
&& [ -n "${install_device}" ]; then
|
&& [ -n "${install_device}" ]; then
|
||||||
if [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t msdos_parttype)" != "41" ]; then
|
if [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t msdos_parttype)" != "41" ]; then
|
||||||
gettext "The chosen partition is not a PReP partition." 1>&2
|
gettext "The chosen partition is not a PReP partition." 1>&2
|
||||||
|
@ -676,7 +718,7 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla
|
||||||
if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')" = ELF ] || [ $(cmp /dev/zero "${install_device}" &>/dev/null) ]; then
|
if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')" = ELF ] || [ $(cmp /dev/zero "${install_device}" &>/dev/null) ]; then
|
||||||
# Change boot device to the harddisk root
|
# Change boot device to the harddisk root
|
||||||
boot_device="$ofpath"
|
boot_device="$ofpath"
|
||||||
dd if="${grubdir}/${target_cpu}-$platform/core.${imgext}" of="${install_device}" status=noxfer || {
|
dd if="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" of="${install_device}" status=noxfer || {
|
||||||
gettext "Failed to copy Grub to the PReP partition." 1>&2
|
gettext "Failed to copy Grub to the PReP partition." 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -698,15 +740,15 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
elif [ x"${target_cpu}-${platform}" = xmips-arc ]; then
|
elif [ x"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = xmips-arc ]; then
|
||||||
dvhtool -d "${install_device}" --unix-to-vh "{grubdir}/${target_cpu}-$platform/core.${imgext}" grub
|
dvhtool -d "${install_device}" --unix-to-vh "{grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" grub
|
||||||
gettext "You will have to set SystemPartition and OSLoader manually." 1>&2
|
gettext "You will have to set SystemPartition and OSLoader manually." 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
elif [ x"$platform" = xefi ]; then
|
elif [ x"$grub_modinfo_platform" = xefi ]; then
|
||||||
cp "${grubdir}/${target_cpu}-$platform/core.${imgext}" "${efidir}/${efi_file}"
|
cp "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" "${efidir}/${efi_file}"
|
||||||
# For old macs. Suggested by Peter Jones.
|
# For old macs. Suggested by Peter Jones.
|
||||||
if [ x$target_cpu = xi386 ]; then
|
if [ x$grub_modinfo_target_cpu = xi386 ]; then
|
||||||
cp "${grubdir}/${target_cpu}-$platform/core.${imgext}" "${efidir}/boot.efi"
|
cp "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" "${efidir}/boot.efi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to make this image bootable using the EFI Boot Manager, if available.
|
# Try to make this image bootable using the EFI Boot Manager, if available.
|
||||||
|
|
Loading…
Reference in a new issue