Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion csmock/csmock
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ class ScanProps:
self.imp_csgrep_filters = []
self.cswrap_path = None
self.kfp_git_url = None
self.use_host_csgrep = False

def enable_cswrap(self):
if self.cswrap_enabled:
Expand Down Expand Up @@ -886,6 +887,12 @@ exceeds the specified limit (defaults to 1024).")
"--kfp-git-url",
help="known false positives git URL (optionally taking a revision delimited by #)")

parser.add_argument(
"--use-host-csgrep",
action="store_true",
help="use staticly linked csgrep installed on host (removes build dependency on csdiff)",
)

csmock.common.util.add_paired_flag(
parser, "use-login-shell",
help="use login shell for build (default)")
Expand Down Expand Up @@ -956,10 +963,14 @@ exceeds the specified limit (defaults to 1024).")
props.use_ldpwrap = args.use_ldpwrap
props.skip_mock_clean = args.no_clean
props.kfp_git_url = args.kfp_git_url
props.use_host_csgrep = args.use_host_csgrep
Comment thread
kdudka marked this conversation as resolved.

if props.embed_context > 0:
# we need 'csgrep --embed-context' to work in the chroot for --embed-context
props.install_opt_pkgs += ["csdiff"]
if props.use_host_csgrep:
props.copy_in_files += ["/usr/libexec/csgrep-static"]
else:
props.install_opt_pkgs += ["csdiff"]

if args.warning_rate_limit > 0:
props.results_limits_opts += [f"--warning-rate-limit={args.warning_rate_limit}"]
Expand Down Expand Up @@ -1165,6 +1176,12 @@ cd %%s*/ || cd *\n\
mock.get_mock_cmd(["--shell", "tar -xC/"]))
results.exec_cmd(cmd, shell=True)

if props.use_host_csgrep:
def symlink_static_csgrep_hook(_, mock):
return mock.exec_chroot_cmd("ln -s /usr/libexec/csgrep-static /usr/bin/csgrep")
Comment on lines +1180 to +1181
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ln -fs ... so that the hook is idempotent. Otherwise it would fail when csmock is used with --no-clean and --skip-init.


props.post_depinst_hooks.append(symlink_static_csgrep_hook)

# run post-depinst hooks
props.run_hooks(results, "post-depinst", results, mock)

Expand Down