| |
@@ -658,14 +658,17 @@
|
| |
)
|
| |
|
| |
|
| |
- def _handle_base_module_virtual_stream_br(mmd):
|
| |
+ def _modify_buildtime_streams(mmd, new_streams_func):
|
| |
"""
|
| |
- Translate a base module virtual stream buildrequire to an actual stream on the input modulemd.
|
| |
+ Modify buildtime streams using the input new_streams_func.
|
| |
+
|
| |
+ This is a helper method for _handle_base_module_virtual_stream_br and
|
| |
+ _process_base_module_stream_suffix.
|
| |
|
| |
:param Modulemd.ModuleStream mmd: the modulemd to apply the overrides on
|
| |
+ :param function new_streams: a function that takes the parameters (module_name, module_streams),
|
| |
+ and returns the streams that should be set on the buildtime dependency.
|
| |
"""
|
| |
- from module_build_service.resolver import system_resolver
|
| |
-
|
| |
deps = mmd.get_dependencies()
|
| |
for dep in deps:
|
| |
overridden = False
|
| |
@@ -675,50 +678,8 @@
|
| |
new_dep = Modulemd.Dependencies()
|
| |
|
| |
for name, streams in brs.items():
|
| |
- if name not in conf.base_module_names:
|
| |
- if streams == []:
|
| |
- new_dep.set_empty_buildtime_dependencies_for_module(name)
|
| |
- else:
|
| |
- for stream in streams:
|
| |
- new_dep.add_buildtime_stream(name, stream)
|
| |
- continue
|
| |
-
|
| |
- new_streams = copy.deepcopy(streams)
|
| |
- for i, stream in enumerate(streams):
|
| |
- # Ignore streams that start with a minus sign, since those are handled in the
|
| |
- # MSE code
|
| |
- if stream.startswith("-"):
|
| |
- continue
|
| |
-
|
| |
- # Check if the base module stream is available
|
| |
- log.debug('Checking to see if the base module "%s:%s" is available', name, stream)
|
| |
- if system_resolver.get_module_count(name=name, stream=stream) > 0:
|
| |
- continue
|
| |
-
|
| |
- # If the base module stream is not available, check if there's a virtual stream
|
| |
- log.debug(
|
| |
- 'Checking to see if there is a base module "%s" with the virtual stream "%s"',
|
| |
- name, stream,
|
| |
- )
|
| |
- base_module_mmd = system_resolver.get_latest_with_virtual_stream(
|
| |
- name=name, virtual_stream=stream
|
| |
- )
|
| |
- if not base_module_mmd:
|
| |
- # If there isn't this base module stream or virtual stream available, skip it,
|
| |
- # and let the dep solving code deal with it like it normally would
|
| |
- log.warning(
|
| |
- 'There is no base module "%s" with stream/virtual stream "%s"',
|
| |
- name, stream,
|
| |
- )
|
| |
- continue
|
| |
-
|
| |
- latest_stream = base_module_mmd.get_stream_name()
|
| |
- log.info(
|
| |
- 'Replacing the buildrequire "%s:%s" with "%s:%s", since "%s" is a virtual '
|
| |
- "stream",
|
| |
- name, stream, name, latest_stream, stream
|
| |
- )
|
| |
- new_streams[i] = latest_stream
|
| |
+ new_streams = new_streams_func(name, streams)
|
| |
+ if streams != new_streams:
|
| |
overridden = True
|
| |
|
| |
if new_streams == []:
|
| |
@@ -741,6 +702,96 @@
|
| |
mmd.add_dependencies(new_dep)
|
| |
|
| |
|
| |
+ def _handle_base_module_virtual_stream_br(mmd):
|
| |
+ """
|
| |
+ Translate a base module virtual stream buildrequire to an actual stream on the input modulemd.
|
| |
+
|
| |
+ :param Modulemd.ModuleStream mmd: the modulemd to apply the overrides on
|
| |
+ """
|
| |
+ from module_build_service.resolver import system_resolver
|
| |
+
|
| |
+ def new_streams_func(name, streams):
|
| |
+ if name not in conf.base_module_names:
|
| |
+ return streams
|
| |
+
|
| |
+ new_streams = copy.deepcopy(streams)
|
| |
+ for i, stream in enumerate(streams):
|
| |
+ # Ignore streams that start with a minus sign, since those are handled in the
|
| |
+ # MSE code
|
| |
+ if stream.startswith("-"):
|
| |
+ continue
|
| |
+
|
| |
+ # Check if the base module stream is available
|
| |
+ log.debug('Checking to see if the base module "%s:%s" is available', name, stream)
|
| |
+ if system_resolver.get_module_count(name=name, stream=stream) > 0:
|
| |
+ continue
|
| |
+
|
| |
+ # If the base module stream is not available, check if there's a virtual stream
|
| |
+ log.debug(
|
| |
+ 'Checking to see if there is a base module "%s" with the virtual stream "%s"',
|
| |
+ name, stream,
|
| |
+ )
|
| |
+ base_module_mmd = system_resolver.get_latest_with_virtual_stream(
|
| |
+ name=name, virtual_stream=stream
|
| |
+ )
|
| |
+ if not base_module_mmd:
|
| |
+ # If there isn't this base module stream or virtual stream available, skip it,
|
| |
+ # and let the dep solving code deal with it like it normally would
|
| |
+ log.warning(
|
| |
+ 'There is no base module "%s" with stream/virtual stream "%s"',
|
| |
+ name, stream,
|
| |
+ )
|
| |
+ continue
|
| |
+
|
| |
+ latest_stream = base_module_mmd.get_stream_name()
|
| |
+ log.info(
|
| |
+ 'Replacing the buildrequire "%s:%s" with "%s:%s", since "%s" is a virtual '
|
| |
+ "stream",
|
| |
+ name, stream, name, latest_stream, stream
|
| |
+ )
|
| |
+ new_streams[i] = latest_stream
|
| |
+
|
| |
+ return new_streams
|
| |
+
|
| |
+ _modify_buildtime_streams(mmd, new_streams_func)
|
| |
+
|
| |
+
|
| |
+ def _process_base_module_stream_suffix(mmd, params):
|
| |
+ """
|
| |
+ Process the base_module_stream_suffix parameter.
|
| |
+
|
| |
+ If provided by the user, the value will be appended to the streams of the base modules that are
|
| |
+ buildrequired.
|
| |
+
|
| |
+ :param Modulemd.ModuleStream mmd: the modulemd to apply the overrides on
|
| |
+ :param dict params: the API parameters passed in by the user
|
| |
+ """
|
| |
+ if not params.get("base_module_stream_suffix"):
|
| |
+ return
|
| |
+
|
| |
+ def new_streams_func(name, streams):
|
| |
+ if name not in conf.base_module_names:
|
| |
+ return streams
|
| |
+
|
| |
+ new_streams = copy.deepcopy(streams)
|
| |
+ for i, stream in enumerate(streams):
|
| |
+ # If the stream already ends with that suffix, it should be skipped
|
| |
+ if stream.endswith(params["base_module_stream_suffix"]):
|
| |
+ continue
|
| |
+
|
| |
+ new_stream = stream + params["base_module_stream_suffix"]
|
| |
+ log.info(
|
| |
+ 'Replacing the buildrequire "%s:%s" with "%s:%s", since "base_module_stream_suffix"'
|
| |
+ " was provided with a value of %s",
|
| |
+ name, stream, name, new_stream, stream, params["base_module_stream_suffix"]
|
| |
+ )
|
| |
+ new_streams[i] = new_stream
|
| |
+
|
| |
+ return new_streams
|
| |
+
|
| |
+ _modify_buildtime_streams(mmd, new_streams_func)
|
| |
+
|
| |
+
|
| |
def submit_module_build(username, mmd, params):
|
| |
"""
|
| |
Submits new module build.
|
| |
@@ -774,6 +825,7 @@
|
| |
default_streams = params["default_streams"]
|
| |
_apply_dep_overrides(mmd, params)
|
| |
_handle_base_module_virtual_stream_br(mmd)
|
| |
+ _process_base_module_stream_suffix(mmd, params)
|
| |
|
| |
mmds = generate_expanded_mmds(db.session, mmd, raise_if_stream_ambigous, default_streams)
|
| |
if not mmds:
|
| |
Why not define this at the python module level? Usually functions are defined on the fly like this if we want to either hide things, or use closure.