1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
= BinaryPackageRelease =
BinaryPackageRelease stores unique versions of binarypackagenames
across build records.
>>> from canonical.launchpad.webapp.testing import verifyObject
>>> from lp.soyuz.interfaces.binarypackagerelease import (
... IBinaryPackageRelease,
... )
>>> from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
>>> firefox_bin_release = BinaryPackageRelease.get(12)
>>> verifyObject(IBinaryPackageRelease, firefox_bin_release)
True
Useful properties:
>>> firefox_bin_release.name, firefox_bin_release.version
(u'mozilla-firefox', u'0.9')
>>> from lp.registry.interfaces.distroseries import IDistroSeriesSet
>>> warty = getUtility(IDistroSeriesSet).get(1)
>>> warty.name
u'warty'
>>> hoary = getUtility(IDistroSeriesSet).get(3)
>>> hoary.name
u'hoary'
Retrieve the respective DistributionSourcePackageRelease, which allow
us to easily link to a source reference published in the web-ui.
>>> from lp.soyuz.interfaces.distributionsourcepackagerelease import IDistributionSourcePackageRelease
>>> verifyObject(
... IDistributionSourcePackageRelease,
... firefox_bin_release.distributionsourcepackagerelease)
True
The 'is_new' property tells us whether or not this
BinaryPackageRelease has ever been published for the DistroArchSeries
it was built for. If not, then 'is_new' will be True, otherwise False.
>>> firefox_bin_release.is_new
False
>>> pmount_bin_release = BinaryPackageRelease.get(20)
>>> pmount_bin_release.name, pmount_bin_release.version
(u'pmount', u'0.1-1')
>>> pmount_bin_release.is_new
True
The IBinaryPackageNameSet.getNotNewByNames() returns all the
BinaryPackageName records for BinaryPackageReleases that are published
in the supplied distroseries in the archives with the supplied
BinaryPackageNames. This is a way of quickly establishing the "is_new"
value for a range of packages all at the same time, although it returns
old (published) packages, not new ones. However, the new packages can
be quickly ascertained through a set operation.
>>> from zope.security.proxy import removeSecurityProxy
>>> from lp.soyuz.interfaces.binarypackagename import (
... IBinaryPackageNameSet)
>>> foobar_name = getUtility(IBinaryPackageNameSet)['foobar']
>>> name_ids = (
... foobar_name.id,
... pmount_bin_release.binarypackagename.id,
... firefox_bin_release.binarypackagename.id)
>>> archive_ids = removeSecurityProxy(
... warty.distribution.all_distro_archive_ids)
>>> names = getUtility(IBinaryPackageNameSet).getNotNewByNames(
... name_ids, warty, archive_ids)
>>> import operator
>>> for name in sorted(names, key=operator.attrgetter('name')):
... print name.name
mozilla-firefox
pmount
Passing no name_ids gives the EmptyResultSet.
>>> getUtility(IBinaryPackageNameSet).getNotNewByNames(
... [], warty, archive_ids).count()
0
Check IBinaryPackageRelease.override() behaviour:
The override method does implicitly exactly the same than:
BinaryPackagerelease.set(component=new_component,
section=new_section,
priority=new_priority)
but it only sets the not-empty given arguments, so you can override the
attributes exclusively. It only exists to improve the code clarity,
in ftp-master/queue tool and other scripts.
Display the current firefox component and section:
>>> firefox_bin_release.component.name, firefox_bin_release.section.name
(u'main', u'base')
Fetch brand new component, section and priority:
>>> from lp.soyuz.enums import PackagePublishingPriority
>>> from lp.soyuz.interfaces.component import IComponentSet
>>> from lp.soyuz.interfaces.section import ISectionSet
>>> new_comp = getUtility(IComponentSet)['universe']
>>> new_sec = getUtility(ISectionSet)['mail']
>>> new_priority = PackagePublishingPriority.IMPORTANT
Override the current firefox with new component/section/priority:
>>> firefox_bin_release.override(component=new_comp, section=new_sec,
... priority=new_priority)
Check if it got overridden correctly:
>>> firefox_bin_release.component.name, firefox_bin_release.section.name, firefox_bin_release.priority.name
(u'universe', u'mail', 'IMPORTANT')
Override again; ensure that only the changed item actually changes:
>>> new_sec = getUtility(ISectionSet)['net']
>>> firefox_bin_release.override(section=new_sec)
>>> (firefox_bin_release.component.name,
... firefox_bin_release.section.name,
... firefox_bin_release.priority.name)
(u'universe', u'net', 'IMPORTANT')
Abort transaction to avoid error propagation of the new attributes:
>>> import transaction
>>> transaction.abort()
== Binary file association ==
BinaryPackageRelease.addFile() associate given `LibraryFileAlias` with
the context binarypackage release.
We will use `SoyuzTestPublisher` for creating a fresh binary package
release.
>>> login('foo.bar@canonical.com')
>>> from lp.soyuz.tests.test_publishing import (
... SoyuzTestPublisher)
>>> test_publisher = SoyuzTestPublisher()
>>> test_publisher.prepareBreezyAutotest()
>>> pubs = test_publisher.getPubBinaries()
>>> a_binary = pubs[0].binarypackagerelease
The just-create package already has a 'DEB' file associtated to
it. We will create a helper function to inspect binary packagefiles.
>>> def print_files(binary):
... for bin_file in binary.files:
... print bin_file.libraryfile.filename, bin_file.filetype.name
>>> print_files(a_binary)
foo-bin_666_all.deb DEB
Additionally to DEB files, UDEB and DDEB extensions are also supported.
>>> deb = test_publisher.addMockFile('foo-extra_666_all.deb')
>>> udeb = test_publisher.addMockFile('foo-inst_666_all.udeb')
>>> ddeb = test_publisher.addMockFile('foo-dbg_666_all.ddeb')
>>> unused = a_binary.addFile(deb)
>>> unused = a_binary.addFile(udeb)
>>> unused = a_binary.addFile(ddeb)
>>> print_files(a_binary)
foo-bin_666_all.deb DEB
foo-extra_666_all.deb DEB
foo-inst_666_all.udeb UDEB
foo-dbg_666_all.ddeb DDEB
An error is raised if a file with an unsupported extension is given.
>>> boing = test_publisher.addMockFile('foo-dbg_666_all.boing')
>>> unused = a_binary.addFile(boing)
Traceback (most recent call last):
...
AssertionError: Unsupported file type: foo-dbg_666_all.boing
|