write trailing newlines on generated files
This adds trailing newlines to /etc/default/locale, /etc/hostname, /etc/timezone.
This commit is contained in:
parent
0fbb323b4e
commit
b1dabc79a9
@ -46,11 +46,8 @@ class Distro(distros.Distro):
|
|||||||
out_fn = self._paths.join(False, '/etc/default/locale')
|
out_fn = self._paths.join(False, '/etc/default/locale')
|
||||||
util.subp(['locale-gen', locale], capture=False)
|
util.subp(['locale-gen', locale], capture=False)
|
||||||
util.subp(['update-locale', locale], capture=False)
|
util.subp(['update-locale', locale], capture=False)
|
||||||
contents = [
|
lines = ["# Created by cloud-init", 'LANG="%s"' % (locale), ""]
|
||||||
"# Created by cloud-init",
|
util.write_file(out_fn, "\n".join(lines))
|
||||||
'LANG="%s"' % (locale),
|
|
||||||
]
|
|
||||||
util.write_file(out_fn, "\n".join(contents))
|
|
||||||
|
|
||||||
def install_packages(self, pkglist):
|
def install_packages(self, pkglist):
|
||||||
self.update_package_sources()
|
self.update_package_sources()
|
||||||
@ -69,11 +66,9 @@ class Distro(distros.Distro):
|
|||||||
util.subp(['hostname', hostname])
|
util.subp(['hostname', hostname])
|
||||||
|
|
||||||
def _write_hostname(self, hostname, out_fn):
|
def _write_hostname(self, hostname, out_fn):
|
||||||
lines = []
|
# "" gives trailing newline.
|
||||||
lines.append("# Created by cloud-init")
|
lines = ["# Created by cloud-init", str(hostname), ""]
|
||||||
lines.append(str(hostname))
|
util.write_file(out_fn, '\n'.join(lines), 0644)
|
||||||
contents = "\n".join(lines)
|
|
||||||
util.write_file(out_fn, contents, 0644)
|
|
||||||
|
|
||||||
def update_hostname(self, hostname, prev_fn):
|
def update_hostname(self, hostname, prev_fn):
|
||||||
hostname_prev = self._read_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):
|
if not os.path.isfile(tz_file):
|
||||||
raise RuntimeError(("Invalid timezone %s,"
|
raise RuntimeError(("Invalid timezone %s,"
|
||||||
" no file found at %s") % (tz, tz_file))
|
" no file found at %s") % (tz, tz_file))
|
||||||
tz_lines = [
|
# "" provides trailing newline during join
|
||||||
"# Created by cloud-init",
|
tz_lines = ["# Created by cloud-init", str(tz), ""]
|
||||||
str(tz),
|
|
||||||
]
|
|
||||||
tz_contents = "\n".join(tz_lines)
|
|
||||||
tz_fn = self._paths.join(False, "/etc/timezone")
|
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"))
|
util.copy(tz_file, self._paths.join(False, "/etc/localtime"))
|
||||||
|
|
||||||
def package_command(self, command, args=None):
|
def package_command(self, command, args=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user