mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-11-28 15:14:32 +08:00
Support base modules with x.y.z versioning and no virtual streams
This commit is contained in:
@@ -212,9 +212,9 @@ class MMDResolver(object):
|
||||
|
||||
return reqs
|
||||
|
||||
def _add_virtual_provides(self, solvable, mmd):
|
||||
def _add_base_module_provides(self, solvable, mmd):
|
||||
"""
|
||||
Adds "virtual_streams" from XMD section of `mmd` to `solvable`.
|
||||
Adds the "stream version" and the "virtual_streams" from XMD section of `mmd` to `solvable`.
|
||||
|
||||
Base modules like "platform" can contain virtual streams which need to be considered
|
||||
when resolving dependencies. For example module "platform:el8.1.0" can provide virtual
|
||||
@@ -223,9 +223,7 @@ class MMDResolver(object):
|
||||
- module(platform:el8.1.0) = 80100 - Modules can require specific platform stream.
|
||||
- module(platform:el8) = 80100 - Module can also require just platform:el8.
|
||||
"""
|
||||
xmd = mmd.get_xmd()
|
||||
# Return in case virtual_streams are not set for this mmd.
|
||||
if "mbs" not in xmd.keys() or "virtual_streams" not in xmd["mbs"].keys():
|
||||
if mmd.get_name() not in conf.base_module_names:
|
||||
return
|
||||
|
||||
# When depsolving, we will need to follow specific rules to choose the right base
|
||||
@@ -234,11 +232,16 @@ class MMDResolver(object):
|
||||
# and so on. We therefore need to convert the stream and version of base module to
|
||||
# integer representation and add "module($name:$stream) = $stream_based_version"
|
||||
# to Provides.
|
||||
version = ModuleBuild.get_stream_version(
|
||||
mmd.get_stream(), right_pad=False)
|
||||
dep = self.pool.Dep("module(%s:%s)" % (mmd.get_name(), mmd.get_stream())).Rel(
|
||||
solv.REL_EQ, self.pool.Dep(str(version)))
|
||||
solvable.add_deparray(solv.SOLVABLE_PROVIDES, dep)
|
||||
version = ModuleBuild.get_stream_version(mmd.get_stream(), right_pad=False)
|
||||
if version:
|
||||
dep = self.pool.Dep("module(%s:%s)" % (mmd.get_name(), mmd.get_stream())).Rel(
|
||||
solv.REL_EQ, self.pool.Dep(str(version)))
|
||||
solvable.add_deparray(solv.SOLVABLE_PROVIDES, dep)
|
||||
|
||||
xmd = mmd.get_xmd()
|
||||
# Return in case virtual_streams are not set for this mmd.
|
||||
if "mbs" not in xmd.keys() or "virtual_streams" not in xmd["mbs"].keys():
|
||||
return
|
||||
|
||||
# For each virtual stream, add
|
||||
# "module($name:$stream) = $virtual_stream_based_version" provide.
|
||||
@@ -323,7 +326,7 @@ class MMDResolver(object):
|
||||
pool.Dep("module(%s:%s)" % (n, s)).Rel(
|
||||
solv.REL_EQ, pool.Dep(str(v))))
|
||||
|
||||
self._add_virtual_provides(solvable, mmd)
|
||||
self._add_base_module_provides(solvable, mmd)
|
||||
|
||||
# Fill in the "Requires" of this module, so we can track its dependencies
|
||||
# on other modules.
|
||||
|
||||
37
tests/staged_data/testmodule_el800.yaml
Normal file
37
tests/staged_data/testmodule_el800.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
document: modulemd
|
||||
version: 1
|
||||
data:
|
||||
summary: A test module in all its beautiful beauty
|
||||
description: >-
|
||||
This module demonstrates how to write simple modulemd files And
|
||||
can be used for testing the build and release pipeline. ’
|
||||
license:
|
||||
module: [ MIT ]
|
||||
dependencies:
|
||||
buildrequires:
|
||||
platform: el8.0.0
|
||||
requires:
|
||||
platform: el8.0.0
|
||||
references:
|
||||
community: https://docs.pagure.org/modularity/
|
||||
documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules
|
||||
profiles:
|
||||
default:
|
||||
rpms:
|
||||
- tangerine
|
||||
api:
|
||||
rpms:
|
||||
- perl-Tangerine
|
||||
- tangerine
|
||||
components:
|
||||
rpms:
|
||||
perl-List-Compare:
|
||||
rationale: A dependency of tangerine.
|
||||
ref: master
|
||||
perl-Tangerine:
|
||||
rationale: Provides API for this module and is a dependency of tangerine.
|
||||
ref: master
|
||||
tangerine:
|
||||
rationale: Provides API for this module.
|
||||
buildorder: 10
|
||||
ref: master
|
||||
@@ -1999,3 +1999,25 @@ class TestViews:
|
||||
assert set(dep.get_buildrequires()['platform'].get()) == {'product1.3'}
|
||||
# The requires should not change
|
||||
assert set(dep.get_requires()['platform'].get()) == {'f28'}
|
||||
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
def test_submit_build_br_xyz_version_no_virtual_streams(self, mocked_scm, mocked_get_user):
|
||||
"""
|
||||
Test that when a build is submitted with a buildrequire on a base module with x.y.z
|
||||
versioning and no virtual streams, that the dependency resolution succeeds.
|
||||
"""
|
||||
init_data(data_size=1, multiple_stream_versions=True)
|
||||
platform_mmd = load_mmd(path.join(base_dir, 'staged_data', 'platform.yaml'), True)
|
||||
platform_mmd.set_stream('el8.0.0')
|
||||
import_mmd(db.session, platform_mmd)
|
||||
|
||||
FakeSCM(mocked_scm, 'testmodule', 'testmodule_el800.yaml',
|
||||
'620ec77321b2ea7b0d67d82992dda3e1d67055b4')
|
||||
|
||||
post_url = '/module-build-service/2/module-builds/'
|
||||
scm_url = ('https://src.stg.fedoraproject.org/modules/testmodule.git?#68931c90de214d9d13fe'
|
||||
'efbd35246a81b6cb8d49')
|
||||
|
||||
rv = self.client.post(post_url, data=json.dumps({'branch': 'master', 'scmurl': scm_url}))
|
||||
assert rv.status_code == 201
|
||||
|
||||
Reference in New Issue
Block a user