summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-09-19 11:31:06 -0400
committerScott Moser <smoser@ubuntu.com>2012-09-19 11:31:06 -0400
commit91f1fc58e134fea2ac3ff04301bb0ea51f8797b1 (patch)
tree88dffa5b4eae73c37d1ec0fff227793bf71f760f /cloudinit/distros
parent9c0cffeabfcc7ddfa5fdac2d22d91e336c538376 (diff)
downloadvyos-cloud-init-91f1fc58e134fea2ac3ff04301bb0ea51f8797b1.tar.gz
vyos-cloud-init-91f1fc58e134fea2ac3ff04301bb0ea51f8797b1.zip
write trailing newlines on generated files
This adds trailing newlines to /etc/default/locale, /etc/hostname, /etc/timezone.
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/debian.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index da8c1a5b..da27f780 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -46,11 +46,8 @@ class Distro(distros.Distro):
out_fn = self._paths.join(False, '/etc/default/locale')
util.subp(['locale-gen', locale], capture=False)
util.subp(['update-locale', locale], capture=False)
- contents = [
- "# Created by cloud-init",
- 'LANG="%s"' % (locale),
- ]
- util.write_file(out_fn, "\n".join(contents))
+ lines = ["# Created by cloud-init", 'LANG="%s"' % (locale), ""]
+ util.write_file(out_fn, "\n".join(lines))
def install_packages(self, pkglist):
self.update_package_sources()
@@ -69,11 +66,9 @@ class Distro(distros.Distro):
util.subp(['hostname', hostname])
def _write_hostname(self, hostname, out_fn):
- lines = []
- lines.append("# Created by cloud-init")
- lines.append(str(hostname))
- contents = "\n".join(lines)
- util.write_file(out_fn, contents, 0644)
+ # "" gives trailing newline.
+ lines = ["# Created by cloud-init", str(hostname), ""]
+ util.write_file(out_fn, '\n'.join(lines), 0644)
def update_hostname(self, hostname, prev_fn):
hostname_prev = self._read_hostname(prev_fn)
@@ -123,13 +118,10 @@ class Distro(distros.Distro):
if not os.path.isfile(tz_file):
raise RuntimeError(("Invalid timezone %s,"
" no file found at %s") % (tz, tz_file))
- tz_lines = [
- "# Created by cloud-init",
- str(tz),
- ]
- tz_contents = "\n".join(tz_lines)
+ # "" provides trailing newline during join
+ tz_lines = ["# Created by cloud-init", str(tz), ""]
tz_fn = self._paths.join(False, "/etc/timezone")
- util.write_file(tz_fn, tz_contents)
+ util.write_file(tz_fn, "\n".join(tz_lines))
util.copy(tz_file, self._paths.join(False, "/etc/localtime"))
def package_command(self, command, args=None):