~launchpad-pqm/launchpad/devel

8687.15.17 by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
4983.1.1 by Curtis Hovey
Added lint exceptions to __init__.py and interface/*.py.
4
# pylint: disable-msg=E0211,E0213
2068 by Canonical.com Patch Queue Manager
[r=SteveA/trivial] import fascism, kill translationeffort, kill sshkey browser code, add __all__s to interfaces, other cleanings-up
5
6
"""Queue interfaces."""
7
8
__metaclass__ = type
9
10
__all__ = [
6269.10.4 by Celso Providelo
applying review comments, r=salgado.
11
    'IHasQueueItems',
3496.1.120 by Celso Providelo
unify the permissions for a DistroReleaseQueue in an abstract model called IPackageUploadQueue.
12
    'IPackageUploadQueue',
3691.441.21 by Malcolm Cleaton
More stuff
13
    'IPackageUpload',
14
    'IPackageUploadBuild',
15
    'IPackageUploadSource',
16
    'IPackageUploadCustom',
17
    'IPackageUploadSet',
6269.10.4 by Celso Providelo
applying review comments, r=salgado.
18
    'NonBuildableSourceUploadError',
19
    'QueueBuildAcceptError',
20
    'QueueInconsistentStateError',
21
    'QueueSourceAcceptError',
22
    'QueueStateWriteProtectedError',
2068 by Canonical.com Patch Queue Manager
[r=SteveA/trivial] import fascism, kill translationeffort, kill sshkey browser code, add __all__s to interfaces, other cleanings-up
23
    ]
24
11411.6.13 by Julian Edwards
fix overzealous removal
25
from lazr.enum import (
26
    DBEnumeratedType,
27
    )
28
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
29
from lazr.restful.declarations import (
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
30
    export_as_webservice_entry,
31
    exported,
32
    )
8697.13.13 by Julian Edwards
Move getPackageUploads to the PackageUploadSet utility.
33
from lazr.restful.fields import Reference
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
34
from zope.interface import (
35
    Attribute,
36
    Interface,
37
    )
38
from zope.schema import (
39
    Choice,
40
    Datetime,
41
    Int,
42
    List,
43
    TextLine,
44
    )
45
46
from canonical.launchpad import _
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
47
11411.6.9 by Julian Edwards
Move PackageUploadStatus and PackageUploadCustomFormat
48
from lp.soyuz.enums import PackageUploadStatus
49
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
50
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
51
class QueueStateWriteProtectedError(Exception):
52
    """This exception prevent directly set operation in queue state.
53
54
    The queue state machine is controlled by its specific provided methods,
3147.2.62 by Celso Providelo
Applying review comments (take 1)
55
    like: setNew, setAccepted and so on.
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
56
    """
57
58
59
class QueueInconsistentStateError(Exception):
60
    """Queue state machine error.
61
3023.4.1 by Christian Reis
Handle review comments from Salgado and Spiv
62
    It's generated when the solicited state makes the record
63
    inconsistent against the current system constraints.
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
64
    """
65
66
6269.10.4 by Celso Providelo
applying review comments, r=salgado.
67
class NonBuildableSourceUploadError(QueueInconsistentStateError):
68
    """Source upload will not result in any build record.
69
70
    This error is raised when trying to accept a source upload that is
71
    consistent but will not build in any of the architectures supported
72
    in its targeted distroseries.
73
    """
74
75
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
76
class QueueSourceAcceptError(Exception):
3691.441.21 by Malcolm Cleaton
More stuff
77
    """It prevents a PackageUploadSource from being ACCEPTED.
2865.2.58 by Celso Providelo
Extend DRQ state machine for builds and tests, also workarround buildd upload policy to acceptevery existent component.
78
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
79
    It is generated by Component and/or Section mismatching in a DistroSeries.
2865.2.58 by Celso Providelo
Extend DRQ state machine for builds and tests, also workarround buildd upload policy to acceptevery existent component.
80
    """
81
6269.10.4 by Celso Providelo
applying review comments, r=salgado.
82
2865.2.58 by Celso Providelo
Extend DRQ state machine for builds and tests, also workarround buildd upload policy to acceptevery existent component.
83
class QueueBuildAcceptError(Exception):
3691.441.21 by Malcolm Cleaton
More stuff
84
    """It prevents a PackageUploadBuild from being ACCEPTED.
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
85
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
86
    It is generated by Component and/or Section mismatching in a DistroSeries.
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
87
    """
88
89
3496.1.120 by Celso Providelo
unify the permissions for a DistroReleaseQueue in an abstract model called IPackageUploadQueue.
90
class IPackageUploadQueue(Interface):
91
    """Used to establish permission to a group of package uploads.
92
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
93
    Recieves an IDistroSeries and a PackageUploadStatus dbschema
3691.442.27 by Celso Providelo
applying review comments (r=jamesh)
94
    on initialisation.
3496.1.120 by Celso Providelo
unify the permissions for a DistroReleaseQueue in an abstract model called IPackageUploadQueue.
95
    No attributes exposed via interface, only used to check permissions.
96
    """
97
98
3691.441.21 by Malcolm Cleaton
More stuff
99
class IPackageUpload(Interface):
10529.1.6 by Jonathan Lange
Fewer mentions of lucille
100
    """A Queue item for the archive uploader."""
101
12243.5.8 by Leonard Richardson
Added web_links to the tests for objects that have them, and removed them from objects that don't.
102
    export_as_webservice_entry(publish_web_link=False)
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
103
104
    id = Int(
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
105
            title=_("ID"), required=True, readonly=True,
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
106
            )
107
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
108
    status = exported(
109
        Choice(
110
            vocabulary=PackageUploadStatus,
111
            description=_("The status of this upload."),
3147.2.62 by Celso Providelo
Applying review comments (take 1)
112
            title=_("Queue status"), required=False, readonly=True,
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
113
            ))
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
114
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
115
    distroseries = exported(
116
        Reference(
8697.13.16 by Julian Edwards
fix circular imports
117
            # Really IDistroSeries, patched in
118
            # _schema_circular_imports.py
119
            schema=Interface,
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
120
            description=_("The distroseries targeted by this upload."),
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
121
            title=_("Series"), required=True, readonly=False,
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
122
            ))
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
123
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
124
    pocket = exported(
125
        Choice(
8697.13.16 by Julian Edwards
fix circular imports
126
            # Really PackagePublishingPocket, patched in
127
            # _schema_circular_imports.py
128
            vocabulary=DBEnumeratedType,
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
129
            description=_("The pocket targeted by this upload."),
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
130
            title=_("The pocket"), required=True, readonly=False,
8697.13.10 by Julian Edwards
Add export of PackageUpload.
131
            ))
2733 by Canonical.com Patch Queue Manager
Upload processor. r=stevea
132
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
133
    date_created = exported(
134
        Datetime(
135
            title=_('Date created'),
136
            description=_("The date this package upload was done.")))
7675.218.1 by Celso Providelo
Creating PackageUploadSet.createDelayedCopy() and adjusting PackageUpload to use its 'date_created' DB column instead of the property based on the changesfile creation date.
137
3032.1.1 by Celso Providelo
Workaround for the Soyuz Production database and test fixing.
138
    changesfile = Attribute("The librarian alias for the changes file "
139
                            "associated with this upload")
2865.2.49 by Celso Providelo
Fix IDistroReleaseQueue.count() to accept an optional distrorelease argument, use this feature in queue tool to display a proper queue counter.
140
3691.424.5 by Celso Providelo
applying review comments (r=bjornt)
141
    signing_key = Attribute("Changesfile Signing Key.")
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
142
    archive = exported(
143
        Reference(
8697.13.16 by Julian Edwards
fix circular imports
144
            # Really IArchive, patched in _schema_circular_imports.py
145
            schema=Interface,
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
146
            description=_("The archive for this upload."),
147
            title=_("Archive"), required=True, readonly=True))
2821.3.1 by Daniel Silverstone
Added a queue ftpmaster script and sundry extra bits.
148
    sources = Attribute("The queue sources associated with this queue item")
149
    builds = Attribute("The queue builds associated with the queue item")
3048.5.39 by Celso Providelo
fix DRQ interface for carlos
150
    customfiles = Attribute("Custom upload files associated with this "
151
                            "queue item")
2821.3.1 by Daniel Silverstone
Added a queue ftpmaster script and sundry extra bits.
152
8697.13.11 by Julian Edwards
Export of custom_file_urls and a new webservice test. Bug still left in getPackageUploads, will fix in next revision.
153
    custom_file_urls = exported(
154
        List(
155
            title=_("Custom File URLs"),
156
            description=_("Librarian URLs for all the custom files attached "
157
                          "to this upload."),
158
            value_type=TextLine(),
159
            required=False,
160
            readonly=True))
161
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
162
    displayname = exported(
163
        TextLine(
8697.13.10 by Julian Edwards
Add export of PackageUpload.
164
            title=_("Generic displayname for a queue item"), readonly=True),
165
        exported_as="display_name")
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
166
    displayversion = exported(
167
        TextLine(
168
            title=_("The source package version for this item"),
8697.13.10 by Julian Edwards
Add export of PackageUpload.
169
            readonly=True),
170
        exported_as="display_version")
8731.1.2 by Julian Edwards
Export IPackageUpload on the webservice.
171
    displayarchs = exported(
172
        TextLine(
8697.13.10 by Julian Edwards
Add export of PackageUpload.
173
            title=_("Architectures related to this item"), readonly=True),
174
        exported_as="display_arches")
3496.1.78 by Celso Providelo
clean up unused helper properties in IDistroReleaseQueue.
175
176
    sourcepackagerelease = Attribute(
177
        "The source package release for this item")
178
4974.4.3 by Julian Edwards
Kiko's review comments:
179
    contains_source = Attribute("whether or not this upload contains sources")
180
    contains_build = Attribute("whether or not this upload contains binaries")
181
    contains_installer = Attribute(
3147.2.85 by Celso Providelo
Implementing Queue tool actions UI
182
        "whether or not this upload contains installers images")
4974.4.3 by Julian Edwards
Kiko's review comments:
183
    contains_translation = Attribute(
3147.2.85 by Celso Providelo
Implementing Queue tool actions UI
184
        "whether or not this upload contains translations")
4974.4.3 by Julian Edwards
Kiko's review comments:
185
    contains_upgrader = Attribute(
3147.2.85 by Celso Providelo
Implementing Queue tool actions UI
186
        "wheter or not this upload contains upgrader images")
4974.4.3 by Julian Edwards
Kiko's review comments:
187
    contains_ddtp = Attribute(
3686.1.13 by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795
188
        "wheter or not this upload contains DDTP images")
4204.2.20 by Julian Edwards
Address remaining review issues and fix some affected tests.
189
    isPPA = Attribute(
190
        "Return True if this PackageUpload is a PPA upload.")
7675.235.2 by Celso Providelo
IPackageUpload.{acceptFromCopy, realiseUpload} adjusted and tested for delayed-copies.
191
    is_delayed_copy = Attribute(
192
        "Whether or not this PackageUpload record is a delayed-copy.")
2821.3.1 by Daniel Silverstone
Added a queue ftpmaster script and sundry extra bits.
193
6269.6.10 by Julian Edwards
Fix test bustage.
194
    components = Attribute(
6269.6.11 by Julian Edwards
gmb's review comments.
195
        """The set of components used in this upload.
6269.6.10 by Julian Edwards
Fix test bustage.
196
197
        For sources, this is the component on the associated
198
        sourcepackagerelease.  For binaries, this is all the components
199
        on all the binarypackagerelease records arising from the build.
200
        """)
201
3147.2.62 by Celso Providelo
Applying review comments (take 1)
202
    def setNew():
3023.4.1 by Christian Reis
Handle review comments from Salgado and Spiv
203
        """Set queue state to NEW."""
2865.2.49 by Celso Providelo
Fix IDistroReleaseQueue.count() to accept an optional distrorelease argument, use this feature in queue tool to display a proper queue counter.
204
3147.2.62 by Celso Providelo
Applying review comments (take 1)
205
    def setUnapproved():
3023.4.1 by Christian Reis
Handle review comments from Salgado and Spiv
206
        """Set queue state to UNAPPROVED."""
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
207
3147.2.62 by Celso Providelo
Applying review comments (take 1)
208
    def setAccepted():
3023.4.1 by Christian Reis
Handle review comments from Salgado and Spiv
209
        """Set queue state to ACCEPTED.
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
210
3691.442.27 by Celso Providelo
applying review comments (r=jamesh)
211
        Perform the required checks on its content, so we guarantee data
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
212
        integrity by code.
213
        """
214
3147.2.62 by Celso Providelo
Applying review comments (take 1)
215
    def setDone():
3023.4.1 by Christian Reis
Handle review comments from Salgado and Spiv
216
        """Set queue state to DONE."""
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
217
3147.2.62 by Celso Providelo
Applying review comments (take 1)
218
    def setRejected():
3023.4.1 by Christian Reis
Handle review comments from Salgado and Spiv
219
        """Set queue state to REJECTED."""
2865.2.49 by Celso Providelo
Fix IDistroReleaseQueue.count() to accept an optional distrorelease argument, use this feature in queue tool to display a proper queue counter.
220
5663.3.3 by Celso Providelo
Encapsulating acceptance procedure in upload-time into IPackageUpload.acceptFromUploader method.
221
    def acceptFromUploader(changesfile_path, logger=None):
222
        """Perform upload acceptance during upload-time.
223
7675.235.5 by Celso Providelo
applying review comments, r=abentley.
224
         * Move the upload to accepted queue in all cases.
225
         * Publish and close bugs for 'single-source' uploads.
5663.3.6 by Celso Providelo
applying review comments, r=sinzui.
226
         * Skip bug-closing for PPA uploads.
7675.235.2 by Celso Providelo
IPackageUpload.{acceptFromCopy, realiseUpload} adjusted and tested for delayed-copies.
227
         * Grant karma to people involved with the upload.
7675.262.1 by Celso Providelo
Relying on bug-closing done by process-accepted for delayed-copies. No need to have local bug closing in IPackageUpload.acceptFromCopy().
228
229
        :raises: AssertionError if the context is a delayed-copy.
7675.235.2 by Celso Providelo
IPackageUpload.{acceptFromCopy, realiseUpload} adjusted and tested for delayed-copies.
230
        """
231
232
    def acceptFromCopy():
233
        """Perform upload acceptance for a delayed-copy record.
234
7675.235.5 by Celso Providelo
applying review comments, r=abentley.
235
         * Move the upload to accepted queue in all cases.
7675.262.1 by Celso Providelo
Relying on bug-closing done by process-accepted for delayed-copies. No need to have local bug closing in IPackageUpload.acceptFromCopy().
236
237
        :raises: AssertionError if the context is not a delayed-copy or
238
            has no sources associated to it.
5663.3.3 by Celso Providelo
Encapsulating acceptance procedure in upload-time into IPackageUpload.acceptFromUploader method.
239
        """
240
5094.3.6 by Julian Edwards
Clean up the interface declarations.
241
    def acceptFromQueue(announce_list, logger=None, dry_run=False):
7675.235.2 by Celso Providelo
IPackageUpload.{acceptFromCopy, realiseUpload} adjusted and tested for delayed-copies.
242
        """Call setAccepted, do a syncUpdate, and send notification email.
243
244
         * Grant karma to people involved with the upload.
7675.262.1 by Celso Providelo
Relying on bug-closing done by process-accepted for delayed-copies. No need to have local bug closing in IPackageUpload.acceptFromCopy().
245
246
        :raises: AssertionError if the context is a delayed-copy.
7675.235.2 by Celso Providelo
IPackageUpload.{acceptFromCopy, realiseUpload} adjusted and tested for delayed-copies.
247
        """
5094.3.3 by Julian Edwards
Refactor the queue acceptance/rejection code that was in the UI and the
248
5094.3.6 by Julian Edwards
Clean up the interface declarations.
249
    def rejectFromQueue(logger=None, dry_run=False):
250
        """Call setRejected, do a syncUpdate, and send notification email."""
5094.3.3 by Julian Edwards
Refactor the queue acceptance/rejection code that was in the UI and the
251
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
252
    def realiseUpload(logger=None):
253
        """Take this ACCEPTED upload and create the publishing records for it
254
        as appropriate.
255
256
        When derivation is taken into account, this may result in queue items
257
        being created for derived distributions.
258
259
        If a logger is provided, messages will be written to it as the upload
260
        is entered into the publishing records.
5663.3.4 by Celso Providelo
Immediatelly creating build ready to be dispatched for PPA uploads. Some tests are pending fixes.
261
262
        Return a list containing the publishing records created.
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
263
        """
2865.2.49 by Celso Providelo
Fix IDistroReleaseQueue.count() to accept an optional distrorelease argument, use this feature in queue tool to display a proper queue counter.
264
2733 by Canonical.com Patch Queue Manager
Upload processor. r=stevea
265
    def addSource(spr):
266
        """Add the provided source package release to this queue entry."""
267
268
    def addBuild(build):
269
        """Add the provided build to this queue entry."""
270
271
    def addCustom(library_file, custom_type):
272
        """Add the provided library file alias as a custom queue entry of
273
        the given custom type.
274
        """
2865.2.49 by Celso Providelo
Fix IDistroReleaseQueue.count() to accept an optional distrorelease argument, use this feature in queue tool to display a proper queue counter.
275
3500.2.13 by Celso Providelo
Replace flush_database_updates in browser/queue.py by simpler syncUpdate build-in method as suggested by spiv in bug #47239
276
    def syncUpdate():
277
        """Write updates made on this object to the database.
278
279
        This should be used when you can't wait until the transaction is
280
        committed to have some updates actually written to the database.
281
        """
4204.2.10 by Julian Edwards
- Rejections added to drq.notify().
282
4785.3.5 by Jeroen Vermeulen
Removed whitespace at ends of lines.
283
    def notify(announce_list=None, summary_text=None,
4204.2.18 by Julian Edwards
Merge RF and address review comments. Forgot to commit after the RF merge since
284
        changes_file_object=None, logger=None):
4285.2.10 by Mark Shuttleworth
Merge RF
285
        """Notify by email when there is a new distroseriesqueue entry.
4204.2.5 by Julian Edwards
Commit work done so far at UDS.
286
287
        This will send new, accept, announce and rejection messages as
288
        appropriate.
4204.2.18 by Julian Edwards
Merge RF and address review comments. Forgot to commit after the RF merge since
289
290
        :param announce_list: The email address of the distro announcements
291
292
        :param summary_text: Any additional text to append to the auto-
293
            generated summary.  This is also the only text used if there is
294
            a rejection message generated.
295
296
        :param changes_file_object: An open file object pointing at the
297
            changes file.  Current, only nascentupload need supply this
298
            as the transaction is not committed to the DB at that point so
299
            data needs to be obtained from the changes file.
300
301
        :param logger: Specify a logger object if required.  Mainly for tests.
4204.2.5 by Julian Edwards
Commit work done so far at UDS.
302
        """
3500.2.13 by Celso Providelo
Replace flush_database_updates in browser/queue.py by simpler syncUpdate build-in method as suggested by spiv in bug #47239
303
6269.6.2 by Julian Edwards
Allow queue admin by those people specified in ArchivePermission, with the
304
    def overrideSource(new_component, new_section, allowed_components):
5985.12.6 by Julian Edwards
Add code that does the overriding, if selected in the UI.
305
        """Override the source package contained in this queue item.
306
307
        :param new_component: An IComponent to replace the existing one
308
            in the upload's source.
309
        :param new_section: An ISection to replace the existing one
310
            in the upload's source.
6269.6.2 by Julian Edwards
Allow queue admin by those people specified in ArchivePermission, with the
311
        :param allowed_components: A sequence of components that the
312
            callsite is allowed to override from and to.
313
314
        :raises QueueInconsistentStateError: if either the existing
315
            or the new_component are not in the allowed_components
316
            sequence.
5985.12.6 by Julian Edwards
Add code that does the overriding, if selected in the UI.
317
318
        The override values may be None, in which case they are not
319
        changed.
320
321
        :return: True if the source was overridden.
322
        """
323
6269.6.7 by Julian Edwards
Fix doc tests for IPackageUpload.override{Source.Binary} with allowed_components.
324
    def overrideBinaries(new_component, new_section, new_priority,
325
                         allowed_components):
5985.12.6 by Julian Edwards
Add code that does the overriding, if selected in the UI.
326
        """Override all the binaries in a binary queue item.
327
328
        :param new_component: An IComponent to replace the existing one
329
            in the upload's source.
330
        :param new_section: An ISection to replace the existing one
331
            in the upload's source.
332
        :param new_priority: A valid PackagePublishingPriority to replace
333
            the existing one in the upload's binaries.
6269.6.2 by Julian Edwards
Allow queue admin by those people specified in ArchivePermission, with the
334
        :param allowed_components: A sequence of components that the
335
            callsite is allowed to override from and to.
336
337
        :raises QueueInconsistentStateError: if either the existing
338
            or the new_component are not in the allowed_components
339
            sequence.
5985.12.6 by Julian Edwards
Add code that does the overriding, if selected in the UI.
340
341
        The override values may be None, in which case they are not
342
        changed.
343
344
        :return: True if the binaries were overridden.
345
        """
346
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
347
3691.441.21 by Malcolm Cleaton
More stuff
348
class IPackageUploadBuild(Interface):
10529.1.6 by Jonathan Lange
Fewer mentions of lucille
349
    """A Queue item's related builds."""
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
350
351
    id = Int(
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
352
            title=_("ID"), required=True, readonly=True,
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
353
            )
354
355
3691.441.21 by Malcolm Cleaton
More stuff
356
    packageupload = Int(
357
            title=_("PackageUpload"), required=True,
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
358
            readonly=False,
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
359
            )
360
361
    build = Int(
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
362
            title=_("The related build"), required=True, readonly=False,
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
363
            )
364
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
365
    def publish(logger=None):
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
366
        """Publish this queued source in the distroseries referred to by
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
367
        the parent queue item.
368
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
369
        We determine the distroarchseries by matching architecturetags against
370
        the distroarchseries the build was compiled for.
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
371
372
        This method can raise NotFoundError if the architecturetag can't be
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
373
        matched up in the queue item's distroseries.
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
374
375
        Returns a list of the secure binary package publishing history
376
        objects in case it is of use to the caller. This may include records
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
377
        published into other distroarchseriess if this build contained arch
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
378
        independant packages.
379
380
        If a logger is provided, information pertaining to the publishing
381
        process will be logged to it.
382
        """
2733 by Canonical.com Patch Queue Manager
Upload processor. r=stevea
383
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
384
3691.441.21 by Malcolm Cleaton
More stuff
385
class IPackageUploadSource(Interface):
10529.1.6 by Jonathan Lange
Fewer mentions of lucille
386
    """A Queue item's related sourcepackagereleases."""
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
387
388
    id = Int(
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
389
            title=_("ID"), required=True, readonly=True,
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
390
            )
391
392
3691.441.21 by Malcolm Cleaton
More stuff
393
    packageupload = Int(
394
            title=_("PackageUpload"), required=True,
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
395
            readonly=False,
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
396
            )
397
398
    sourcepackagerelease = Int(
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
399
            title=_("The related source package release"), required=True,
400
            readonly=False,
401
            )
3691.442.27 by Celso Providelo
applying review comments (r=jamesh)
402
6149.4.2 by Celso Providelo
Requesting Diffs in upload-time.
403
    def getSourceAncestry():
404
        """Return a suitable ancestry publication for this context.
405
406
        The possible ancestries locations for a give source upload, assuming
407
        that only PRIMARY archive allows post-RELEASE pockets are:
408
6455.1.2 by Celso Providelo
applying review comments, r=barry.
409
         1. original archive, original distroseries and pocket (old
7675.235.5 by Celso Providelo
applying review comments, r=abentley.
410
            DEVELOPMENT/SRU/PPA uploads).
6455.1.2 by Celso Providelo
applying review comments, r=barry.
411
         2. primary archive, original distroseries and release pocket (NEW
7675.235.5 by Celso Providelo
applying review comments, r=abentley.
412
            SRU/PPA uploads fallback).
6455.1.2 by Celso Providelo
applying review comments, r=barry.
413
         3. primary_archive, any distroseries and release pocket (BACKPORTS)
6149.4.2 by Celso Providelo
Requesting Diffs in upload-time.
414
415
        We lookup a source publication with the same name in those location
416
        and in that order. If an ancestry is found it is returned, otherwise
417
        it returns None.
418
6455.1.2 by Celso Providelo
applying review comments, r=barry.
419
        :return: `ISourcePackagePublishingHistory` for the corresponding
6149.4.2 by Celso Providelo
Requesting Diffs in upload-time.
420
             ancestry or None if it wasn't found.
421
        """
422
4359.1.7 by Celso Providelo
Using a more AOP (informally) approach to identify archive inconsistencies in PackageUpload time. Introducing PackageUploadSource.{checkBeforeAccepted, checkBeforePublish} methods.
423
    def verifyBeforeAccept():
424
        """Perform overall checks before promoting source to ACCEPTED queue.
4359.1.1 by Celso Providelo
Code fix for bug #119753, pending tests.
425
426
        If two queue items have the same (name, version) pair there is
4359.1.7 by Celso Providelo
Using a more AOP (informally) approach to identify archive inconsistencies in PackageUpload time. Introducing PackageUploadSource.{checkBeforeAccepted, checkBeforePublish} methods.
427
        an inconsistency. To identify this situation we check the accepted
428
        & done queue items for each distroseries for such duplicates and
429
        raise an exception if any are found.
430
        See bug #31038 & #62976 for details.
431
        """
432
433
    def verifyBeforePublish():
434
        """Perform overall checks before publishing a source queue record.
435
4359.1.9 by Celso Providelo
more review comments (r=flacoste).
436
        Check if the source package files do not collide with the
4359.1.1 by Celso Providelo
Code fix for bug #119753, pending tests.
437
        ones already published in the archive. We need this to catch
438
        inaccurate  *epoched* versions, which would pass the upload version
4359.1.9 by Celso Providelo
more review comments (r=flacoste).
439
        check but would collide with diff(s) or dsc(s) previously published
440
        on disk. This inconsistency is well known in debian-like archives
4359.1.7 by Celso Providelo
Using a more AOP (informally) approach to identify archive inconsistencies in PackageUpload time. Introducing PackageUploadSource.{checkBeforeAccepted, checkBeforePublish} methods.
441
        and happens because filenames do not contain epoch. For further
442
        information see bug #119753.
4359.1.1 by Celso Providelo
Code fix for bug #119753, pending tests.
443
        """
444
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
445
    def checkComponentAndSection():
446
        """Verify the current Component and Section via Selection table.
447
448
        Check if the current sourcepackagerelease component and section
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
449
        matches with those included in the target distribution series,
2865.2.22 by Celso Providelo
Land state-machine for DRQ content class, deny direcly write access for DRQ.status, fix tests and callsites properly, reduce soyuz-upload test verbosity.
450
        if not raise QueueSourceAcceptError exception.
451
        """
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
452
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
453
    def publish(logger=None):
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
454
        """Publish this queued source in the distroseries referred to by
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
455
        the parent queue item.
456
457
        Returns the secure source package publishing history object in case
458
        it is of use to the caller.
459
460
        If a logger is provided, information pertaining to the publishing
461
        process will be logged to it.
462
        """
463
2733 by Canonical.com Patch Queue Manager
Upload processor. r=stevea
464
3691.441.21 by Malcolm Cleaton
More stuff
465
class IPackageUploadCustom(Interface):
3500.3.49 by Celso Providelo
improve DRQC docstring, got definitive r=spiv
466
    """Stores anything else than source and binaries that needs publication.
467
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
468
    It is essentially a map between DistroSeries/Pocket/LibrarianFileAlias.
3500.3.49 by Celso Providelo
improve DRQC docstring, got definitive r=spiv
469
470
    The LibrarianFileAlias usually is a TGZ containing an specific format.
471
    Currently we support:
472
     [Debian-Installer, Rosetta-Translation, Dist-Upgrader, DDTP-Tarball]
473
474
    Each one has an processor which is invoked by the publish method.
475
    """
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
476
477
    id = Int(
478
            title=_("ID"), required=True, readonly=True,
479
            )
480
3691.441.21 by Malcolm Cleaton
More stuff
481
    packageupload = Int(
482
            title=_("PackageUpload"), required=True,
2713 by Canonical.com Patch Queue Manager
Various fixes to queue, build etc. add zcml for queue, DB patch included. r=stevea,stub. Also fix dbschema security proxy bug (bug 1971) r=stevea
483
            readonly=False,
484
            )
485
486
    customformat = Int(
487
            title=_("The custom format for the file"), required=True,
488
            readonly=False,
489
            )
490
491
    libraryfilealias = Int(
492
            title=_("The file"), required=True, readonly=False,
950 by Canonical.com Patch Queue Manager
Queue tables for Lucille
493
            )
494
3627.2.5 by Daniel Silverstone
temp_filename is no longer a property, use full_suite_name since it's not really a distroreleasename
495
    def temp_filename():
496
        """Return a filename containing the libraryfile for this upload.
497
498
        This filename will be in a temporary directory and can be the
499
        ensure dir can be deleted once whatever needed the file is finished
500
        with it.
501
        """
502
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
503
    def publish(logger=None):
504
        """Publish this custom item directly into the filesystem.
505
506
        This can only be run by a process which has filesystem access to
507
        the archive (or wherever else the content will go).
508
509
        If a logger is provided, information pertaining to the publishing
510
        process will be logged to it.
511
        """
512
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
513
    def publishDebianInstaller(logger=None):
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
514
        """Publish this custom item as a raw installer tarball.
515
516
        This will write the installer tarball out to the right part of
517
        the archive.
518
519
        If a logger is provided, information pertaining to the publishing
520
        process will be logged to it.
521
        """
522
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
523
    def publishDistUpgrader(logger=None):
3147.2.37 by Celso Providelo
DistUpgraderUpload implementation and fixing some tests
524
        """Publish this custom item as a raw dist-upgrader tarball.
525
526
        This will write the dist-upgrader tarball out to the right part of
527
        the archive.
528
529
        If a logger is provided, information pertaining to the publishing
530
        process will be logged to it.
531
        """
532
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
533
    def publishDdtpTarball(logger=None):
3500.3.49 by Celso Providelo
improve DRQC docstring, got definitive r=spiv
534
        """Publish this custom item as a raw ddtp-tarball.
535
536
        This will write the ddtp-tarball out to the right part of
537
        the archive.
538
539
        If a logger is provided, information pertaining to the publishing
540
        process will be logged to it.
541
        """
542
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
543
    def publishRosettaTranslations(logger=None):
2756 by Canonical.com Patch Queue Manager
Queue-Accepted processor and some upload tweaks to fit it. r=stevea
544
        """Publish this custom item as a rosetta tarball.
545
546
        Essentially this imports the tarball into rosetta.
547
548
        If a logger is provided, information pertaining to the publishing
549
        process will be logged to it.
550
        """
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
551
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
552
    def publishStaticTranslations(logger):
8697.13.2 by Julian Edwards
Add interface declaration.
553
        """Publish this custom item as a static translations tarball.
554
555
        This is currently a no-op as we don't publish these files, they only
556
        reside in the librarian for later retrieval using the webservice.
557
        """
558
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
559
    def publishMetaData(logger):
11015.1.4 by Julian Edwards
Add the interface definition for publish_META_DATA
560
        """Publish this custom item as a meta-data file.
561
562
        This method writes the meta-data custom file to the archive in
563
        the location matching this schema:
564
        /<person>/meta/<ppa_name>/<filename>
565
566
        It's not written to the main archive location because that could be
567
        protected by htaccess in the case of private archives.
568
        """
569
8697.13.2 by Julian Edwards
Add interface declaration.
570
3691.441.21 by Malcolm Cleaton
More stuff
571
class IPackageUploadSet(Interface):
572
    """Represents a set of IPackageUploads"""
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
573
574
    def __iter__():
3691.441.21 by Malcolm Cleaton
More stuff
575
        """IPackageUpload iterator"""
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
576
577
    def __getitem__(queue_id):
3691.441.21 by Malcolm Cleaton
More stuff
578
        """Retrieve an IPackageUpload by a given id"""
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
579
580
    def get(queue_id):
3691.441.21 by Malcolm Cleaton
More stuff
581
        """Retrieve an IPackageUpload by a given id"""
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
582
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
583
    def count(status=None, distroseries=None, pocket=None):
3691.441.21 by Malcolm Cleaton
More stuff
584
        """Number of IPackageUpload present in a given status.
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
585
2865.2.49 by Celso Providelo
Fix IDistroReleaseQueue.count() to accept an optional distrorelease argument, use this feature in queue tool to display a proper queue counter.
586
        If status is ommitted return the number of all entries.
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
587
        'distroseries' is optional and restrict the results in given
588
        distroseries, same for pocket.
2865.2.31 by Celso Providelo
Infrasctructure for new queue plans, readding GPGV wrapper.
589
        """
3147.2.75 by Celso Providelo
Converge IDistroRelease.getFancyQueueItem in IHasQueueItems.getQueueItem, experimental 'View Queue' page for Distroreleases, IDRQ.queue_icon attribute and test fixing.
590
7675.218.1 by Celso Providelo
Creating PackageUploadSet.createDelayedCopy() and adjusting PackageUpload to use its 'date_created' DB column instead of the property based on the changesfile creation date.
591
    def createDelayedCopy(archive, distroseries, pocket, signing_key):
592
        """Return a `PackageUpload` record for a delayed-copy operation.
593
594
        :param archive: target `IArchive`,
595
        :param distroseries: target `IDistroSeries`,
596
        :param pocket: target `PackagePublishingPocket`,
597
        :param signing_key: `IGPGKey` of the user requesting this copy.
598
599
        :return: an `IPackageUpload` record in NEW state.
600
        """
601
8697.13.13 by Julian Edwards
Move getPackageUploads to the PackageUploadSet utility.
602
    def getAll(distroseries, created_since_date=None, status=None,
603
               archive=None, pocket=None, custom_type=None):
604
        """Get package upload records for a series with optional filtering.
605
606
        :param created_since_date: If specified, only returns items uploaded
607
            since the timestamp supplied.
608
        :param status: Filter results by this `PackageUploadStatus`
609
        :param archive: Filter results for this `IArchive`
610
        :param pocket: Filter results by this `PackagePublishingPocket`
611
        :param custom_type: Filter results by this `PackageUploadCustomFormat`
612
        :return: A result set containing `IPackageUpload`s
613
        """
614
8750.2.1 by Celso Providelo
Isolating upload queue conflict detection code, so it can be used while checking delayed copy candidates.
615
    def findSourceUpload(name, version, archive, distribution):
616
        """Return a `PackageUpload` for a matching source.
617
618
        :param name: a string with the exact source name.
619
        :param version: a string with the exact source version.
620
        :param archive: source upload target `IArchive`.
621
        :param distribution: source upload target `IDistribution`.
622
623
        :return: a matching `IPackageUpload` object.
624
        """
625
6557.3.1 by Julian Edwards
Pre-fetch package upload builds and remove a query caused by count() in
626
    def getBuildByBuildIDs(build_ids):
627
        """Return `PackageUploadBuilds`s for the supplied build IDs."""
628
6557.3.4 by Julian Edwards
Speed up display of source uploads.
629
    def getSourceBySourcePackageReleaseIDs(spr_ids):
630
        """Return `PackageUploadSource`s for the sourcepackagerelease IDs."""
631
6557.3.1 by Julian Edwards
Pre-fetch package upload builds and remove a query caused by count() in
632
3147.2.75 by Celso Providelo
Converge IDistroRelease.getFancyQueueItem in IHasQueueItems.getQueueItem, experimental 'View Queue' page for Distroreleases, IDRQ.queue_icon attribute and test fixing.
633
class IHasQueueItems(Interface):
634
    """An Object that has queue items"""
635
3496.1.120 by Celso Providelo
unify the permissions for a DistroReleaseQueue in an abstract model called IPackageUploadQueue.
636
    def getPackageUploadQueue(state):
637
        """Return an IPackageUploadeQueue occording the given state."""
638
3500.2.18 by Celso Providelo
re-enable 26-queue-pages re-post test and add pocket support for IHasBuildRecords and IHasQueueItems
639
    def getQueueItems(status=None, name=None, version=None,
3691.446.1 by Celso Providelo
Incorporate 'path-aware' upload processing as part of PPA upload support, doc/soyuz-upload.txt & doc/soyuz-set-of-uploads.txt are busted.
640
                      exact_match=False, pocket=None, archive=None):
3147.2.78 by Celso Providelo
Add custom upload support for getQueueItems(), fix tests and doc strings
641
        """Get the union of builds, sources and custom queue items.
3147.2.75 by Celso Providelo
Converge IDistroRelease.getFancyQueueItem in IHasQueueItems.getQueueItem, experimental 'View Queue' page for Distroreleases, IDRQ.queue_icon attribute and test fixing.
642
3147.2.78 by Celso Providelo
Add custom upload support for getQueueItems(), fix tests and doc strings
643
        Returns builds, sources and custom queue items in a given state,
3500.3.45 by Celso Providelo
Fix bug #62976 (accepting duplicated queue entries within a batch, refuse to overwrite files on disk when fetching duplicated queue items)
644
        matching a give name and version terms.
645
646
        If 'status' is not supplied, return all items in the queues,
3500.3.46 by Celso Providelo
review comments, r=spiv
647
        it supports multiple statuses as a list.
3500.3.45 by Celso Providelo
Fix bug #62976 (accepting duplicated queue entries within a batch, refuse to overwrite files on disk when fetching duplicated queue items)
648
3500.3.46 by Celso Providelo
review comments, r=spiv
649
        If 'name' and 'version' are supplied only items which match (SQL LIKE)
650
        the sourcepackage name, binarypackage name or the filename will be
651
        returned.  'name' can be supplied without supplying 'version'.
652
        'version' has no effect on custom queue items.
3500.3.45 by Celso Providelo
Fix bug #62976 (accepting duplicated queue entries within a batch, refuse to overwrite files on disk when fetching duplicated queue items)
653
654
        If 'pocket' is specified return only queue items inside it, otherwise
3500.3.46 by Celso Providelo
review comments, r=spiv
655
        return all pockets.  It supports multiple pockets as a list.
3500.3.45 by Celso Providelo
Fix bug #62976 (accepting duplicated queue entries within a batch, refuse to overwrite files on disk when fetching duplicated queue items)
656
3691.446.1 by Celso Providelo
Incorporate 'path-aware' upload processing as part of PPA upload support, doc/soyuz-upload.txt & doc/soyuz-set-of-uploads.txt are busted.
657
        If 'archive' is specified return only queue items targeted to this
12611.3.1 by Abel Deuring
Disable POTemplate/POFile imports from source packages if upstream translation sharing is enabled.
658
        archive, if not restrict the results to the
659
        IDistribution.main_archive.
3691.446.1 by Celso Providelo
Incorporate 'path-aware' upload processing as part of PPA upload support, doc/soyuz-upload.txt & doc/soyuz-set-of-uploads.txt are busted.
660
3147.2.75 by Celso Providelo
Converge IDistroRelease.getFancyQueueItem in IHasQueueItems.getQueueItem, experimental 'View Queue' page for Distroreleases, IDRQ.queue_icon attribute and test fixing.
661
        Use 'exact_match' argument for precise results.
662
        """