Merge ~larsks/cloud-init:feature/move-to-git into cloud-init:master

Proposed by Lars Kellogg-Stedman
Status: Merged
Merged at revision: 72d6adcb2e4cb5911f7809b89835965d4bf04476
Proposed branch: ~larsks/cloud-init:feature/move-to-git
Merge into: cloud-init:master
Diff against target: 746 lines (+228/-275)
9 files modified
.gitignore (+5/-0)
HACKING.rst (+46/-22)
MANIFEST.in (+2/-0)
dev/null (+0/-21)
packages/brpm (+123/-171)
packages/redhat/cloud-init.spec.in (+6/-14)
packages/suse/cloud-init.spec.in (+3/-11)
tools/make-tarball (+22/-30)
tools/read-dependencies (+21/-6)
Reviewer Review Type Date Requested Status
Joshua Harlow Pending
Review via email: mp+301310@code.launchpad.net

Description of the change

Update build tools to work with git

- Update HACKING.rst to include git instructions
- update MANIFEST.in and .gitignore to ignore git-related things
- replaced tarball generation scripts with git-based script
- have the spec files correctly identify themselves as cheetah templates
- make brpm work with git

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
0new file mode 1006440new file mode 100644
index 0000000..f8b0f3e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
1.tox
2dist
3cloud_init.egg-info
4__pycache__
5build
diff --git a/HACKING.rst b/HACKING.rst
index 6bfe4b4..63a5bde 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -2,47 +2,71 @@
2Hacking on cloud-init2Hacking on cloud-init
3=====================3=====================
44
5To get changes into cloud-init, the process to follow is:5This document describes how to contribute changes to cloud-init.
6
7Do these things once
8--------------------
69
7* If you have not already, be sure to sign the CCA:10* If you have not already, be sure to sign the CCA:
811
9 - `Canonical Contributor Agreement`_12 - `Canonical Contributor Agreement`_
1013
11* Get your changes into a local bzr branch.14* Clone the `LaunchPad`_ repository:
12 Initialize a repo, and checkout trunk (init repo is to share bzr info across multiple checkouts, its different than git):15
16 git clone YOUR_USERNAME@git.launchpad.net:cloud-init
17 cd cloud-init
18
19 If you would prefer a bzr style `git clone lp:cloud-init`, see
20 the `Instructions on LaunchPad`_ for more information.
1321
14 - ``bzr init-repo cloud-init``22* Create a new remote pointing to your personal LaunchPad
15 - ``bzr branch lp:cloud-init trunk.dist``23 repository::
16 - ``bzr branch trunk.dist my-topic-branch``24
25 git remote add YOUR_USERNAME YOUR_USERNAME@git.launchpad.net:~YOUR_USERNAME/cloud-init
26
27.. _Canonical Contributor Agreement: http://www.canonical.com/contributors
1728
18* Commit your changes (note, you can make multiple commits, fixes, more commits.):29Do these things for each feature or bug
30---------------------------------------
1931
20 - ``bzr commit``32* Create a new topic branch for your work::
2133
22* Check pep8 and test, and address any issues:34 git checkout -b my-topic-branch
2335
24 - ``make test pep8``36.. _Instructions on launchpad: https://help.launchpad.net/Code/Git
2537
26* Push to launchpad to a personal branch:38* Make and commit your changes (note, you can make multiple commits,
39 fixes, more commits.)::
2740
28 - ``bzr push lp:~<YOUR_USERNAME>/cloud-init/<BRANCH_NAME>``41 git commit
2942
30* Propose that for a merge into lp:cloud-init via web browser.43* Check pep8 and test, and address any issues::
3144
32 - Open the branch in `Launchpad`_45 make test pep8
3346
34 - It will typically be at ``https://code.launchpad.net/<YOUR_USERNAME>/<PROJECT>/<BRANCH_NAME>``47* Push your changes to your personal LaunchPad repository::
35 - ie. https://code.launchpad.net/~smoser/cloud-init/mybranch
3648
37* Click 'Propose for merging'49 git push -u YOUR_USERNAME my-topic-branch
38* Select 'lp:cloud-init' as the target branch
3950
40Then, someone on cloud-init-dev (currently `Scott Moser`_ and `Joshua Harlow`_) will 51* Use your browser to create a merge request:
41review your changes and follow up in the merge request.
4252
43Feel free to ping and/or join #cloud-init on freenode (irc) if you have any questions.53 - Open the branch on `LaunchPad`_
54
55 - It will typically be at
56 ``https://code.launchpad.net/~YOUR_USERNAME/cloud-init/+git/cloud-init/+ref/BRANCHNAME``
57 for example
58 https://code.launchpad.net/~larsks/cloud-init/+git/cloud-init/+ref/feature/move-to-git
59
60 - Click 'Propose for merging`
61 - Select ``cloud-init`` as the target repository
62 - Select ``master`` as the target reference path
63
64Then, someone on cloud-init-dev (currently `Scott Moser`_ and `Joshua
65Harlow`_) will review your changes and follow up in the merge request.
66
67Feel free to ping and/or join ``#cloud-init`` on freenode (irc) if you
68have any questions.
4469
45.. _Launchpad: https://launchpad.net70.. _Launchpad: https://launchpad.net
46.. _Canonical Contributor Agreement: http://www.canonical.com/contributors
47.. _Scott Moser: https://launchpad.net/~smoser71.. _Scott Moser: https://launchpad.net/~smoser
48.. _Joshua Harlow: https://launchpad.net/~harlowja72.. _Joshua Harlow: https://launchpad.net/~harlowja
diff --git a/MANIFEST.in b/MANIFEST.in
index 90f6c7d..9426464 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,5 +4,7 @@ graft tools
4prune build4prune build
5prune dist5prune dist
6prune .tox6prune .tox
7prune .git
7prune .bzr8prune .bzr
9exclude .gitignore
8exclude .bzrignore10exclude .bzrignore
diff --git a/packages/brpm b/packages/brpm
index 45e4761..5d16eb7 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -1,27 +1,24 @@
1#!/usr/bin/python1#!/usr/bin/env python
22
3import argparse3import argparse
4import contextlib
5import glob4import glob
6import os5import os
7import shutil6import shutil
8import subprocess
9import sys7import sys
10import tempfile8import tempfile
11import re9import time
12
13from datetime import datetime
1410
1511
16def find_root():12def find_root():
17 # expected path is in <top_dir>/packages/13 # expected path is in <top_dir>/packages/
18 top_dir = os.environ.get("CLOUD_INIT_TOP_D", None)14 top_dir = os.environ.get("CLOUD_INIT_TOP_D", None)
19 if top_dir is None:15 if top_dir is None:
20 top_dir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))16 top_dir = os.path.dirname(
17 os.path.dirname(os.path.abspath(sys.argv[0])))
21 if os.path.isfile(os.path.join(top_dir, 'setup.py')):18 if os.path.isfile(os.path.join(top_dir, 'setup.py')):
22 return os.path.abspath(top_dir)19 return os.path.abspath(top_dir)
23 raise OSError(("Unable to determine where your cloud-init topdir is."20 raise OSError(("Unable to determine where your cloud-init topdir is."
24 " set CLOUD_INIT_TOP_D?"))21 " set CLOUD_INIT_TOP_D?"))
2522
2623
27# Use the util functions from cloudinit24# Use the util functions from cloudinit
@@ -30,34 +27,15 @@ sys.path.insert(0, find_root())
30from cloudinit import templater27from cloudinit import templater
31from cloudinit import util28from cloudinit import util
3229
33# Mapping of expected packages to there full name...30# Map python requirements to package names. If a match isn't found
34# this is a translation of the 'requires'31# here, we assume 'python-<pypi_name>'.
35# file pypi package name to a redhat/fedora package name.32PACKAGE_MAP = {
36PKG_MP = {
37 'redhat': {33 'redhat': {
38 'argparse': 'python-argparse',
39 'cheetah': 'python-cheetah',
40 'jinja2': 'python-jinja2',
41 'configobj': 'python-configobj',
42 'jsonpatch': 'python-jsonpatch',
43 'oauthlib': 'python-oauthlib',
44 'prettytable': 'python-prettytable',
45 'pyserial': 'pyserial',34 'pyserial': 'pyserial',
46 'pyyaml': 'PyYAML',35 'pyyaml': 'PyYAML',
47 'requests': 'python-requests',
48 'six': 'python-six',
49 },36 },
50 'suse': {37 'suse': {
51 'argparse': 'python-argparse',
52 'cheetah': 'python-cheetah',
53 'configobj': 'python-configobj',
54 'jsonpatch': 'python-jsonpatch',
55 'oauthlib': 'python-oauthlib',
56 'prettytable': 'python-prettytable',
57 'pyserial': 'python-pyserial',
58 'pyyaml': 'python-yaml',38 'pyyaml': 'python-yaml',
59 'requests': 'python-requests',
60 'six': 'python-six',
61 }39 }
62}40}
6341
@@ -65,113 +43,79 @@ PKG_MP = {
65RPM_BUILD_SUBDIRS = ['BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']43RPM_BUILD_SUBDIRS = ['BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']
6644
6745
68def get_log_header(version):46def read_dependencies():
69 # Try to find the version in the tags output47 '''Returns the Python depedencies from requirements.txt. This explicitly
70 cmd = ['bzr', 'tags']48 removes 'argparse' from the list of requirements for python >= 2.7,
71 (stdout, _stderr) = util.subp(cmd)49 because with 2.7 argparse became part of the standard library.'''
72 a_rev = None50 cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')]
73 for t in stdout.splitlines():
74 ver, rev = t.split(None)
75 if ver == version:
76 a_rev = rev
77 break
78 if not a_rev:
79 return None
80
81 # Extract who made that tag as the header
82 cmd = ['bzr', 'log', '-r%s' % (a_rev), '--timezone=utc']
83 (stdout, _stderr) = util.subp(cmd)51 (stdout, _stderr) = util.subp(cmd)
84 kvs = {52 return [p.lower().strip() for p in stdout.splitlines()
85 'comment': version,53 if p != 'argparse' or (p == 'argparse'
86 }54 and sys.version_info[0:2] < (2, 7))]
8755
88 for line in stdout.splitlines():
89 if line.startswith('committer:'):
90 kvs['who'] = line[len('committer:'):].strip()
91 if line.startswith('timestamp:'):
92 ts = line[len('timestamp:'):]
93 ts = ts.strip()
94 # http://bugs.python.org/issue6641
95 ts = ts.replace("+0000", '').strip()
96 ds = datetime.strptime(ts, '%a %Y-%m-%d %H:%M:%S')
97 kvs['ds'] = ds
9856
99 return format_change_line(**kvs)57def translate_dependencies(deps, distro):
58 '''Maps python requirements into package names. We assume
59 python-<pypi_name> for packages not listed explicitly in
60 PACKAGE_MAP.'''
61 return [PACKAGE_MAP[distro][req]
62 if req in PACKAGE_MAP[distro] else 'python-%s' % req
63 for req in deps]
10064
10165
102def format_change_line(ds, who, comment=None):66def read_version():
103 # Rpmbuild seems to be pretty strict about the date format67 '''Read version information. We parse the version itself from
104 d = ds.strftime("%a %b %d %Y")68 the changelog, and then ask git for the commit id and distance
105 d += " - %s" % (who)69 from the last tag.'''
106 if comment:
107 d += " - %s" % (comment)
108 return "* %s" % (d)
109
110
111def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
112
113 # Figure out the version and revno70 # Figure out the version and revno
114 cmd = [util.abs_join(find_root(), 'tools', 'read-version')]71 cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
115 (stdout, _stderr) = util.subp(cmd)72 (stdout, _stderr) = util.subp(cmd)
116 version = stdout.strip()73 version = stdout.strip()
117 74
118 cmd = ['bzr', 'revno']75 cmd = ['git', 'describe', '--tags']
119 (stdout, _stderr) = util.subp(cmd)76 (stdout, _stderr) = util.subp(cmd)
120 revno = stdout.strip()77 git_version = stdout.strip()
78
79 try:
80 _version, distance, revno = git_version.split('-')
81 except ValueError:
82 distance = None
83 revno = None
84
85 return (version, distance, revno)
86
87
88def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
89
90 # This will get us something like ('0.7.6', None, None) for a
91 # tagged commit, and something like ('0.7.6', '1026', 'gd1d5796')
92 # for an untagged commited.
93 version, distance, revno = read_version()
12194
122 # Tmpl params95 # Tmpl params
123 subs = {}96 subs = {}
124 subs['version'] = version97 subs['version'] = version
125 subs['revno'] = revno98 subs['revno'] = revno
126 subs['release'] = "bzr%s" % (revno)99 subs['distance'] = distance
100
101 if distance is not None:
102 now = time.strftime('%Y%m%d', time.localtime())
103 release = '.%sgit%s' % (now, revno)
104 else:
105 release = ''
106
127 if args.sub_release is not None:107 if args.sub_release is not None:
128 subs['subrelease'] = "." + str(args.sub_release)108 subs['subrelease'] = release + "." + str(args.sub_release)
129 else:109 else:
130 subs['subrelease'] = ''110 subs['subrelease'] = release
131 subs['archive_name'] = arc_fn
132111
133 cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')]112 subs['archive_name'] = arc_fn
134 (stdout, _stderr) = util.subp(cmd)113 subs['source_name'] = os.path.basename(arc_fn).replace('.tar.gz', '')
135 pkgs = [p.lower().strip() for p in stdout.splitlines()]
136114
137 # Map to known packages115 # Map to known packages
138 requires = []116 python_deps = read_dependencies()
139 for p in pkgs:117 package_deps = translate_dependencies(python_deps, args.distro)
140 if p == 'argparse' and sys.version_info[0:2] >= (2, 7):118 subs['requires'] = package_deps
141 # Not needed on anything but 2.6 or older.
142 continue
143 tgt_pkg = PKG_MP[args.distro].get(p)
144 if not tgt_pkg:
145 raise RuntimeError(("Do not know how to translate pypi dependency"
146 " %r to a known package") % (p))
147 else:
148 requires.append(tgt_pkg)
149 subs['requires'] = requires
150
151 # Format a nice changelog (as best as we can)
152 changelog = util.load_file(util.abs_join(find_root(), 'ChangeLog'))
153 changelog_lines = []
154 missing_versions = 0
155 for line in changelog.splitlines():
156 if not line.strip():
157 continue
158 if re.match(r"^\s*[\d][.][\d][.][\d]:\s*", line):
159 line = line.strip(":")
160 header = get_log_header(line)
161 if not header:
162 missing_versions += 1
163 if missing_versions == 1:
164 # Must be using a new 'dev'/'trunk' release
165 changelog_lines.append(format_change_line(datetime.now(),
166 '??'))
167 else:
168 sys.stderr.write(("Changelog version line %s does not "
169 "have a corresponding tag!\n") % (line))
170 else:
171 changelog_lines.append(header)
172 else:
173 changelog_lines.append(line)
174 subs['changelog'] = "\n".join(changelog_lines)
175119
176 if args.boot == 'sysvinit':120 if args.boot == 'sysvinit':
177 subs['sysvinit'] = True121 subs['sysvinit'] = True
@@ -183,21 +127,23 @@ def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
183 else:127 else:
184 subs['systemd'] = False128 subs['systemd'] = False
185129
186 subs['defines'] = ["_topdir %s" % (top_dir)]
187 subs['init_sys'] = args.boot130 subs['init_sys'] = args.boot
188 subs['patches'] = [os.path.basename(p) for p in args.patches]131 subs['patches'] = [os.path.basename(p) for p in args.patches]
189 return templater.render_from_file(tmpl_fn, params=subs)132 return templater.render_from_file(tmpl_fn, params=subs)
190133
191134
192def main():135def main():
193 136
194 parser = argparse.ArgumentParser()137 parser = argparse.ArgumentParser()
195 parser.add_argument("-d", "--distro", dest="distro",138 parser.add_argument("-d", "--distro", dest="distro",
196 help="select distro (default: %(default)s)",139 help="select distro (default: %(default)s)",
197 metavar="DISTRO", default='redhat',140 metavar="DISTRO", default='redhat',
198 choices=('redhat', 'suse'))141 choices=('redhat', 'suse'))
142 parser.add_argument('--srpm',
143 help='Produce a source rpm',
144 action='store_true')
199 parser.add_argument("-b", "--boot", dest="boot",145 parser.add_argument("-b", "--boot", dest="boot",
200 help="select boot type (default: %(default)s)", 146 help="select boot type (default: %(default)s)",
201 metavar="TYPE", default='sysvinit',147 metavar="TYPE", default='sysvinit',
202 choices=('sysvinit', 'systemd'))148 choices=('sysvinit', 'systemd'))
203 parser.add_argument("-v", "--verbose", dest="verbose",149 parser.add_argument("-v", "--verbose", dest="verbose",
@@ -221,57 +167,63 @@ def main():
221 if args.verbose:167 if args.verbose:
222 capture = False168 capture = False
223169
224 # Clean out the root dir and make sure the dirs we want are in place170 workdir = None
225 root_dir = os.path.expanduser("~/rpmbuild")171 try:
226 if os.path.isdir(root_dir):172 workdir = tempfile.mkdtemp(prefix='rpmbuild')
227 shutil.rmtree(root_dir)173 os.environ['HOME'] = workdir
228174 topdir = os.path.join(workdir, 'rpmbuild')
229 arc_dir = util.abs_join(root_dir, 'SOURCES')175 build_dirs = [os.path.join(topdir, dir)
230 build_dirs = [root_dir, arc_dir]176 for dir in RPM_BUILD_SUBDIRS]
231 for dname in RPM_BUILD_SUBDIRS:177 util.ensure_dirs(build_dirs)
232 build_dirs.append(util.abs_join(root_dir, dname))178
233 build_dirs.sort()179 # Archive the code
234 util.ensure_dirs(build_dirs)180 cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')]
235181 (stdout, _stderr) = util.subp(cmd)
236 # Archive the code182 archive_fn = stdout.strip()
237 cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')]183 print "Archived source as %s" % archive_fn
238 (stdout, _stderr) = util.subp(cmd)184 real_archive_fn = os.path.join(topdir, 'SOURCES',
239 archive_fn = stdout.strip()185 os.path.basename(archive_fn))
240 real_archive_fn = os.path.join(arc_dir, os.path.basename(archive_fn))186 shutil.move(archive_fn, real_archive_fn)
241 shutil.move(archive_fn, real_archive_fn)187 print("Archived the code in %r" % (real_archive_fn))
242 print("Archived the code in %r" % (real_archive_fn))188
243189 # Form the spec file to be used
244 # Form the spec file to be used190 tmpl_fn = util.abs_join(find_root(), 'packages',
245 tmpl_fn = util.abs_join(find_root(), 'packages',191 args.distro, 'cloud-init.spec.in')
246 args.distro, 'cloud-init.spec.in')192 contents = generate_spec_contents(args, tmpl_fn, topdir,
247 contents = generate_spec_contents(args, tmpl_fn, root_dir,193 os.path.basename(archive_fn))
248 os.path.basename(archive_fn))194 spec_fn = util.abs_join(topdir, 'SPECS', 'cloud-init.spec')
249 spec_fn = util.abs_join(root_dir, 'cloud-init.spec')195 util.write_file(spec_fn, contents)
250 util.write_file(spec_fn, contents)196 print("Created spec file at %r" % (spec_fn))
251 print("Created spec file at %r" % (spec_fn))197 for p in args.patches:
252 print(contents)198 util.copy(p, util.abs_join(topdir, 'SOURCES', os.path.basename(p)))
253 for p in args.patches:199
254 util.copy(p, util.abs_join(arc_dir, os.path.basename(p)))200 # Now build it!
255201 print("Running 'rpmbuild' in %r" % (topdir))
256 # Now build it!202
257 print("Running 'rpmbuild' in %r" % (root_dir))203 if args.srpm:
258 cmd = ['rpmbuild', '-ba', spec_fn]204 cmd = ['rpmbuild', '-bs', '--nodeps', spec_fn]
259 util.subp(cmd, capture=capture)205 else:
260206 cmd = ['rpmbuild', '-ba', spec_fn]
261 # Copy the items built to our local dir207
262 globs = [] 208 util.subp(cmd, capture=capture)
263 globs.extend(glob.glob("%s/*.rpm" %209
264 (util.abs_join(root_dir, 'RPMS', 'noarch'))))210 # Copy the items built to our local dir
265 globs.extend(glob.glob("%s/*.rpm" %211 globs = []
266 (util.abs_join(root_dir, 'RPMS', 'x86_64'))))212 globs.extend(glob.glob("%s/*.rpm" %
267 globs.extend(glob.glob("%s/*.rpm" %213 (util.abs_join(topdir, 'RPMS', 'noarch'))))
268 (util.abs_join(root_dir, 'RPMS'))))214 globs.extend(glob.glob("%s/*.rpm" %
269 globs.extend(glob.glob("%s/*.rpm" %215 (util.abs_join(topdir, 'RPMS', 'x86_64'))))
270 (util.abs_join(root_dir, 'SRPMS'))))216 globs.extend(glob.glob("%s/*.rpm" %
271 for rpm_fn in globs:217 (util.abs_join(topdir, 'RPMS'))))
272 tgt_fn = util.abs_join(os.getcwd(), os.path.basename(rpm_fn))218 globs.extend(glob.glob("%s/*.rpm" %
273 shutil.move(rpm_fn, tgt_fn)219 (util.abs_join(topdir, 'SRPMS'))))
274 print("Wrote out %s package %r" % (args.distro, tgt_fn))220 for rpm_fn in globs:
221 tgt_fn = util.abs_join(os.getcwd(), os.path.basename(rpm_fn))
222 shutil.move(rpm_fn, tgt_fn)
223 print("Wrote out %s package %r" % (args.distro, tgt_fn))
224 finally:
225 if workdir is not None:
226 shutil.rmtree(workdir)
275227
276 return 0228 return 0
277229
diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in
index 254d209..c30d33c 100644
--- a/packages/redhat/cloud-init.spec.in
+++ b/packages/redhat/cloud-init.spec.in
@@ -1,17 +1,13 @@
1## This is a cheetah template1## template: cheetah
2%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}2%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
33
4# See: http://www.zarb.org/~jasonc/macros.php4# See: http://www.zarb.org/~jasonc/macros.php
5# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets5# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
6# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html6# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
77
8#for $d in $defines
9%define ${d}
10#end for
11
12Name: cloud-init8Name: cloud-init
13Version: ${version}9Version: ${version}
14Release: ${release}${subrelease}%{?dist}10Release: 1${subrelease}%{?dist}
15Summary: Cloud instance init scripts11Summary: Cloud instance init scripts
1612
17Group: System Environment/Base13Group: System Environment/Base
@@ -22,9 +18,9 @@ Source0: ${archive_name}
22BuildArch: noarch18BuildArch: noarch
23BuildRoot: %{_tmppath}19BuildRoot: %{_tmppath}
2420
25BuildRequires: python-devel21BuildRequires: python-devel
26BuildRequires: python-setuptools22BuildRequires: python-setuptools
27BuildRequires: python-cheetah23BuildRequires: python-cheetah
2824
29# System util packages needed25# System util packages needed
30Requires: shadow-utils26Requires: shadow-utils
@@ -68,7 +64,7 @@ need special scripts to run during initialization to retrieve and install
68ssh keys and to let the user run various scripts.64ssh keys and to let the user run various scripts.
6965
70%prep66%prep
71%setup -q -n %{name}-%{version}~${release}67%setup -q -n ${source_name}
7268
73# Custom patches activation69# Custom patches activation
74#set $size = 070#set $size = 0
@@ -198,7 +194,3 @@ fi
198194
199# Python code is here...195# Python code is here...
200%{python_sitelib}/*196%{python_sitelib}/*
201
202%changelog
203
204${changelog}
diff --git a/packages/suse/cloud-init.spec.in b/packages/suse/cloud-init.spec.in
index 53e6ad1..f994a0c 100644
--- a/packages/suse/cloud-init.spec.in
+++ b/packages/suse/cloud-init.spec.in
@@ -1,16 +1,12 @@
1## This is a cheetah template1## template: cheetah
22
3# See: http://www.zarb.org/~jasonc/macros.php3# See: http://www.zarb.org/~jasonc/macros.php
4# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets4# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
5# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html5# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
66
7#for $d in $defines
8%define ${d}
9#end for
10
11Name: cloud-init7Name: cloud-init
12Version: ${version}8Version: ${version}
13Release: ${release}${subrelease}%{?dist}9Release: 1${subrelease}%{?dist}
14Summary: Cloud instance init scripts10Summary: Cloud instance init scripts
1511
16Group: System/Management12Group: System/Management
@@ -63,7 +59,7 @@ need special scripts to run during initialization to retrieve and install
63ssh keys and to let the user run various scripts.59ssh keys and to let the user run various scripts.
6460
65%prep61%prep
66%setup -q -n %{name}-%{version}~${release}62%setup -q -n ${source_name}
6763
68# Custom patches activation64# Custom patches activation
69#set $size = 065#set $size = 0
@@ -157,7 +153,3 @@ mkdir -p %{buildroot}/var/lib/cloud
157%{python_sitelib}/*153%{python_sitelib}/*
158154
159/var/lib/cloud155/var/lib/cloud
160
161%changelog
162
163${changelog}
diff --git a/tools/make-dist-tarball b/tools/make-dist-tarball
164deleted file mode 100755156deleted file mode 100755
index 5b07851..0000000
--- a/tools/make-dist-tarball
+++ /dev/null
@@ -1,21 +0,0 @@
1#!/bin/sh
2
3Usage() {
4 cat <<EOF
5Usage: ${0##*/} version
6 make a tarball of 'version'
7 must be in a bzr directory, and 'version' must be a tag
8
9EOF
10}
11
12topdir="$PWD"
13tag="$1"
14
15[ -n "$tag" ] || { Usage 1>&2 ; exit 1; }
16
17out="${topdir}/cloud-init-${tag}.tar.gz"
18
19bzr export --format=tgz --root="cloud-init-$tag" \
20 "--revision=tag:${tag}" "$out" "$topdir" &&
21 echo "Wrote ${out}"
diff --git a/tools/make-tarball b/tools/make-tarball
index b703915..25d6f93 100755
--- a/tools/make-tarball
+++ b/tools/make-tarball
@@ -1,39 +1,31 @@
1#!/bin/sh1#!/bin/sh
2set -e2set -e
33
4find_root() {4rev=${1:-HEAD}
5 local topd5if [ "$rev" = HEAD ]; then
6 if [ -z "${CLOUD_INIT_TOP_D}" ]; then6 revname=$(git describe --tags)
7 topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
8 else
9 topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
10 fi
11 [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
12 ROOT_DIR="$topd"
13}
14
15if ! find_root; then
16 echo "Unable to locate 'setup.py' file that should" \
17 "exist in the cloud-init root directory." 1>&2
18 exit 1;
19fi
20
21REVNO=$(bzr revno "$ROOT_DIR")
22
23if [ ! -z "$1" ]; then
24 ARCHIVE_FN="$1"
25else7else
26 VERSION=$("$ROOT_DIR/tools/read-version")8 revname="$rev"
27 ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
28fi9fi
2910
30export_uncommitted=""11archive_base="cloud-init-$revname"
31if [ "${UNCOMMITTED:-0}" != "0" ]; then12
32 export_uncommitted="--uncommitted"13# when building an archiving from HEAD, ensure that there aren't any
14# uncomitted changes in the working directory (because these would not
15# end up in the archive).
16if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then
17 if [ -z "$SKIP_UNCOMITTED_CHANGES_CHECK" ]; then
18 echo "ERROR: There are uncommitted changes in your working directory." >&2
19 exit 1
20 else
21 echo "WARNING: There are uncommitted changes in your working directory." >&2
22 echo " This changes will not be included in the archive." >&2
23 fi
33fi24fi
3425
35bzr export ${export_uncommitted} \26git archive \
36 --format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \27 --format=tar \
37 "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"28 --prefix "$archive_base/" $rev > "$archive_base.tar"
29gzip -f9 ${archive_base}.tar
3830
39echo "$ARCHIVE_FN"31echo ${archive_base}.tar.gz
diff --git a/tools/read-dependencies b/tools/read-dependencies
index 6a6f3e1..c8a5d23 100755
--- a/tools/read-dependencies
+++ b/tools/read-dependencies
@@ -1,13 +1,21 @@
1#!/usr/bin/env python1#!/usr/bin/env python
22
3# You might be tempted to rewrite this as a shell script, but you
4# would be surprised to discover that things like 'egrep' or 'sed' may
5# differ between Linux and *BSD.
6
3import os7import os
4import re8import re
5import sys9import sys
10import subprocess
611
7if 'CLOUD_INIT_TOP_D' in os.environ:12if 'CLOUD_INIT_TOP_D' in os.environ:
8 topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))13 topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
9else:14else:
10 topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))15 p = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'],
16 stdout=subprocess.PIPE)
17 out, err = p.communicate()
18 topd = out.splitlines()[0]
1119
12for fname in ("setup.py", "requirements.txt"):20for fname in ("setup.py", "requirements.txt"):
13 if not os.path.isfile(os.path.join(topd, fname)):21 if not os.path.isfile(os.path.join(topd, fname)):
@@ -16,14 +24,21 @@ for fname in ("setup.py", "requirements.txt"):
16 sys.exit(1)24 sys.exit(1)
1725
18if len(sys.argv) > 1:26if len(sys.argv) > 1:
19 reqfile = sys.argv[1]27 reqfile = sys.argv[1]
20else:28else:
21 reqfile = "requirements.txt"29 reqfile = "requirements.txt"
22 30
23with open(os.path.join(topd, reqfile), "r") as fp:31with open(os.path.join(topd, reqfile), "r") as fp:
24 for line in fp:32 for line in fp:
25 if not line.strip() or line.startswith("#"):33 line = line.strip()
34 if not line or line.startswith("#"):
26 continue35 continue
27 sys.stdout.write(re.split("[>=.<]*", line)[0].strip() + "\n")36
37 # remove pip-style markers
38 dep = line.split(';')[0]
39
40 # remove version requirements
41 dep = re.split("[>=.<]*", dep)[0].strip()
42 print dep
2843
29sys.exit(0)44sys.exit(0)

Subscribers

People subscribed via source and target branches