aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-installer/anaconda/files/0026-support-timezone-setting.patch
blob: 4d3860a248fc4f809b0aefc36d213b397820df73 (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
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>
---
 pyanaconda/timezone.py | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/pyanaconda/timezone.py b/pyanaconda/timezone.py
index 6f074ae..40d0f89 100644
--- a/pyanaconda/timezone.py
+++ b/pyanaconda/timezone.py
@@ -23,6 +23,7 @@ configuration, valid timezones recognition etc.
 """
 
 import os
+import shutil
 import pytz
 import langtable
 from collections import OrderedDict
@@ -101,6 +102,9 @@ def write_timezone_config(timezone_proxy, root):
     rooted_tz_file = os.path.normpath(root + tz_file)
     relative_path = os.path.normpath("../" + tz_file)
     link_path = os.path.normpath(root + "/etc/localtime")
+    if not os.access(rooted_tz_file, os.R_OK) and os.access(tz_file, os.R_OK):
+        util.mkdirChain(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)
@@ -117,28 +121,9 @@ def write_timezone_config(timezone_proxy, root):
             log.error("Error when symlinking timezone (from %s): %s",
                       rooted_tz_file, oserr.strerror)
 
-    if arch.is_s390():
-        # there is no HW clock on s390(x)
-        return
-
-    try:
-        fobj = open(os.path.normpath(root + "/etc/adjtime"), "r")
-        lines = fobj.readlines()
-        fobj.close()
-    except IOError:
-        lines = ["0.0 0 0.0\n", "0\n"]
-
-    try:
-        with open(os.path.normpath(root + "/etc/adjtime"), "w") as fobj:
-            fobj.write(lines[0])
-            fobj.write(lines[1])
-            if timezone_proxy.IsUTC:
-                fobj.write("UTC\n")
-            else:
-                fobj.write("LOCAL\n")
-    except IOError as ioerr:
-        msg = "Error while writing /etc/adjtime file: %s" % ioerr.strerror
-        raise TimezoneConfigError(msg)
+    log.info("timezone %s" % timezone_proxy.Timezone)
+    with open(root + "/etc/timezone", "w") as fobj:
+        fobj.write('%s\n' % timezone_proxy.Timezone)
 
 def save_hw_clock(timezone_proxy=None):
     """
-- 
2.7.4