diff --git a/py/plugins/clippy.py b/py/plugins/clippy.py index d96721a..e4690ea 100644 --- a/py/plugins/clippy.py +++ b/py/plugins/clippy.py @@ -1,6 +1,6 @@ import os -import csmock.common.util +from csmock.common.util import write_toolver_from_rpmlist RUN_CLIPPY_CONVERT = "/usr/share/csmock/scripts/convert-clippy.py" CLIPPY_OUTPUT = "/builddir/clippy-output.txt" @@ -28,14 +28,20 @@ def handle_args(self, parser, args, props): if not self.enabled: return + # install `clippy` only if the package is available in the build repos + props.install_opt_pkgs += ["clippy"] + def inject_clippy_hook(results, mock): - return mock.exec_chroot_cmd(CLIPPY_INJECT_SCRIPT) - props.post_depinst_hooks += [inject_clippy_hook] + ec = write_toolver_from_rpmlist(results, mock, "clippy", "clippy") + if 0 != ec: + # a warning has already been emitted + return 0 - props.install_pkgs += ["clippy"] - props.copy_out_files += [CLIPPY_OUTPUT] + # clippy was found in the buildroot -> instrument the build + props.copy_out_files += [CLIPPY_OUTPUT] + return mock.exec_chroot_cmd(CLIPPY_INJECT_SCRIPT) - csmock.common.util.install_default_toolver_hook(props, "clippy") + props.post_depinst_hooks += [inject_clippy_hook] def convert_hook(results): src = f"{results.dbgdir_raw}{CLIPPY_OUTPUT}"