launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20172
[Merge] lp:~cjwatson/launchpad/refactor-component-dependencies into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/refactor-component-dependencies into lp:launchpad.
Commit message:
Refactor component dependency lookups to go through get_components_for_context.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/refactor-component-dependencies/+merge/290532
Refactor component dependency lookups to go through get_components_for_context rather than looking things up in component_dependencies directly. This will let us apply more flexible policies around component dependencies.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/refactor-component-dependencies into lp:launchpad.
=== modified file 'lib/lp/code/model/recipebuilder.py'
--- lib/lp/code/model/recipebuilder.py 2016-01-15 11:50:57 +0000
+++ lib/lp/code/model/recipebuilder.py 2016-03-30 21:24:29 +0000
@@ -64,7 +64,7 @@
args['archive_purpose'] = self.build.archive.purpose.name
args["ogrecomponent"] = get_primary_current_component(
self.build.archive, self.build.distroseries,
- None)
+ None).name
args['archives'] = get_sources_list_for_building(
self.build, distroarchseries, None,
tools_source=config.builddmaster.bzr_builder_sources_list,
=== modified file 'lib/lp/soyuz/adapters/archivedependencies.py'
--- lib/lp/soyuz/adapters/archivedependencies.py 2016-01-07 18:34:07 +0000
+++ lib/lp/soyuz/adapters/archivedependencies.py 2016-03-30 21:24:29 +0000
@@ -7,7 +7,6 @@
and pocket dependencies and helper function to handler `ArchiveDependency`
records.
- * component_dependencies: static map of component dependencies
* pocket_dependencies: static map of pocket dependencies
Auxiliary functions exposed for testing purposes:
@@ -15,7 +14,7 @@
* get_components_for_context: return the corresponding component
dependencies for a component and pocket, this result is known as
'ogre_components';
- * get_primary_current_component: return the component name where the
+ * get_primary_current_component: return the component where the
building source is published in the primary archive.
`sources_list` content generation.
@@ -28,7 +27,6 @@
__metaclass__ = type
__all__ = [
- 'component_dependencies',
'default_component_dependency_name',
'default_pocket_dependency',
'expand_dependencies',
@@ -55,6 +53,7 @@
PackagePublishingStatus,
)
from lp.soyuz.interfaces.archive import ALLOW_RELEASE_BUILDS
+from lp.soyuz.interfaces.component import IComponentSet
component_dependencies = {
@@ -114,7 +113,7 @@
def get_primary_current_component(archive, distroseries, sourcepackagename):
- """Return the component name of the primary archive ancestry.
+ """Return the component of the primary archive ancestry.
If no ancestry could be found, default to 'universe'.
"""
@@ -129,7 +128,7 @@
if ancestry is not None:
return ancestry.component.name
else:
- return 'universe'
+ return getUtility(IComponentSet)['universe']
def expand_dependencies(archive, distro_arch_series, pocket, component,
@@ -166,15 +165,14 @@
# the component where the source is published in the primary
# archive.
if archive_dependency.component is None:
- components = component_dependencies[primary_component]
+ archive_component = primary_component
else:
- components = component_dependencies[
- archive_dependency.component.name]
+ archive_component = archive_dependency.component
# Follow pocket dependencies.
for pocket in pocket_dependencies[archive_dependency.pocket]:
deps.append(
(archive_dependency.dependency, distro_arch_series, pocket,
- components))
+ get_components_for_context(archive_component, pocket)))
# Consider build tools archive dependencies.
if tools_source is not None:
@@ -205,11 +203,11 @@
dep_arch_series = dsp.parent_series.getDistroArchSeries(
distro_arch_series.architecturetag)
dep_archive = dsp.parent_series.distribution.main_archive
- components = component_dependencies[dsp.component.name]
# Follow pocket dependencies.
for pocket in pocket_dependencies[dsp.pocket]:
deps.append(
- (dep_archive, dep_arch_series, pocket, components))
+ (dep_archive, dep_arch_series, pocket,
+ get_components_for_context(dsp.component, pocket)))
except NotFoundError:
pass
@@ -353,13 +351,11 @@
archive.
"""
if archive.purpose in ALLOW_RELEASE_BUILDS:
- primary_pockets = pocket_dependencies[
- default_pocket_dependency]
- primary_components = component_dependencies[
+ component = getUtility(IComponentSet)[
default_component_dependency_name]
- else:
- primary_pockets = pocket_dependencies[pocket]
- primary_components = get_components_for_context(component, pocket)
+ pocket = default_pocket_dependency
+ primary_components = get_components_for_context(component, pocket)
+ primary_pockets = pocket_dependencies[pocket]
primary_dependencies = []
for pocket in primary_pockets:
=== modified file 'lib/lp/soyuz/doc/archive-dependencies.txt'
--- lib/lp/soyuz/doc/archive-dependencies.txt 2016-01-08 13:49:28 +0000
+++ lib/lp/soyuz/doc/archive-dependencies.txt 2016-03-30 21:24:29 +0000
@@ -10,10 +10,8 @@
We use `SoyuzTestPublisher` to generate a source publications and
build candidates for ubuntu/hoary.
- >>> from lp.registry.interfaces.distribution import (
- ... IDistributionSet)
- >>> from lp.soyuz.tests.test_publishing import (
- ... SoyuzTestPublisher)
+ >>> from lp.registry.interfaces.distribution import IDistributionSet
+ >>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
>>> from lp.testing import login
>>> login('foo.bar@xxxxxxxxxxxxx')
@@ -29,35 +27,10 @@
== Static dependency maps ==
-`component_dependencies` contains a static map of the default ubuntu
-component dependencies (known as the 'ogre-model').
-
- >>> from lp.soyuz.adapters.archivedependencies import (
- ... component_dependencies)
-
- >>> def show_component_deps():
- ... print "Component | Dependencies"
- ... print "-----------+---------------"
- ... for key, value in sorted(component_dependencies.items()):
- ... print "%10s |" % (key,),
- ... for dep in value:
- ... print dep,
- ... print
-
- >>> show_component_deps()
- Component | Dependencies
- -----------+---------------
- main | main
- multiverse | main restricted universe multiverse
- partner | partner
- restricted | main restricted
- universe | main universe
-
`pocket_dependencies` contains a static map of the default ubuntu
pocket dependencies.
- >>> from lp.soyuz.adapters.archivedependencies import (
- ... pocket_dependencies)
+ >>> from lp.soyuz.adapters.archivedependencies import pocket_dependencies
>>> def show_pocket_deps():
... print "Pocket | Dependencies"
@@ -182,8 +155,9 @@
Security
Updates
- >>> for component_name in component_dependencies[
- ... default_component_dependency_name]:
+ >>> for component_name in get_components_for_context(
+ ... getUtility(IComponentSet)[default_component_dependency_name],
+ ... pocket):
... print component_name
main
restricted
@@ -215,8 +189,7 @@
no binary published in Celso's PPA hoary/i386, so there is
no need to request the builder to load its archive indexes.
- >>> from lp.soyuz.enums import (
- ... PackagePublishingStatus)
+ >>> from lp.soyuz.enums import PackagePublishingStatus
>>> cprov.archive.getAllPublishedBinaries(
... distroarchseries=a_build.distro_arch_series,
@@ -345,7 +318,7 @@
... get_primary_current_component)
>>> print get_primary_current_component(a_build.archive,
- ... a_build.distro_series, a_build.source_package_release.name)
+ ... a_build.distro_series, a_build.source_package_release.name).name
universe
>>> print_building_sources_list(a_build)
=== modified file 'lib/lp/soyuz/model/archivedependency.py'
--- lib/lp/soyuz/model/archivedependency.py 2015-07-08 16:05:11 +0000
+++ lib/lp/soyuz/model/archivedependency.py 2016-03-30 21:24:29 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Database class for ArchiveDependency."""
@@ -16,7 +16,7 @@
from lp.services.database.datetimecol import UtcDateTimeCol
from lp.services.database.enumcol import EnumCol
from lp.services.database.sqlbase import SQLBase
-from lp.soyuz.adapters.archivedependencies import component_dependencies
+from lp.soyuz.adapters.archivedependencies import get_components_for_context
from lp.soyuz.interfaces.archivedependency import IArchiveDependency
@@ -63,6 +63,6 @@
return pocket_title
component_part = ", ".join(
- component_dependencies[self.component.name])
+ get_components_for_context(self.component, self.pocket))
return "%s (%s)" % (pocket_title, component_part)
=== modified file 'lib/lp/soyuz/model/binarypackagebuildbehaviour.py'
--- lib/lp/soyuz/model/binarypackagebuildbehaviour.py 2015-07-08 16:05:11 +0000
+++ lib/lp/soyuz/model/binarypackagebuildbehaviour.py 2016-03-30 21:24:29 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Builder behaviour for binary package builds."""
@@ -153,7 +153,8 @@
args['archive_purpose'] = ArchivePurpose.PRIMARY.name
args["ogrecomponent"] = (
get_primary_current_component(build.archive,
- build.distro_series, build.source_package_release.name))
+ build.distro_series,
+ build.source_package_release.name)).name
else:
args['archive_purpose'] = archive_purpose.name
args["ogrecomponent"] = (
Follow ups