[OS-BUILD PATCH] redhat: shellcheck fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

redhat: shellcheck fixes

shellcheck fixes for scripts in redhat/ directory.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/redhat/configs/build_configs.sh b/redhat/configs/build_configs.sh
index blahblah..blahblah 100755
--- a/redhat/configs/build_configs.sh
+++ b/redhat/configs/build_configs.sh
@@ -50,6 +50,8 @@ function combine_config_layer()
 	fi
 
 	# avoid picking up editor backup files
+	# shellcheck disable=SC2046
+	# shellcheck disable=SC2010
 	cat $(ls -1 "$dir"/CONFIG_* | grep -v "~$") > "$file"
 }
 
@@ -158,14 +160,16 @@ function build_flavor()
 			fi
 
 			merge_configs "$arch" "$configs" "$order" "$flavor" "$count" &
+			# shellcheck disable=SC2004
 			waitpids[$count]=$!
 			((count++))
 			while [ "$(jobs | grep -c Running)" -ge "$RHJOBS" ]; do :; done
 		fi
 	done < "$control_file"
 
+	# shellcheck disable=SC2048
 	for pid in ${waitpids[*]}; do
-		wait $pid
+		wait "$pid"
 	done
 }
 
diff --git a/redhat/configs/generate_all_configs.sh b/redhat/configs/generate_all_configs.sh
index blahblah..blahblah 100755
--- a/redhat/configs/generate_all_configs.sh
+++ b/redhat/configs/generate_all_configs.sh
@@ -21,15 +21,16 @@ fi
 
 # The +1 is to remove the - at the end of the SPECPACKAGE_NAME string
 specpackage_name_len=$((${#SPECPACKAGE_NAME} + 1))
-for i in ${SPECPACKAGE_NAME}*-"$FLAVOR".config; do
-	NEW=${SPECPACKAGE_NAME}-"$SPECRPMVERSION"-$(echo ${i:$specpackage_name_len} | sed s/-"$FLAVOR"//)
+for i in "${SPECPACKAGE_NAME}"*-"$FLAVOR".config; do
+	# shellcheck disable=SC3057
+	NEW=${SPECPACKAGE_NAME}-"$SPECRPMVERSION"-$(echo "${i:$specpackage_name_len}" | sed s/-"$FLAVOR"//)
 	mv "$i" "$NEW"
 done
 
 rm -f kernel-*-"$SECONDARY".config
 
 if [ "$DEBUGBUILDSENABLED" -eq 0 ]; then
-	for i in ${SPECPACKAGE_NAME}-*debug*.config; do
+	for i in "${SPECPACKAGE_NAME}"-*debug*.config; do
 		base=$(echo "$i" | sed -r s/-?debug//g)
 		NEW=${SPECPACKAGE_NAME}-$(echo "$base" | cut -d - -f2-)
 		mv "$i" "$NEW"
diff --git a/redhat/configs/process_configs.sh b/redhat/configs/process_configs.sh
index blahblah..blahblah 100755
--- a/redhat/configs/process_configs.sh
+++ b/redhat/configs/process_configs.sh
@@ -311,12 +311,14 @@ function process_configs()
 			process_config "$cfg" "$count"
 		fi
 		process_config "$cfg" "$count" &
+		# shellcheck disable=SC2004
 		waitpids[${count}]=$!
 		((count++))
 		while [ "$(jobs | grep -c Running)" -ge "$RHJOBS" ]; do :; done
 	done
+	# shellcheck disable=SC2048
 	for pid in ${waitpids[*]}; do
-		wait ${pid}
+		wait "${pid}"
 	done
 
 	rm "$SCRIPT_DIR"/*.config*.old
diff --git a/redhat/scripts/ci/ark-create-release.sh b/redhat/scripts/ci/ark-create-release.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/ci/ark-create-release.sh
+++ b/redhat/scripts/ci/ark-create-release.sh
@@ -8,7 +8,7 @@
 set -e
 
 # source common CI functions and variables
-# shellcheck source=./redhat/scripts/ci/ark-ci-env.sh
+# shellcheck disable=SC1091
 . "$(dirname "$0")"/ark-ci-env.sh
 
 git checkout "${BRANCH}"
diff --git a/redhat/scripts/ci/ark-update-configs.sh b/redhat/scripts/ci/ark-update-configs.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/ci/ark-update-configs.sh
+++ b/redhat/scripts/ci/ark-update-configs.sh
@@ -19,11 +19,12 @@
 set -e
 
 # source common CI functions and variables
-# shellcheck source=./redhat/scripts/ci/ark-ci-env.sh
+# shellcheck disable=SC1091
 . "$(dirname "$0")"/ark-ci-env.sh
 
 finish()
 {
+	# shellcheck disable=SC2317
 	rm "$TMPFILE"
 }
 trap finish EXIT
diff --git a/redhat/scripts/cross-compile/download_cross.sh b/redhat/scripts/cross-compile/download_cross.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/cross-compile/download_cross.sh
+++ b/redhat/scripts/cross-compile/download_cross.sh
@@ -44,6 +44,7 @@ dnf -y install /usr/lib/rpm/redhat/dist.sh
 
 if [ -x /usr/lib/rpm/redhat/dist.sh ]; then
 	dist=$(/usr/lib/rpm/redhat/dist.sh)
+	# shellcheck disable=SC2081
 	[ "$dist" == el* ] && dnf -y install epel-release
 fi
 
diff --git a/redhat/scripts/expand_srpm.sh b/redhat/scripts/expand_srpm.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/expand_srpm.sh
+++ b/redhat/scripts/expand_srpm.sh
@@ -9,8 +9,8 @@ die() {
 cloned="$1"
 
 # Avoid accidental "rm *" in the root directory
-test "$cloned" || die '$1 is not given'
-test "$SPECPACKAGE_NAME" || die '$SPECPACKAGE_NAME is not set'
+test "$cloned" || die "$1 is not given"
+test "$SPECPACKAGE_NAME" || die "$SPECPACKAGE_NAME is not set"
 
 cd "$cloned/$SPECPACKAGE_NAME" || die "\"$cloned\" doesn't seem to have a dist-git clone"
 
diff --git a/redhat/scripts/mod/mod-sign.sh b/redhat/scripts/mod/mod-sign.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/mod/mod-sign.sh
+++ b/redhat/scripts/mod/mod-sign.sh
@@ -19,7 +19,7 @@ NPROC=$(nproc)
 [ -z "$NPROC" ] && NPROC=1
 
 # NB: this loop runs 2000+ iterations. Try to be fast.
-echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
+echo "$modules" | xargs -r -n16 -P "$NPROC" sh -c "
 for mod; do
     ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
     rm -f \$mod.sig \$mod.dig
diff --git a/redhat/scripts/update_scripts.sh b/redhat/scripts/update_scripts.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/update_scripts.sh
+++ b/redhat/scripts/update_scripts.sh
@@ -7,6 +7,6 @@ fi
 TARGET="$1"
 
 for i in "$RPM_SOURCE_DIR"/*."$TARGET"; do
-	NEW=${i%.$TARGET}
+	NEW=${i%."$TARGET"}
 	cp "$i" "$(basename "$NEW")"
 done
diff --git a/redhat/self-test/data/create-data.sh b/redhat/self-test/data/create-data.sh
index blahblah..blahblah 100755
--- a/redhat/self-test/data/create-data.sh
+++ b/redhat/self-test/data/create-data.sh
@@ -68,11 +68,13 @@ do
 				sort -u >& "${destdir}/${varfilename}" && \
 				sed -i 's/ \S*\(rhpkg.mk\)\S*//g' "${destdir}/${varfilename}" &
 
+			# shellcheck disable=SC2004
 			waitpids[${count}]=$!
 			((count++))
 
 			echo "building ${destdir}/${varfilename}.spec"
 			specfile_helper "${varfilename}" &
+			# shellcheck disable=SC2004
 			waitpids[${count}]=$!
 			((count++))
 		done
@@ -80,8 +82,9 @@ do
 		# There isn't an easy way to make sure the parallel execution doesn't go crazy
 		# and hammer a system.  Putting the wait loop here will artificially limit the
 		# number of jobs.
+		# shellcheck disable=SC2048
 		for pid in ${waitpids[*]}; do
-			wait ${pid}
+			wait "${pid}"
 		done
 	done
 done

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2642
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux