Turn shellcheck into a normal make target. Fix new files it caught

This checks every file it checked (and a few more),
but explicitly instead of "if it works it works" best-effort
(which wasn't that good anyway)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #10512
Closes #12101
This commit is contained in:
наб
2021-05-21 23:43:38 +02:00
committed by Brian Behlendorf
parent d6f8f41c21
commit 132240507d
39 changed files with 213 additions and 107 deletions
+13 -5
View File
@@ -1,3 +1,5 @@
include $(top_srcdir)/config/Shellcheck.am
pkgdatadir = $(datadir)/@PACKAGE@
dist_pkgdata_SCRIPTS = \
@@ -7,19 +9,25 @@ dist_pkgdata_SCRIPTS = \
zloop.sh \
zfs-helpers.sh
EXTRA_DIST = \
EXTRA_SCRIPTS = \
commitcheck.sh \
common.sh.in \
cstyle.pl \
dkms.mkconf \
dkms.postbuild \
enum-extract.pl \
kmodtool \
make_gitrev.sh \
man-dates.sh \
paxcheck.sh \
paxcheck.sh
EXTRA_DIST = \
cstyle.pl \
enum-extract.pl \
zfs2zol-patch.sed \
zol2zfs-patch.sed
zol2zfs-patch.sed \
$(EXTRA_SCRIPTS)
SHELLCHECK_IGNORE = ,SC1117
SHELLCHECKSCRIPTS = $(EXTRA_SCRIPTS)
define EXTRA_ENVIRONMENT
+7 -5
View File
@@ -6,19 +6,21 @@ pkgcfg=/etc/sysconfig/zfs
while getopts "n:v:c:f:" opt; do
case $opt in
n) pkgname=$OPTARG ;;
v) pkgver=$OPTARG ;;
c) pkgcfg=$OPTARG ;;
n) pkgname=$OPTARG ;;
v) pkgver=$OPTARG ;;
c) pkgcfg=$OPTARG ;;
f) filename=$OPTARG ;;
*) err=1 ;;
esac
done
if [ -z "${pkgname}" ] || [ -z "${pkgver}" ] || [ -z "${filename}" ]; then
if [ -z "${pkgname}" ] || [ -z "${pkgver}" ] || [ -z "${filename}" ] ||
[ -n "${err}" ]; then
echo "Usage: $PROG -n <pkgname> -v <pkgver> -c <pkgcfg> -f <filename>"
exit 1
fi
cat >${filename} <<EOF
exec cat >"${filename}" <<EOF
PACKAGE_NAME="${pkgname}"
PACKAGE_VERSION="${pkgver}"
PACKAGE_CONFIG="${pkgcfg}"
+4 -3
View File
@@ -9,16 +9,17 @@ while getopts "a:k:n:t:v:" opt; do
n) pkgname=$OPTARG ;;
t) tree=$OPTARG ;;
v) pkgver=$OPTARG ;;
*) err=1 ;;
esac
done
if [ -z "${arch}" ] || [ -z "${kver}" ] || [ -z "${pkgname}" ] || \
[ -z "${tree}" ] || [ -z "${pkgver}" ]; then
[ -z "${tree}" ] || [ -z "${pkgver}" ] || [ -n "${err}" ]; then
echo "Usage: $PROG -a <arch> -k <kver> -n <pkgname>" \
"-t <tree> -v <pkgver>"
"-t <tree> -v <pkgver>"
exit 1
fi
cp "${tree}/${pkgname}/${pkgver}/build/zfs_config.h" \
exec cp "${tree}/${pkgname}/${pkgver}/build/zfs_config.h" \
"${tree}/${pkgname}/${pkgver}/build/module/Module.symvers" \
"${tree}/${pkgname}/${pkgver}/${kver}/${arch}/"
+8 -6
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2086
# kmodtool - Helper script for building kernel module RPMs
# Copyright (c) 2003-2012 Ville Skyttä <ville.skytta@iki.fi>,
@@ -38,15 +39,16 @@ prefix=
filterfile=
target=
buildroot=
dashvariant=
error_out()
{
local errorlevel=${1}
shift
echo "Error: $@" >&2
echo "Error: $*" >&2
# the next line is not multi-line safe -- not needed *yet*
echo "%global kmodtool_check echo \"kmodtool error: $@\"; exit ${errorlevel};"
exit ${errorlevel}
echo "%global kmodtool_check echo \"kmodtool error: $*\"; exit ${errorlevel};"
exit "${errorlevel}"
}
print_rpmtemplate_header()
@@ -579,7 +581,7 @@ elif [[ ! "${kmodname}" ]]; then
error_out 2 "please pass kmodname with --kmodname"
elif [[ ! "${kernels_known_variants}" ]] ; then
error_out 2 "could not determine known variants"
elif ( [[ "${obsolete_name}" ]] && [[ ! "${obsolete_version}" ]] ) || ( [[ ! "${obsolete_name}" ]] && [[ "${obsolete_version}" ]] ) ; then
elif { [[ "${obsolete_name}" ]] && [[ ! "${obsolete_version}" ]]; } || { [[ ! "${obsolete_name}" ]] && [[ "${obsolete_version}" ]]; } ; then
error_out 2 "you need to provide both --obsolete-name and --obsolete-version"
fi
@@ -597,7 +599,7 @@ else
# we need more sanity checks in this case
if [[ ! "${repo}" ]]; then
error_out 2 "please provide repo name with --repo"
elif ! $(which buildsys-build-${repo}-kerneldevpkgs &> /dev/null) ; then
elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" &> /dev/null ; then
error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
fi
@@ -611,7 +613,7 @@ else
kernel_versions_to_build_for="$(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
returncode=$?
if (( ${returncode} != 0 )); then
if (( returncode != 0 )); then
error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: $(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
fi