10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.22
by Karl Fogel
Add the copyright header block to the remaining .py files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
6 |
"""Archive Override Check
|
7 |
||
8 |
Given a distribution to run on, report any override inconsistence found.
|
|
9 |
It basically check if all published source and binaries are coherent.
|
|
10 |
"""
|
|
11 |
||
12 |
import _pythonpath |
|
13 |
||
13970.7.15
by William Grant
archive-override-check.py too. |
14 |
import transaction |
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
15 |
from zope.component import getUtility |
16 |
||
11270.1.3
by Tim Penhey
Changed NotFoundError imports - gee there were a lot of them. |
17 |
from lp.app.errors import NotFoundError |
8294.6.5
by Julian Edwards
Fix a bunch of circular imports, but there's still one I can't find. |
18 |
from lp.registry.interfaces.distribution import IDistributionSet |
9113.7.7
by Jonathan Lange
Update all the rest of the imports of PackagePublishingPocket. |
19 |
from lp.registry.interfaces.pocket import PackagePublishingPocket |
14612.2.7
by William Grant
scripts |
20 |
from lp.services.config import config |
13970.7.15
by William Grant
archive-override-check.py too. |
21 |
from lp.services.scripts.base import LaunchpadScript |
14612.2.7
by William Grant
scripts |
22 |
from lp.soyuz.enums import PackagePublishingStatus |
8294.6.5
by Julian Edwards
Fix a bunch of circular imports, but there's still one I can't find. |
23 |
from lp.soyuz.scripts.ftpmaster import PubSourceChecker |
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
24 |
|
13970.7.15
by William Grant
archive-override-check.py too. |
25 |
|
26 |
class ArchiveOverrideCheckScript(LaunchpadScript): |
|
27 |
||
28 |
def add_my_options(self): |
|
29 |
self.parser.add_option( |
|
30 |
"-d", "--distribution", action="store", |
|
31 |
dest="distribution", metavar="DISTRO", default="ubuntu", |
|
32 |
help="Distribution to consider") |
|
33 |
self.parser.add_option( |
|
34 |
"-s", "--suite", action="store", |
|
35 |
dest="suite", metavar="SUITE", default=None, |
|
36 |
help=("Suite to consider, if not passed consider the " |
|
37 |
"currentseries and the RELEASE pocket")) |
|
38 |
||
39 |
def main(self): |
|
3686.2.3
by Celso Providelo
Applying review comments from salgado |
40 |
try: |
13970.7.15
by William Grant
archive-override-check.py too. |
41 |
try: |
42 |
distribution = getUtility(IDistributionSet)[ |
|
43 |
self.options.distribution] |
|
44 |
if self.options.suite is None: |
|
45 |
distroseries = distribution.currentseries |
|
46 |
pocket = PackagePublishingPocket.RELEASE |
|
47 |
else: |
|
48 |
distroseries, pocket = ( |
|
49 |
distribution.getDistroSeriesAndPocket( |
|
50 |
self.options.suite)) |
|
51 |
||
52 |
self.logger.debug( |
|
53 |
"Considering: %s/%s/%s/%s." |
|
54 |
% (distribution.name, distroseries.name, pocket.name, |
|
55 |
distroseries.status.name)) |
|
56 |
||
57 |
checkOverrides(distroseries, pocket, self.logger) |
|
58 |
except NotFoundError, info: |
|
59 |
self.logger.error('Not found: %s' % info) |
|
60 |
finally: |
|
61 |
self.logger.debug("Rolling back any remaining transactions.") |
|
62 |
transaction.abort() |
|
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
63 |
|
64 |
||
4285.2.4
by Mark Shuttleworth
Test fixes with renamed distrorelease |
65 |
def checkOverrides(distroseries, pocket, log): |
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
66 |
"""Initialize and handle PubSourceChecker.
|
67 |
||
68 |
Iterate over PUBLISHED sources and perform PubSourceChecker.check()
|
|
69 |
on each published Source/Binaries couple.
|
|
70 |
"""
|
|
4285.2.4
by Mark Shuttleworth
Test fixes with renamed distrorelease |
71 |
spps = distroseries.getSourcePackagePublishing( |
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
72 |
status=PackagePublishingStatus.PUBLISHED, |
73 |
pocket=pocket) |
|
74 |
||
75 |
log.debug('%s published sources' % spps.count()) |
|
76 |
||
77 |
for spp in spps: |
|
3686.2.15
by Celso Providelo
more review comments. |
78 |
spr = spp.sourcepackagerelease |
79 |
checker = PubSourceChecker( |
|
80 |
spr.name, spr.version, spp.component.name, spp.section.name, |
|
81 |
spr.urgency.name) |
|
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
82 |
|
5084.5.1
by Christian Robottom Reis
Fix SSPPH.getPublishedBinaries to look packages up in the right archive. |
83 |
for bpp in spp.getPublishedBinaries(): |
3686.2.15
by Celso Providelo
more review comments. |
84 |
bpr = bpp.binarypackagerelease |
85 |
checker.addBinary( |
|
4285.2.4
by Mark Shuttleworth
Test fixes with renamed distrorelease |
86 |
bpr.name, bpr.version, bpp.distroarchseries.architecturetag, |
3686.2.15
by Celso Providelo
more review comments. |
87 |
bpp.component.name, bpp.section.name, bpr.priority.name) |
3686.2.1
by Celso Providelo
archive-override-check prototype, pending tests for ISourcePackagePublishing.publishedBinaries (requires better sample data) |
88 |
|
89 |
checker.check() |
|
90 |
||
91 |
report = checker.renderReport() |
|
92 |
||
93 |
if report: |
|
94 |
print report |
|
95 |
||
96 |
if __name__ == '__main__': |
|
13970.7.15
by William Grant
archive-override-check.py too. |
97 |
script = ArchiveOverrideCheckScript( |
98 |
'archive-override-check', config.archivepublisher.dbuser) |
|
99 |
script.lock_and_run() |