def publish(self, binarypackage, bpdata): """Create the publishing entry on db if does not exist.""" # These need to be pulled from the binary package data, not the # binary package release: the data represents data from /this # specific distroseries/, whereas the package represents data # from when it was first built. if self.component_override is not None: component = self.distro_handler.getComponentByName( self.component_override) log.info('Overriding binary %s component' % binarypackage.binarypackagename.name) else: component = self.distro_handler.getComponentByName( bpdata.component) distribution = self.distroarchseries.distroseries.distribution archive = distribution.getArchiveByComponent(component.name) section = self.distro_handler.ensureSection(bpdata.section) priority = prioritymap[bpdata.priority] # Check if the binarypackage is already published and if yes, # just report it. binpkg_publishinghistory = self._checkPublishing(binarypackage) if binpkg_publishinghistory: if ((binpkg_publishinghistory.section, binpkg_publishinghistory.priority, binpkg_publishinghistory.component) == (section, priority, component)): # If nothing has changed in terms of publication # (overrides) we are free to let this one go log.info('BinaryPackageRelease already published with no ' 'changes as %s' % binpkg_publishinghistory.status.title) return BinaryPackagePublishingHistory( binarypackagerelease=binarypackage.id, binarypackagename=binarypackage.binarypackagename, component=component.id, section=section.id, priority=priority, distroarchseries=self.distroarchseries.id, status=PackagePublishingStatus.PUBLISHED, datecreated=UTC_NOW, datepublished=UTC_NOW, pocket=self.pocket, datesuperseded=None, supersededby=None, datemadepending=None, dateremoved=None, archive=archive) log.info('BinaryPackage %s-%s published into %s.' % (binarypackage.binarypackagename.name, binarypackage.version, self.distroarchseries.architecturetag))
def createPublishingForDistroArchSeries(self, binarypackagerelease, distroarchseries): """Return a list of `BinaryPackagePublishingHistory`. The publishing records are created according to the given `BinaryPackageRelease` and `DistroArchSeries` for all (status, archive, pocket) returned from `sample_publishing_data`. """ sample_pub = [] for status, archive, pocket in self.sample_publishing_data: pub = BinaryPackagePublishingHistory( binarypackagerelease=binarypackagerelease, binarypackagename=binarypackagerelease.binarypackagename, distroarchseries=distroarchseries, component=binarypackagerelease.component, section=binarypackagerelease.section, priority=binarypackagerelease.priority, status=status, archive=archive, pocket=pocket) # Flush the object changes into DB do guarantee stable database # ID order as expected in the callsites. sample_pub.append(pub) return sample_pub