diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-02 15:40:51 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-02 15:40:51 -0700 |
commit | 37aa678a39d8ac568351ce754d202c1069034d1c (patch) | |
tree | 873d70069f9d3a7a2eb96c12941c0a525eff1b61 /packages | |
parent | 879946c26f005f5ae5c2bbdd537beb295d7f4773 (diff) | |
download | vyos-cloud-init-37aa678a39d8ac568351ce754d202c1069034d1c.tar.gz vyos-cloud-init-37aa678a39d8ac568351ce754d202c1069034d1c.zip |
1. Fixup the setup.py to not include custom startup scripts, let the packaging solutions handle these
2. Get the cloud-init specfile working for the init.d case (with the right postun and post and install sections)
a. It works!!!
Diffstat (limited to 'packages')
-rwxr-xr-x | packages/brpm | 106 | ||||
-rw-r--r-- | packages/redhat/cloud-init.spec | 179 |
2 files changed, 171 insertions, 114 deletions
diff --git a/packages/brpm b/packages/brpm index bbf30565..3abd9f15 100755 --- a/packages/brpm +++ b/packages/brpm @@ -71,6 +71,7 @@ def get_log_header(version): def format_change_line(ds, who, comment=None): + # Rpmbuild seems to be pretty strict about the date format d = ds.strftime("%a %b %d %Y") d += " - %s" % (who) if comment: @@ -134,94 +135,22 @@ def generate_spec_contents(args, tmpl_fn): changelog_lines.append(line) subs['changelog'] = "\n".join(changelog_lines) - # See: http://www.zarb.org/~jasonc/macros.php - # Pickup any special files - docs = [ - 'TODO', - 'LICENSE', - 'ChangeLog', - 'Requires', - '%{_defaultdocdir}/cloud-init/*', - ] - subs['docs'] = docs - configs = [ - 'cloud/cloud.cfg', - 'cloud/cloud.cfg.d/*.cfg', - 'cloud/cloud.cfg.d/README', - 'cloud/templates/*', - ] - subs['configs'] = configs - other_files = [ - '%{_bindir}/*', - '/usr/lib/cloud-init/*', - ] - - # Since setup.py installs them all, we need to selectively - # remove the wrong ones and ensure the right one/s are kept - # for the boot mode that is desired... - boot_remove = { - 'initd': [ - '/etc/init.d/cloud-init-local', - # Remove the other auto-start folders - '/etc/systemd/', - '/etc/init/', - ], - 'initd-local': [ - '/etc/init.d/cloud-init', - # Remove the other auto-start folders - '/etc/systemd/', - '/etc/init/', - ], - # It seems like systemd can work with - # all of its files being 'active' (and not have naming - # or event name conflicts??) - 'systemd': [ - # Remove the other auto-start folders - '/etc/init.d/', - '/etc/init/', - ], - 'upstart': [ - '/etc/init/cloud-init-nonet.conf', - '/etc/init/cloud-init-local.conf', - # Remove the other auto-start folders - '/etc/init.d/', - '/etc/systemd/', - ], - 'upstart-local': [ - '/etc/init/cloud-init.conf', - # Remove the other auto-start folders - '/etc/init.d/', - '/etc/systemd/', - ] - } - boot_keep = { - 'systemd': [ - '/etc/systemd/*', - ], - 'upstart': [ - '/etc/init/*', - ], - 'upstart-local': [ - '/etc/init/*', - ], - 'initd-local': [ - '/etc/init.d/*', - ], - 'initd': [ - '/etc/init.d/*', - ], - } - subs['post_remove'] = boot_remove[args.boot] - other_files.extend(boot_keep[args.boot]) - subs['files'] = other_files - return templater.render_from_file(tmpl_fn, params=subs) + if args.boot == 'initd': + subs['init_d'] = True + subs['init_d_local'] = False + elif args.boot == 'initd-local': + subs['init_d'] = True + subs['init_d_local'] = True + else: + subs['init_d'] = False + subs['init_d_local'] = False + + if args.boot == 'systemd': + subs['systemd'] = True + else: + subs['systemd'] = False - -def archive_code(): - (stdout, _stderr) = tiny_p([sys.executable, - join(os.getcwd(), 'make-tarball')]) - (revno, version, bname, arc_fn) = stdout.split(None) - return (revno, version, arc_fn) + return templater.render_from_file(tmpl_fn, params=subs) def main(): @@ -230,8 +159,7 @@ def main(): parser.add_argument("-b", "--boot", dest="boot", help="select boot type (default: %(default)s)", metavar="TYPE", default='initd', - choices=('upstart', 'initd', 'systemd', - 'upstart-local', 'initd-local')) + choices=('initd', 'systemd', 'initd-local')) parser.add_argument("-v", "--verbose", dest="verbose", help=("run verbosely" " (default: %(default)s)"), diff --git a/packages/redhat/cloud-init.spec b/packages/redhat/cloud-init.spec index ddb6617d..e9ce087a 100644 --- a/packages/redhat/cloud-init.spec +++ b/packages/redhat/cloud-init.spec @@ -1,5 +1,9 @@ %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} +# See: See: http://www.zarb.org/~jasonc/macros.php +# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets +# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html + Name: cloud-init Version: {{version}} Release: {{release}}%{?dist} @@ -10,27 +14,45 @@ License: GPLv3 URL: http://launchpad.net/cloud-init Source0: {{archive_name}} - BuildArch: noarch - BuildRoot: %{_tmppath} +BuildRequires: python-devel +BuildRequires: python-setuptools -{{for r in bd_requires}} -BuildRequires: {{r}} -{{endfor}} +# System util packages needed +Requires: shadow-utils +Requires: rsyslog +Requires: iproute +Requires: e2fsprogs +Requires: net-tools +Requires: procps +Requires: shadow-utils -# Install requirements +# Install pypi 'dynamic' requirements {{for r in requires}} -Requires: {{r}} +Requires: {{r}} {{endfor}} +{{if init_d}} +Requires(post): chkconfig +Requires(postun): initscripts +Requires(preun): chkconfig +Requires(preun): initscripts +{{endif}} + +{{if systemd}} +BuildRequires: systemd-units +Requires(post): systemd-units +Requires(postun): systemd-units +Requires(preun): systemd-units +{{endif}} + %description Cloud-init is a set of init scripts for cloud instances. Cloud instances need special scripts to run during initialization to retrieve and install ssh keys and to let the user run various scripts. - %prep %setup -q -n %{name}-%{version}-{{revno}} @@ -41,32 +63,139 @@ ssh keys and to let the user run various scripts. rm -rf $RPM_BUILD_ROOT %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT -# Remove anything after it was installed?? -{{for r in post_remove}} -rm -rfv $RPM_BUILD_ROOT/{{r}} -{{endfor}} +# Note that /etc/rsyslog.d didn't exist by default until F15. +# el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420 +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d +cp -p tools/21-cloudinit.conf \ + $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf + +{{if init_d}} +mkdir -p $RPM_BUILD_ROOT/%{_initddir}/ +{{endif}} +{{if init_d_local}} +cp -p initd/cloud-init-local $RPM_BUILD_ROOT/%{_initddir}/ +cp -p initd/cloud-config $RPM_BUILD_ROOT/%{_initddir}/ +cp -p initd/cloud-final $RPM_BUILD_ROOT/%{_initddir}/ +{{elif init_d}} +cp -p initd/cloud-init $RPM_BUILD_ROOT/%{_initddir}/ +cp -p initd/cloud-config $RPM_BUILD_ROOT/%{_initddir}/ +cp -p initd/cloud-final $RPM_BUILD_ROOT/%{_initddir}/ +{{endif}} + +{{if systemd}} +mkdir -p $RPM_BUILD_ROOT/%{_unitdir} +cp -p systemd/* $RPM_BUILD_ROOT/%{_unitdir} +{{endif}} %clean rm -rf $RPM_BUILD_ROOT +%post + +{{if systemd}} +if [ $1 -eq 1 ] +then + /bin/systemctl enable cloud-config.service >/dev/null 2>&1 || : + /bin/systemctl enable cloud-final.service >/dev/null 2>&1 || : + /bin/systemctl enable cloud-init.service >/dev/null 2>&1 || : + /bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || : +fi +{{endif}} + +{{if init_d_local}} +/sbin/chkconfig --add /etc/rc.d/init.d/cloud-init-local +{{elif init_d}} +/sbin/chkconfig --add /etc/rc.d/init.d/cloud-init +{{endif}} +{{if init_d}} +/sbin/chkconfig --add /etc/rc.d/init.d/cloud-config +/sbin/chkconfig --add /etc/rc.d/init.d/cloud-final +{{endif}} + +%preun + +{{if init_d_local}} +if [ $1 -eq 0 ] +then + /sbin/service cloud-init-local stop >/dev/null 2>&1 + /sbin/chkconfig --del cloud-init-local +fi +{{elif init_d}} +if [ $1 -eq 0 ] +then + /sbin/service cloud-init stop >/dev/null 2>&1 + /sbin/chkconfig --del cloud-init +fi +{{endif}} +{{if init_d}} +if [ $1 -eq 0 ] +then + /sbin/service cloud-config stop >/dev/null 2>&1 + /sbin/chkconfig --del cloud-config + /sbin/service cloud-final stop >/dev/null 2>&1 + /sbin/chkconfig --del cloud-final +fi +{{endif}} + +{{if systemd}} +if [ $1 -eq 0 ] +then + /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || : + /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || : + /bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || : + /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || : +fi +{{endif}} + +%postun + +{{if systemd}} +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +{{endif}} + %files +{{if init_d}} +%attr(0755, root, root) %{_initddir}/cloud-config +%attr(0755, root, root) %{_initddir}/cloud-final +{{endif}} +{{if init_d_local}} +%attr(0755, root, root) %{_initddir}/cloud-init-local +{{elif init_d}} +%attr(0755, root, root) %{_initddir}/cloud-init +{{endif}} + +{{if systemd}} +%{_unitdir}/cloud-config.service +%{_unitdir}/cloud-config.target +%{_unitdir}/cloud-init.service +%{_unitdir}/cloud-init-local.service +%{_unitdir}/cloud-final.service +{{endif}} + +# 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 + # Docs -{{for r in docs}} -%doc {{r}} -{{endfor}} +%doc TODO LICENSE ChangeLog Requires +%doc %{_defaultdocdir}/cloud-init/* # Configs -{{for r in configs}} -%config(noreplace) %{_sysconfdir}/{{r}} -{{endfor}} - -# Other files -{{for r in files}} -{{r}} -{{endfor}} - -# Python sitelib +%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg +%dir %{_sysconfdir}/cloud/cloud.cfg.d +%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/*.cfg +%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/README +%dir %{_sysconfdir}/cloud/templates +%config(noreplace) %{_sysconfdir}/cloud/templates/* +%config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf + +# Python code is here... %{python_sitelib}/* %changelog |