Skip to content

Commit ae7c422

Browse files
committed
csmock: add --use-host-csgrep param
This param copies in the statically linked version of csgrep installed on the host into the mock root, removing the build dependency on csgrep. Requires the `csgrep-static` package is installed on the host. This is both to support hermetic (re-)builds with csmock and to work towards using unchanged mock configs from the original build.
1 parent 41af877 commit ae7c422

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

csmock/csmock

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,12 @@ exceeds the specified limit (defaults to 1024).")
886886
"--kfp-git-url",
887887
help="known false positives git URL (optionally taking a revision delimited by #)")
888888

889+
parser.add_argument(
890+
"--use-host-csgrep",
891+
action="store_true",
892+
help="use staticly linked csgrep installed on host (removes build dependency on csdiff)",
893+
)
894+
889895
csmock.common.util.add_paired_flag(
890896
parser, "use-login-shell",
891897
help="use login shell for build (default)")
@@ -956,10 +962,14 @@ exceeds the specified limit (defaults to 1024).")
956962
props.use_ldpwrap = args.use_ldpwrap
957963
props.skip_mock_clean = args.no_clean
958964
props.kfp_git_url = args.kfp_git_url
965+
props.use_host_csgrep = args.use_host_csgrep
959966

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

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

1178+
if props.use_host_csgrep:
1179+
def symlink_static_csgrep_hook(_, mock):
1180+
return mock.exec_chroot_cmd("ln -s /usr/libexec/csgrep-static /usr/bin/csgrep")
1181+
1182+
props.post_depinst_hooks.append(symlink_static_csgrep_hook)
1183+
11681184
# run post-depinst hooks
11691185
props.run_hooks(results, "post-depinst", results, mock)
11701186

0 commit comments

Comments
 (0)