summaryrefslogtreecommitdiffstats
path: root/src/locale/localectl.c
diff options
context:
space:
mode:
authorMatthias Klumpp <matthias@tenstral.net>2021-01-08 23:59:38 +0100
committerMatthias Klumpp <matthias@tenstral.net>2021-01-12 23:15:12 +0100
commit8f20232fcb52dbe6255f3df6101fc057af90bcfa (patch)
treeea0fc53090f6b2bc14e1a72a93ef3e24a2bd37d9 /src/locale/localectl.c
parentAdd helper for case-independent string equality checks (diff)
downloadsystemd-8f20232fcb52dbe6255f3df6101fc057af90bcfa.tar.xz
systemd-8f20232fcb52dbe6255f3df6101fc057af90bcfa.zip
localed: Run locale-gen if available to generate missing locale
This change improves integration with distributions using locale-gen to generate missing locale on-demand, like Debian-based distributions (Debian/Ubuntu/PureOS/Tanglu/...) and Arch Linux. We only ever enable new locales for generation, and never disable them. Furthermore, we only generate UTF-8 locale. This feature is only used if explicitly enabled at compile-time, and will also be inert at runtime if the locale-gen binary is missing.
Diffstat (limited to 'src/locale/localectl.c')
-rw-r--r--src/locale/localectl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 7d2e887660..7d3d3f8c18 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -26,6 +26,9 @@
#include "verbs.h"
#include "virt.h"
+/* Enough time for locale-gen to finish server-side (in case it is in use) */
+#define LOCALE_SLOW_BUS_CALL_TIMEOUT_USEC (2*USEC_PER_MINUTE)
+
static PagerFlags arg_pager_flags = 0;
static bool arg_ask_password = true;
static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
@@ -176,7 +179,8 @@ static int set_locale(int argc, char **argv, void *userdata) {
if (r < 0)
return bus_log_create_error(r);
- r = sd_bus_call(bus, m, 0, &error, NULL);
+ /* We use a longer timeout for the method call in case localed is running locale-gen */
+ r = sd_bus_call(bus, m, LOCALE_SLOW_BUS_CALL_TIMEOUT_USEC, &error, NULL);
if (r < 0)
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));