From: Prarit Bhargava <prarit(a)redhat.com>
redhat/self-test: Fix shellcheck test
Fix shellcheck errors and the shellcheck test.
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
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
@@ -16,6 +16,7 @@ else
echo "$3" > .flavors
fi
+# shellcheck disable=SC2015
RHJOBS="$(test -n "$4" && echo "$4" || nproc
--all)"
LANG=en_US.UTF-8
@@ -73,7 +74,7 @@ function merge_configs()
name=$OUTPUT_DIR/$PACKAGE_NAME-$archvar-$flavor.config
echo "Building $name ... "
- touch config-merging.$count config-merged.$count
+ touch config-merging."$count" config-merged."$count"
# apply based on order
skip_if_missing=""
@@ -85,31 +86,34 @@ function merge_configs()
test -n "$skip_if_missing" && test ! -e "$cfile"
&& continue
- if ! perl merge.pl "$cfile" config-merging.$count > config-merged.$count;
then
+ if ! perl merge.pl "$cfile" config-merging."$count" >
config-merged."$count"; then
die "Failed to merge $cfile"
fi
- mv config-merged.$count config-merging.$count
+ mv config-merged."$count" config-merging."$count"
done
# first configs in $order is baseline, all files should be
# there. second pass is overrides and can be missing.
skip_if_missing="1"
done
- if [ "x$arch" == "xaarch64" ]; then
- echo "# arm64" > "$name"
- elif [ "x$arch" == "xppc64le" ]; then
- echo "# powerpc" > "$name"
- elif [ "x$arch" == "xs390x" ]; then
- echo "# s390" > "$name"
- elif [ "x$arch" == "xarmv7hl" ]; then
- echo "# arm" > "$name"
- elif [ "x$arch" == "xi686" ]; then
- echo "# i386" > "$name"
- else
- echo "# $arch" > "$name"
- fi
- sort config-merging.$count >> "$name"
- rm -f config-merged.$count config-merging.$count
+
+ case "$arch" in
+ "aarch64")
+ echo "# arm64" > "$name";;
+ "ppc64le")
+ echo "# powerpc" > "$name";;
+ "s390x")
+ echo "# s390" > "$name";;
+ "armv7hl")
+ echo "# arm" > "$name";;
+ "i686")
+ echo "# i386" > "$name";;
+ *)
+ echo "# $arch" > "$name";;
+ esac
+
+ sort config-merging."$count" >> "$name"
+ rm -f config-merged."$count" config-merging."$count"
echo "Building $name complete"
}
@@ -156,7 +160,7 @@ function build_flavor()
merge_configs "$arch" "$configs" "$order"
"$flavor" "$count" &
waitpids[$count]=$!
((count++))
- while [ "$(jobs | grep Running | wc -l)" -ge $RHJOBS ]; do :; done
+ while [ "$(jobs | grep -c Running)" -ge "$RHJOBS" ]; do :; done
fi
done < "$control_file"
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
@@ -85,10 +85,10 @@ checkoptions()
print "Found "a[1]"="a[2]" after generation, had "
a[1]"="configs[a[1]]" in Source tree";
}
}
- ' "$1" "$2" > .mismatches${count}
+ ' "$1" "$2" > .mismatches"${count}"
checkoptions_error=false
- if test -s .mismatches${count}
+ if test -s .mismatches"${count}"
then
while read -r LINE
do
@@ -100,14 +100,14 @@ checkoptions()
checkoptions_error=true
break
fi
- done < .mismatches${count}
+ done < .mismatches"${count}"
! $checkoptions_error && return
- sed -i "1s/^/Error: Mismatches found in configuration files for ${arch}
${variant}\n/" .mismatches${count}
+ sed -i "1s/^/Error: Mismatches found in configuration files for ${arch}
${variant}\n/" .mismatches"${count}"
[ "$CONTINUEONERROR" ] || exit 1
else
- rm -f .mismatches${count}
+ rm -f .mismatches"${count}"
fi
}
@@ -206,11 +206,13 @@ function commit_new_configs()
fi
echo -n "Checking for new configs in $cfg ... "
- make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE=$(get_cross_compile $arch)
KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile
"$arch")" KCONFIG_CONFIG="$cfgorig" listnewconfig >&
.listnewconfig
grep -E 'CONFIG_' .listnewconfig > .newoptions
if test -s .newoptions
then
- make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE=$(get_cross_compile $arch)
KCONFIG_CONFIG="$cfgorig" helpnewconfig >& .helpnewconfig
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile
"$arch")" KCONFIG_CONFIG="$cfgorig" helpnewconfig >&
.helpnewconfig
parsenewconfigs
fi
rm .newoptions
@@ -249,31 +251,33 @@ function process_config()
echo "Processing $cfg ... "
- make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE=$(get_cross_compile $arch)
KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig${count}
- grep -E 'CONFIG_' .listnewconfig${count} > .newoptions${count}
- if test -n "$NEWOPTIONS" && test -s .newoptions${count}
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile
"$arch")" KCONFIG_CONFIG="$cfgorig" listnewconfig >&
.listnewconfig"${count}"
+ grep -E 'CONFIG_' .listnewconfig"${count}" >
.newoptions"${count}"
+ if test -n "$NEWOPTIONS" && test -s .newoptions"${count}"
then
- echo "Found unset config items in ${arch} ${variant}, please set them to an
appropriate value" >> .errors${count}
- cat .newoptions${count} >> .errors${count}
- rm .newoptions${count}
+ echo "Found unset config items in ${arch} ${variant}, please set them to an
appropriate value" >> .errors"${count}"
+ cat .newoptions"${count}" >> .errors"${count}"
+ rm .newoptions"${count}"
RETURNCODE=1
[ "$CONTINUEONERROR" ] || exit 1
fi
- rm .newoptions${count}
+ rm .newoptions"${count}"
- grep -E 'config.*warning' .listnewconfig${count} > .warnings${count}
- if test -n "$CHECKWARNINGS" && test -s .warnings${count}
+ grep -E 'config.*warning' .listnewconfig"${count}" >
.warnings"${count}"
+ if test -n "$CHECKWARNINGS" && test -s .warnings"${count}"
then
- echo "Found misconfigured config items in ${arch} ${variant}, please set them to
an appropriate value" >> .errors${count}
- cat .warnings${count} >> .errors${count}
- rm .warnings${count}
+ echo "Found misconfigured config items in ${arch} ${variant}, please set them to
an appropriate value" >> .errors"${count}"
+ cat .warnings"${count}" >> .errors"${count}"
+ rm .warnings"${count}"
[ "$CONTINUEONERROR" ] || exit 1
fi
- rm .warnings${count}
+ rm .warnings"${count}"
- rm .listnewconfig${count}
+ rm .listnewconfig"${count}"
- make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE=$(get_cross_compile $arch)
KCONFIG_CONFIG="$cfgorig" olddefconfig > /dev/null || exit 1
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile
"$arch")" KCONFIG_CONFIG="$cfgorig" olddefconfig > /dev/null
|| exit 1
echo "# $arch" > "$cfgtmp"
cat "$cfgorig" >> "$cfgtmp"
if test -n "$CHECKOPTIONS"
@@ -307,7 +311,7 @@ function process_configs()
process_config "$cfg" "$count" &
waitpids[${count}]=$!
((count++))
- while [ "$(jobs | grep Running | wc -l)" -ge $RHJOBS ]; do :; done
+ while [ "$(jobs | grep -c Running)" -ge "$RHJOBS" ]; do :; done
done
for pid in ${waitpids[*]}; do
wait ${pid}
@@ -374,7 +378,7 @@ do
;;
-m)
shift
- if [ "$1" = "CC=clang" -o "$1" = "LLVM=1" ];
then
+ if [ "$1" = "CC=clang" ] || [ "$1" = "LLVM=1"
]; then
CC_IS_CLANG=1
fi
MAKEOPTS="$MAKEOPTS $1"
@@ -389,6 +393,7 @@ PACKAGE_NAME="${1:-kernel}" # defines the package name used
KVERREL="$(test -n "$2" && echo "-$2" || echo
"")"
SUBARCH="$(test -n "$3" && echo "-$3" || echo
"")"
FLAVOR="$(test -n "$4" && echo "-$4" || echo
"-ark")"
+# shellcheck disable=SC2015
RHJOBS="$(test -n "$5" && echo "$5" || nproc
--all)"
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")
diff --git a/redhat/genspec.sh b/redhat/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-LAST_MARKER=$(cat $REDHAT/marker)
+LAST_MARKER=$(cat "${REDHAT}"/marker)
clogf="$SOURCES/changelog"
# hide [redhat] entries from changelog
HIDE_REDHAT=1;
@@ -25,11 +25,11 @@ if [[ -z $lasttag ]]; then
fi
echo "Gathering new log entries since $lasttag"
# master is expected to track mainline.
-UPSTREAM="$(git rev-parse -q --verify origin/$UPSTREAM_BRANCH || \
- git rev-parse -q --verify $UPSTREAM_BRANCH)"
+UPSTREAM=$(git rev-parse -q --verify origin/"${UPSTREAM_BRANCH}" || \
+ git rev-parse -q --verify "${UPSTREAM_BRANCH}")
git log --topo-order --reverse --no-merges -z --format="- %s (%an)%n%b" \
- ^${UPSTREAM} "$lasttag".. -- ':!/redhat/rhdocs' | ${0%/*}/genlog.py
>> "$clogf"
+ ^"${UPSTREAM}" "$lasttag".. -- ':!/redhat/rhdocs' |
"${0%/*}"/genlog.py >> "$clogf"
grep -v "tagging $RPMVERSION" "$clogf" >
"$clogf.stripped"
cp "$clogf.stripped" "$clogf"
@@ -151,10 +151,10 @@ if [ "$SINGLE_TARBALL" = 0 ]; then
# May need to preserve word splitting in EXCLUDE_FILES
# shellcheck disable=SC2086
git diff -p --no-renames --stat "$MARKER".. $EXCLUDE_FILES \
- >
"$SOURCES"/patch-"${RPMKVERSION}.${RPMKPATCHLEVEL}"-redhat.patch
+ > ${SOURCES}/patch-${RPMKVERSION}.${RPMKPATCHLEVEL}-redhat.patch
else
# Need an empty file for dist-git compatibility
- touch
"$SOURCES"/patch-"${RPMKVERSION}.${RPMKPATCHLEVEL}"-redhat.patch
+ touch "${SOURCES}/patch-${RPMKVERSION}.${RPMKPATCHLEVEL}"-redhat.patch
fi
# We depend on work splitting of BUILDOPTS
diff --git a/redhat/self-test/0001-shellcheck.bats
b/redhat/self-test/0001-shellcheck.bats
index blahblah..blahblah 100644
--- a/redhat/self-test/0001-shellcheck.bats
+++ b/redhat/self-test/0001-shellcheck.bats
@@ -3,6 +3,5 @@
then
skip "The ShellCheck package is not installed"
fi
- run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh")
- [ "$status" = 0 ]
+ shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh" -not -path
"$BATS_TEST_DIRNAME/../rpm/*")
}
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1642