Skip to contentSkip to conversation

Config file generation failure on Linux

PATCH Grégoire Sutre 2 participants 6 messages Dec 30, 2009 – Jan 3, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

Config file generation with grub-mkconfig fails on Linux when grub is not installed in the same prefix as gettext, since the script util/grub.d/10_linux.in contains:

. ${bindir}/gettext.sh

A possible patch is given below, but there are surely other ways to deal with it. The patch simply falls back to echo instead of gettext if the gettext binary cannot be found.

Thanks for your time,

Grégoire

grub.d/10_linux.in renamed from grub.d/10_linux.in.orig +8 -3
@@ -22,7 +22,12 @@ bindir=@bindir@
 libdir=@libdir@
 . ${libdir}/grub/grub-mkconfig_lib
 
-. ${bindir}/gettext.sh
+if $(which gettext >/dev/null 2>/dev/null) ; then
+  gettext="gettext"
+else
+  gettext="echo"
+fi
+
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR=@localedir@
 
@@ -54,9 +59,9 @@ linux_entry ()
   recovery="$3"
   args="$4"
   if ${recovery} ; then
-    title="$(gettext "%s, with Linux %s (recovery mode)")"
+    title="$(${gettext} "%s, with Linux %s (recovery mode)")"
   else
-    title="$(gettext "%s, with Linux %s")"
+    title="$(${gettext} "%s, with Linux %s")"
   fi
   printf "menuentry \"${title}\" {\n" "${os}" "${version}"
   if [ -z "${prepare_boot_cache}" ]; then
#1 lore raw
Quoted 11 lines · Grégoire Sutre

Hi,

Config file generation with grub-mkconfig fails on Linux when grub is not installed in the same prefix as gettext, since the script util/grub.d/10_linux.in contains:

. ${bindir}/gettext.sh

A possible patch is given below, but there are surely other ways to deal with it. The patch simply falls back to echo instead of gettext if the gettext binary cannot be found.

It'd be better if this was an autoconf check.

Signature · 3 lines
Robert Millan

  "Be the change you want to see in the world" -- Gandhi
#2 lore raw

Re: Config file generation failure on Linux (gettext.sh)

Quoted 3 lines · Robert Millan
Quoted 1 line

A possible patch is given below, but there are surely other ways to deal with it. The patch simply falls back to echo instead of gettext if the gettext binary cannot be found.

It'd be better if this was an autoconf check.

You mean with an AC_PATH_PROG(GETTEXTBIN, gettext, echo) and substitute GETTEXTBIN in 10_linux?

But, in order to have a robust configuration script, it would still be desirable to check in 10_linux whether @GETTEXTBIN@ exists and revert to echo otherwise, wouldn't it?

Grégoire

#3 lore raw

Re: Config file generation failure on Linux (gettext.sh)

Quoted 2 lines · Grégoire Sutre

You mean with an AC_PATH_PROG(GETTEXTBIN, gettext, echo) and substitute GETTEXTBIN in 10_linux?

Yes.

Quoted 3 lines

But, in order to have a robust configuration script, it would still be desirable to check in 10_linux whether @GETTEXTBIN@ exists and revert to echo otherwise, wouldn't it?

As long as the script complains appropiately and exits non-zero if gettext was installed, I would consider it robust (keep in mind grub.cfg isn't touched at all unless all sub-scripts exit succesfuly).

Signature · 3 lines
Robert Millan

  "Be the change you want to see in the world" -- Gandhi
#4 lore raw

Re: Config file generation failure on Linux (gettext.sh)

Quoted 2 lines · Robert Millan

As long as the script complains appropiately and exits non-zero if gettext was installed, I would consider it robust (keep in mind grub.cfg isn't

    ^^^

I meant "wasn't" of course.

Signature · 3 lines
Robert Millan

  "Be the change you want to see in the world" -- Gandhi
#5 lore raw

Re: Config file generation failure on Linux (gettext.sh)

Quoted 6 lines · Robert Millan
Quoted 2 lines · Robert Millan

As long as the script complains appropiately and exits non-zero if gettext was installed, I would consider it robust (keep in mind grub.cfg isn't

    ^^^

I meant "wasn't" of course.

Ok, here is the new patch. This one also takes care of 10_kfreebsd, as it uses gettext in the same way as 10_linux. Please let me know if I missed something.

Thanks,

Grégoire

configure.ac renamed from configure.ac.orig +1 -0
@@ -179,6 +179,7 @@ test "x$GCC" = xyes || AC_MSG_ERROR([GCC
 
 AC_GNU_SOURCE
 AM_GNU_GETTEXT([external])
+AC_PATH_PROG([GETTEXTBIN], [gettext], [echo])
 AC_SYS_LARGEFILE
 
 # Identify characteristics of the host architecture.
grub.d/10_kfreebsd.in renamed from grub.d/10_kfreebsd.in.orig +7 -2
@@ -20,9 +20,14 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
 libdir=@libdir@
+gettext=@GETTEXTBIN@
 . ${libdir}/grub/grub-mkconfig_lib
 
-. ${bindir}/gettext.sh
+if [ "x${gettext}" != "xecho" ] && ! test -x "${gettext}" ; then
+  echo "10_kfreebsd: error: \`${gettext}' is missing." >&2
+  exit 1
+fi
+
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR=@localedir@
 
@@ -37,7 +42,7 @@ kfreebsd_entry ()
   version="$2"
   recovery="$3"	# not used yet
   args="$4"	# not used yet
-  title="$(gettext "%s, with kFreeBSD %s")"
+  title="$(${gettext} "%s, with kFreeBSD %s")"
   printf "menuentry \"${title}\" {\n" "${os}" "${version}"
   if [ -z "${prepare_boot_cache}" ]; then
     prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
grub.d/10_linux.in renamed from grub.d/10_linux.in.orig +8 -3
@@ -20,9 +20,14 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
 libdir=@libdir@
+gettext=@GETTEXTBIN@
 . ${libdir}/grub/grub-mkconfig_lib
 
-. ${bindir}/gettext.sh
+if [ "x${gettext}" != "xecho" ] && ! test -x "${gettext}" ; then
+  echo "10_linux: error: \`${gettext}' is missing." >&2
+  exit 1
+fi
+
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR=@localedir@
 
@@ -54,9 +59,9 @@ linux_entry ()
   recovery="$3"
   args="$4"
   if ${recovery} ; then
-    title="$(gettext "%s, with Linux %s (recovery mode)")"
+    title="$(${gettext} "%s, with Linux %s (recovery mode)")"
   else
-    title="$(gettext "%s, with Linux %s")"
+    title="$(${gettext} "%s, with Linux %s")"
   fi
   printf "menuentry \"${title}\" {\n" "${os}" "${version}"
   if [ -z "${prepare_boot_cache}" ]; then