Skip to content
Snippets Groups Projects
Commit 3fee6bcc authored by Ludovico de Nittis's avatar Ludovico de Nittis
Browse files

Merge branch 'wip/denittis/arch_locales' into 'master'

Add support for Arch Linux /etc/locale.gen

Closes #5

See merge request steam/steam-runtime-tools!151
parents 34fd568f 9563cfae
No related branches found
No related tags found
1 merge request!151Add support for Arch Linux /etc/locale.gen
Pipeline #4772 passed
......@@ -46,11 +46,15 @@ fi
# We currently only look for I18NDIR data in /usr/share/i18n, the
# 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
# should enhance this script to iterate through a search path.
#
# 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 () {
printf '%s\n' "$me: $*" >&2
......
......@@ -128,6 +128,22 @@ test_object (Fixture *f,
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
test_complete (Fixture *f,
gconstpointer context)
......@@ -135,13 +151,20 @@ test_complete (Fixture *f,
SrtLocale *locale = NULL;
SrtSystemInfo *info = srt_system_info_new (NULL);
SrtLocaleIssues issues;
SrtLocaleIssues additional_issues = SRT_LOCALE_ISSUES_NONE;
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_helpers_path (info, f->builddir);
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);
g_assert_no_error (error);
......@@ -222,15 +245,20 @@ test_legacy (Fixture *f,
SrtLocale *locale = NULL;
SrtSystemInfo *info = srt_system_info_new (NULL);
SrtLocaleIssues issues;
SrtLocaleIssues additional_issues = SRT_LOCALE_ISSUES_NONE;
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_helpers_path (info, f->builddir);
issues = srt_system_info_get_locale_issues (info);
g_assert_cmpint (issues, ==,
(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);
g_assert_no_error (error);
......@@ -306,13 +334,19 @@ test_unamerican (Fixture *f,
SrtLocale *locale = NULL;
SrtSystemInfo *info = srt_system_info_new (NULL);
SrtLocaleIssues issues;
SrtLocaleIssues additional_issues = SRT_LOCALE_ISSUES_NONE;
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_helpers_path (info, f->builddir);
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);
g_assert_no_error (error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment