20
20
series = getUtility(IDistributionSet)[distro_name].getSeries(series_name)
21
21
dominator = Dominator(logger, series.main_archive)
23
# XXX JeroenVermeulen 2011-09-08, bug=844550: This is a transitional
24
# hack. Gina used to create SPPHs in Pending state. We cleaned up
25
# the bulk of them, and changed the code to create Published ones, but
26
# some new ones will have been created since.
27
# Update those to match what the new Gina does.
28
from canonical.launchpad.interfaces.lpstorm import IStore
29
from lp.soyuz.enums import PackagePublishingStatus
30
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
31
SPPH = SourcePackagePublishingHistory
35
SPPH.archive == series.main_archive,
36
SPPH.distroseries == series,
37
SPPH.pocket == pocket,
38
SPPH.status == PackagePublishingStatus.PENDING)
39
spphs.set(status=PackagePublishingStatus.PUBLISHED)
41
# Dominate packages found in the Sources list we're importing.
23
# Dominate all packages published in the series. This includes all
24
# packages listed in the Sources file we imported, but also packages
25
# that have been recently deleted.
42
26
package_names = dominator.findPublishedSourcePackageNames(series, pocket)
43
27
for package_name in package_names:
44
entries = packages_map.src_map.get(package_name)
47
# XXX JeroenVermeulen 2011-09-08, bug=844550: This is a
48
# transitional hack. The database is full of "Published"
49
# Debian SPPHs whose packages have actually been deleted.
50
# In the future such publications should simply be marked
51
# Deleted, but for the legacy baggage we currently carry
52
# around we'll just do traditional domination first: pick
53
# the latest Published version, and mark the rest of the
54
# SPPHs as superseded by that version. The latest version
55
# will then, finally, be marked appropriately Deleted once
56
# we remove this transitional hack.
57
# To remove the transitional hack, just let live_versions
58
# default to the empty list instead of doing this:
60
from lp.services.database.bulk import load_related
61
from lp.soyuz.model.sourcepackagerelease import (
65
dominator.findPublishedSPPHs(series, pocket, package_name))
67
# Without at least two published SPPHs, the transitional
68
# code will make no changes. Skip, and leave the
69
# algorithm free to assume there's a pubs[0].
72
SourcePackageRelease, pubs, ['sourcepackagereleaseID'])
74
# Close off the transaction to avoid being idle-killed.
75
# Nothing else is going to supersede or delete these
76
# publications in the meantime, so our data stays valid; and
77
# if new ones become published, they still won't be
81
# Find the "latest" publication. A purely in-memory
82
# operation; won't open a new transaction.
83
def is_newer(candidate, reference):
84
comparison = apt_pkg.VersionCompare(
85
candidate.sourcepackagerelease.version,
86
reference.sourcepackagerelease.version)
92
return candidate.datecreated > reference.datecreated
96
if is_newer(pub, latest_pub):
98
live_versions = [latest_pub.sourcepackagerelease.version]
102
for entry in entries if 'Version' in entry]
28
entries = packages_map.src_map.get(package_name, [])
30
entry['Version'] for entry in entries if 'Version' in entry]
104
32
dominator.dominateRemovedSourceVersions(
105
33
series, pocket, package_name, live_versions)