GenericBuilder: Add a boolean 'succeeded' parameter to finalize

Previously MockModuleBuilder was checking the module state to see if
it should run a final createrepo, but since eafa93037f, finalize() is
called before changing the module state; add an explicit boolean to
GenericBuilder.finalize() to avoid worrying about ordering.
This commit is contained in:
Owen W. Taylor
2019-04-02 14:56:53 -04:00
committed by mprahl
parent 63bccb28ff
commit da57146bf2
8 changed files with 25 additions and 12 deletions

View File

@@ -1209,7 +1209,7 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules
nvrs = set(kobo.rpmlib.make_nvr(rpm, force_epoch=True) for rpm in rpms)
return list(nvrs)
def finalize(self):
def finalize(self, succeeded=True):
# Only import to koji CG if the module is "build" and not scratch.
if (not self.module.scratch and
self.config.koji_enable_content_generator and

View File

@@ -542,11 +542,11 @@ class MockModuleBuilder(GenericBuilder):
def repo_from_tag(cls, config, tag_name, arch):
pass
def finalize(self):
# If the state is "done", run one last createrepo, to include
def finalize(self, succeeded=True):
# For successful builds, do one last createrepo, to include
# the module metadata. We don't want to do this for failed builds,
# since that makes it impossible to retry a build manually.
if self.module.state == models.BUILD_STATES["done"]:
if succeeded:
self._createrepo(include_module_yaml=True)
@classmethod

View File

@@ -262,12 +262,13 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
raise NotImplementedError()
@abstractmethod
def finalize(self):
def finalize(self, succeeded=True):
"""
:param succeeded: True if all module builds were successful
:return: None
This method is supposed to be called after all module builds are
successfully finished.
finished.
It could be utilized for various purposes such as cleaning or
running additional build-system based operations on top of