From 2e610d6273875fb73626b062e2ae42cb9306a94d Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 11 May 2007 15:53:02 +0000 Subject: [PATCH] 2007-05-11 Robert Millan * util/update-grub.in: Create device.map if it doesn't already exist, before attempting to run grub-probe. Check for grub-probe and grub-mkdevicemap with the same code grub-install is using. Remove test mode. --- ChangeLog | 8 +++++++ util/update-grub.in | 52 ++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index aea205f17..7b5cef72d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-05-11 Robert Millan + + * util/update-grub.in: Create device.map if it doesn't already exist, + before attempting to run grub-probe. + Check for grub-probe and grub-mkdevicemap with the same code + grub-install is using. + Remove test mode. + 2007-05-09 Jeroen Dekkers * Makefile.in: Add the datarootdir autoconf variable. diff --git a/util/update-grub.in b/util/update-grub.in index c9f1601f7..7a8fe7736 100644 --- a/util/update-grub.in +++ b/util/update-grub.in @@ -19,11 +19,16 @@ transform="@program_transform_name@" +prefix=@prefix@ +exec_prefix=@exec_prefix@ +sbindir=@sbindir@ sysconfdir=@sysconfdir@ grub_prefix=`echo /boot/grub | sed ${transform}` grub_cfg=${grub_prefix}/grub.cfg update_grub_dir=${sysconfdir}/grub.d -test_mode=false + +grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` +grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` if [ "x$UID" = "x" ] ; then UID=`id -u` @@ -38,34 +43,31 @@ if [ "$1" = "-y" ] ; then echo "$0: warning: Ignoring -y option (no longer needed)." >&2 fi -if test -d ${update_grub_dir} ; then : ; else - if test -d ./grub.d ; then - update_grub_dir=./grub.d - test_mode=true - fi +set $grub_mkdevicemap dummy +if test -f "$1"; then + : +else + echo "$1: Not found." 1>&2 + exit 1 fi -found=false -old_IFS="$IFS" -IFS=: -for i in $PATH ; do - if test -x "$i/grub-probe" ; then - found=true - break - fi -done -IFS="$old_IFS" -if ${found} ; then : ; else - echo "$0: grub-probe not found in PATH." >&2 - exit 1 +set $grub_probe dummy +if test -f "$1"; then + : +else + echo "$1: Not found." 1>&2 + exit 1 fi -if ${test_mode} ; then : ; else - mkdir -p ${grub_prefix} - exec > ${grub_cfg}.new - chmod 444 ${grub_cfg}.new +mkdir -p ${grub_prefix} + +if test -e ${grub_prefix}/device.map ; then : ; else + grub-mkdevicemap fi +exec > ${grub_cfg}.new +chmod 444 ${grub_cfg}.new + if test -f ${sysconfdir}/default/grub ; then . ${sysconfdir}/default/grub fi @@ -100,8 +102,6 @@ for i in ${update_grub_dir}/* ; do done # none of the children aborted with error, install the new grub.cfg -if ${test_mode} ; then : ; else - mv ${grub_cfg}.new ${grub_cfg} -fi +mv ${grub_cfg}.new ${grub_cfg} echo "done" >&2