From 38e75f473be881988cdd7ecbefa2a5472227e40c Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 14 Jun 2024 19:53:42 +0200 Subject: [PATCH] clippy: always create the capture file for Clippy ... to avoid triggering a non-fatal failure while exporting files from the chroot in case Clippy is enabled for a non-Rust project: ``` tar: /builddir/clippy-output.txt: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors ``` Related: https://issues.redhat.com/browse/OSH-57 --- scripts/inject-clippy.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/inject-clippy.sh b/scripts/inject-clippy.sh index 7fa3fb0..69812f5 100755 --- a/scripts/inject-clippy.sh +++ b/scripts/inject-clippy.sh @@ -3,9 +3,11 @@ ORIGINAL_LOCATION="/usr/bin/cargo" NEW_LOCATION="/usr/bin/cargo_original" -if [ -f "$NEW_LOCATION" ]; then - # remove capture file created by previous runs if --skip-init is in effect - rm -fv "/builddir/clippy-output.txt" +# create empty or truncate existing (if --skip-init is in effect) capture file +runuser mockbuild -c "truncate --size=0 /builddir/clippy-output.txt" + +if [ -x "$NEW_LOCATION" ]; then + # binary already moved (most likely by a previous run of this script) exit 0 fi