summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-06-13 09:06:41 -0500
committerScott Moser <smoser@brickies.net>2017-07-19 17:52:32 -0400
commitdcbe479575fac9f293c5c4089f4bcb46ab887206 (patch)
tree43fbeea7110338747135af20f9b702200f7c2607 /setup.py
parent97abd83513bee191b58f095f4d683b18acce0b49 (diff)
downloadvyos-cloud-init-dcbe479575fac9f293c5c4089f4bcb46ab887206.tar.gz
vyos-cloud-init-dcbe479575fac9f293c5c4089f4bcb46ab887206.zip
Templatize systemd unit files for cross distro deltas.
Under el7, cloud-init systemd files need some unit tweaks to ensure they run at the right time. Pull in current el7 downstream systemd unit changes.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/setup.py b/setup.py
index bce06ad9..1197eceb 100755
--- a/setup.py
+++ b/setup.py
@@ -87,8 +87,8 @@ def read_requires():
return str(deps).splitlines()
-def render_cloud_cfg():
- """render cloud.cfg into a tmpdir under same dir as setup.py
+def render_tmpl(template):
+ """render template into a tmpdir under same dir as setup.py
This is rendered to a temporary directory under the top level
directory with the name 'cloud.cfg'. The reason for not just rendering
@@ -99,16 +99,21 @@ def render_cloud_cfg():
# older versions of tox use bdist (xenial), and then install from there.
# newer versions just use install.
if not (sys.argv[1] == 'install' or sys.argv[1].startswith('bdist*')):
- return 'config/cloud.cfg.tmpl'
+ return template
+
+ tmpl_ext = ".tmpl"
+ # we may get passed a non-template file, just pass it back
+ if not template.endswith(tmpl_ext):
+ return template
+
topdir = os.path.dirname(sys.argv[0])
tmpd = tempfile.mkdtemp(dir=topdir)
atexit.register(shutil.rmtree, tmpd)
- fpath = os.path.join(tmpd, 'cloud.cfg')
- tiny_p([sys.executable, './tools/render-cloudcfg',
- 'config/cloud.cfg.tmpl', fpath])
- # relpath is relative to setup.py
- relpath = os.path.join(os.path.basename(tmpd), 'cloud.cfg')
- return relpath
+ bname = os.path.basename(template).rstrip(tmpl_ext)
+ fpath = os.path.join(tmpd, bname)
+ tiny_p([sys.executable, './tools/render-cloudcfg', template, fpath])
+ # return path relative to setup.py
+ return os.path.join(os.path.basename(tmpd), bname)
INITSYS_FILES = {
@@ -116,8 +121,10 @@ INITSYS_FILES = {
'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)],
'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)],
'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)],
- 'systemd': [f for f in (glob('systemd/*.service') +
- glob('systemd/*.target')) if is_f(f)],
+ 'systemd': [render_tmpl(f)
+ for f in (glob('systemd/*.tmpl') +
+ glob('systemd/*.service') +
+ glob('systemd/*.target')) if is_f(f)],
'systemd.generators': [f for f in glob('systemd/*-generator') if is_f(f)],
'upstart': [f for f in glob('upstart/*') if is_f(f)],
}
@@ -195,7 +202,7 @@ if not in_virtualenv():
INITSYS_ROOTS[k] = "/" + INITSYS_ROOTS[k]
data_files = [
- (ETC + '/cloud', [render_cloud_cfg()]),
+ (ETC + '/cloud', [render_tmpl("config/cloud.cfg.tmpl")]),
(ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
(ETC + '/cloud/templates', glob('templates/*')),
(USR_LIB_EXEC + '/cloud-init', ['tools/ds-identify',