suppress error message "/grub2/locale/en.mo.gz not found"
PATCH 1/1 suppress error message "/grub2/locale/en.mo.gz not found"
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
--- util/grub.d/00_header.in | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
util/grub.d/00_header.in +7 -3
@@ -182,10 +182,14 @@ EOF # Gettext variables and module if [ "x${LANG}" != "xC" ] ; then +# We don't insert gettext module if message catalog file missing +# To prevent error message from being logged (bnc#771393) cat << EOF - set locale_dir=\$prefix/locale - set lang=${grub_lang} - insmod gettext + if [ -f "\$prefix/locale/${grub_lang}.mo" ] ; then + set locale_dir=\$prefix/locale + set lang=${grub_lang} + insmod gettext + fi EOF fi
Signature · 1 line
1.7.3.4
Quoted 13 lines · Michael Chang
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
Signed-off-by Michael Chang <[email protected]>--- util/grub.d/00_header.in | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)util/grub.d/00_header.in +0
-0
util/grub.d/00_header.in EOF · line 184
Quoted 3 lines
util/grub.d/00_header.in +0
-0@@ -182,10 +182,14 @@ EOF # Gettext variables and module if [ "x${LANG}" != "xC" ] ; then
Couldn't / sholdn't this check be replaced by the new check you introduce?
util/grub.d/00_header.in EOF · line 186
Quoted 2 lines
util/grub.d/00_header.in +2
-0+# We don't insert gettext module if message catalog file missing +# To prevent error message from being logged (bnc#771393)
That seems like a reference to some (internal Suse?) bugtracker? To me it is https://bugzilla.redhat.com/show_bug.cgi?id=817187 , but I guess https://savannah.gnu.org/bugs/?35880 is the best reference.
util/grub.d/00_header.in EOF · line 194
Quoted 11 lines
util/grub.d/00_header.in +5
-3cat << EOF - set locale_dir=\$prefix/locale - set lang=${grub_lang} - insmod gettext + if [ -f "\$prefix/locale/${grub_lang}.mo" ] ; then + set locale_dir=\$prefix/locale + set lang=${grub_lang} + insmod gettext + fi EOF fi
I'm +1 for the principle, but does it really work for real world locales like de_DE which will use de.mo on runtime?
I would guess that it also should handle all the logic in gettext.c grub_gettext_init_ext() and grub_mofile_open_lang() and how these functions are invoked: .gz extension, _CC stripping and primary/secondary locale_dir.
(I would prefer if all this processing could be done in mkconfig instead of on runtime, but I guess the desire for backward compatibility prevents that.)
(It also seems to me like the current system lacks support for fallback from ll_CC@unknownvariant to ll_CC and ll. I don't know if that is a real problem.)
/Mads
В Пн., 24/09/2012 в 11:37 +0200, Mads Kiilerich пишет:
Quoted 39 lines · Michael Chang
Quoted 13 lines
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
Signed-off-by Michael Chang <[email protected]>--- util/grub.d/00_header.in | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)util/grub.d/00_header.in +0
-0util/grub.d/00_header.in EOF · line 184
Quoted 3 lines
util/grub.d/00_header.in +0
-0@@ -182,10 +182,14 @@ EOF # Gettext variables and module if [ "x${LANG}" != "xC" ] ; thenCouldn't / sholdn't this check be replaced by the new check you introduce?
util/grub.d/00_header.in EOF · line 186
Quoted 2 lines
util/grub.d/00_header.in +2
-0+# We don't insert gettext module if message catalog file missing +# To prevent error message from being logged (bnc#771393)That seems like a reference to some (internal Suse?) bugtracker? To me it is https://bugzilla.redhat.com/show_bug.cgi?id=817187 , but I guess
https://savannah.gnu.org/bugs/?35880 is the best reference.util/grub.d/00_header.in EOF · line 194
Quoted 11 lines
util/grub.d/00_header.in +5
-3cat << EOF - set locale_dir=\$prefix/locale - set lang=${grub_lang} - insmod gettext + if [ -f "\$prefix/locale/${grub_lang}.mo" ] ; then + set locale_dir=\$prefix/locale + set lang=${grub_lang} + insmod gettext + fi EOF fi
Quoted 3 lines
I'm +1 for the principle, but does it really work for real world locales like
de_DEwhich will use de.mo on runtime?
No. It does not, except for zh_CN and zh_TW.
Quoted 5 lines
I would guess that it also should handle all the logic in
gettext.cgrub_gettext_init_ext()andgrub_mofile_open_lang()and how these functions are invoked: .gz extension,_CCstripping and primary/secondarylocale_dir.
What about removing this error message altogether? Under OS gettext does not complaint when catalog does not exist; why should it do it here? Having English interface is enough indication that message catalog was not found.
-andrey
2012/9/24 Mads Kiilerich <[email protected]>:
Quoted 10 lines · Michael Chang
Quoted 9 lines
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
Signed-off-by Michael Chang <[email protected]>--- util/grub.d/00_header.in | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
Quoted 10 lines
util/grub.d/00_header.in EOF · line 183
Quoted 7 lines
util/grub.d/00_header.in +0
-0@@ -182,10 +182,14 @@ EOF # Gettext variables and module if [ "x${LANG}" != "xC" ] ; thenCouldn't / sholdn't this check be replaced by the new check you introduce?
Yes. It should be done in mkconfig, which is in general better than in run-time. The problem is that I don't know how to get $prefix environment grub2 set implicitly at runtime. (It seems to be retrieved somewhere from grub module header but I can't tell in exact).
Quoted 9 lines
util/grub.d/00_header.in EOF · line 186
Quoted 4 lines
util/grub.d/00_header.in +2
-0+# We don't insert gettext module if message catalog file missing +# To prevent error message from being logged (bnc#771393)That seems like a reference to some (internal Suse?) bugtracker? To me it is
https://bugzilla.redhat.com/show_bug.cgi?id=817187 , but I guess
https://savannah.gnu.org/bugs/?35880 is the best reference.
The bug is public report against openSUSE 12.2 :
https://bugzilla.novell.com/show_bug.cgi?id=771393
Quoted 15 lines
util/grub.d/00_header.in EOF · line 194
Quoted 13 lines
util/grub.d/00_header.in +5
-3cat << EOF - set locale_dir=\$prefix/locale - set lang=${grub_lang} - insmod gettext + if [ -f "\$prefix/locale/${grub_lang}.mo" ] ; then + set locale_dir=\$prefix/locale + set lang=${grub_lang} + insmod gettext + fi EOF fi
Quoted 2 lines
I'm +1 for the principle, but does it really work for real world locales like
de_DEwhich will use de.mo on runtime?
No it doesn't. :(
Quoted 4 lines
I would guess that it also should handle all the logic in
gettext.cgrub_gettext_init_ext()andgrub_mofile_open_lang()and how these functions are invoked: .gz extension,_CCstripping and primary/secondarylocale_dir.
You're right. All logics in gettext.c should be considered and implemented in the patch, otherwise it would cause regressions.
Quoted 8 lines
(I would prefer if all this processing could be done in mkconfig instead of on runtime, but I guess the desire for backward compatibility prevents that.)
(It also seems to me like the current system lacks support for fallback from ll_CC@unknownvariant to
ll_CCand ll. I don't know if that is a real problem.)
Thank you for your great review here, and please forgive my ignorant not checking the gettext.c before working the patch. :)
Regards,
Michael
Quoted 8 lines
/Mads
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
2012/9/25 Andrey Borzenkov <[email protected]>:
Quoted 52 lines
В Пн., 24/09/2012 в 11:37 +0200, Mads Kiilerich пишет:
Quoted 39 lines · Michael Chang
Quoted 13 lines
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
Signed-off-by Michael Chang <[email protected]>--- util/grub.d/00_header.in | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)util/grub.d/00_header.in +0
-0util/grub.d/00_header.in EOF · line 184
Quoted 3 lines
util/grub.d/00_header.in +0
-0@@ -182,10 +182,14 @@ EOF # Gettext variables and module if [ "x${LANG}" != "xC" ] ; thenCouldn't / sholdn't this check be replaced by the new check you introduce?
util/grub.d/00_header.in EOF · line 186
Quoted 2 lines
util/grub.d/00_header.in +2
-0+# We don't insert gettext module if message catalog file missing +# To prevent error message from being logged (bnc#771393)That seems like a reference to some (internal Suse?) bugtracker? To me it is https://bugzilla.redhat.com/show_bug.cgi?id=817187 , but I guess
https://savannah.gnu.org/bugs/?35880 is the best reference.util/grub.d/00_header.in EOF · line 194
Quoted 11 lines
util/grub.d/00_header.in +5
-3cat << EOF - set locale_dir=\$prefix/locale - set lang=${grub_lang} - insmod gettext + if [ -f "\$prefix/locale/${grub_lang}.mo" ] ; then + set locale_dir=\$prefix/locale + set lang=${grub_lang} + insmod gettext + fi EOF fiQuoted 3 lines
I'm +1 for the principle, but does it really work for real world locales like
de_DEwhich will use de.mo on runtime?No. It does not, except for
zh_CNandzh_TW.Quoted 5 lines
I would guess that it also should handle all the logic in
gettext.cgrub_gettext_init_ext()andgrub_mofile_open_lang()and how these functions are invoked: .gz extension,_CCstripping and primary/secondarylocale_dir.
Quoted 4 lines
What about removing this error message altogether? Under OS gettext does not complaint when catalog does not exist; why should it do it here? Having English interface is enough indication that message catalog was not found.
I agree with you. IMHO the problem is it's not emitted directly from gettext module but from common underlying fs level, removing it would lead to other message which is fatal be ignored as well.
Another question is : Is there any other good method offered by grub2 to check the files existence that we could test before calling grub_file_open() in gettext.c ? Anybody has good idea on this ?
Thanks,
Michael
Quoted 4 lines
-andrey
В Вт., 25/09/2012 в 12:46 +0800, Michael Chang пишет:
Quoted 5 lines
2012/9/25 Andrey Borzenkov <[email protected]>:
Quoted 4 lines
В Пн., 24/09/2012 в 11:37 +0200, Mads Kiilerich пишет:
Quoted 3 lines · Michael Chang
Quoted 2 lines
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
[...]
Quoted 10 lines
Quoted 5 lines
What about removing this error message altogether? Under OS gettext does not complaint when catalog does not exist; why should it do it here? Having English interface is enough indication that message catalog was not found.
I agree with you. IMHO the problem is it's not emitted directly from gettext module but from common underlying fs level, removing it would lead to other message which is fatal be ignored as well.
As far as I can tell it is emitted explicitly when setting "lang":
grub-core/gettext/gettext.c:grub_gettext_env_write_lang()
grub_err_t err;
err = grub_gettext_init_ext (&main_context, val, grub_env_get
("locale_dir"),
grub_env_get ("prefix"));
if (err)
grub_print_error ();and later. There are some more places which also try to reload catalog.
May be this messages can be turned into debugging message instead of error.
-andrey
В Вт., 25/09/2012 в 19:24 +0400, Andrey Borzenkov пишет:
Quoted 22 lines
В Вт., 25/09/2012 в 12:46 +0800, Michael Chang пишет:
Quoted 5 lines
2012/9/25 Andrey Borzenkov <[email protected]>:
Quoted 4 lines
В Пн., 24/09/2012 в 11:37 +0200, Mads Kiilerich пишет:
Quoted 3 lines · Michael Chang
Quoted 2 lines
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
[...]
Quoted 10 lines
Quoted 5 lines
What about removing this error message altogether? Under OS gettext does not complaint when catalog does not exist; why should it do it here? Having English interface is enough indication that message catalog was not found.
I agree with you. IMHO the problem is it's not emitted directly from gettext module but from common underlying fs level, removing it would lead to other message which is fatal be ignored as well.
As far as I can tell it is emitted explicitly when setting "lang":
grub-core/gettext/gettext.c:grub_gettext_env_write_lang()
Quoted 9 lines
grub_err_terr;
err =grub_gettext_init_ext(&main_context, val,grub_env_get
("locale_dir"),grub_env_get ("prefix")); if (err) grub_print_error ();and later. There are some more places which also try to reload catalog.
Attached is prototype patch (tested) which suppresses error return from grub_text_init_ext(). Proper patch would need to also change function prototype, as its return value is now useless.
Quoted 3 lines
May be this messages can be turned into debugging message instead of error.
That I do not know how to do.
grub-core/gettext/gettext.c +6 -1
@@ -395,6 +395,9 @@ grub_gettext_init_ext (struct grub_getteif (!part1 || part1[0 ] ==0 )return 0 ; +/* It is not an error if message catalog does not exist */ +grub_error_push (); + err =grub_mofile_open_lang (ctx, part1, part2, locale);/* ll_CC didn't work, so try ll. */
@@ -412,7 +415,9 @@ grub_gettext_init_ext (struct grub_gettegrub_free (lang); } -return err; + +grub_error_pop (); +return 0 ; } static char *
Quoted 2 lines · Michael Chang
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
I already posted a patch against the gettext module itself with a similar rationale, which I think is a better place for this:
https://savannah.gnu.org/bugs/?35880
Signature · 1 line
Colin Watson [[email protected]]
Quoted 3 lines · Michael Chang
I agree with you. IMHO the problem is it's not emitted directly from gettext module but from common underlying fs level, removing it would lead to other message which is fatal be ignored as well.
That's incorrect; the gettext module is perfectly able to disregard errors from lower-level methods that it doesn't care about.
Quoted 3 lines
Another question is : Is there any other good method offered by grub2 to check the files existence that we could test before calling
grub_file_open()ingettext.c? Anybody has good idea on this ?
This is the wrong approach; you should try it and then handle errors, not look-before-you-leap.
Signature · 1 line
Colin Watson [[email protected]]
2012/9/26 Colin Watson <[email protected]>:
Quoted 7 lines · Michael Chang
Quoted 3 lines
I agree with you. IMHO the problem is it's not emitted directly from gettext module but from common underlying fs level, removing it would lead to other message which is fatal be ignored as well.
That's incorrect; the gettext module is perfectly able to disregard errors from lower-level methods that it doesn't care about.
I'd say I'm too careless in understanding how grub2 message logging. I see grub_error(...) and think it was logged to screen immediately after that function returns, which is completely wrong.
The error message and number are staging in the buffer and it's up to the module to use grub_print_error (...) to flush all pending messages to the screen. Nevertheless you could stack errors with push|pop, which is extremely useful as grub2 could be stacked by modules ..
Glad to know one more good and flexible design of grub2. :)
Thanks,
Michael
Quoted 16 lines
Quoted 4 lines
Another question is : Is there any other good method offered by grub2 to check the files existence that we could test before calling
grub_file_open()ingettext.c? Anybody has good idea on this ?This is the wrong approach; you should try it and then handle errors, not look-before-you-leap.
--
Colin Watson [[email protected]]_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines · Michael Chang
The error message and number are staging in the buffer and it's up to the module to use
grub_print_error(...) to flush all pending messages to the screen. Nevertheless you could stack errors with push|pop, which is extremely useful as grub2 could be stacked by modules ..
That is one way to do it, but it's also possible to clear errors you're not interested in without that. There's an "Error Handling" section in docs/grub-dev.texi which you may find useful.
Signature · 1 line
Colin Watson [[email protected]]
В Tue, 25 Sep 2012 22:52:29 +0100
Colin Watson <[email protected]> пишет:
Quoted 9 lines · Michael Chang
Quoted 2 lines
We don't insert gettext module if message catalog file missing to prevent error message from being logged.
I already posted a patch against the gettext module itself with a similar rationale, which I think is a better place for this:
Anything against applying this? Was used successfully in openSUSE for quite some time.