Merge lp:~smoser/cloud-archive-utils/add-cloud-tools into lp:cloud-archive-utils

Proposed by Scott Moser
Status: Merged
Approved by: Adam Gandelman
Approved revision: no longer in the source branch.
Merged at revision: 16
Proposed branch: lp:~smoser/cloud-archive-utils/add-cloud-tools
Merge into: lp:cloud-archive-utils
Diff against target: 237 lines (+107/-12)
6 files modified
bin/cloud-archive-tools-backport (+51/-0)
cloudarchive/backport.py (+27/-9)
cloudarchive/common.py (+8/-0)
cloudarchive/dput/scripts.py (+1/-0)
cloudarchive/utils.py (+10/-3)
dput.d/profiles/cact.json (+10/-0)
To merge this branch: bzr merge lp:~smoser/cloud-archive-utils/add-cloud-tools
Reviewer Review Type Date Requested Status
Adam Gandelman (community) Approve
Review via email: mp+185891@code.launchpad.net

Description of the change

add cloud-tools support.

2 primary things here:
 * add bin/cloud-archive-tools-backport an analog of cloud-archive-backport
   but for the cloud-tools pocket.
 * make do_backport a wrapper around newly added do_explicit_backport
   do_explicit_backport just contains explicit arguments for each of the
   things that do_backport was figuring out internally.
   do_backport should remain backwards compatible.

To post a comment you must log in.
Revision history for this message
Adam Gandelman (gandelman-a) wrote :

LGTM.

review: Approve
16. By Adam Gandelman

[smoser] add cact (cloud archive cloud tools) dput-ng profile

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/cloud-archive-tools-backport'
2--- bin/cloud-archive-tools-backport 1970-01-01 00:00:00 +0000
3+++ bin/cloud-archive-tools-backport 2013-09-16 19:00:42 +0000
4@@ -0,0 +1,51 @@
5+#! /usr/bin/python
6+
7+import optparse
8+import sys
9+
10+from cloudarchive.backport import do_explicit_backport, CABackportException
11+from cloudarchive.common import UBUNTU_DEV, UBUNTU_STABLE, SERIES
12+from ubuntutools.logger import Logger
13+
14+if __name__ == '__main__':
15+ usage = 'usage: %prog [options] package(s)'
16+ parser = optparse.OptionParser(usage=usage)
17+ parser.add_option('-N', '--next',
18+ help='target cloud-tools-next rather than '
19+ 'cloud-tools-staging',
20+ dest='next', action='store_true', default=False)
21+ parser.add_option('-c', '--changelog-message',
22+ help='Changelog message to use.',
23+ dest='changelog', action='store')
24+ parser.add_option('-s', '--suffix',
25+ help='Backport suffix to use (default=~cloud0).',
26+ dest='suffix', action='store', default="~cloud0")
27+ parser.add_option('-o', '--outdir',
28+ help='Directory to save source package',
29+ dest='out_dir', action='store', default=None)
30+ parser.add_option('-y', '--yes', help='Assume yes to any prompt.',
31+ dest='assume_yes', action='store_true', default=False)
32+ (opts, args) = parser.parse_args()
33+
34+ if len(args) == 0:
35+ parser.print_usage()
36+ sys.exit(1)
37+ else:
38+ packages = args
39+
40+ chlog_dist = SERIES
41+ changes_dist = SERIES
42+ if opts.next:
43+ ubuntu_series = UBUNTU_DEV
44+ target_ppa = 'cloud-tools-next'
45+ else:
46+ ubuntu_series = UBUNTU_STABLE
47+ target_ppa = 'cloud-tools-staging'
48+
49+ for package in args:
50+ Logger.normal('Backporting %s from %s to %s.',
51+ package, ubuntu_series, target_ppa)
52+ do_explicit_backport(package, ubuntu_series, target_ppa, chlog_dist,
53+ changes_dist=SERIES, message=opts.changelog,
54+ suffix=opts.suffix, out_dir=opts.out_dir,
55+ assume_yes=opts.assume_yes)
56
57=== modified file 'cloudarchive/backport.py'
58--- cloudarchive/backport.py 2013-08-28 18:42:45 +0000
59+++ cloudarchive/backport.py 2013-09-16 19:00:42 +0000
60@@ -32,6 +32,23 @@
61 def do_backport(package, release, message=None, suffix="~cloud0",
62 out_dir=None, assume_yes=False):
63
64+ ubuntu_series = SOURCE_RELEASE[release]
65+ os_series = release
66+ check_ppa = "{}-staging".format(os_series)
67+ chlog_dist = '{}-{}'.format(SERIES, os_series)
68+
69+ return do_explicit_backport(package, ubuntu_series=ubuntu_series,
70+ check_ppa=check_ppa, chlog_dist=chlog_dist,
71+ changes_dist=SERIES, message=message,
72+ suffix=suffix, out_dir=out_dir,
73+ assume_yes=assume_yes)
74+
75+
76+def do_explicit_backport(package, ubuntu_series, check_ppa, chlog_dist,
77+ changes_dist=SERIES,
78+ message=None, suffix="~cloud0", out_dir=None,
79+ assume_yes=False):
80+
81 if not out_dir:
82 out_dir = os.getcwd()
83 else:
84@@ -42,20 +59,20 @@
85
86 archive = Distribution('ubuntu').getArchive()
87 Logger.normal('Looking for package %s in %s',
88- package, SOURCE_RELEASE[release])
89+ package, ubuntu_series)
90
91 pkgs = []
92 for pocket in ['Security', 'Release', 'Updates']:
93 try:
94- pkg = archive.getSourcePackage(
95- package, SOURCE_RELEASE[release], pocket=pocket)
96+ pkg = archive.getSourcePackage(package, ubuntu_series,
97+ pocket=pocket)
98 pkgs.append(pkg)
99 except PackageNotFoundException:
100 pass
101
102 if not pkgs:
103 raise CABackportException("Unable to find source package %s in %s",
104- package, SOURCE_RELEASE[release])
105+ package, ubuntu_series)
106
107 # find the most recent upload in all pockets.
108 pkgs = sorted(pkgs, cmp=version_compare,
109@@ -68,9 +85,9 @@
110 Logger.normal('Backporting from %s.' % spph.getSeriesAndPocket())
111 Logger.normal('Version: %s', version)
112
113- old_version = utils.get_package_version(package, release)
114+ old_version = utils.get_package_version(package, ppa=check_ppa)
115 Logger.normal('Existing version for %s in %s Cloud Archive: %s',
116- package, release, old_version)
117+ package, ubuntu_series, old_version)
118 if not old_version:
119 old_version = "0"
120 new_version = '{}{}'.format(version, suffix)
121@@ -81,7 +98,7 @@
122
123 out_dir = os.path.join(out_dir, '{}-{}'.format(package, new_version))
124
125- dirname = '{}-{}'.format(package, SOURCE_RELEASE[release])
126+ dirname = '{}-{}'.format(package, ubuntu_series)
127 dirname = os.path.join(out_dir, dirname)
128
129 for d in [out_dir, dirname]:
130@@ -119,7 +136,7 @@
131 '--newversion', new_version,
132 '--force-bad-version',
133 '--preserve',
134- '--distribution', '{}-{}'.format(SERIES, release),
135+ '--distribution', chlog_dist,
136 '--force-distribution', message
137 ]
138 check_call(cmd, cwd=dirname)
139@@ -128,8 +145,9 @@
140 'debuild', '--no-lintian',
141 '-S', '-sa', '-nc', '-uc', '-us',
142 '-v{}'.format(previous_version),
143- '--changes-option=-DDistribution={}'.format(SERIES)
144+ '--changes-option=-DDistribution={}'.format(changes_dist)
145 ]
146+
147 if version_compare(upstream_version(version),
148 upstream_version(old_version)) == 1:
149 cmd.append('-sa')
150
151=== modified file 'cloudarchive/common.py'
152--- cloudarchive/common.py 2013-07-01 20:47:20 +0000
153+++ cloudarchive/common.py 2013-09-16 19:00:42 +0000
154@@ -27,6 +27,14 @@
155 "havana": "saucy"
156 }
157
158+UBUNTU_SERIES = [
159+ 'raring',
160+ 'saucy',
161+]
162+
163+UBUNTU_DEV = UBUNTU_SERIES[-1]
164+UBUNTU_STABLE = UBUNTU_SERIES[-2]
165+
166 LTS_SERIES = {
167 'precise': ['essex', 'folsom', 'grizzly', 'havana', 'icehouse']
168 }
169
170=== modified file 'cloudarchive/dput/scripts.py'
171--- cloudarchive/dput/scripts.py 2013-06-20 13:02:22 +0000
172+++ cloudarchive/dput/scripts.py 2013-09-16 19:00:42 +0000
173@@ -39,6 +39,7 @@
174 else:
175 logger.info('OK: Upload is targetting Ubuntu: %s.', distribution)
176
177+ logger.info("profile: %s", profile)
178 openstack_target = changes.get("Changes").split()[2]\
179 .strip(';').split('-')[-1]
180 upload_target = profile['incoming'].split('/')[-1].split('-')[0]
181
182=== modified file 'cloudarchive/utils.py'
183--- cloudarchive/utils.py 2013-08-21 01:23:49 +0000
184+++ cloudarchive/utils.py 2013-09-16 19:00:42 +0000
185@@ -3,6 +3,7 @@
186
187 from apt_pkg import version_compare
188
189+from ubuntutools.logger import Logger
190 from common import SERIES, SOURCE_RELEASE, LTS_SERIES
191
192 from ubuntutools.lp.lpapicache import (Launchpad, Distribution,
193@@ -32,6 +33,8 @@
194 release=SERIES):
195 ''' Query a PPA for source packages and versions '''
196 get_lp()
197+ Logger.normal("query_ca_ppa: checking ppa=%s, release=%s, owner=%s",
198+ ppa, release, owner)
199 ppa = Launchpad.people[owner].getPPAByName(name=ppa)
200 distro = ppa.distribution.getSeries(name_or_version=release)
201 out = {}
202@@ -61,13 +64,17 @@
203 return pkgs[0].getVersion()
204
205
206-def get_package_version(package, os_series="folsom"):
207+def get_package_version(package, os_series="folsom", ppa=None):
208 ''' Retrieve the version of package from the staging PPA for os_series '''
209- source_versions = query_ca_ppa(ppa="{}-staging".format(os_series),
210- release=SERIES)
211+ if ppa is None:
212+ ppa = "{}-staging".format(os_series)
213+
214+ source_versions = query_ca_ppa(ppa=ppa, release=SERIES)
215+
216 if package in source_versions:
217 return source_versions[package]
218 else:
219+ Logger.normal("quering distro for %s", package)
220 return query_distro(package)
221
222
223
224=== added file 'dput.d/profiles/cact.json'
225--- dput.d/profiles/cact.json 1970-01-01 00:00:00 +0000
226+++ dput.d/profiles/cact.json 2013-09-16 19:00:42 +0000
227@@ -0,0 +1,10 @@
228+{
229+ "meta": "ubuntu",
230+ "fqdn": "ppa.launchpad.net",
231+ "incoming": "~ubuntu-cloud-archive/cloud-tools-%(cact)s",
232+ "+hooks": [
233+ ],
234+ "-hooks": [
235+ "suite-mismatch"
236+ ]
237+}

Subscribers

People subscribed via source and target branches