On Sun, Oct 03, 2010 at 07:42:10PM -0400, Daniel Kahn Gillmor wrote: > On 09/21/2010 06:51 AM, Colin Watson wrote: > > Does the attached patch work? It's a partial resync with the main > > version of grub-install, anticipating the next snapshot/release where > > all the different grub-installs are merged into a single version. > > hrm, no, this doesn't work. i get: > > >> 0 attica:/usr/sbin# grub-install /dev/hda > >> /usr/sbin/grub-install: 229: make_system_path_relative_to_its_root: not > >> found > >> 1 attica:/usr/sbin#
Whoops, I forgot a piece. Try this one. -- Colin Watson [cjwat...@debian.org]
Description: Backport ieee1275 grub-install improvements We need to encode a prefix in the generated image, otherwise it will need manual help to find the boot directory. Author: Daniel Kahn Gillmor <d...@fifthhorseman.net> Author: Colin Watson <cjwat...@debian.org> Bug-Debian: http://bugs.debian.org/597538 Forwarded: not-needed Last-Update: 2010-09-21 Index: b/util/ieee1275/grub-install.in =================================================================== --- a/util/ieee1275/grub-install.in +++ b/util/ieee1275/grub-install.in @@ -146,6 +146,9 @@ esac done +# for make_system_path_relative_to_its_root() +. ${libdir}/grub/grub-mkconfig_lib + # If the debugging feature is enabled, print commands. if test $debug = yes; then set -x @@ -156,6 +159,8 @@ grubdir=${bootdir}/`echo grub | sed ${transform}` device_map=${grubdir}/device.map +grub_probe="${grub_probe} --device-map=${device_map}" + set $grub_mkimage dummy if test -f "$1"; then : @@ -196,12 +201,15 @@ cp -f $file ${grubdir} || exit 1 done +# Write device to a variable so we don't have to traverse /dev every time. +grub_device=`$grub_probe --target=device ${grubdir}` || exit 1 + if ! test -f ${grubdir}/grubenv; then $grub_editenv ${grubdir}/grubenv create fi # Create the core image. First, auto-detect the filesystem module. -fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}` +fs_module=`$grub_probe --target=fs --device ${grub_device}` if test "x$fs_module" = x -a "x$modules" = x; then echo "Auto-detection of a filesystem module failed." 1>&2 echo "Please specify the module with the option \`--modules' explicitly." 1>&2 @@ -212,17 +220,66 @@ # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). partmap_module= -for x in `$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`; do +for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do partmap_module="$partmap_module part_$x"; done # Device abstraction module, if any (lvm, raid). -devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}` +devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` modules="$modules $fs_module $partmap_module $devabstraction_module" +relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1 +if [ "x${relative_grubdir}" = "x" ] ; then + relative_grubdir=/ +fi + +prefix_drive= +config_opt= + +rm -f ${grubdir}/load.cfg + +if [ "x${devabstraction_module}" = "x" ] ; then + if [ x"${install_device}" != x ]; then + if echo "${install_device}" | grep -qx "(.*)" ; then + install_drive="${install_device}" + else + install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1 + fi + install_drive="`echo ${install_drive} | sed -e s/,[a-z0-9,]*//g`" + fi + grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1 + + # Strip partition number + grub_drive="`echo ${grub_drive} | sed -e s/,[a-z0-9,]*//g`" + if [ "$disk_module" = ata ] ; then + # generic method (used on coreboot and ata mod) + uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" + if [ "x${uuid}" = "x" ] ; then + echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + exit 1 + fi + echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg + echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg + config_opt="-c ${grubdir}/load.cfg " + modules="$modules search_fs_uuid" + elif [ "x${grub_drive}" != "x${install_drive}" ] ; then + uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" + if [ "x${uuid}" = "x" ] ; then + echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + exit 1 + fi + echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg + echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg + config_opt="-c ${grubdir}/load.cfg " + modules="$modules search_fs_uuid" + fi +else + prefix_drive=`$grub_probe --target=drive --device ${grub_device}` || exit 1 +fi + # Now perform the installation. -"$grub_mkimage" -O ${target_cpu}-ieee1275 --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1 +"$grub_mkimage" ${config_opt} -O ${target_cpu}-ieee1275 --directory=${pkglibdir} --output=${grubdir}/grub --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 if test $update_nvram = yes; then set $ofpathname dummy