aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-installer/anaconda/files/0026-support-timezone-setting.patch
blob: 135d4b37e94612d36f7477aacd3dc517c5fd95f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From b57b55b6fcdf01ff2bc0fe959b8f146ad6553fe4 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 24 Jul 2018 14:40:25 +0800
Subject: [PATCH 26/65] support timezone setting

- If selected timezone does not exist in target,
  try to make a copy from host

- Drop unused /etc/adjtime (redhat specific),
  use /etc/localtime to replace (oe-core specific).

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

Rebase for anaconda 34.

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for anaconda 37:
* replace pyanaconda.core.util.mkdirChain with pyanaconda.core.path.make_directories

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 pyanaconda/modules/timezone/installation.py | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/pyanaconda/modules/timezone/installation.py b/pyanaconda/modules/timezone/installation.py
index 0cd75106c7..600c3407de 100644
--- a/pyanaconda/modules/timezone/installation.py
+++ b/pyanaconda/modules/timezone/installation.py
@@ -17,9 +17,10 @@
 #
 import os
 import os.path
+import shutil
 
 from pyanaconda import ntp
-from pyanaconda.core import service, util
+from pyanaconda.core import service, util, path
 from pyanaconda.core.configuration.anaconda import conf
 from pyanaconda.timezone import NTP_SERVICE
 from pyanaconda.anaconda_loggers import get_module_logger
@@ -107,6 +108,9 @@ class ConfigureTimezoneTask(Task):
         rooted_tz_file = os.path.normpath(self._sysroot + tz_file)
         relative_path = os.path.normpath("../" + tz_file)
         link_path = os.path.normpath(self._sysroot + "/etc/localtime")
+        if not os.access(rooted_tz_file, os.R_OK) and os.access(tz_file, os.R_OK):
+            path.make_directories(os.path.dirname(rooted_tz_file))
+            shutil.copyfile(tz_file, rooted_tz_file)
 
         if not os.access(rooted_tz_file, os.R_OK):
             log.error("Timezone to be linked (%s) doesn't exist", rooted_tz_file)
@@ -133,23 +137,9 @@ class ConfigureTimezoneTask(Task):
             # there is no Hardware clock on s390(x)
             return
 
-        try:
-            with open(os.path.normpath(self._sysroot + "/etc/adjtime"), "r") as fobj:
-                lines = fobj.readlines()
-        except OSError:
-            lines = ["0.0 0 0.0\n", "0\n"]
-
-        try:
-            with open(os.path.normpath(self._sysroot + "/etc/adjtime"), "w") as fobj:
-                fobj.write(lines[0])
-                fobj.write(lines[1])
-                if self._is_utc:
-                    fobj.write("UTC\n")
-                else:
-                    fobj.write("LOCAL\n")
-        except OSError as e:
-            msg = "Error while writing /etc/adjtime file: {}".format(e.strerror)
-            raise TimezoneConfigurationError(msg) from e
+        log.info("timezone %s" % self._timezone)
+        with open(self._sysroot + "/etc/timezone", "w") as fobj:
+            fobj.write('%s\n' % self._timezone)
 
 
 class ConfigureNTPTask(Task):
-- 
2.7.4