From: Michael Biebl <biebl@debian.org>
Date: Thu, 18 Jul 2013 20:11:02 +0200
Subject: 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
46a2911bf2780f616396df5671dd901cc7cb54fd
99f861310d3f05f4e86cb9582a94b891dbb3382b
---
 src/core/locale-setup.c  | 22 ++++++++++++++++++++++
 src/timedate/timedated.c | 16 ++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c
index 7a41035..3817ab0 100644
--- a/src/core/locale-setup.c
+++ b/src/core/locale-setup.c
@@ -120,6 +120,28 @@ int locale_setup(char ***environment) {
                         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],
+                                   "LANGUAGE",          &variables[VARIABLE_LANGUAGE],
+                                   "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);
+
+                if (r < 0 && r != -ENOENT)
+                        log_warning("Failed to read /etc/default/locale: %s", strerror(-r));
+        }
+
         add = NULL;
         for (i = 0; i < _VARIABLE_MAX; i++) {
                 char *s;
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 204031f..58745cf 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -136,6 +136,12 @@ static int context_read_data(Context *c) {
                 }
         }
 
+        r = read_one_line_file("/etc/timezone", &c->zone);
+        if (r < 0) {
+                if (r != -ENOENT)
+                        log_warning("Failed to read /etc/timezone: %s", strerror(-r));
+        }
+
 have_timezone:
         if (isempty(c->zone)) {
                 free(c->zone);
@@ -150,6 +156,7 @@ have_timezone:
 static int context_write_data_timezone(Context *c) {
         _cleanup_free_ char *p = NULL;
         int r = 0;
+        struct stat st;
 
         assert(c);
 
@@ -157,6 +164,9 @@ static int context_write_data_timezone(Context *c) {
                 if (unlink("/etc/localtime") < 0 && errno != ENOENT)
                         r = -errno;
 
+                if (unlink("/etc/timezone") < 0 && errno != ENOENT)
+                        r = -errno;
+
                 return r;
         }
 
@@ -168,6 +178,12 @@ static int context_write_data_timezone(Context *c) {
         if (r < 0)
                 return r;
 
+        if (stat("/etc/timezone", &st) == 0 && S_ISREG(st.st_mode)) {
+                r = write_string_file_atomic("/etc/timezone", c->zone);
+                if (r < 0)
+                        return r;
+        }
+
         return 0;
 }
 
