Skip to content
Snippets Groups Projects
Commit 9563cfae authored by Ludovico de Nittis's avatar Ludovico de Nittis :palm_tree:
Browse files

Add support for Arch Linux /etc/locale.gen

parent 34fd568f
No related branches found
No related tags found
1 merge request!151Add support for Arch Linux /etc/locale.gen
Pipeline #4767 passed
...@@ -46,11 +46,15 @@ fi ...@@ -46,11 +46,15 @@ fi
# We currently only look for I18NDIR data in /usr/share/i18n, the # We currently only look for I18NDIR data in /usr/share/i18n, the
# glibc default path. # glibc default path.
# #
# Instead of just /usr/share/i18n/SUPPORTED, we also try to parse
# /etc/locale.gen because in some distributions, e.g. Arch Linux,
# /usr/share/i18n/SUPPORTED might not be present.
#
# If we discover that some distros use a different default, then we # If we discover that some distros use a different default, then we
# should enhance this script to iterate through a search path. # should enhance this script to iterate through a search path.
# #
# Please keep this in sync with srt_system_info_get_locale_issues(). # Please keep this in sync with srt_system_info_get_locale_issues().
SUPPORTED="/usr/share/i18n/SUPPORTED" SUPPORTED="/etc/locale.gen /usr/share/i18n/SUPPORTED"
log () { log () {
printf '%s\n' "$me: $*" >&2 printf '%s\n' "$me: $*" >&2
......
...@@ -128,6 +128,22 @@ test_object (Fixture *f, ...@@ -128,6 +128,22 @@ test_object (Fixture *f,
g_object_unref (locale); g_object_unref (locale);
} }
static gboolean
is_host_os_like (SrtSystemInfo *info,
const gchar *host)
{
g_auto(GStrv) os_like = NULL;
gsize i;
os_like = srt_system_info_dup_os_id_like (info, TRUE);
for (i = 0; os_like != NULL && os_like[i] != NULL; i++)
{
if (g_strcmp0 (os_like[i], host) == 0)
return TRUE;
}
return FALSE;
}
static void static void
test_complete (Fixture *f, test_complete (Fixture *f,
gconstpointer context) gconstpointer context)
...@@ -135,13 +151,20 @@ test_complete (Fixture *f, ...@@ -135,13 +151,20 @@ test_complete (Fixture *f,
SrtLocale *locale = NULL; SrtLocale *locale = NULL;
SrtSystemInfo *info = srt_system_info_new (NULL); SrtSystemInfo *info = srt_system_info_new (NULL);
SrtLocaleIssues issues; SrtLocaleIssues issues;
SrtLocaleIssues additional_issues = SRT_LOCALE_ISSUES_NONE;
GError *error = NULL; GError *error = NULL;
/* With Arch Linux it is expected to not have the SUPPORTED locale file */
if (is_host_os_like (info, "arch"))
additional_issues = SRT_LOCALE_ISSUES_I18N_SUPPORTED_MISSING;
srt_system_info_set_primary_multiarch_tuple (info, "mock"); srt_system_info_set_primary_multiarch_tuple (info, "mock");
srt_system_info_set_helpers_path (info, f->builddir); srt_system_info_set_helpers_path (info, f->builddir);
issues = srt_system_info_get_locale_issues (info); issues = srt_system_info_get_locale_issues (info);
g_assert_cmpint (issues, ==, SRT_LOCALE_ISSUES_NONE); g_assert_cmpint (issues, ==,
(SRT_LOCALE_ISSUES_NONE
| additional_issues));
locale = srt_system_info_check_locale (info, "C", &error); locale = srt_system_info_check_locale (info, "C", &error);
g_assert_no_error (error); g_assert_no_error (error);
...@@ -222,15 +245,20 @@ test_legacy (Fixture *f, ...@@ -222,15 +245,20 @@ test_legacy (Fixture *f,
SrtLocale *locale = NULL; SrtLocale *locale = NULL;
SrtSystemInfo *info = srt_system_info_new (NULL); SrtSystemInfo *info = srt_system_info_new (NULL);
SrtLocaleIssues issues; SrtLocaleIssues issues;
SrtLocaleIssues additional_issues = SRT_LOCALE_ISSUES_NONE;
GError *error = NULL; GError *error = NULL;
if (is_host_os_like (info, "arch"))
additional_issues = SRT_LOCALE_ISSUES_I18N_SUPPORTED_MISSING;
srt_system_info_set_primary_multiarch_tuple (info, "mock-legacy"); srt_system_info_set_primary_multiarch_tuple (info, "mock-legacy");
srt_system_info_set_helpers_path (info, f->builddir); srt_system_info_set_helpers_path (info, f->builddir);
issues = srt_system_info_get_locale_issues (info); issues = srt_system_info_get_locale_issues (info);
g_assert_cmpint (issues, ==, g_assert_cmpint (issues, ==,
(SRT_LOCALE_ISSUES_DEFAULT_NOT_UTF8 (SRT_LOCALE_ISSUES_DEFAULT_NOT_UTF8
| SRT_LOCALE_ISSUES_C_UTF8_MISSING)); | SRT_LOCALE_ISSUES_C_UTF8_MISSING
| additional_issues));
locale = srt_system_info_check_locale (info, "C", &error); locale = srt_system_info_check_locale (info, "C", &error);
g_assert_no_error (error); g_assert_no_error (error);
...@@ -306,13 +334,19 @@ test_unamerican (Fixture *f, ...@@ -306,13 +334,19 @@ test_unamerican (Fixture *f,
SrtLocale *locale = NULL; SrtLocale *locale = NULL;
SrtSystemInfo *info = srt_system_info_new (NULL); SrtSystemInfo *info = srt_system_info_new (NULL);
SrtLocaleIssues issues; SrtLocaleIssues issues;
SrtLocaleIssues additional_issues = SRT_LOCALE_ISSUES_NONE;
GError *error = NULL; GError *error = NULL;
if (is_host_os_like (info, "arch"))
additional_issues = SRT_LOCALE_ISSUES_I18N_SUPPORTED_MISSING;
srt_system_info_set_primary_multiarch_tuple (info, "mock-unamerican"); srt_system_info_set_primary_multiarch_tuple (info, "mock-unamerican");
srt_system_info_set_helpers_path (info, f->builddir); srt_system_info_set_helpers_path (info, f->builddir);
issues = srt_system_info_get_locale_issues (info); issues = srt_system_info_get_locale_issues (info);
g_assert_cmpint (issues, ==, SRT_LOCALE_ISSUES_EN_US_UTF8_MISSING); g_assert_cmpint (issues, ==,
(SRT_LOCALE_ISSUES_EN_US_UTF8_MISSING
| additional_issues));
locale = srt_system_info_check_locale (info, "C", &error); locale = srt_system_info_check_locale (info, "C", &error);
g_assert_no_error (error); g_assert_no_error (error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment