mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-12-01 00:48:18 +00:00
752ceb1640
Signed-off-by: Peter Jones <pjones@redhat.com>
177 lines
5.2 KiB
Diff
177 lines
5.2 KiB
Diff
From 3d8439da8c9a4acf9bc1c41b364ec6e1680ef052 Mon Sep 17 00:00:00 2001
|
|
From: Olaf Hering <olaf@aepfle.de>
|
|
Date: Fri, 13 Apr 2018 23:36:49 +0200
|
|
Subject: [PATCH] grub-install: Locale depends on nls
|
|
|
|
With --disable-nls no locales exist.
|
|
|
|
Avoid runtime error by moving code that copies locales into its own
|
|
function. Return early in case nls was disabled. That way the compiler
|
|
will throw away unreachable code, no need to put preprocessor
|
|
conditionals everywhere to avoid warnings about unused code.
|
|
|
|
Fix memleak by freeing srcf and dstf.
|
|
Convert tabs to spaces in moved code.
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
util/grub-install-common.c | 106 ++++++++++++++++++++++++---------------------
|
|
1 file changed, 57 insertions(+), 49 deletions(-)
|
|
|
|
diff --git a/util/grub-install-common.c b/util/grub-install-common.c
|
|
index 9e3e358c96a..0a2e24a79f1 100644
|
|
--- a/util/grub-install-common.c
|
|
+++ b/util/grub-install-common.c
|
|
@@ -592,6 +592,7 @@ copy_all (const char *srcd,
|
|
grub_util_fd_closedir (d);
|
|
}
|
|
|
|
+#if !(defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS)
|
|
static const char *
|
|
get_localedir (void)
|
|
{
|
|
@@ -646,6 +647,59 @@ copy_locales (const char *dstd)
|
|
}
|
|
grub_util_fd_closedir (d);
|
|
}
|
|
+#endif
|
|
+
|
|
+static void
|
|
+grub_install_copy_nls(const char *src __attribute__ ((unused)),
|
|
+ const char *dst __attribute__ ((unused)))
|
|
+{
|
|
+#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
|
|
+ {
|
|
+ size_t i;
|
|
+ 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) == 0)
|
|
+ grub_util_error (_("cannot find locale `%s'"),
|
|
+ install_locales.entries[i]);
|
|
+ free (srcf);
|
|
+ free (dstf);
|
|
+ }
|
|
+ }
|
|
+ free (dst_locale);
|
|
+#endif
|
|
+}
|
|
|
|
static struct
|
|
{
|
|
@@ -731,7 +785,7 @@ 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 +796,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 +850,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 +912,6 @@ grub_install_copy_files (const char *src,
|
|
}
|
|
|
|
free (dst_platform);
|
|
- free (dst_locale);
|
|
free (dst_fonts);
|
|
}
|
|
|