Skip to content

Commit

Permalink
rust-clippy: move the chroot fixup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmatouse committed Mar 26, 2024
1 parent 4b6cb74 commit 48e3d24
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions make-srpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
5 changes: 5 additions & 0 deletions py/plugins/clippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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]

Expand Down
1 change: 1 addition & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 5 additions & 0 deletions scripts/chroot-fixups/clippy.sh → scripts/clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 48e3d24

Please sign in to comment.