diff options
-rw-r--r-- | cloudinit/config/cc_keys_to_console.py | 19 | ||||
-rw-r--r-- | cloudinit/distros/__init__.py | 1 | ||||
-rw-r--r-- | cloudinit/distros/rhel.py | 1 | ||||
-rwxr-xr-x | packages/brpm | 1 | ||||
-rw-r--r-- | packages/redhat/cloud-init.spec.in | 23 | ||||
-rwxr-xr-x | setup.py | 8 |
6 files changed, 37 insertions, 16 deletions
diff --git a/cloudinit/config/cc_keys_to_console.py b/cloudinit/config/cc_keys_to_console.py index ed7af690..f1c1adff 100644 --- a/cloudinit/config/cc_keys_to_console.py +++ b/cloudinit/config/cc_keys_to_console.py @@ -26,13 +26,22 @@ from cloudinit import util frequency = PER_INSTANCE # This is a tool that cloud init provides -HELPER_TOOL = '/usr/lib/cloud-init/write-ssh-key-fingerprints' +HELPER_TOOL_TPL = '%s/cloud-init/write-ssh-key-fingerprints' -def handle(name, cfg, _cloud, log, _args): - if not os.path.exists(HELPER_TOOL): +def _get_helper_tool_path(distro): + try: + base_lib = distro.usr_lib_exec + except AttributeError: + base_lib = '/usr/lib' + return HELPER_TOOL_TPL % base_lib + + +def handle(name, cfg, cloud, log, _args): + helper_path = _get_helper_tool_path(cloud.distro) + if not os.path.exists(helper_path): log.warn(("Unable to activate module %s," - " helper tool not found at %s"), name, HELPER_TOOL) + " helper tool not found at %s"), name, helper_path) return fp_blacklist = util.get_cfg_option_list(cfg, @@ -42,7 +51,7 @@ def handle(name, cfg, _cloud, log, _args): ["ssh-dss"]) try: - cmd = [HELPER_TOOL] + cmd = [helper_path] cmd.append(','.join(fp_blacklist)) cmd.append(','.join(key_blacklist)) (stdout, _stderr) = util.subp(cmd) diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 83c2eebf..bf465442 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -51,6 +51,7 @@ LOG = logging.getLogger(__name__) class Distro(object): __metaclass__ = abc.ABCMeta + usr_lib_exec = "/usr/lib" hosts_fn = "/etc/hosts" ci_sudoers_fn = "/etc/sudoers.d/90-cloud-init-users" hostname_conf_fn = "/etc/hostname" diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index 13335df5..d5cc15fe 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -50,6 +50,7 @@ class Distro(distros.Distro): network_script_tpl = '/etc/sysconfig/network-scripts/ifcfg-%s' resolve_conf_fn = "/etc/resolv.conf" tz_local_fn = "/etc/localtime" + usr_lib_exec = "/usr/libexec" def __init__(self, name, cfg, paths): distros.Distro.__init__(self, name, cfg, paths) diff --git a/packages/brpm b/packages/brpm index b8bbff9d..9657b1dd 100755 --- a/packages/brpm +++ b/packages/brpm @@ -244,6 +244,7 @@ def main(): spec_fn = util.abs_join(root_dir, 'cloud-init.spec') util.write_file(spec_fn, contents) print("Created spec file at %r" % (spec_fn)) + print(contents) for p in args.patches: util.copy(p, util.abs_join(arc_dir, os.path.basename(p))) diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in index 75dd4d22..81cccce5 100644 --- a/packages/redhat/cloud-init.spec.in +++ b/packages/redhat/cloud-init.spec.in @@ -81,7 +81,7 @@ ssh keys and to let the user run various scripts. %{__python} setup.py build %install -rm -rf \$RPM_BUILD_ROOT + %{__python} setup.py install -O1 \ --skip-build --root \$RPM_BUILD_ROOT \ --init-system=${init_sys} @@ -92,6 +92,13 @@ mkdir -p \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d cp -p tools/21-cloudinit.conf \ \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf +# Remove the tests +rm -rf \$RPM_BUILD_ROOT%{python_sitelib}/tests + +# Required dirs... +mkdir -p \$RPM_BUILD_ROOT/%{_sharedstatedir}/cloud +mkdir -p \$RPM_BUILD_ROOT/%{_libexecdir}/%{name} + #if $systemd mkdir -p \$RPM_BUILD_ROOT/%{_unitdir} cp -p systemd/* \$RPM_BUILD_ROOT/%{_unitdir} @@ -166,15 +173,11 @@ fi # Program binaries %{_bindir}/cloud-init* - -# There doesn't seem to be an agreed upon place for these -# although it appears the standard says /usr/lib but rpmbuild -# will try /usr/lib64 ?? -/usr/lib/%{name}/uncloud-init -/usr/lib/%{name}/write-ssh-key-fingerprints +%{_libexecdir}/%{name}/uncloud-init +%{_libexecdir}/%{name}/write-ssh-key-fingerprints # Docs -%doc TODO LICENSE ChangeLog requirements.txt +%doc LICENSE ChangeLog TODO.rst requirements.txt %doc %{_defaultdocdir}/cloud-init/* # Configs @@ -185,7 +188,9 @@ fi %dir %{_sysconfdir}/cloud/templates %config(noreplace) %{_sysconfdir}/cloud/templates/* %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf -%config(noreplace) %{_sysconfdir}/sudoers.d/cloud-init + +%{_libexecdir}/%{name} +%dir %{_sharedstatedir}/cloud # Python code is here... %{python_sitelib}/* @@ -82,9 +82,13 @@ INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) # FreeBSD systems. USR = "/usr" ETC = "/etc" +USR_LIB_EXEC = "/usr/lib" if os.uname()[0] == 'FreeBSD': USR = "/usr/local" + USR_LIB_EXEC = "/usr/local/lib" ETC = "/usr/local/etc" +elif os.path.isfile('/etc/redhat-release'): + USR_LIB_EXEC = "/usr/libexec" # Avoid having datafiles installed in a virtualenv... @@ -155,8 +159,8 @@ else: (ETC + '/cloud', glob('config/*.cfg')), (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), (ETC + '/cloud/templates', glob('templates/*')), - (USR + '/lib/cloud-init', ['tools/uncloud-init', - 'tools/write-ssh-key-fingerprints']), + (USR_LIB_EXEC + '/cloud-init', ['tools/uncloud-init', + 'tools/write-ssh-key-fingerprints']), (USR + '/share/doc/cloud-init', [f for f in glob('doc/*') if is_f(f)]), (USR + '/share/doc/cloud-init/examples', [f for f in glob('doc/examples/*') if is_f(f)]), |