Commit 1dc49ae4 authored by Michael Biebl's avatar Michael Biebl

Add back support for Debian specific config files

For now fallback to read the locale settings from /etc/default/locale.

This reverts the Debian specific bits from
46a2911b
99f86131
parent 0712c329
......@@ -117,6 +117,27 @@ int locale_setup(void) {
log_warning("Failed to read /etc/locale.conf: %s", strerror(-r));
}
if (r <= 0 &&
(r = parse_env_file("/etc/default/locale", NEWLINE,
"LANG", &variables[VARIABLE_LANG],
"LC_CTYPE", &variables[VARIABLE_LC_CTYPE],
"LC_NUMERIC", &variables[VARIABLE_LC_NUMERIC],
"LC_TIME", &variables[VARIABLE_LC_TIME],
"LC_COLLATE", &variables[VARIABLE_LC_COLLATE],
"LC_MONETARY", &variables[VARIABLE_LC_MONETARY],
"LC_MESSAGES", &variables[VARIABLE_LC_MESSAGES],
"LC_PAPER", &variables[VARIABLE_LC_PAPER],
"LC_NAME", &variables[VARIABLE_LC_NAME],
"LC_ADDRESS", &variables[VARIABLE_LC_ADDRESS],
"LC_TELEPHONE", &variables[VARIABLE_LC_TELEPHONE],
"LC_MEASUREMENT", &variables[VARIABLE_LC_MEASUREMENT],
"LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION],
NULL)) < 0) {
if (r != -ENOENT)
log_warning("Failed to read /etc/default/locale: %s", strerror(-r));
}
if (!variables[VARIABLE_LANG]) {
variables[VARIABLE_LANG] = strdup("C");
if (!variables[VARIABLE_LANG]) {
......
......@@ -183,6 +183,12 @@ static int read_data(void) {
}
}
r = read_one_line_file("/etc/timezone", &tz.zone);
if (r < 0) {
if (r != -ENOENT)
log_warning("Failed to read /etc/timezone: %s", strerror(-r));
}
have_timezone:
if (isempty(tz.zone)) {
free(tz.zone);
......@@ -198,10 +204,15 @@ static int write_data_timezone(void) {
int r = 0;
_cleanup_free_ char *p = NULL;
struct stat st;
if (!tz.zone) {
if (unlink("/etc/localtime") < 0 && errno != ENOENT)
r = -errno;
if (unlink("/etc/timezone") < 0 && errno != ENOENT)
r = -errno;
return r;
}
......@@ -213,6 +224,13 @@ static int write_data_timezone(void) {
if (r < 0)
return r;
if (stat("/etc/timezone", &st) == 0 && S_ISREG(st.st_mode)) {
r = write_string_file_atomic("/etc/timezone", tz.zone);
if (r < 0)
return r;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment