| |
@@ -111,28 +111,40 @@
|
| |
db_session, username, handle, params, stream=None, skiptests=False
|
| |
):
|
| |
yaml_file = to_text_type(handle.read())
|
| |
- mmd = load_mmd(yaml_file)
|
| |
+ # load_mmd can return either a ModuleStreamV2 or PackagerV3 object
|
| |
+ # PackagerV3 objects become ModuleStreamV2 objects in submit_module_build
|
| |
+ stream_or_packager = load_mmd(yaml_file)
|
| |
if hasattr(handle, "filename"):
|
| |
def_name = str(os.path.splitext(os.path.basename(handle.filename))[0])
|
| |
- elif not mmd.get_module_name():
|
| |
+ elif not stream_or_packager.get_module_name():
|
| |
raise ValidationError(
|
| |
"The module's name was not present in the modulemd file. Please use the "
|
| |
'"module_name" parameter'
|
| |
)
|
| |
- module_name = mmd.get_module_name() or def_name
|
| |
- module_stream = stream or mmd.get_stream_name() or "master"
|
| |
- if module_name != mmd.get_module_name() or module_stream != mmd.get_stream_name():
|
| |
+ module_name = stream_or_packager.get_module_name() or def_name
|
| |
+ module_stream = stream or stream_or_packager.get_stream_name() or "master"
|
| |
+ if module_name != stream_or_packager.get_module_name() or \
|
| |
+ module_stream != stream_or_packager.get_stream_name():
|
| |
# This is how you set the name and stream in the modulemd
|
| |
- mmd = mmd.copy(module_name, module_stream)
|
| |
- if skiptests:
|
| |
- buildopts = mmd.get_buildopts() or Modulemd.Buildopts()
|
| |
+ if isinstance(stream_or_packager, Modulemd.ModuleStream):
|
| |
+ # This is a ModuleStreamV2 object
|
| |
+ stream_or_packager = stream_or_packager.copy(module_name, module_stream)
|
| |
+ else:
|
| |
+ # This is a PackagerV3 object
|
| |
+ stream_or_packager = stream_or_packager.copy()
|
| |
+ stream_or_packager.set_module_name(module_name)
|
| |
+ stream_or_packager.set_stream_name(module_stream)
|
| |
+ if skiptests and isinstance(stream_or_packager, Modulemd.ModuleStream):
|
| |
+ # PackagerV3 objects do not have buildopts methods
|
| |
+ buildopts = stream_or_packager.get_buildopts() or Modulemd.Buildopts()
|
| |
macros = buildopts.get_rpm_macros() or ""
|
| |
buildopts.set_rpm_macros(macros + "\n\n%__spec_check_pre exit 0\n")
|
| |
- mmd.set_buildopts(buildopts)
|
| |
+ stream_or_packager.set_buildopts(buildopts)
|
| |
|
| |
- module_stream_version = provide_module_stream_version_from_mmd(mmd)
|
| |
+ module_stream_version = provide_module_stream_version_from_mmd(stream_or_packager)
|
| |
|
| |
- return submit_module_build(db_session, username, mmd, params, module_stream_version)
|
| |
+ return submit_module_build(db_session, username, stream_or_packager, params,
|
| |
+ module_stream_version)
|
| |
|
| |
|
| |
_url_check_re = re.compile(r"^[^:/]+:.*$")
|
| |
@@ -146,11 +158,12 @@
|
| |
log.info("'{}' is not a valid URL, assuming local path".format(url))
|
| |
url = os.path.abspath(url)
|
| |
url = "file://" + url
|
| |
- mmd, scm = fetch_mmd(url, branch, allow_local_url)
|
| |
+ stream_or_packager, scm = fetch_mmd(url, branch, allow_local_url)
|
| |
|
| |
module_stream_version = int(scm.version)
|
| |
|
| |
- return submit_module_build(db_session, username, mmd, params, module_stream_version)
|
| |
+ return submit_module_build(db_session, username, stream_or_packager, params,
|
| |
+ module_stream_version)
|
| |
|
| |
|
| |
def _apply_dep_overrides(mmd, params):
|
| |
@@ -540,13 +553,14 @@
|
| |
_modify_buildtime_streams(db_session, mmd, new_streams_func)
|
| |
|
| |
|
| |
- def submit_module_build(db_session, username, mmd, params, module_stream_version):
|
| |
+ def submit_module_build(db_session, username, stream_or_packager, params, module_stream_version):
|
| |
"""
|
| |
Submits new module build.
|
| |
|
| |
:param db_session: SQLAlchemy session object.
|
| |
:param str username: Username of the build's owner.
|
| |
- :param Modulemd.ModuleStream mmd: Modulemd defining the build.
|
| |
+ :type stream_or_packager: Modulemd.ModuleStream or Modulemd.PackagerV3
|
| |
+ Modulemd.ModuleStream or PackagerV3 object defining the build.
|
| |
:param dict params: the API parameters passed in by the user
|
| |
:rtype: list with ModuleBuild
|
| |
:return: List with submitted module builds.
|
| |
@@ -562,7 +576,8 @@
|
| |
if "default_streams" in params:
|
| |
default_streams = params["default_streams"]
|
| |
|
| |
- input_mmds, static_context = process_module_context_configuration(mmd)
|
| |
+ # PackagerV3 objects become ModuleStreamV2 objects at this point
|
| |
+ input_mmds, static_context = process_module_context_configuration(stream_or_packager)
|
| |
|
| |
for mmd in input_mmds:
|
| |
mmd.set_version(module_stream_version)
|
| |
@@ -712,17 +727,17 @@
|
| |
return modules
|
| |
|
| |
|
| |
- def process_module_context_configuration(mmd):
|
| |
+ def process_module_context_configuration(stream_or_packager):
|
| |
"""
|
| |
Processes initial module metadata context configurations and creates individual module
|
| |
metadata for each context, if static context configuration is present.
|
| |
|
| |
- :param Modulemd.ModuleStream packager_mmd: Packager (initial) modulemd which kickstarts
|
| |
- the build.
|
| |
+ :type stream_or_packager: Modulemd.ModuleStream or Modulemd.PackagerV3
|
| |
+ Packager (initial) modulemd which kickstarts the build.
|
| |
:rtype: list with ModuleBuild
|
| |
:return: list of generated module metadata from context configurations.
|
| |
"""
|
| |
- mdversion = mmd.get_mdversion()
|
| |
+ mdversion = stream_or_packager.get_mdversion()
|
| |
static_context = False
|
| |
|
| |
# we check what version of the metadata format we are using.
|
| |
@@ -730,7 +745,7 @@
|
| |
# v3 we always talking about a new build and the static context
|
| |
# will be always True
|
| |
static_context = True
|
| |
- mdindex = mmd.convert_to_index()
|
| |
+ mdindex = stream_or_packager.convert_to_index()
|
| |
streams = mdindex.search_streams()
|
| |
|
| |
for stream in streams:
|
| |
@@ -753,19 +768,20 @@
|
| |
|
| |
return streams, static_context
|
| |
else:
|
| |
- xmd = mmd.get_xmd()
|
| |
+ xmd = stream_or_packager.get_xmd()
|
| |
# check if we are handling rebuild of a static context module
|
| |
if "mbs" in xmd:
|
| |
# check if it is a static context
|
| |
- if "static_context" in xmd["mbs"] or mmd.is_static_context():
|
| |
+ if "static_context" in xmd["mbs"] or stream_or_packager.is_static_context():
|
| |
static_context = True
|
| |
- return [mmd], static_context
|
| |
+ return [stream_or_packager], static_context
|
| |
|
| |
# we check if static contexts are enabled by the `contexts` property defined by the user i
|
| |
# as an build option.
|
| |
static_context = "mbs_options" in xmd and "contexts" in xmd["mbs_options"]
|
| |
# if the static context configuration exists we expand it. If not we just return
|
| |
# the mmd unchanged, for futher processing.
|
| |
- streams = generate_mmds_from_static_contexts(mmd) if static_context else [mmd]
|
| |
+ streams = generate_mmds_from_static_contexts(stream_or_packager) if static_context \
|
| |
+ else [stream_or_packager]
|
| |
|
| |
return streams, static_context
|
| |
I'll comment again that all three of the PackagerV3 branches are not covered by any test.