Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-updates-src > by-pkgid > 3dd8bca5a331f46a5ba1cbec6d91c01d > files > 35

systemd-217-11.2.mga5.src.rpm

From 6b842dd4a2cbd1e1e6cabd1d6293d7650e36d16a Mon Sep 17 00:00:00 2001
From: Colin Guthrie <colin@mageia.org>
Date: Sun, 8 Feb 2015 12:47:12 +0000
Subject: [PATCH] Add path to locale search.

Mageia seems to store it's locales in /usr/share/locale (and also seems
to copy it to /etc/locale??) so add in /usr/share/locale in addition to
/usr/lib/locale. We should investigate if we 'force' the share path and
make steps to move it if it's a pointless deviation.

We should also find out why we have /etc/locale/ directory tree populated.
---
 src/shared/locale-util.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/shared/locale-util.c b/src/shared/locale-util.c
index 9addb05..79ada48 100644
--- a/src/shared/locale-util.c
+++ b/src/shared/locale-util.c
@@ -155,6 +155,33 @@ static int add_locales_from_libdir (Set *locales) {
         return 0;
 }
 
+static int add_locales_from_sharedir (Set *locales) {
+        _cleanup_closedir_ DIR *dir = NULL;
+        struct dirent *entry;
+        int r;
+
+        dir = opendir("/usr/share/locale");
+        if (!dir)
+                return errno == ENOENT ? 0 : -errno;
+
+        FOREACH_DIRENT(entry, dir, return -errno) {
+                char *z;
+
+                if (entry->d_type != DT_DIR)
+                        continue;
+
+                z = strdup(entry->d_name);
+                if (!z)
+                        return -ENOMEM;
+
+                r = set_consume(locales, z);
+                if (r < 0 && r != -EEXIST)
+                        return r;
+        }
+
+        return 0;
+}
+
 int get_locales(char ***ret) {
         _cleanup_set_free_ Set *locales = NULL;
         _cleanup_strv_free_ char **l = NULL;
@@ -172,6 +199,10 @@ int get_locales(char ***ret) {
         if (r < 0)
                 return r;
 
+        r = add_locales_from_sharedir(locales);
+        if (r < 0)
+                return r;
+
         l = set_get_strv(locales);
         if (!l)
                 return -ENOMEM;
-- 
2.3.0