From 815423d9c47f7e63d80c5e4da3248bb0c4572903 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/basic/locale-util.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 61db9a8..852bc6e 100644 --- a/src/basic/locale-util.c +++ b/src/basic/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.2