launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #17456
[Merge] lp:~wgrant/launchpad/abolish-SPR-createBuild into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/abolish-SPR-createBuild into lp:launchpad.
Commit message:
Replace SourcePackageRelease.createBuild with an improved BinaryPackageBuildSet.new.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/abolish-SPR-createBuild/+merge/240222
--
https://code.launchpad.net/~wgrant/launchpad/abolish-SPR-createBuild/+merge/240222
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/abolish-SPR-createBuild into lp:launchpad.
=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
--- lib/lp/archiveuploader/nascentuploadfile.py 2013-10-10 18:47:16 +0000
+++ lib/lp/archiveuploader/nascentuploadfile.py 2014-10-31 07:41:13 +0000
@@ -56,6 +56,7 @@
PackagePublishingPriority,
PackageUploadCustomFormat,
)
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
from lp.soyuz.interfaces.component import IComponentSet
from lp.soyuz.interfaces.section import ISectionSet
@@ -855,9 +856,9 @@
else:
# No luck. Make one.
# Usually happen for security binary uploads.
- build = sourcepackagerelease.createBuild(
- dar, self.policy.pocket, self.policy.archive,
- status=BuildStatus.FULLYBUILT)
+ build = getUtility(IBinaryPackageBuildSet).new(
+ sourcepackagerelease, self.policy.archive, dar,
+ self.policy.pocket, status=BuildStatus.FULLYBUILT)
self.logger.debug("Build %s created" % build.id)
return build
=== modified file 'lib/lp/archiveuploader/tests/nascentupload.txt'
--- lib/lp/archiveuploader/tests/nascentupload.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/archiveuploader/tests/nascentupload.txt 2014-10-31 07:41:13 +0000
@@ -558,9 +558,11 @@
Build creation is done based on the SourcePackageRelease object, step 5:
- >>> multibar_build = multibar_spr.createBuild(
- ... hoary['i386'], PackagePublishingPocket.RELEASE,
- ... multibar_src_queue.archive)
+ >>> from lp.soyuz.interfaces.binarypackagebuild import (
+ ... IBinaryPackageBuildSet)
+ >>> multibar_build = getUtility(IBinaryPackageBuildSet).new(
+ ... multibar_spr, multibar_src_queue.archive, hoary['i386'],
+ ... PackagePublishingPocket.RELEASE)
>>> multibar_build.status.name
'NEEDSBUILD'
=== modified file 'lib/lp/archiveuploader/tests/test_buildduploads.py'
--- lib/lp/archiveuploader/tests/test_buildduploads.py 2013-09-13 06:20:49 +0000
+++ lib/lp/archiveuploader/tests/test_buildduploads.py 2014-10-31 07:41:13 +0000
@@ -20,6 +20,7 @@
PackagePublishingStatus,
PackageUploadStatus,
)
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.processor import IProcessorSet
from lp.soyuz.interfaces.publishing import IPublishingSet
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
@@ -139,9 +140,9 @@
def _createBuild(self, archtag):
"""Create a build record attached to the base source."""
spr = self.source_queue.sources[0].sourcepackagerelease
- build = spr.createBuild(
- distro_arch_series=self.distroseries[archtag],
- pocket=self.pocket, archive=self.distroseries.main_archive)
+ build = getUtility(IBinaryPackageBuildSet).new(
+ spr, self.distroseries.main_archive, self.distroseries[archtag],
+ self.pocket)
self.layer.txn.commit()
return build
=== modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2014-08-21 03:00:46 +0000
+++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2014-10-31 07:41:13 +0000
@@ -33,6 +33,7 @@
PackageUploadStatus,
SourcePackageFormat,
)
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.queue import NonBuildableSourceUploadError
from lp.soyuz.interfaces.sourcepackageformat import (
ISourcePackageFormatSelectionSet,
@@ -420,9 +421,9 @@
# Create a build record for source bar for breezy-i386
# distroarchseries in cprov PPA.
- build_bar_i386 = cprov_pub_bar.sourcepackagerelease.createBuild(
- self.breezy['i386'], PackagePublishingPocket.RELEASE,
- cprov.archive)
+ build_bar_i386 = getUtility(IBinaryPackageBuildSet).new(
+ cprov_pub_bar.sourcepackagerelease, cprov.archive,
+ self.breezy['i386'], PackagePublishingPocket.RELEASE)
# Binary upload to the just-created build record.
self.options.context = 'buildd'
=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2014-08-29 02:03:52 +0000
+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2014-10-31 07:41:13 +0000
@@ -74,6 +74,7 @@
)
from lp.soyuz.interfaces.archive import IArchiveSet
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.component import IComponentSet
from lp.soyuz.interfaces.packageset import IPackagesetSet
from lp.soyuz.interfaces.publishing import (
@@ -839,9 +840,9 @@
bar_copied_source = bar_source_pub.copyTo(
breezy_autotest, PackagePublishingPocket.RELEASE,
self.ubuntu.main_archive)
- bar_copied_build = bar_copied_source.sourcepackagerelease.createBuild(
- breezy_autotest_i386, PackagePublishingPocket.RELEASE,
- self.ubuntu.main_archive)
+ bar_copied_build = getUtility(IBinaryPackageBuildSet).new(
+ bar_copied_source.sourcepackagerelease, self.ubuntu.main_archive,
+ breezy_autotest_i386, PackagePublishingPocket.RELEASE)
# Re-upload the same 'bar-1.0-1' binary as if it was rebuilt
# in breezy-autotest context.
@@ -1058,9 +1059,9 @@
# Fudge a build for foocomm so that it's not in the partner archive.
# We can then test that uploading a binary package must match the
# build's archive.
- foocomm_build = foocomm_spr.createBuild(
- self.breezy['i386'], PackagePublishingPocket.RELEASE,
- self.ubuntu.main_archive)
+ foocomm_build = getUtility(IBinaryPackageBuildSet).new(
+ foocomm_spr, self.ubuntu.main_archive, self.breezy['i386'],
+ PackagePublishingPocket.RELEASE)
self.layer.txn.commit()
upload_dir = self.queueUpload("foocomm_1.0-1_binary")
build_uploadprocessor = self.getUploadProcessor(
=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py'
--- lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py 2014-06-26 11:50:58 +0000
+++ lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py 2014-10-31 07:41:13 +0000
@@ -35,6 +35,7 @@
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.config import config
from lp.services.log.logger import BufferLogger
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.processor import IProcessorSet
from lp.testing import (
TestCase,
@@ -100,9 +101,8 @@
pocket = PackagePublishingPocket.RELEASE
spr = self.factory.makeSourcePackageRelease(
distroseries=distroseries, archive=archive)
-
- return spr.createBuild(
- distroarchseries=distroarchseries, pocket=pocket, archive=archive)
+ return getUtility(IBinaryPackageBuildSet).new(
+ spr, archive, distroarchseries, pocket)
def test_getUploadDirLeaf(self):
# getUploadDirLeaf returns the current time, followed by the build
=== modified file 'lib/lp/soyuz/browser/tests/archive-views.txt'
--- lib/lp/soyuz/browser/tests/archive-views.txt 2014-08-08 17:27:07 +0000
+++ lib/lp/soyuz/browser/tests/archive-views.txt 2014-10-31 07:41:13 +0000
@@ -389,9 +389,9 @@
... IBinaryPackageBuildSet)
>>> warty_hppa = getUtility(IDistributionSet)['ubuntu']['warty']['hppa']
>>> source = view.filtered_sources[0]
- >>> ignore = source.sourcepackagerelease.createBuild(
- ... distro_arch_series=warty_hppa, archive=view.context,
- ... pocket=source.pocket)
+ >>> ignore = getUtility(IBinaryPackageBuildSet).new(
+ ... source.sourcepackagerelease, view.context, warty_hppa,
+ ... source.pocket)
>>> builds = getUtility(IBinaryPackageBuildSet).getBuildsForArchive(
... view.context)
>>> for build in builds:
=== modified file 'lib/lp/soyuz/browser/tests/distributionsourcepackagerelease-views.txt'
--- lib/lp/soyuz/browser/tests/distributionsourcepackagerelease-views.txt 2010-02-11 12:47:50 +0000
+++ lib/lp/soyuz/browser/tests/distributionsourcepackagerelease-views.txt 2014-10-31 07:41:13 +0000
@@ -126,11 +126,15 @@
# Create extras builds for the testing DSPR.
>>> login('foo.bar@xxxxxxxxxxxxx')
>>> hoary_amd64 = hoary['amd64']
- >>> unused = source.sourcepackagerelease.createBuild(
- ... hoary_amd64, release_pocket, stp.ubuntutest.main_archive)
+ >>> from lp.soyuz.interfaces.binarypackagebuild import (
+ ... IBinaryPackageBuildSet)
+ >>> unused = getUtility(IBinaryPackageBuildSet).new(
+ ... source.sourcepackagerelease, stp.ubuntutest.main_archive,
+ ... hoary_amd64, release_pocket)
>>> breezy_hppa = stp.breezy_autotest['hppa']
- >>> unused = source.sourcepackagerelease.createBuild(
- ... breezy_hppa, release_pocket, stp.ubuntutest.main_archive)
+ >>> unused = getUtility(IBinaryPackageBuildSet).new(
+ ... source.sourcepackagerelease, stp.ubuntutest.main_archive,
+ ... breezy_hppa, release_pocket)
>>> login(ANONYMOUS)
>>> dspr_view = create_initialized_view(dspr, name="+index")
=== modified file 'lib/lp/soyuz/browser/tests/test_build_views.py'
--- lib/lp/soyuz/browser/tests/test_build_views.py 2013-12-04 07:07:04 +0000
+++ lib/lp/soyuz/browser/tests/test_build_views.py 2014-10-31 07:41:13 +0000
@@ -29,6 +29,7 @@
from lp.soyuz.browser.build import BuildContextMenu
from lp.soyuz.enums import ArchivePurpose
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.packageset import IPackagesetSet
from lp.soyuz.model.queue import PackageUploadBuild
from lp.testing import (
@@ -68,8 +69,9 @@
# current_component used by the view returns None in that case.
spph = self.factory.makeSourcePackagePublishingHistory()
other_das = self.factory.makeDistroArchSeries()
- build = spph.sourcepackagerelease.createBuild(
- other_das, PackagePublishingPocket.RELEASE, spph.archive)
+ build = getUtility(IBinaryPackageBuildSet).new(
+ spph.sourcepackagerelease, spph.archive, other_das,
+ PackagePublishingPocket.RELEASE)
view = create_initialized_view(build, name="+index")
self.assertEqual('unknown', view.component_name)
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue-translations.txt'
--- lib/lp/soyuz/doc/distroseriesqueue-translations.txt 2013-10-24 04:43:51 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue-translations.txt 2014-10-31 07:41:13 +0000
@@ -77,9 +77,11 @@
# Do the upload into the system.
- >>> build = source_package_release.createBuild(
- ... dapper_amd64, PackagePublishingPocket.RELEASE,
- ... dapper.main_archive)
+ >>> from lp.soyuz.interfaces.binarypackagebuild import (
+ ... IBinaryPackageBuildSet)
+ >>> build = getUtility(IBinaryPackageBuildSet).new(
+ ... source_package_release, dapper.main_archive,
+ ... dapper_amd64, PackagePublishingPocket.RELEASE)
>>> buildd_policy = getPolicy(
... name='buildd', distro='ubuntu', distroseries='dapper')
=== modified file 'lib/lp/soyuz/doc/sourcepackagerelease-build-lookup.txt'
--- lib/lp/soyuz/doc/sourcepackagerelease-build-lookup.txt 2012-11-21 07:19:09 +0000
+++ lib/lp/soyuz/doc/sourcepackagerelease-build-lookup.txt 2014-10-31 07:41:13 +0000
@@ -39,8 +39,8 @@
... PackagePublishingPocket)
>>> pocket_release = PackagePublishingPocket.RELEASE
-The base method createBuild() is able to create a build to a given
-distro_arch_series, pocket and archive.
+The base method BinaryPackageBuildSet.new() is able to create a build to
+a given distro_arch_series, pocket and archive.
Build.status, by default is set to NEEDSBUILD, but you can
optionally provide another status.
@@ -49,8 +49,10 @@
>>> evo_release = hoary_evo_source['1.0'].sourcepackagerelease
>>> from lp.buildmaster.enums import BuildStatus
- >>> evo_build_i386 = evo_release.createBuild(
- ... hoary_i386, pocket_release, ubuntu.main_archive,
+ >>> from lp.soyuz.interfaces.binarypackagebuild import (
+ ... IBinaryPackageBuildSet)
+ >>> evo_build_i386 = getUtility(IBinaryPackageBuildSet).new(
+ ... evo_release, ubuntu.main_archive, hoary_i386, pocket_release,
... status=BuildStatus.FULLYBUILT)
>>> print evo_build_i386.status.name
@@ -192,8 +194,9 @@
versions, so the resulted binary will be influenced by the PPA
contents at the time it was built.
- >>> evo_build_i386_ppa = copy.sourcepackagerelease.createBuild(
- ... hoary_i386, pocket_release, cprov.archive)
+ >>> evo_build_i386_ppa = getUtility(IBinaryPackageBuildSet).new(
+ ... copy.sourcepackagerelease, cprov.archive, hoary_i386,
+ ... pocket_release)
>>> evo_build_i386_ppa.status.name
'NEEDSBUILD'
@@ -219,8 +222,9 @@
When we create a hoary/hppa build in the PPA context, it will continue
to be missing in the PRIMARY archive context.
- >>> evo_build_hppa_ppa = copy.sourcepackagerelease.createBuild(
- ... hoary_hppa, pocket_release, cprov.archive)
+ >>> evo_build_hppa_ppa = getUtility(IBinaryPackageBuildSet).new(
+ ... copy.sourcepackagerelease, cprov.archive, hoary_hppa,
+ ... pocket_release)
>>> test_build_hppa_ppa = copy.sourcepackagerelease.getBuildByArch(
... hoary_hppa, cprov.archive)
=== modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py'
--- lib/lp/soyuz/interfaces/binarypackagebuild.py 2014-10-31 03:12:58 +0000
+++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2014-10-31 07:41:13 +0000
@@ -295,19 +295,15 @@
class IBinaryPackageBuildSet(ISpecificBuildFarmJobSource):
"""Interface for BinaryPackageBuildSet"""
- def new(distro_arch_series, source_package_release, processor,
- archive, pocket, status=BuildStatus.NEEDSBUILD,
- date_created=None, builder=None):
+ def new(source_package_release, archive, distro_arch_series, pocket,
+ status=BuildStatus.NEEDSBUILD, builder=None):
"""Create a new `IBinaryPackageBuild`.
- :param distro_arch_series: An `IDistroArchSeries`.
:param source_package_release: An `ISourcePackageRelease`.
- :param processor: An `IProcessor`.
:param archive: An `IArchive` in which context the build is built.
+ :param distro_arch_series: An `IDistroArchSeries`.
:param pocket: An item of `PackagePublishingPocket`.
:param status: A `BuildStatus` item indicating the builds status.
- :param date_created: An optional datetime to ensure multiple builds
- in the same transaction don't all get the same UTC_NOW.
:param builder: An optional `IBuilder`.
"""
=== modified file 'lib/lp/soyuz/interfaces/packagecloner.py'
--- lib/lp/soyuz/interfaces/packagecloner.py 2013-09-10 06:28:26 +0000
+++ lib/lp/soyuz/interfaces/packagecloner.py 2014-10-31 07:41:13 +0000
@@ -16,8 +16,7 @@
"""Copies publishing history data across archives."""
def clonePackages(origin, destination, distroarchseries_list=None,
- processors=None, sourcepackagenames=None,
- always_create=False):
+ processors=None, sourcepackagenames=None):
"""Copy packages from origin to destination.
Copies the source packages, as well as the binary packages for the
@@ -30,7 +29,6 @@
:param processors: the processors that builds will be created for.
:param sourcepackagenames: the source packages which are to be
copied.
- :param always_create: if builds should always be created.
"""
def mergeCopy(origin, destination):
=== modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
--- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2014-06-11 15:40:51 +0000
+++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2014-10-31 07:41:13 +0000
@@ -174,16 +174,6 @@
:return the corresponding `ILibraryFileAlias` if the file was found.
"""
- def createBuild(distroarchseries, pocket, archive, processor=None,
- status=None):
- """Create a build for a given distroarchseries/pocket/archive
-
- If the processor isn't given, guess it from the distroarchseries.
- If the status isn't given, use NEEDSBUILD.
-
- Return the just created IBuild.
- """
-
def getBuildByArch(distroarchseries, archive):
"""Return build for the given distroarchseries/archive.
=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
--- lib/lp/soyuz/model/binarypackagebuild.py 2014-10-31 03:17:04 +0000
+++ lib/lp/soyuz/model/binarypackagebuild.py 2014-10-31 07:41:13 +0000
@@ -893,27 +893,28 @@
class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin):
implements(IBinaryPackageBuildSet)
- def new(self, distro_arch_series, source_package_release, processor,
- archive, pocket, status=BuildStatus.NEEDSBUILD,
- date_created=None, builder=None):
+ def new(self, source_package_release, archive, distro_arch_series, pocket,
+ status=BuildStatus.NEEDSBUILD, builder=None):
"""See `IBinaryPackageBuildSet`."""
+ # Force the current timestamp instead of the default UTC_NOW for
+ # the transaction, avoid several row with same datecreated.
+ date_created = datetime.datetime.now(pytz.timezone('UTC'))
# Create the BuildFarmJob for the new BinaryPackageBuild.
build_farm_job = getUtility(IBuildFarmJobSource).new(
BinaryPackageBuild.job_type, status, date_created, builder,
archive)
- binary_package_build = BinaryPackageBuild(
+ return BinaryPackageBuild(
build_farm_job=build_farm_job,
distro_arch_series=distro_arch_series,
source_package_release=source_package_release,
- archive=archive, pocket=pocket, status=status, processor=processor,
+ archive=archive, pocket=pocket, status=status,
+ processor=distro_arch_series.processor,
virtualized=archive.require_virtualized, builder=builder,
is_distro_archive=archive.is_main,
distribution=distro_arch_series.distroseries.distribution,
distro_series=distro_arch_series.distroseries,
- source_package_name=source_package_release.sourcepackagename)
- if date_created is not None:
- binary_package_build.date_created = date_created
- return binary_package_build
+ source_package_name=source_package_release.sourcepackagename,
+ date_created=date_created)
def getByID(self, id):
"""See `IBinaryPackageBuildSet`."""
@@ -1352,7 +1353,8 @@
build_candidate.status == BuildStatus.FULLYBUILT)):
return None
- build = sourcepackagerelease.createBuild(
+ build = self.new(
+ source_package_release=sourcepackagerelease,
distro_arch_series=arch, archive=archive, pocket=pocket)
# Create the builds in suspended mode for disabled archives.
build_queue = build.queueBuild(suspended=not archive.enabled)
=== modified file 'lib/lp/soyuz/model/packagecloner.py'
--- lib/lp/soyuz/model/packagecloner.py 2013-09-10 06:28:26 +0000
+++ lib/lp/soyuz/model/packagecloner.py 2014-10-31 07:41:13 +0000
@@ -16,7 +16,6 @@
from zope.interface import implements
from zope.security.proxy import removeSecurityProxy
-from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.services.database.constants import UTC_NOW
from lp.services.database.interfaces import IStore
from lp.services.database.sqlbase import (
@@ -58,8 +57,7 @@
implements(IPackageCloner)
def clonePackages(self, origin, destination, distroarchseries_list=None,
- processors=None, sourcepackagenames=None,
- always_create=False):
+ processors=None, sourcepackagenames=None):
"""Copies packages from origin to destination package location.
Binary packages are only copied for the `DistroArchSeries` pairs
@@ -78,9 +76,6 @@
@param sourcepackagenames: the sourcepackages to copy to the
destination
@type sourcepackagenames: Iterable
- @param always_create: if we should create builds for every source
- package copied, useful if no binaries are to be copied.
- @type always_create: Boolean
"""
# First clone the source packages.
self._clone_source_packages(
@@ -99,11 +94,10 @@
self._create_missing_builds(
destination.distroseries, destination.archive,
- distroarchseries_list, processors, always_create)
+ distroarchseries_list, processors)
def _create_missing_builds(self, distroseries, archive,
- distroarchseries_list, processors,
- always_create):
+ distroarchseries_list, processors):
"""Create builds for all cloned source packages.
:param distroseries: the distro series for which to create builds.
@@ -132,16 +126,7 @@
distroseries=distroseries, status=active_publishing_status)
for pubrec in sources_published:
- builds = pubrec.createMissingBuilds(
- architectures_available=architectures)
- # If the last build was sucessful, we should create a new
- # build, since createMissingBuilds() won't.
- if not builds and always_create:
- for arch in architectures:
- build = pubrec.sourcepackagerelease.createBuild(
- distro_arch_series=arch, archive=archive,
- pocket=PackagePublishingPocket.RELEASE)
- build.queueBuild(suspended=not archive.enabled)
+ pubrec.createMissingBuilds(architectures_available=architectures)
# Commit to avoid MemoryError: bug 304459
transaction.commit()
@@ -269,7 +254,7 @@
self._create_missing_builds(
destination.distroseries, destination.archive, (),
- processors, False)
+ processors)
def _compute_packageset_delta(self, origin):
"""Given a source/target archive find obsolete or missing packages.
=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
--- lib/lp/soyuz/model/sourcepackagerelease.py 2014-06-11 18:14:35 +0000
+++ lib/lp/soyuz/model/sourcepackagerelease.py 2014-10-31 07:41:13 +0000
@@ -63,7 +63,6 @@
)
from lp.soyuz.enums import PackageDiffStatus
from lp.soyuz.interfaces.archive import MAIN_ARCHIVE_PURPOSES
-from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.packagediff import PackageDiffAlreadyRequested
from lp.soyuz.interfaces.packagediffjob import IPackageDiffJobSource
from lp.soyuz.interfaces.queue import QueueInconsistentStateError
@@ -297,30 +296,6 @@
else:
return 0.0
- def createBuild(self, distro_arch_series, pocket, archive, processor=None,
- status=None):
- """See ISourcePackageRelease."""
- # If a processor is not provided, use the DAS' processor.
- if processor is None:
- processor = distro_arch_series.processor
-
- if status is None:
- status = BuildStatus.NEEDSBUILD
-
- # Force the current timestamp instead of the default
- # UTC_NOW for the transaction, avoid several row with
- # same datecreated.
- date_created = datetime.datetime.now(pytz.timezone('UTC'))
-
- return getUtility(IBinaryPackageBuildSet).new(
- distro_arch_series=distro_arch_series,
- source_package_release=self,
- processor=processor,
- status=status,
- date_created=date_created,
- pocket=pocket,
- archive=archive)
-
def findBuildsByArchitecture(self, distroseries, archive):
"""Find associated builds, by architecture.
=== modified file 'lib/lp/soyuz/scripts/gina/handlers.py'
--- lib/lp/soyuz/scripts/gina/handlers.py 2014-06-11 10:09:30 +0000
+++ lib/lp/soyuz/scripts/gina/handlers.py 2014-10-31 07:41:13 +0000
@@ -181,7 +181,7 @@
self.distro = self._get_distro(distro_name)
self.distroseries = self._get_distroseries(distroseries_name)
- self.archinfo = {}
+ self.arch_map = {}
self.imported_sources = []
self.imported_bins = {}
@@ -192,7 +192,7 @@
self.sppublisher = SourcePackagePublisher(
self.distroseries, pocket, self.component_override)
- # This is initialized in ensure_archinfo
+ # This is initialized in ensure_arch
self.bppublishers = {}
def commit(self):
@@ -203,25 +203,23 @@
"""Rollback changes to the database."""
self.ztm.abort()
- def ensure_archinfo(self, archtag):
+ def ensure_arch(self, archtag):
"""Append retrived distroarchseries info to a dict."""
- if archtag in self.archinfo.keys():
+ if archtag in self.arch_map:
return
# Get distroarchseries and processor from the architecturetag.
- dar = DistroArchSeries.selectOneBy(
+ das = DistroArchSeries.selectOneBy(
distroseriesID=self.distroseries.id,
architecturetag=archtag)
- if not dar:
+ if not das:
raise DataSetupError("Error finding distroarchseries for %s/%s"
% (self.distroseries.name, archtag))
- processor = dar.processor
- info = {'distroarchseries': dar, 'processor': processor}
- self.archinfo[archtag] = info
+ self.arch_map[archtag] = das
self.bppublishers[archtag] = BinaryPackagePublisher(
- dar, self.pocket, self.component_override)
+ das, self.pocket, self.component_override)
self.imported_bins[archtag] = []
#
@@ -282,9 +280,8 @@
happen, for instance, if a binary package didn't change over
releases, or if Gina runs multiple times over the same release
"""
- distroarchinfo = self.archinfo[archtag]
- binarypackagerelease = self.bphandler.checkBin(binarypackagedata,
- distroarchinfo)
+ binarypackagerelease = self.bphandler.checkBin(
+ binarypackagedata, self.arch_map[archtag])
if not binarypackagerelease:
log.debug('BPR not found in preimport: %r %r %r' %
(binarypackagedata.package, binarypackagedata.version,
@@ -297,13 +294,12 @@
def import_binarypackage(self, archtag, binarypackagedata):
"""Handler the binarypackage import process"""
- distroarchinfo = self.archinfo[archtag]
-
# We know that preimport_binarycheck has run
- assert not self.bphandler.checkBin(binarypackagedata, distroarchinfo)
+ assert not self.bphandler.checkBin(
+ binarypackagedata, self.arch_map[archtag])
# Find the sourcepackagerelease that generated this binarypackage.
- distroseries = distroarchinfo['distroarchseries'].distroseries
+ distroseries = self.arch_map[archtag].distroseries
sourcepackage = self.locate_sourcepackage(binarypackagedata,
distroseries)
if not sourcepackage:
@@ -317,7 +313,7 @@
binarypackagedata.source_version))
binarypackagerelease = self.bphandler.createBinaryPackage(
- binarypackagedata, sourcepackage, distroarchinfo, archtag)
+ binarypackagedata, sourcepackage, self.arch_map[archtag], archtag)
self.publish_binarypackage(binarypackagerelease, binarypackagedata,
archtag)
@@ -733,7 +729,7 @@
self.archive_root = archive_root
self.pocket = pocket
- def checkBin(self, binarypackagedata, distroarchinfo):
+ def checkBin(self, binarypackagedata, distroarchseries):
"""Returns a binarypackage -- if it exists."""
try:
binaryname = BinaryPackageName.byName(binarypackagedata.package)
@@ -747,7 +743,7 @@
clauseTables = ["BinaryPackageRelease", "DistroSeries",
"BinaryPackageBuild", "DistroArchSeries"]
- distroseries = distroarchinfo['distroarchseries'].distroseries
+ distroseries = distroarchseries.distroseries
# When looking for binaries, we need to remember that they are
# shared between distribution releases, so match on the
@@ -777,7 +773,7 @@
distroseries.distribution.name))
return bpr
- def createBinaryPackage(self, bin, srcpkg, distroarchinfo, archtag):
+ def createBinaryPackage(self, bin, srcpkg, distroarchseries, archtag):
"""Create a new binarypackage."""
fdir, fname = os.path.split(bin.filename)
to_upload = check_not_in_librarian(fname, bin.archive_root, fdir)
@@ -788,7 +784,7 @@
architecturespecific = (bin.architecture != "all")
bin_name = getUtility(IBinaryPackageNameSet).ensure(bin.package)
- build = self.ensureBuild(bin, srcpkg, distroarchinfo, archtag)
+ build = self.ensureBuild(bin, srcpkg, distroarchseries, archtag)
# Create the binarypackage entry on lp db.
binpkg = BinaryPackageRelease(
@@ -828,9 +824,8 @@
# Return the binarypackage object.
return binpkg
- def ensureBuild(self, binary, srcpkg, distroarchinfo, archtag):
+ def ensureBuild(self, binary, srcpkg, distroarchseries, archtag):
"""Ensure a build record."""
- distroarchseries = distroarchinfo['distroarchseries']
distribution = distroarchseries.distroseries.distribution
clauseTables = [
"BinaryPackageBuild",
@@ -872,14 +867,9 @@
"for package %s (%s)" %
(build.id, binary.package, binary.version))
else:
- processor = distroarchinfo['processor']
build = getUtility(IBinaryPackageBuildSet).new(
- processor=processor,
- distro_arch_series=distroarchseries,
- status=BuildStatus.FULLYBUILT,
- source_package_release=srcpkg,
- pocket=self.pocket,
- archive=distroarchseries.main_archive)
+ srcpkg, distroarchseries.main_archive, distroarchseries,
+ self.pocket, status=BuildStatus.FULLYBUILT)
return build
=== modified file 'lib/lp/soyuz/scripts/gina/runner.py'
--- lib/lp/soyuz/scripts/gina/runner.py 2013-05-22 11:57:26 +0000
+++ lib/lp/soyuz/scripts/gina/runner.py 2014-10-31 07:41:13 +0000
@@ -110,7 +110,7 @@
for archtag in archs:
try:
- importer_handler.ensure_archinfo(archtag)
+ importer_handler.ensure_arch(archtag)
except DataSetupError:
log.exception("Database setup required for run on %s", archtag)
sys.exit(1)
=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
--- lib/lp/soyuz/scripts/initialize_distroseries.py 2014-07-24 03:37:02 +0000
+++ lib/lp/soyuz/scripts/initialize_distroseries.py 2014-10-31 07:41:13 +0000
@@ -541,7 +541,7 @@
distroarchseries_list = ()
getUtility(IPackageCloner).clonePackages(
origin, destination, distroarchseries_list,
- processors, spns, self.rebuild)
+ processors, spns)
else:
# There is only one available pocket in an unreleased
# series.
=== modified file 'lib/lp/soyuz/tests/test_binarypackagebuild.py'
--- lib/lp/soyuz/tests/test_binarypackagebuild.py 2014-07-24 09:37:03 +0000
+++ lib/lp/soyuz/tests/test_binarypackagebuild.py 2014-10-31 07:41:13 +0000
@@ -89,9 +89,9 @@
def create_previous_build(self, duration):
spr = self.build.source_package_release
- build = spr.createBuild(
- distro_arch_series=self.build.distro_arch_series,
- archive=self.build.archive, pocket=self.build.pocket)
+ build = getUtility(IBinaryPackageBuildSet).new(
+ spr, self.build.archive, self.build.distro_arch_series,
+ self.build.pocket)
now = datetime.now(pytz.UTC)
build.updateStatus(
BuildStatus.BUILDING,
=== modified file 'lib/lp/soyuz/tests/test_build.py'
--- lib/lp/soyuz/tests/test_build.py 2013-11-28 08:51:32 +0000
+++ lib/lp/soyuz/tests/test_build.py 2014-10-31 07:41:13 +0000
@@ -23,7 +23,10 @@
PackagePublishingPriority,
PackageUploadStatus,
)
-from lp.soyuz.interfaces.binarypackagebuild import CannotBeRescored
+from lp.soyuz.interfaces.binarypackagebuild import (
+ CannotBeRescored,
+ IBinaryPackageBuildSet,
+ )
from lp.soyuz.interfaces.component import IComponentSet
from lp.soyuz.interfaces.publishing import PackagePublishingStatus
from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
@@ -154,8 +157,9 @@
# current_component returns None in that case.
spph = self.publisher.getPubSource()
other_das = self.factory.makeDistroArchSeries()
- build = spph.sourcepackagerelease.createBuild(
- other_das, PackagePublishingPocket.RELEASE, spph.archive)
+ build = getUtility(IBinaryPackageBuildSet).new(
+ spph.sourcepackagerelease, spph.archive, other_das,
+ PackagePublishingPocket.RELEASE)
self.assertIs(None, build.current_component)
def test_retry_for_released_series(self):
=== modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2013-10-10 18:37:49 +0000
+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2014-10-31 07:41:13 +0000
@@ -22,6 +22,7 @@
PackagePublishingStatus,
SourcePackageFormat,
)
+from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.interfaces.sourcepackageformat import (
ISourcePackageFormatSelectionSet,
@@ -230,8 +231,8 @@
distroseries=dsp.parent_series)
das = self.factory.makeDistroArchSeries(
distroseries=dsp.parent_series, supports_virtualized=True)
- orig_build = spr.createBuild(
- das, PackagePublishingPocket.RELEASE, parent_archive,
+ orig_build = getUtility(IBinaryPackageBuildSet).new(
+ spr, parent_archive, das, PackagePublishingPocket.RELEASE,
status=BuildStatus.FULLYBUILT)
bpr = self.factory.makeBinaryPackageRelease(build=orig_build)
self.factory.makeBinaryPackagePublishingHistory(
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2014-09-01 03:41:31 +0000
+++ lib/lp/testing/factory.py 2014-10-31 07:41:13 +0000
@@ -75,7 +75,6 @@
from lp.blueprints.enums import (
NewSpecificationDefinitionStatus,
SpecificationDefinitionStatus,
- SpecificationPriority,
SpecificationWorkItemStatus,
)
from lp.blueprints.interfaces.specification import ISpecificationSet
@@ -3578,9 +3577,9 @@
:param builder: An optional builder to assign.
:param status: The BuildStatus for the build.
"""
- if processor is None:
- processor = self.makeProcessor()
if distroarchseries is None:
+ if processor is None:
+ processor = self.makeProcessor()
if source_package_release is not None:
distroseries = source_package_release.upload_distroseries
elif archive is not None:
@@ -3590,6 +3589,11 @@
distroseries = self.makeDistroSeries()
distroarchseries = self.makeDistroArchSeries(
distroseries=distroseries, processor=processor)
+ else:
+ if (processor is not None
+ and processor != distroarchseries.processor):
+ raise AssertionError(
+ "DistroArchSeries and Processor must match.")
if archive is None:
if source_package_release is None:
archive = distroarchseries.main_archive
@@ -3612,18 +3616,14 @@
pocket=pocket)
if status is None:
status = BuildStatus.NEEDSBUILD
- if date_created is None:
- date_created = self.getUniqueDate()
admins = getUtility(ILaunchpadCelebrities).admin
with person_logged_in(admins.teamowner):
binary_package_build = getUtility(IBinaryPackageBuildSet).new(
source_package_release=source_package_release,
- processor=processor,
distro_arch_series=distroarchseries,
status=status,
archive=archive,
pocket=pocket,
- date_created=date_created,
builder=builder)
IStore(binary_package_build).flush()
return binary_package_build
Follow ups