diff --git a/module_build_service/utils/reuse.py b/module_build_service/utils/reuse.py index efbbc0a..d548264 100644 --- a/module_build_service/utils/reuse.py +++ b/module_build_service/utils/reuse.py @@ -25,7 +25,7 @@ import kobo.rpmlib import module_build_service.messaging -from module_build_service import log, models, conf +from module_build_service import log, models, conf, glib def reuse_component(component, previous_component_build, @@ -110,6 +110,21 @@ def _get_reusable_module(session, module): log.info("Cannot re-use. %r is the first module build." % module) return None + xmd = glib.from_variant_dict(mmd.get_xmd()) + old_mmd = previous_module_build.mmd() + old_xmd = glib.from_variant_dict(old_mmd.get_xmd()) + + # Make sure that the module buildrequires commit hashes are exactly the same + for br_module_name, br_module in xmd['mbs']['buildrequires'].items(): + # Assumes that the streams have been replaced with commit hashes, so we + # can compare to see if they have changed. Since a build is unique to + # a commit hash, this is a safe test. + ref1 = br_module.get('ref') + ref2 = old_xmd['mbs']['buildrequires'][br_module_name].get('ref') + if not (ref1 and ref2) or ref1 != ref2: + log.info('Cannot re-use. The buildrequired module %s ref hash changed', br_module_name) + return None + return previous_module_build