Merge lp:~cjwatson/launchpad/build-depends-arch-user-defined into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17915
Proposed branch: lp:~cjwatson/launchpad/build-depends-arch-user-defined
Merge into: lp:launchpad
Diff against target: 310 lines (+86/-18)
8 files modified
lib/lp/archivepublisher/indices.py (+13/-2)
lib/lp/archivepublisher/tests/test_indices.py (+11/-2)
lib/lp/registry/browser/sourcepackage.py (+12/-0)
lib/lp/registry/templates/sourcepackage-index.pt (+12/-0)
lib/lp/soyuz/doc/package-relationship.txt (+5/-1)
lib/lp/soyuz/interfaces/sourcepackagerelease.py (+1/-1)
lib/lp/soyuz/model/sourcepackagerelease.py (+9/-7)
lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt (+23/-5)
To merge this branch: bzr merge lp:~cjwatson/launchpad/build-depends-arch-user-defined
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+285197@code.launchpad.net

Commit message

Handle Build-Depends-Arch and Build-Conflicts-Arch from SPR.user_defined_fields in Sources generation and SP:+index.

Description of the change

Handle Build-Depends-Arch and Build-Conflicts-Arch like their -Indep siblings.

This supersedes https://code.launchpad.net/~cjwatson/launchpad/db-build-depends-arch/+merge/282344 and https://code.launchpad.net/~cjwatson/launchpad/build-depends-arch/+merge/282345; rather than the approach taken there of adding new columns, this just special-cases entries in SPR.user_defined_fields if it finds them there.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/indices.py'
2--- lib/lp/archivepublisher/indices.py 2014-10-31 13:28:31 +0000
3+++ lib/lp/archivepublisher/indices.py 2016-02-05 15:25:49 +0000
4@@ -10,6 +10,7 @@
5
6 __metaclass__ = type
7
8+from collections import OrderedDict
9 import hashlib
10 import os.path
11 import re
12@@ -109,6 +110,9 @@
13 files_list.append((spf.libraryfile.content.md5, common))
14 sha1_list.append((spf.libraryfile.content.sha1, common))
15 sha256_list.append((spf.libraryfile.content.sha256, common))
16+ user_defined_fields = OrderedDict([
17+ (key.lower(), (key, value))
18+ for key, value in spr.user_defined_fields])
19 # Filling stanza options.
20 fields = IndexStanzaFields()
21 fields.append('Package', spr.name)
22@@ -118,8 +122,16 @@
23 fields.append('Maintainer', spr.dsc_maintainer_rfc822)
24 fields.append('Build-Depends', spr.builddepends)
25 fields.append('Build-Depends-Indep', spr.builddependsindep)
26+ if 'build-depends-arch' in user_defined_fields:
27+ fields.append(
28+ 'Build-Depends-Arch',
29+ user_defined_fields.pop('build-depends-arch')[1])
30 fields.append('Build-Conflicts', spr.build_conflicts)
31 fields.append('Build-Conflicts-Indep', spr.build_conflicts_indep)
32+ if 'build-conflicts-arch' in user_defined_fields:
33+ fields.append(
34+ 'Build-Conflicts-Arch',
35+ user_defined_fields.pop('build-conflicts-arch')[1])
36 fields.append('Architecture', spr.architecturehintlist)
37 fields.append('Standards-Version', spr.dsc_standards_version)
38 fields.append('Format', spr.dsc_format)
39@@ -128,8 +140,7 @@
40 fields.append('Checksums-Sha1', format_file_list(sha1_list))
41 fields.append('Checksums-Sha256', format_file_list(sha256_list))
42 fields.append('Homepage', spr.homepage)
43- if spr.user_defined_fields:
44- fields.extend(spr.user_defined_fields)
45+ fields.extend(user_defined_fields.values())
46
47 return fields
48
49
50=== modified file 'lib/lp/archivepublisher/tests/test_indices.py'
51--- lib/lp/archivepublisher/tests/test_indices.py 2014-10-31 13:05:52 +0000
52+++ lib/lp/archivepublisher/tests/test_indices.py 2016-02-05 15:25:49 +0000
53@@ -64,7 +64,10 @@
54 """
55 pub_source = self.getPubSource(
56 builddepends='fooish', builddependsindep='pyfoo',
57- build_conflicts='bar', build_conflicts_indep='pybar')
58+ build_conflicts='bar', build_conflicts_indep='pybar',
59+ user_defined_fields=[
60+ ("Build-Depends-Arch", "libfoo-dev"),
61+ ("Build-Conflicts-Arch", "libbar-dev")])
62
63 self.assertEqual(
64 [u'Package: foo',
65@@ -74,8 +77,10 @@
66 u'Maintainer: Foo Bar <foo@bar.com>',
67 u'Build-Depends: fooish',
68 u'Build-Depends-Indep: pyfoo',
69+ u'Build-Depends-Arch: libfoo-dev',
70 u'Build-Conflicts: bar',
71 u'Build-Conflicts-Indep: pybar',
72+ u'Build-Conflicts-Arch: libbar-dev',
73 u'Architecture: all',
74 u'Standards-Version: 3.6.2',
75 u'Format: 1.0',
76@@ -102,7 +107,9 @@
77 build_conflicts='bar', build_conflicts_indep='pybar',
78 user_defined_fields=[
79 ("Python-Version", "< 1.5"),
80- ("CHECKSUMS-SHA1", "BLAH")])
81+ ("CHECKSUMS-SHA1", "BLAH"),
82+ ("Build-Depends-Arch", "libfoo-dev"),
83+ ("Build-Conflicts-Arch", "libbar-dev")])
84
85 self.assertEqual(
86 [u'Package: foo',
87@@ -112,8 +119,10 @@
88 u'Maintainer: Foo Bar <foo@bar.com>',
89 u'Build-Depends: fooish',
90 u'Build-Depends-Indep: pyfoo',
91+ u'Build-Depends-Arch: libfoo-dev',
92 u'Build-Conflicts: bar',
93 u'Build-Conflicts-Indep: pybar',
94+ u'Build-Conflicts-Arch: libbar-dev',
95 u'Architecture: all',
96 u'Standards-Version: 3.6.2',
97 u'Format: 1.0',
98
99=== modified file 'lib/lp/registry/browser/sourcepackage.py'
100--- lib/lp/registry/browser/sourcepackage.py 2015-10-01 17:32:41 +0000
101+++ lib/lp/registry/browser/sourcepackage.py 2016-02-05 15:25:49 +0000
102@@ -520,6 +520,12 @@
103 self.context.currentrelease.builddependsindep)
104
105 @property
106+ def builddependsarch(self):
107+ return self._relationship_parser(
108+ self.context.currentrelease.getUserDefinedField(
109+ "Build-Depends-Arch"))
110+
111+ @property
112 def build_conflicts(self):
113 return self._relationship_parser(
114 self.context.currentrelease.build_conflicts)
115@@ -529,6 +535,12 @@
116 return self._relationship_parser(
117 self.context.currentrelease.build_conflicts_indep)
118
119+ @property
120+ def build_conflicts_arch(self):
121+ return self._relationship_parser(
122+ self.context.currentrelease.getUserDefinedField(
123+ "Build-Conflicts-Arch"))
124+
125 def requestCountry(self):
126 return ICountry(self.request, None)
127
128
129=== modified file 'lib/lp/registry/templates/sourcepackage-index.pt'
130--- lib/lp/registry/templates/sourcepackage-index.pt 2015-11-24 01:44:28 +0000
131+++ lib/lp/registry/templates/sourcepackage-index.pt 2016-02-05 15:25:49 +0000
132@@ -124,6 +124,12 @@
133 <tal:block tal:condition="relationships/has_items"
134 replace="structure relationships/@@+render-list"/>
135 </td>
136+ <td id="dependsarch"
137+ tal:define="relationships view/builddependsarch">
138+ <h3>Platform-dependent build dependencies</h3>
139+ <tal:block tal:condition="relationships/has_items"
140+ replace="structure relationships/@@+render-list"/>
141+ </td>
142 </tr>
143 <tr>
144 <td id="conflicts" tal:define="relationships view/build_conflicts">
145@@ -137,6 +143,12 @@
146 <tal:block tal:condition="relationships/has_items"
147 replace="structure relationships/@@+render-list"/>
148 </td>
149+ <td id="conflictsarch"
150+ tal:define="relationships view/build_conflicts_arch">
151+ <h3>Platform-dependent build dependencies</h3>
152+ <tal:block tal:condition="relationships/has_items"
153+ replace="structure relationships/@@+render-list"/>
154+ </td>
155 </tr>
156 </table>
157 </div>
158
159=== modified file 'lib/lp/soyuz/doc/package-relationship.txt'
160--- lib/lp/soyuz/doc/package-relationship.txt 2015-07-29 16:55:28 +0000
161+++ lib/lp/soyuz/doc/package-relationship.txt 2016-02-05 15:25:49 +0000
162@@ -1,12 +1,16 @@
163 = Package Relationship Model =
164
165 We call "package relationship" the DSC field which describes relation
166-between the package in question and others availble:
167+between the package in question and others available:
168
169 For sources DSC provides:
170
171 * builddepends
172 * builddependsindep
173+ * builddependsarch
174+ * build_conflicts
175+ * build_conflicts_indep
176+ * build_conflicts_arch
177
178 For binaries we have:
179
180
181=== modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
182--- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2015-09-28 17:38:45 +0000
183+++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2016-02-05 15:25:49 +0000
184@@ -50,7 +50,7 @@
185 "package depends to build"),
186 required=False)
187 builddependsindep = TextLine(
188- title=_("DSC build depends"),
189+ title=_("DSC arch-independent build depends"),
190 description=_("Same as builddepends, but the list is of "
191 "arch-independent packages"),
192 required=False)
193
194=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
195--- lib/lp/soyuz/model/sourcepackagerelease.py 2015-11-20 17:57:46 +0000
196+++ lib/lp/soyuz/model/sourcepackagerelease.py 2016-02-05 15:25:49 +0000
197@@ -8,6 +8,7 @@
198
199
200 import datetime
201+import json
202 import operator
203 import re
204 from StringIO import StringIO
205@@ -19,7 +20,6 @@
206 ChangelogParseError,
207 )
208 import pytz
209-import simplejson
210 from sqlobject import (
211 ForeignKey,
212 SQLMultipleJoin,
213@@ -132,7 +132,7 @@
214
215 def __init__(self, *args, **kwargs):
216 if 'user_defined_fields' in kwargs:
217- kwargs['_user_defined_fields'] = simplejson.dumps(
218+ kwargs['_user_defined_fields'] = json.dumps(
219 kwargs['user_defined_fields'])
220 del kwargs['user_defined_fields']
221 # copyright isn't on the Storm class, since we don't want it
222@@ -173,13 +173,15 @@
223 """See `IBinaryPackageRelease`."""
224 if self._user_defined_fields is None:
225 return []
226- return simplejson.loads(self._user_defined_fields)
227+ user_defined_fields = json.loads(self._user_defined_fields)
228+ if user_defined_fields is None:
229+ return []
230+ return user_defined_fields
231
232 def getUserDefinedField(self, name):
233- if self.user_defined_fields:
234- for k, v in self.user_defined_fields:
235- if k.lower() == name.lower():
236- return v
237+ for k, v in self.user_defined_fields:
238+ if k.lower() == name.lower():
239+ return v
240
241 @cachedproperty
242 def package_diffs(self):
243
244=== modified file 'lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt'
245--- lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt 2015-11-30 04:18:39 +0000
246+++ lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt 2016-02-05 15:25:49 +0000
247@@ -118,12 +118,12 @@
248 ... 'http://launchpad.dev/ubuntu/breezy-autotest/+source/'
249 ... 'commercialpackage')
250
251-PackageRelationships, 'builddepends', 'builddependsindep',
252-'build_conflicts' and 'build_conflicts_indep' for the source in
253-question are provided in this page.
254+PackageRelationships, 'builddepends', 'builddependsindep', 'builddependsarch',
255+'build_conflicts', 'build_conflicts_indep', and 'build_conflicts_arch' for the
256+source in question are provided in this page.
257
258-Even when the relationshipt section is empty they are presented,
259-keeping the page format contant.
260+Even when the relationship section is empty they are presented,
261+keeping the page format constant.
262
263 >>> depends_section = find_tag_by_id(browser.contents, 'depends')
264 >>> parse_relationship_section(str(depends_section))
265@@ -133,6 +133,10 @@
266 >>> parse_relationship_section(str(dependsindep_section))
267 EMPTY SECTION
268
269+ >>> dependsarch_section = find_tag_by_id(browser.contents, 'dependsarch')
270+ >>> parse_relationship_section(str(dependsarch_section))
271+ EMPTY SECTION
272+
273 >>> conflicts_section = find_tag_by_id(browser.contents, 'conflicts')
274 >>> parse_relationship_section(str(conflicts_section))
275 EMPTY SECTION
276@@ -142,6 +146,11 @@
277 >>> parse_relationship_section(str(conflictsindep_section))
278 EMPTY SECTION
279
280+ >>> conflictsarch_section = find_tag_by_id(
281+ ... browser.contents, 'conflictsarch')
282+ >>> parse_relationship_section(str(conflictsarch_section))
283+ EMPTY SECTION
284+
285 Let's inspect a page with non-empty relationships.
286
287 >>> browser.open(
288@@ -163,6 +172,10 @@
289 LINK: "pmount" -> http://launchpad.dev/ubuntu/warty/+package/pmount
290 TEXT: "postgresql-client (&gt;= 7.4)"
291
292+ >>> dependsarch_section = find_tag_by_id(browser.contents, 'dependsarch')
293+ >>> parse_relationship_section(str(dependsarch_section))
294+ EMPTY SECTION
295+
296 >>> conflicts_section = find_tag_by_id(browser.contents, 'conflicts')
297 >>> parse_relationship_section(str(conflicts_section))
298 TEXT: "gcc-4.0"
299@@ -174,6 +187,11 @@
300 TEXT: "gcc-4.0-base"
301 LINK: "pmount" -> http://launchpad.dev/ubuntu/warty/+package/pmount
302
303+ >>> conflictsarch_section = find_tag_by_id(
304+ ... browser.contents, 'conflictsarch')
305+ >>> parse_relationship_section(str(conflictsarch_section))
306+ EMPTY SECTION
307+
308
309 The '+changelog' page provides an aggregation of the changelogs for
310 SourcePackageReleases published in this DistroSeries.