From 48e3d2494630ff00aaa2d0b3de68bb05ffc2ed63 Mon Sep 17 00:00:00 2001 From: Petr Matousek Date: Tue, 26 Mar 2024 15:19:24 +0100 Subject: [PATCH] rust-clippy: move the chroot fixup as pointed out by @kdudka, having the per plugin chroot fixup script in actual chroot-fixups can be problematic when the plugin is not enabled at all. change it so that chroot fixup is invoked only when the plugin is enabled. --- make-srpm.sh | 1 + py/plugins/clippy.py | 5 +++++ scripts/CMakeLists.txt | 1 + scripts/{chroot-fixups => }/clippy.sh | 5 +++++ 4 files changed, 12 insertions(+) rename scripts/{chroot-fixups => }/clippy.sh (84%) diff --git a/make-srpm.sh b/make-srpm.sh index b3eadf1a..f87de07d 100755 --- a/make-srpm.sh +++ b/make-srpm.sh @@ -368,6 +368,7 @@ This package contains the Rust Clippy plug-in for csmock. %{python3_sitelib}/csmock/plugins/__pycache__/unicontrol.* %files -n csmock-plugin-clippy +%{_datadir}/csmock/scripts/clippy.sh %{_datadir}/csmock/scripts/convert-clippy.py %{python3_sitelib}/csmock/plugins/clippy.py* %{python3_sitelib}/csmock/plugins/__pycache__/clippy.* diff --git a/py/plugins/clippy.py b/py/plugins/clippy.py index 94420d21..52712e55 100644 --- a/py/plugins/clippy.py +++ b/py/plugins/clippy.py @@ -2,6 +2,7 @@ RUN_CLIPPY_CONVERT = "python3 /usr/share/csmock/scripts/convert-clippy.py" CLIPPY_OUTPUT = "/builddir/clippy-output.txt" +CLIPPY_INSTALL = "/usr/share/csmock/scripts/clippy.sh" class PluginProps: def __init__(self): @@ -25,6 +26,10 @@ def handle_args(self, parser, args, props): if not self.enabled: return + def install_clippy_hook(results, mock): + return mock.exec_chroot_cmd(CLIPPY_INSTALL) + props.post_depinst_hooks += [install_clippy_hook] + props.install_pkgs += ["clippy"] props.copy_out_files += [CLIPPY_OUTPUT] diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index a40ac7fc..01f51c9d 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -37,6 +37,7 @@ if(ENABLE_CSMOCK) ${CMAKE_CURRENT_SOURCE_DIR}/run-pylint.sh ${CMAKE_CURRENT_SOURCE_DIR}/run-shellcheck.sh ${CMAKE_CURRENT_SOURCE_DIR}/convert-clippy.py + ${CMAKE_CURRENT_SOURCE_DIR}/clippy.sh DESTINATION ${SHARE_INSTALL_PREFIX}/csmock/scripts PERMISSIONS ${PERM_EXECUTABLE}) endif() diff --git a/scripts/chroot-fixups/clippy.sh b/scripts/clippy.sh similarity index 84% rename from scripts/chroot-fixups/clippy.sh rename to scripts/clippy.sh index 16691ea9..2871bc4e 100755 --- a/scripts/chroot-fixups/clippy.sh +++ b/scripts/clippy.sh @@ -3,6 +3,11 @@ ORIGINAL_BINARY="/usr/bin/cargo" NEW_LOCATION="/usr/bin/cargo_original" +if [ -f "$NEW_LOCATION" ]; then + rm "/builddir/clippy-output.txt" + exit 0 +fi + mv $ORIGINAL_BINARY $NEW_LOCATION cat > $ORIGINAL_BINARY << 'EOF'