Skip to content

Commit

Permalink
clippy: do not fail the scan if clippy fails to install
Browse files Browse the repository at this point in the history
If the `clippy` package is not available in the build repos, a warning
is emitted and `clippy` is not recorded as an enabled tool in the scan
properties.  But the scan continues without `clippy` in this case.

The approach is similar to what `--gcc-analyze` does.  This is needed
because `clippy` is not available for each mock config and we do not
want to configure the set of enabled tools separately for each mock
config.

Related: https://issues.redhat.com/browse/OSH-30
Closes: #174
  • Loading branch information
kdudka committed Jun 19, 2024
1 parent bd4a143 commit 69b366f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions py/plugins/clippy.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit 69b366f

Please sign in to comment.