1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

firstboot: suppress locale menu if there's nothing to choose from

This commit is contained in:
Lennart Poettering 2019-07-12 13:43:31 +02:00
parent b65011dad0
commit bdd7cd264a

View File

@ -219,6 +219,22 @@ static int prompt_locale(void) {
if (r < 0)
return log_error_errno(r, "Cannot query locales list: %m");
if (strv_isempty(locales))
log_debug("No locales found, skipping locale selection.");
else if (strv_length(locales) == 1) {
if (streq(locales[0], SYSTEMD_DEFAULT_LOCALE))
log_debug("Only installed locale is default locale anyway, not setting locale explicitly.");
else {
log_debug("Only a single locale available (%s), selecting it as default.", locales[0]);
arg_locale = strdup(locales[0]);
if (!arg_locale)
return log_oom();
/* Not setting arg_locale_message here, since it defaults to LANG anyway */
}
} else {
print_welcome();
printf("\nAvailable Locales:\n\n");
@ -239,6 +255,11 @@ static int prompt_locale(void) {
if (r < 0)
return r;
/* Suppress the messages setting if it's the same as the main locale anyway */
if (streq_ptr(arg_locale, arg_locale_messages))
arg_locale_messages = mfree(arg_locale_messages);
}
return 0;
}