← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~smoser/cloud-init/trunk.lp1543025 into lp:cloud-init

 

Scott Moser has proposed merging lp:~smoser/cloud-init/trunk.lp1543025 into lp:cloud-init.

Commit message:
timezone: use a symlink when updating /etc/localtime

Unless /etc/localtime is an existing file and not a symlink,
then we will symlink instead of copying the tz_file to /etc/localtime.

The copy was due to an old bug in Ubuntu, symlink should be preferred.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1543025 in cloud-init: "Wrong UTC zoneinfo in cloud-images"
  https://bugs.launchpad.net/cloud-init/+bug/1543025

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/trunk.lp1543025/+merge/287682
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.lp1543025 into lp:cloud-init.
=== modified file 'ChangeLog'
--- ChangeLog	2016-03-01 05:51:26 +0000
+++ ChangeLog	2016-03-01 17:33:06 +0000
@@ -81,6 +81,8 @@
  - lxd: add support for setting up lxd using 'lxd init' (LP: #1522879)
  - Add Image Customization Parser for VMware vSphere Hypervisor
    Support. [Sankar Tanguturi]
+ - timezone: use a symlink rather than copy for /etc/localtime
+   unless it is already a file (LP: #1543025).
 
 0.7.6:
  - open 0.7.6

=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2015-07-22 12:06:34 +0000
+++ cloudinit/distros/__init__.py	2016-03-01 17:33:06 +0000
@@ -897,5 +897,9 @@
     util.write_file(tz_conf, str(tz).rstrip() + "\n")
     # This ensures that the correct tz will be used for the system
     if tz_local and tz_file:
-        util.copy(tz_file, tz_local)
+        # use a symlink if there exists a symlink or tz_local is not present
+        if os.path.islink(tz_local) or not os.path.exists(tz_local):
+            os.symlink(tz_file, tz_local)
+        else:
+            util.copy(tz_file, tz_local)
     return


References