grub-install: locale depends on nls
PATCH 1/1 grub-install: locale depends on nls
With --disable-nls no locales exist.
Avoid runtime error by wrapping install logic inside ENABLE_NLS.
--- util/grub-install-common.c | 108 +++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 49 deletions(-)
util/grub-install-common.c +59 -49
@@ -725,13 +725,69 @@ grub_install_get_platform_platform (enum grub_install_plat platid)return platforms[platid].platform; } +static void +grub_install_copy_nls (const char *src,const char *dst) +{ +#if (defined (GRUB_UTIL ) && defined(ENABLE_NLS ) &&ENABLE_NLS ) +char *dst_locale; + + dst_locale =grub_util_path_concat (2 , dst,"locale" ); +grub_install_mkdir_p (dst_locale); +clean_grub_dir (dst_locale); + +if (install_locales.is_default) + { +char *srcd =grub_util_path_concat (2 , src,"po" ); +copy_by_ext (srcd, dst_locale,".mo" ,0 ); +copy_locales (dst_locale); +free (srcd); + } +else + { +const char *locale_dir =get_localedir (); + +for (i =0 ; i < install_locales.n_entries; i++) + { +char *srcf =grub_util_path_concat_ext (3 , src, +"po" , + install_locales.entries[i], +".mo" ); +char *dstf =grub_util_path_concat_ext (2 , dst_locale, + install_locales.entries[i], +".mo" ); +if (grub_install_compress_file (srcf, dstf,0 )) + { +free (srcf); +free (dstf); +continue ; + } +free (srcf); + srcf =grub_util_path_concat_ext (4 , + locale_dir, + install_locales.entries[i], +"LC_MESSAGES" , +PACKAGE , +".mo" ); +if (grub_install_compress_file (srcf, dstf,0 )) + { +free (srcf); +free (dstf); +continue ; + } +grub_util_error (_ ("cannot find locale `%s'" ), + install_locales.entries[i]); + } + } +free (dst_locale); +#endif +}void grub_install_copy_files (const char *src,const char *dst,enum grub_install_plat platid) { -char *dst_platform, *dst_locale, *dst_fonts; +char *dst_platform, *dst_fonts;const char *pkgdatadir =grub_util_get_pkgdatadir ();char *themes_dir;
@@ -742,13 +798,12 @@ grub_install_copy_files (const char *src, dst_platform =grub_util_path_concat (2 , dst, platform);free (platform); } - dst_locale =grub_util_path_concat (2 , dst,"locale" ); dst_fonts =grub_util_path_concat (2 , dst,"fonts" );grub_install_mkdir_p (dst_platform); -grub_install_mkdir_p (dst_locale);clean_grub_dir (dst);clean_grub_dir (dst_platform); -clean_grub_dir (dst_locale); + +grub_install_copy_nls (src, dst);if (install_modules.is_default)copy_by_ext (src, dst_platform,".mod" ,1 );
@@ -797,50 +852,6 @@ grub_install_copy_files (const char *src,free (dstf); } -if (install_locales.is_default) - { -char *srcd =grub_util_path_concat (2 , src,"po" ); -copy_by_ext (srcd, dst_locale,".mo" ,0 ); -copy_locales (dst_locale); -free (srcd); - } -else - { -const char *locale_dir =get_localedir (); - -for (i =0 ; i < install_locales.n_entries; i++) - { -char *srcf =grub_util_path_concat_ext (3 , src, -"po" , - install_locales.entries[i], -".mo" ); -char *dstf =grub_util_path_concat_ext (2 , dst_locale, - install_locales.entries[i], -".mo" ); -if (grub_install_compress_file (srcf, dstf,0 )) - { -free (srcf); -free (dstf); -continue ; - } -free (srcf); - srcf =grub_util_path_concat_ext (4 , - locale_dir, - install_locales.entries[i], -"LC_MESSAGES" , -PACKAGE , -".mo" ); -if (grub_install_compress_file (srcf, dstf,0 )) - { -free (srcf); -free (dstf); -continue ; - } -grub_util_error (_ ("cannot find locale `%s'" ), - install_locales.entries[i]); - } - } -if (install_themes.is_default) { install_themes.is_default =0 ;
@@ -903,7 +914,6 @@ grub_install_copy_files (const char *src, }free (dst_platform); -free (dst_locale);free (dst_fonts); }
Quoted 11 lines · Olaf Hering
With --disable-nls no locales exist.
Avoid runtime error by wrapping install logic insideENABLE_NLS.Signed-off-by Olaf Hering <[email protected]>--- util/grub-install-common.c | 108 +++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 49 deletions(-)
util/grub-install-common.c grub_install_get_platform_platform (enum grub_install_plat platid) · line 729
Quoted 5 lines
util/grub-install-common.c +2
-0@@ -725,13 +725,69 @@ grub_install_get_platform_platform (enum grub_install_plat platid)return platforms[platid].platform; } +static void +grub_install_copy_nls (const char *src,const char *dst)
Does not compiler complain that arguments are unused if ENABLE_NLS is not defined?
util/grub-install-common.c grub_install_get_platform_platform (enum grub_install_plat platid) · line 731
Quoted 2 lines
util/grub-install-common.c +2
-0+{ +#if (defined (GRUB_UTIL ) && defined(ENABLE_NLS ) &&ENABLE_NLS )
Is not "#if defined(GRUB_UTIL) && defined(ENABLE_NLS)" sufficient?
Quoted 16 lines
util/grub-install-common.c +16
-0+char *dst_locale; + + dst_locale =grub_util_path_concat (2 , dst,"locale" ); +grub_install_mkdir_p (dst_locale); +clean_grub_dir (dst_locale); + +if (install_locales.is_default) + { +char *srcd =grub_util_path_concat (2 , src,"po" ); +copy_by_ext (srcd, dst_locale,".mo" ,0 ); +copy_locales (dst_locale); +free (srcd); + } +else + { +const char *locale_dir =get_localedir ();
util/grub-install-common.c grub_install_get_platform_platform (enum grub_install_plat platid) · line 757
Quoted 10 lines
util/grub-install-common.c +10
-0+ +for (i =0 ; i < install_locales.n_entries; i++) + { +char *srcf =grub_util_path_concat_ext (3 , src, +"po" , + install_locales.entries[i], +".mo" ); +char *dstf =grub_util_path_concat_ext (2 , dst_locale, + install_locales.entries[i], +".mo" );
If you move code around please fix the arguments alignment.
util/grub-install-common.c grub_install_get_platform_platform (enum grub_install_plat platid) · line 770
Quoted 13 lines
util/grub-install-common.c +13
-0+if (grub_install_compress_file (srcf, dstf,0 )) + { +free (srcf); +free (dstf); +continue ; + } +free (srcf); + srcf =grub_util_path_concat_ext (4 , + locale_dir, + install_locales.entries[i], +"LC_MESSAGES" , +PACKAGE , +".mo" );
Ditto.
Daniel
PS Please CC me next time.
Am Mon, 5 Mar 2018 17:23:12 +0100
schrieb Daniel Kiper <[email protected]>:
Quoted 3 lines · Olaf Hering
Quoted 1 line
+grub_install_copy_nls(const char *src, const char *dst)
Does not compiler complain that arguments are unused if
ENABLE_NLSis not defined?
There are indeed a few non-fatal warnings after the change.
Quoted 2 lines
Quoted 1 line
+#if (defined (
GRUB_UTIL) &&defined(ENABLE_NLS)&&ENABLE_NLS)Is not "#if
defined(GRUB_UTIL)&&defined(ENABLE_NLS)" sufficient?
I copied that from elsewhere.
Will send v2 shortly.
Olaf