1129
1129
return getUtility(IBinaryPackageBuildSet).getBuildsByArchIds(
1130
1130
self, arch_ids, build_state, name, pocket)
1132
def getSourcePackageCaches(self, archive=None):
1133
"""See `IDistribution`."""
1134
if archive is not None:
1135
archives = [archive.id]
1137
archives = self.all_distro_archive_ids
1139
caches = DistributionSourcePackageCache.select("""
1140
distribution = %s AND
1142
""" % sqlvalues(self, archives),
1144
prejoins=['sourcepackagename'])
1148
def removeOldCacheItems(self, archive, log):
1149
"""See `IDistribution`."""
1151
# Get the set of source package names to deal with.
1152
spns = set(SourcePackageName.select("""
1153
SourcePackagePublishingHistory.distroseries =
1155
DistroSeries.distribution = %s AND
1157
SourcePackagePublishingHistory.archive = Archive.id AND
1158
SourcePackagePublishingHistory.sourcepackagerelease =
1159
SourcePackageRelease.id AND
1160
SourcePackageRelease.sourcepackagename =
1161
SourcePackageName.id AND
1162
SourcePackagePublishingHistory.dateremoved is NULL AND
1163
Archive.enabled = TRUE
1164
""" % sqlvalues(self, archive),
1169
'SourcePackagePublishingHistory',
1170
'SourcePackageRelease']))
1172
# Remove the cache entries for packages we no longer publish.
1173
for cache in self.getSourcePackageCaches(archive):
1174
if cache.sourcepackagename not in spns:
1176
"Removing source cache for '%s' (%s)"
1177
% (cache.name, cache.id))
1180
def updateCompleteSourcePackageCache(self, archive, log, ztm,
1182
"""See `IDistribution`."""
1183
# Do not create cache entries for disabled archives.
1184
if not archive.enabled:
1187
# Get the set of source package names to deal with.
1188
spns = list(SourcePackageName.select("""
1189
SourcePackagePublishingHistory.distroseries =
1191
DistroSeries.distribution = %s AND
1192
SourcePackagePublishingHistory.archive = %s AND
1193
SourcePackagePublishingHistory.sourcepackagerelease =
1194
SourcePackageRelease.id AND
1195
SourcePackageRelease.sourcepackagename =
1196
SourcePackageName.id AND
1197
SourcePackagePublishingHistory.dateremoved is NULL
1198
""" % sqlvalues(self, archive),
1201
clauseTables=['SourcePackagePublishingHistory', 'DistroSeries',
1202
'SourcePackageRelease']))
1204
number_of_updates = 0
1207
log.debug("Considering source '%s'" % spn.name)
1208
self.updateSourcePackageCache(spn, archive, log)
1210
number_of_updates += 1
1211
if chunk_size == commit_chunk:
1213
log.debug("Committing")
1216
return number_of_updates
1218
def updateSourcePackageCache(self, sourcepackagename, archive, log):
1219
"""See `IDistribution`."""
1221
# Get the set of published sourcepackage releases.
1222
sprs = list(SourcePackageRelease.select("""
1223
SourcePackageRelease.sourcepackagename = %s AND
1224
SourcePackageRelease.id =
1225
SourcePackagePublishingHistory.sourcepackagerelease AND
1226
SourcePackagePublishingHistory.distroseries =
1228
DistroSeries.distribution = %s AND
1229
SourcePackagePublishingHistory.archive = %s AND
1230
SourcePackagePublishingHistory.dateremoved is NULL
1231
""" % sqlvalues(sourcepackagename, self, archive),
1233
clauseTables=['SourcePackagePublishingHistory', 'DistroSeries'],
1237
log.debug("No sources releases found.")
1240
# Find or create the cache entry.
1241
cache = DistributionSourcePackageCache.selectOne("""
1242
distribution = %s AND
1244
sourcepackagename = %s
1245
""" % sqlvalues(self, archive, sourcepackagename))
1247
log.debug("Creating new source cache entry.")
1248
cache = DistributionSourcePackageCache(
1251
sourcepackagename=sourcepackagename)
1253
# Make sure the name is correct.
1254
cache.name = sourcepackagename.name
1256
# Get the sets of binary package names, summaries, descriptions.
1258
# XXX Julian 2007-04-03:
1259
# This bit of code needs fixing up, it is doing stuff that
1260
# really needs to be done in SQL, such as sorting and uniqueness.
1261
# This would also improve the performance.
1263
binpkgsummaries = set()
1264
binpkgdescriptions = set()
1265
sprchangelog = set()
1267
log.debug("Considering source version %s" % spr.version)
1268
# changelog may be empty, in which case we don't want to add it
1269
# to the set as the join would fail below.
1270
if spr.changelog_entry is not None:
1271
sprchangelog.add(spr.changelog_entry)
1272
binpkgs = BinaryPackageRelease.select("""
1273
BinaryPackageRelease.build = BinaryPackageBuild.id AND
1274
BinaryPackageBuild.source_package_release = %s
1275
""" % sqlvalues(spr.id),
1276
clauseTables=['BinaryPackageBuild'])
1277
for binpkg in binpkgs:
1278
log.debug("Considering binary '%s'" % binpkg.name)
1279
binpkgnames.add(binpkg.name)
1280
binpkgsummaries.add(binpkg.summary)
1281
binpkgdescriptions.add(binpkg.description)
1283
# Update the caches.
1284
cache.binpkgnames = ' '.join(sorted(binpkgnames))
1285
cache.binpkgsummaries = ' '.join(sorted(binpkgsummaries))
1286
cache.binpkgdescriptions = ' '.join(sorted(binpkgdescriptions))
1287
cache.changelog = ' '.join(sorted(sprchangelog))
1289
1132
def searchSourcePackageCaches(
1290
1133
self, text, has_packaging=None, publishing_distroseries=None):
1291
1134
"""See `IDistribution`."""