From 6da2490abd89cc203edeb2fd1eb6ef3b9414fe8b Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 10 Nov 2025 16:14:08 +0100 Subject: [PATCH] csmock --embed-context: use csgrep-static in chroot ... so that `csdiff` does not need to be available in build repos Related: https://github.com/csutils/csdiff/pull/196 --- csmock/csmock | 9 ++++++--- make-srpm.sh | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/csmock/csmock b/csmock/csmock index 4ea509b..efb96e0 100755 --- a/csmock/csmock +++ b/csmock/csmock @@ -49,6 +49,9 @@ CSMOCK_DATADIR = "/usr/share/csmock" CWE_MAP_FILE = CSMOCK_DATADIR + "/cwe-map.csv" +# path to the csgrep-static executable +CSGREP_STATIC = "/usr/libexec/csgrep-static" + CSMOCK_SCRIPTS = CSMOCK_DATADIR + "/scripts" CHROOT_FIXUPS = CSMOCK_SCRIPTS + "/chroot-fixups" @@ -958,8 +961,8 @@ exceeds the specified limit (defaults to 1024).") props.kfp_git_url = args.kfp_git_url if props.embed_context > 0: - # we need 'csgrep --embed-context' to work in the chroot for --embed-context - props.install_opt_pkgs += ["csdiff"] + # we need csgrep-static in the chroot for --embed-context + props.copy_in_files += [CSGREP_STATIC] if args.warning_rate_limit > 0: props.results_limits_opts += [f"--warning-rate-limit={args.warning_rate_limit}"] @@ -1289,7 +1292,7 @@ cd %%s*/ || cd *\n\ if props.embed_context > 0: # embed context lines from source program files tmp_file = f"{all_file}.tmp" - csgrep_cmd = f"csgrep --mode=json --embed-context {props.embed_context}" + csgrep_cmd = f"{CSGREP_STATIC} --mode=json --embed-context {props.embed_context}" if props.results_limits_opts: # apply results limits already while embedding context to avoid creating excessively huge output diff --git a/make-srpm.sh b/make-srpm.sh index 14a84fa..2ae2864 100755 --- a/make-srpm.sh +++ b/make-srpm.sh @@ -126,6 +126,7 @@ Tool for plugging static analyzers into the build process, free of mock. %package common Summary: Core of csmock (a mock wrapper for Static Analysis tools) Requires: csdiff > 3.5.1 +Requires: csdiff-static Requires: csgcca Requires: cswrap Requires: mock >= 5.7