diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-09 16:41:45 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-07-09 16:41:45 -0400 |
commit | 75af023c864d1b6c4e48788b1b4cf7aad5eb2204 (patch) | |
tree | 2f79d479ee27ecb26faa94b91ea47e10b63c6612 /packages | |
parent | 50b9e8b7be096e331eb070c5c48d833b1756463c (diff) | |
download | vyos-cloud-init-75af023c864d1b6c4e48788b1b4cf7aad5eb2204.tar.gz vyos-cloud-init-75af023c864d1b6c4e48788b1b4cf7aad5eb2204.zip |
Revert back to using cheetah + adjust resultant code + templates
At this point there is a mixture of "double hash" cheetah comments and '#*'
cheetah comments.
Diffstat (limited to 'packages')
-rwxr-xr-x | packages/bddeb | 31 | ||||
-rwxr-xr-x | packages/brpm | 27 | ||||
-rw-r--r-- | packages/debian/changelog | 3 | ||||
-rw-r--r-- | packages/debian/control | 17 | ||||
-rw-r--r-- | packages/redhat/cloud-init.spec | 88 |
5 files changed, 86 insertions, 80 deletions
diff --git a/packages/bddeb b/packages/bddeb index bfe24474..ddc0776f 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -25,15 +25,16 @@ from cloudinit import util import argparse # Package names that will showup in requires to what we can actually -# use in our debian 'control' file +# use in our debian 'control' file, this is a translation of the 'requires' +# file pypi package name to a debian/ubuntu package name. PKG_MP = { - 'tempita': 'python-tempita', 'boto': 'python-boto', 'configobj': 'python-configobj', 'oauth': 'python-oauth', - 'yaml': 'python-yaml', + 'pyyaml': 'python-yaml', 'prettytable': 'python-prettytable', 'argparse': 'python-argparse', + 'cheetah': 'python-cheetah', } @@ -43,7 +44,7 @@ def write_debian_folder(root, version, revno): # Fill in the change log template templater.render_to_file(util.abs_join(find_root(), - 'packages', 'debian', 'changelog'), + 'packages', 'debian', 'changelog.in'), util.abs_join(deb_dir, 'changelog'), params={ 'version': version, @@ -53,27 +54,23 @@ def write_debian_folder(root, version, revno): # Write out the control file template cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')] (stdout, _stderr) = util.subp(cmd) + pkgs = [p.lower().strip() for p in stdout.splitlines()] # Map to known packages - pkgs = [p.lower().strip() for p in stdout.splitlines()] requires = [] for p in pkgs: - tgt_pkg = None - for name in PKG_MP.keys(): - if p.find(name) != -1: - tgt_pkg = PKG_MP.get(name) - break + tgt_pkg = PKG_MP.get(p) if not tgt_pkg: - raise RuntimeError(("Do not know how to translate %s to " - " a known package") % (p)) + raise RuntimeError(("Do not know how to translate pypi dependency" + " %r to a known package") % (p)) else: requires.append(tgt_pkg) templater.render_to_file(util.abs_join(find_root(), - 'packages', 'debian', 'control'), + 'packages', 'debian', 'control.in'), util.abs_join(deb_dir, 'control'), params={'requires': requires}) - + # Just copy the following directly for base_fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']: shutil.copy(util.abs_join(find_root(), @@ -143,6 +140,12 @@ def main(): cmd.extend(os.listdir(xdir)) util.subp(cmd, capture=capture) + # Copy it locally for reference + shutil.copy(util.abs_join(tdir, tar_fn), + util.abs_join(os.getcwd(), tar_fn)) + print("Copied that archive to %r for local usage (if desired)." % + (util.abs_join(os.getcwd(), tar_fn))) + print("Running 'debuild' in %r" % (xdir)) with util.chdir(xdir): cmd = ['debuild', '--preserve-envvar', 'INIT_SYSTEM'] diff --git a/packages/brpm b/packages/brpm index 3acbe28f..77de0cf2 100755 --- a/packages/brpm +++ b/packages/brpm @@ -31,14 +31,16 @@ from cloudinit import templater from cloudinit import util # Mapping of expected packages to there full name... +# this is a translation of the 'requires' +# file pypi package name to a redhat/fedora package name. PKG_MP = { 'boto': 'python-boto', - 'tempita': 'python-tempita', + 'cheetah': 'python-cheetah', 'prettytable': 'python-prettytable', 'oauth': 'python-oauth', 'configobj': 'python-configobj', - 'yaml': 'PyYAML', - 'argparse': 'python-argparse' + 'pyyaml': 'PyYAML', + 'argparse': 'python-argparse', } # Subdirectories of the ~/rpmbuild dir @@ -106,25 +108,18 @@ def generate_spec_contents(args, tmpl_fn, arc_fn): subs['revno'] = revno subs['release'] = "bzr%s" % (revno) subs['archive_name'] = arc_fn - subs['bd_requires'] = ['python-devel', 'python-setuptools'] cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')] (stdout, _stderr) = util.subp(cmd) - - # Map to known packages pkgs = [p.lower().strip() for p in stdout.splitlines()] # Map to known packages requires = [] for p in pkgs: - tgt_pkg = None - for name in PKG_MP.keys(): - if p.find(name) != -1: - tgt_pkg = PKG_MP.get(name) - break + tgt_pkg = PKG_MP.get(p) if not tgt_pkg: - raise RuntimeError(("Do not know how to translate %s to " - " a known package") % (p)) + raise RuntimeError(("Do not know how to translate pypi dependency" + " %r to a known package") % (p)) else: requires.append(tgt_pkg) subs['requires'] = requires @@ -195,8 +190,10 @@ def main(): print("Archived the code in %r" % (real_archive_fn)) # Form the spec file to be used - tmpl_fn = util.abs_join(find_root(), 'packages', 'redhat', 'cloud-init.spec') - contents = generate_spec_contents(args, tmpl_fn, os.path.basename(archive_fn)) + tmpl_fn = util.abs_join(find_root(), 'packages', + 'redhat', 'cloud-init.spec.in') + contents = generate_spec_contents(args, tmpl_fn, + os.path.basename(archive_fn)) spec_fn = util.abs_join(root_dir, 'cloud-init.spec') util.write_file(spec_fn, contents) print("Created spec file at %r" % (spec_fn)) diff --git a/packages/debian/changelog b/packages/debian/changelog index ac5bcf98..eda08c57 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -1,4 +1,5 @@ -cloud-init ({{version}}~{{revision}}-1) UNRELEASED; urgency=low +## This is a cheetah template +cloud-init (${version}~${revision}-1) UNRELEASED; urgency=low * build diff --git a/packages/debian/control b/packages/debian/control index 926228d5..4e151e3e 100644 --- a/packages/debian/control +++ b/packages/debian/control @@ -1,13 +1,16 @@ +## This is a cheetah template Source: cloud-init Section: admin Priority: extra Maintainer: Scott Moser <smoser@ubuntu.com> Build-Depends: cdbs, - debhelper (>= 5.0.38), + debhelper (>= 5.0.38), python (>= 2.6.6-3~), python-nose, pyflakes, pylint, + python-setuptools, + python-cheetah, python-mocker, python-setuptools XS-Python-Version: all @@ -18,13 +21,13 @@ Architecture: all Depends: cloud-utils, procps, python, -{{for r in requires}} - {{r}}, -{{endfor}} +#for $r in $requires + ${r}, +#end for python-software-properties, - ${misc:Depends}, - ${python:Depends} -XB-Python-Version: ${python:Versions} + \${misc:Depends}, + \${python:Depends} +XB-Python-Version: \${python:Versions} Description: Init scripts for cloud instances Cloud instances need special scripts to run during initialisation to retrieve and install ssh keys and to let the user run various scripts. diff --git a/packages/redhat/cloud-init.spec b/packages/redhat/cloud-init.spec index 5dfb6b0d..35b27beb 100644 --- a/packages/redhat/cloud-init.spec +++ b/packages/redhat/cloud-init.spec @@ -1,3 +1,4 @@ +## This is a cheetah template %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} # See: http://www.zarb.org/~jasonc/macros.php @@ -5,20 +6,21 @@ # Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html Name: cloud-init -Version: {{version}} -Release: {{release}}%{?dist} +Version: ${version} +Release: ${release}%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base License: GPLv3 URL: http://launchpad.net/cloud-init -Source0: {{archive_name}} +Source0: ${archive_name} BuildArch: noarch BuildRoot: %{_tmppath} BuildRequires: python-devel BuildRequires: python-setuptools +BuildRequires: python-cheetah # System util packages needed Requires: shadow-utils @@ -30,23 +32,23 @@ Requires: procps Requires: shadow-utils # Install pypi 'dynamic' requirements -{{for r in requires}} -Requires: {{r}} -{{endfor}} +#for $r in $requires +Requires: ${r} +#end for -{{if sysvinit}} +#if $sysvinit Requires(post): chkconfig Requires(postun): initscripts Requires(preun): chkconfig Requires(preun): initscripts -{{endif}} +#end if -{{if systemd}} +#if $systemd BuildRequires: systemd-units Requires(post): systemd-units Requires(postun): systemd-units Requires(preun): systemd-units -{{endif}} +#end if %description Cloud-init is a set of init scripts for cloud instances. Cloud instances @@ -54,89 +56,89 @@ 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}~{{release}} +%setup -q -n %{name}-%{version}~${release} %build %{__python} setup.py build %install -rm -rf $RPM_BUILD_ROOT +rm -rf \$RPM_BUILD_ROOT %{__python} setup.py install -O1 \ - --skip-build --root $RPM_BUILD_ROOT \ - --init-system={{init_sys}} + --skip-build --root \$RPM_BUILD_ROOT \ + --init-system=${init_sys} # 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 +mkdir -p \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d cp -p tools/21-cloudinit.conf \ - $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf + \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf %clean -rm -rf $RPM_BUILD_ROOT +rm -rf \$RPM_BUILD_ROOT %post -{{if systemd}} -if [ $1 -eq 1 ] +#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}} +#end if -{{if sysvinit}} +#if $sysvinit /sbin/chkconfig --add %{_initrddir}/cloud-init-local /sbin/chkconfig --add %{_initrddir}/cloud-init /sbin/chkconfig --add %{_initrddir}/cloud-config /sbin/chkconfig --add %{_initrddir}/cloud-final -{{endif}} +#end if %preun -{{if sysvinit}} -if [ $1 -eq 0 ] +#if $sysvinit +if [ \$1 -eq 0 ] then - /sbin/service cloud-init stop >/dev/null 2>&1 - /sbin/chkconfig --del cloud-init - /sbin/service cloud-init-local stop >/dev/null 2>&1 - /sbin/chkconfig --del cloud-init-local - /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 + /sbin/service cloud-init stop >/dev/null 2>&1 || : + /sbin/chkconfig --del cloud-init || : + /sbin/service cloud-init-local stop >/dev/null 2>&1 || : + /sbin/chkconfig --del cloud-init-local || : + /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}} +#end if -{{if systemd}} -if [ $1 -eq 0 ] +#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}} +#end if %postun -{{if systemd}} +#if $systemd /bin/systemctl daemon-reload >/dev/null 2>&1 || : -{{endif}} +#end if %files -{{if sysvinit}} +#if $sysvinit %attr(0755, root, root) %{_initddir}/cloud-config %attr(0755, root, root) %{_initddir}/cloud-final %attr(0755, root, root) %{_initddir}/cloud-init-local %attr(0755, root, root) %{_initddir}/cloud-init -{{endif}} +#end if -{{if systemd}} +#if $systemd %{_unitdir}/cloud-* -{{endif}} +#end if # Program binaries %{_bindir}/cloud-init* @@ -165,4 +167,4 @@ fi %changelog -{{changelog}} +${changelog} |