Add ShellCheck's `--enable=all` inside `scripts/`
Strengthen static code analysis for shell scripts. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: szubersk <szuberskidamian@gmail.com> Closes #12914
This commit is contained in:
parent
8a7c4efd3c
commit
836136961a
|
@ -28,6 +28,7 @@ EXTRA_DIST = \
|
||||||
$(EXTRA_SCRIPTS)
|
$(EXTRA_SCRIPTS)
|
||||||
|
|
||||||
SHELLCHECKSCRIPTS = $(EXTRA_SCRIPTS)
|
SHELLCHECKSCRIPTS = $(EXTRA_SCRIPTS)
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
|
||||||
define EXTRA_ENVIRONMENT
|
define EXTRA_ENVIRONMENT
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ new_change_commit()
|
||||||
error=1
|
error=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $error
|
return "$error"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_coverity_fix()
|
is_coverity_fix()
|
||||||
|
@ -99,7 +99,7 @@ coverity_fix_commit()
|
||||||
error=1
|
error=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $error
|
return "$error"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
|
|
129
scripts/kmodtool
129
scripts/kmodtool
|
@ -54,9 +54,9 @@ error_out()
|
||||||
print_rpmtemplate_header()
|
print_rpmtemplate_header()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
echo '%global kmodinstdir_prefix '${prefix}/lib/modules/
|
echo "%global kmodinstdir_prefix ${prefix}/lib/modules/"
|
||||||
echo '%global kmodinstdir_postfix '/extra/${kmodname}/
|
echo "%global kmodinstdir_postfix /extra/${kmodname}/"
|
||||||
echo '%global kernel_versions '${kernel_versions}
|
echo "%global kernel_versions ${kernel_versions}"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
|
||||||
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
|
Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "Provides: akmod-${obsolete_name} = ${obsolete_version}"
|
echo "Provides: akmod-${obsolete_name} = ${obsolete_version}"
|
||||||
echo "Obsoletes: akmod-${obsolete_name} < ${obsolete_version}"
|
echo "Obsoletes: akmod-${obsolete_name} < ${obsolete_version}"
|
||||||
fi
|
fi
|
||||||
|
@ -116,7 +116,7 @@ Provides: kmod-${kmodname}-PAE = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||||
Requires: akmod-${kmodname} = %{?epoch:%{epoch}:}%{version}-%{release}
|
Requires: akmod-${kmodname} = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "Provides: kmod-${obsolete_name} = ${obsolete_version}"
|
echo "Provides: kmod-${obsolete_name} = ${obsolete_version}"
|
||||||
echo "Obsoletes: kmod-${obsolete_name} < ${obsolete_version}"
|
echo "Obsoletes: kmod-${obsolete_name} < ${obsolete_version}"
|
||||||
fi
|
fi
|
||||||
|
@ -134,10 +134,10 @@ EOF
|
||||||
|
|
||||||
print_rpmtemplate_per_kmodpkg ()
|
print_rpmtemplate_per_kmodpkg ()
|
||||||
{
|
{
|
||||||
if [[ "${1}" == "--custom" ]]; then
|
if [ "${1}" = "--custom" ]; then
|
||||||
shift
|
shift
|
||||||
local customkernel=true
|
local customkernel=true
|
||||||
elif [[ "${1}" == "--redhat" ]]; then
|
elif [ "${1}" = "--redhat" ]; then
|
||||||
# this is needed for akmods
|
# this is needed for akmods
|
||||||
shift
|
shift
|
||||||
local redhatkernel=true
|
local redhatkernel=true
|
||||||
|
@ -148,7 +148,7 @@ print_rpmtemplate_per_kmodpkg ()
|
||||||
|
|
||||||
# Detect depmod install location
|
# Detect depmod install location
|
||||||
local depmod_path=/sbin/depmod
|
local depmod_path=/sbin/depmod
|
||||||
if [ ! -f ${depmod_path} ]; then
|
if [ ! -f "${depmod_path}" ]; then
|
||||||
depmod_path=/usr/sbin/depmod
|
depmod_path=/usr/sbin/depmod
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -171,30 +171,30 @@ Requires(postun): kmod
|
||||||
%endif
|
%endif
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "Provides: kmod-${obsolete_name}-${kernel_uname_r} = ${obsolete_version}"
|
echo "Provides: kmod-${obsolete_name}-${kernel_uname_r} = ${obsolete_version}"
|
||||||
echo "Obsoletes: kmod-${obsolete_name}-${kernel_uname_r} < ${obsolete_version}"
|
echo "Obsoletes: kmod-${obsolete_name}-${kernel_uname_r} < ${obsolete_version}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# second part
|
# second part
|
||||||
if [[ ! "${customkernel}" ]]; then
|
if [ -z "${customkernel}" ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Requires: kernel-uname-r = ${kernel_uname_r}
|
Requires: kernel-uname-r = ${kernel_uname_r}
|
||||||
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
|
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
|
||||||
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
|
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
|
||||||
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
|
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
|
||||||
%post -n kmod-${kmodname}-${kernel_uname_r}
|
%post -n kmod-${kmodname}-${kernel_uname_r}
|
||||||
if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
|
if [ -f "/boot/System.map-${kernel_uname_r}" ]; then
|
||||||
${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
|
${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
|
||||||
elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
|
elif [ -f "/lib/modules/${kernel_uname_r}/System.map" ]; then
|
||||||
${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/null || :
|
${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/null || :
|
||||||
else
|
else
|
||||||
${prefix}${depmod_path} -ae ${kernel_uname_r} &> /dev/null || :
|
${prefix}${depmod_path} -ae ${kernel_uname_r} &> /dev/null || :
|
||||||
fi
|
fi
|
||||||
%postun -n kmod-${kmodname}-${kernel_uname_r}
|
%postun -n kmod-${kmodname}-${kernel_uname_r}
|
||||||
if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
|
if [ -f "/boot/System.map-${kernel_uname_r}" ]; then
|
||||||
${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
|
${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
|
||||||
elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
|
elif [ -f "/lib/modules/${kernel_uname_r}/System.map" ]; then
|
||||||
${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/null || :
|
${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/null || :
|
||||||
else
|
else
|
||||||
${prefix}${depmod_path} -a ${kernel_uname_r} &> /dev/null || :
|
${prefix}${depmod_path} -a ${kernel_uname_r} &> /dev/null || :
|
||||||
|
@ -204,9 +204,9 @@ EOF
|
||||||
else
|
else
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
%post -n kmod-${kmodname}-${kernel_uname_r}
|
%post -n kmod-${kmodname}-${kernel_uname_r}
|
||||||
[[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}${depmod_path} -a > /dev/null || :
|
[ "\$(uname -r)" = "${kernel_uname_r}" ] && ${prefix}${depmod_path} -a > /dev/null || :
|
||||||
%postun -n kmod-${kmodname}-${kernel_uname_r}
|
%postun -n kmod-${kmodname}-${kernel_uname_r}
|
||||||
[[ "\$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}${depmod_path} -a > /dev/null || :
|
[ "\$(uname -r)" = "${kernel_uname_r}" ] && ${prefix}${depmod_path} -a > /dev/null || :
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
@ -227,10 +227,10 @@ EOF
|
||||||
|
|
||||||
print_rpmtemplate_kmoddevelpkg ()
|
print_rpmtemplate_kmoddevelpkg ()
|
||||||
{
|
{
|
||||||
if [[ "${1}" == "--custom" ]]; then
|
if [ "${1}" = "--custom" ]; then
|
||||||
shift
|
shift
|
||||||
local customkernel=true
|
local customkernel=true
|
||||||
elif [[ "${1}" == "--redhat" ]]; then
|
elif [ "${1}" = "--redhat" ]; then
|
||||||
shift
|
shift
|
||||||
local redhatkernel=true
|
local redhatkernel=true
|
||||||
fi
|
fi
|
||||||
|
@ -244,11 +244,11 @@ Group: System Environment/Kernel
|
||||||
Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
|
Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ ! ${customkernel} ]] && [[ ! ${redhatkernel} ]]; then
|
if [ -z "${customkernel}" ] && [ -z "${redhatkernel}" ]; then
|
||||||
echo "Requires: kmod-${kmodname}-devel-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}"
|
echo "Requires: kmod-${kmodname}-devel-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "Provides: kmod-${obsolete_name}-devel = ${obsolete_version}"
|
echo "Provides: kmod-${obsolete_name}-devel = ${obsolete_version}"
|
||||||
echo "Obsoletes: kmod-${obsolete_name}-devel < ${obsolete_version}"
|
echo "Obsoletes: kmod-${obsolete_name}-devel < ${obsolete_version}"
|
||||||
fi
|
fi
|
||||||
|
@ -263,14 +263,14 @@ the ${kmodname}-devel-<kernel> objects for the newest kernel.
|
||||||
%defattr(644,root,root,755)
|
%defattr(644,root,root,755)
|
||||||
%{_usrsrc}/${kmodname}-%{version}
|
%{_usrsrc}/${kmodname}-%{version}
|
||||||
EOF
|
EOF
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "%{_usrsrc}/${obsolete_name}-%{version}"
|
echo "%{_usrsrc}/${obsolete_name}-%{version}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for kernel in ${1}; do
|
for kernel in ${1}; do
|
||||||
local kernel_uname_r=${kernel}
|
local kernel_uname_r=${kernel}
|
||||||
echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}"
|
echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}"
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "%exclude %{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}"
|
echo "%exclude %{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -281,10 +281,10 @@ EOF
|
||||||
|
|
||||||
print_rpmtemplate_per_kmoddevelpkg ()
|
print_rpmtemplate_per_kmoddevelpkg ()
|
||||||
{
|
{
|
||||||
if [[ "${1}" == "--custom" ]]; then
|
if [ "${1}" = "--custom" ]; then
|
||||||
shift
|
shift
|
||||||
local customkernel=true
|
local customkernel=true
|
||||||
elif [[ "${1}" == "--redhat" ]]; then
|
elif [ "${1}" = "--redhat" ]; then
|
||||||
# this is needed for akmods
|
# this is needed for akmods
|
||||||
shift
|
shift
|
||||||
local redhatkernel=true
|
local redhatkernel=true
|
||||||
|
@ -303,13 +303,13 @@ Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{relea
|
||||||
Provides: kmod-${kmodname}-devel-uname-r = ${kernel_uname_r}
|
Provides: kmod-${kmodname}-devel-uname-r = ${kernel_uname_r}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "Provides: kmod-${obsolete_name}-devel-${kernel_uname_r} = ${obsolete_version}"
|
echo "Provides: kmod-${obsolete_name}-devel-${kernel_uname_r} = ${obsolete_version}"
|
||||||
echo "Obsoletes: kmod-${obsolete_name}-devel-${kernel_uname_r} < ${obsolete_version}"
|
echo "Obsoletes: kmod-${obsolete_name}-devel-${kernel_uname_r} < ${obsolete_version}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# second part
|
# second part
|
||||||
if [[ ! "${customkernel}" ]]; then
|
if [ -z "${customkernel}" ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Requires: kernel-devel-uname-r = ${kernel_uname_r}
|
Requires: kernel-devel-uname-r = ${kernel_uname_r}
|
||||||
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
|
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
|
||||||
|
@ -328,7 +328,7 @@ kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
|
||||||
%defattr(644,root,root,755)
|
%defattr(644,root,root,755)
|
||||||
%{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}
|
%{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}
|
||||||
EOF
|
EOF
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "%{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}"
|
echo "%{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ Requires: kmod-${kmodname}-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{vers
|
||||||
%{?KmodsMetaRequires:Requires: %{?KmodsMetaRequires}}
|
%{?KmodsMetaRequires:Requires: %{?KmodsMetaRequires}}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ ${obsolete_name} ]]; then
|
if [ -n "${obsolete_name}" ]; then
|
||||||
echo "Provides: kmod-${obsolete_name}${kernel_variant} = ${obsolete_version}"
|
echo "Provides: kmod-${obsolete_name}${kernel_variant} = ${obsolete_version}"
|
||||||
echo "Obsoletes: kmod-${obsolete_name}${kernel_variant} < ${obsolete_version}"
|
echo "Obsoletes: kmod-${obsolete_name}${kernel_variant} < ${obsolete_version}"
|
||||||
fi
|
fi
|
||||||
|
@ -371,7 +371,7 @@ print_customrpmtemplate ()
|
||||||
{
|
{
|
||||||
for kernel in ${1}
|
for kernel in ${1}
|
||||||
do
|
do
|
||||||
if [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]] ; then
|
if [ -e "${buildroot}/usr/src/kernels/${kernel}" ] ; then
|
||||||
# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
|
# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
|
||||||
kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
|
kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
|
||||||
|
|
||||||
|
@ -380,14 +380,14 @@ print_customrpmtemplate ()
|
||||||
print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
||||||
|
|
||||||
# create development package
|
# create development package
|
||||||
if [[ "${devel}" ]]; then
|
if [ -n "${devel}" ]; then
|
||||||
# create devel package including common headers
|
# create devel package including common headers
|
||||||
print_rpmtemplate_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
||||||
|
|
||||||
# create devel package
|
# create devel package
|
||||||
print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
|
||||||
fi
|
fi
|
||||||
elif [[ -e ${prefix}/lib/modules/"${kernel}"/build/Makefile ]] ; then
|
elif [ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]; then
|
||||||
# likely a user-build-kernel with available buildfiles
|
# likely a user-build-kernel with available buildfiles
|
||||||
# fixme: we should check if uname from Makefile is the same as ${kernel}
|
# fixme: we should check if uname from Makefile is the same as ${kernel}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ print_customrpmtemplate ()
|
||||||
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
|
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
|
||||||
|
|
||||||
# create development package
|
# create development package
|
||||||
if [[ "${devel}" ]]; then
|
if [ -n "${devel}" ]; then
|
||||||
# create devel package including common headers
|
# create devel package including common headers
|
||||||
print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
|
print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
|
||||||
|
|
||||||
|
@ -429,17 +429,17 @@ print_rpmtemplate ()
|
||||||
local kernel_verrelarch=${kernel%%${kernels_known_variants}}
|
local kernel_verrelarch=${kernel%%${kernels_known_variants}}
|
||||||
|
|
||||||
# create metapackage
|
# create metapackage
|
||||||
print_rpmtemplate_kmodmetapkg ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_kmodmetapkg "${kernel}" "${kernel##${kernel_verrelarch}}"
|
||||||
|
|
||||||
# create package
|
# create package
|
||||||
print_rpmtemplate_per_kmodpkg ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_per_kmodpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
|
||||||
|
|
||||||
if [[ "${devel}" ]]; then
|
if [ -n "${devel}" ]; then
|
||||||
# create devel package including common headers
|
# create devel package including common headers
|
||||||
print_rpmtemplate_kmoddevelpkg ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_kmoddevelpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
|
||||||
|
|
||||||
# create devel package
|
# create devel package
|
||||||
print_rpmtemplate_per_kmoddevelpkg ${kernel} ${kernel##${kernel_verrelarch}}
|
print_rpmtemplate_per_kmoddevelpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -447,8 +447,10 @@ print_rpmtemplate ()
|
||||||
myprog_help ()
|
myprog_help ()
|
||||||
{
|
{
|
||||||
echo "Usage: ${0##*/} [OPTIONS]"
|
echo "Usage: ${0##*/} [OPTIONS]"
|
||||||
echo $'\n'"Creates a template to be used during kmod building"
|
echo
|
||||||
echo $'\n'"Available options:"
|
echo "Creates a template to be used during kmod building"
|
||||||
|
echo
|
||||||
|
echo "Available options:"
|
||||||
echo " --filterfile <file> -- filter the results with grep --file <file>"
|
echo " --filterfile <file> -- filter the results with grep --file <file>"
|
||||||
echo " --for-kernels <list> -- created templates only for these kernels"
|
echo " --for-kernels <list> -- created templates only for these kernels"
|
||||||
echo " --kmodname <file> -- name of the kmod (required)"
|
echo " --kmodname <file> -- name of the kmod (required)"
|
||||||
|
@ -459,13 +461,13 @@ myprog_help ()
|
||||||
echo " --buildroot <dir> -- Build root (place to look for build files)"
|
echo " --buildroot <dir> -- Build root (place to look for build files)"
|
||||||
}
|
}
|
||||||
|
|
||||||
while [ "${1}" ] ; do
|
while [ -n "${1}" ] ; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
--filterfile)
|
--filterfile)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
|
error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
|
||||||
elif [[ ! -e "${1}" ]]; then
|
elif [ ! -e "${1}" ]; then
|
||||||
error_out 2 "Filterfile ${1} not found" >&2
|
error_out 2 "Filterfile ${1} not found" >&2
|
||||||
fi
|
fi
|
||||||
filterfile="${1}"
|
filterfile="${1}"
|
||||||
|
@ -473,7 +475,7 @@ while [ "${1}" ] ; do
|
||||||
;;
|
;;
|
||||||
--kmodname)
|
--kmodname)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
|
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
|
||||||
fi
|
fi
|
||||||
# strip pending -kmod
|
# strip pending -kmod
|
||||||
|
@ -486,7 +488,7 @@ while [ "${1}" ] ; do
|
||||||
;;
|
;;
|
||||||
--prefix)
|
--prefix)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide a prefix with --prefix" >&2
|
error_out 2 "Please provide a prefix with --prefix" >&2
|
||||||
fi
|
fi
|
||||||
prefix="${1}"
|
prefix="${1}"
|
||||||
|
@ -494,7 +496,7 @@ while [ "${1}" ] ; do
|
||||||
;;
|
;;
|
||||||
--repo)
|
--repo)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide the name of the repo together with --repo" >&2
|
error_out 2 "Please provide the name of the repo together with --repo" >&2
|
||||||
fi
|
fi
|
||||||
repo=${1}
|
repo=${1}
|
||||||
|
@ -502,7 +504,7 @@ while [ "${1}" ] ; do
|
||||||
;;
|
;;
|
||||||
--for-kernels)
|
--for-kernels)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
|
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
|
||||||
fi
|
fi
|
||||||
for_kernels="${1}"
|
for_kernels="${1}"
|
||||||
|
@ -514,7 +516,7 @@ while [ "${1}" ] ; do
|
||||||
;;
|
;;
|
||||||
--obsolete-name)
|
--obsolete-name)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide the name of the kmod to obsolete together with --obsolete-name" >&2
|
error_out 2 "Please provide the name of the kmod to obsolete together with --obsolete-name" >&2
|
||||||
fi
|
fi
|
||||||
obsolete_name="${1}"
|
obsolete_name="${1}"
|
||||||
|
@ -522,7 +524,7 @@ while [ "${1}" ] ; do
|
||||||
;;
|
;;
|
||||||
--obsolete-version)
|
--obsolete-version)
|
||||||
shift
|
shift
|
||||||
if [[ ! "${1}" ]] ; then
|
if [ -z "${1}" ] ; then
|
||||||
error_out 2 "Please provide the version of the kmod to obsolete together with --obsolete-version" >&2
|
error_out 2 "Please provide the version of the kmod to obsolete together with --obsolete-version" >&2
|
||||||
fi
|
fi
|
||||||
obsolete_version="${1}"
|
obsolete_version="${1}"
|
||||||
|
@ -566,30 +568,30 @@ while [ "${1}" ] ; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -e ./kmodtool-kernel-variants ]]; then
|
if [ -e ./kmodtool-kernel-variants ]; then
|
||||||
kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
|
kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
|
||||||
elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then
|
elif [ -e /usr/share/kmodtool/kernel-variants ] ; then
|
||||||
kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
|
kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
|
||||||
else
|
else
|
||||||
kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)"
|
kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# general sanity checks
|
# general sanity checks
|
||||||
if [[ ! "${target}" ]]; then
|
if [ -z "${target}" ]; then
|
||||||
error_out 2 "please pass target arch with --target"
|
error_out 2 "please pass target arch with --target"
|
||||||
elif [[ ! "${kmodname}" ]]; then
|
elif [ -z "${kmodname}" ]; then
|
||||||
error_out 2 "please pass kmodname with --kmodname"
|
error_out 2 "please pass kmodname with --kmodname"
|
||||||
elif [[ ! "${kernels_known_variants}" ]] ; then
|
elif [ -z "${kernels_known_variants}" ] ; then
|
||||||
error_out 2 "could not determine known variants"
|
error_out 2 "could not determine known variants"
|
||||||
elif { [[ "${obsolete_name}" ]] && [[ ! "${obsolete_version}" ]]; } || { [[ ! "${obsolete_name}" ]] && [[ "${obsolete_version}" ]]; } ; then
|
elif { [ -n "${obsolete_name}" ] && [ -z "${obsolete_version}" ]; } || { [ -z "${obsolete_name}" ] && [ -n "${obsolete_version}" ]; } ; then
|
||||||
error_out 2 "you need to provide both --obsolete-name and --obsolete-version"
|
error_out 2 "you need to provide both --obsolete-name and --obsolete-version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# go
|
# go
|
||||||
if [[ "${for_kernels}" ]]; then
|
if [ -n "${for_kernels}" ]; then
|
||||||
# this is easy:
|
# this is easy:
|
||||||
print_customrpmtemplate "${for_kernels}"
|
print_customrpmtemplate "${for_kernels}"
|
||||||
elif [[ "${build_kernels}" == "akmod" ]]; then
|
elif [ "${build_kernels}" = "akmod" ]; then
|
||||||
# do only a akmod package
|
# do only a akmod package
|
||||||
print_akmodtemplate
|
print_akmodtemplate
|
||||||
print_akmodmeta
|
print_akmodmeta
|
||||||
|
@ -597,9 +599,9 @@ else
|
||||||
# seems we are on out own to decide for which kernels to build
|
# seems we are on out own to decide for which kernels to build
|
||||||
|
|
||||||
# we need more sanity checks in this case
|
# we need more sanity checks in this case
|
||||||
if [[ ! "${repo}" ]]; then
|
if [ -z "${repo}" ]; then
|
||||||
error_out 2 "please provide repo name with --repo"
|
error_out 2 "please provide repo name with --repo"
|
||||||
elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" &> /dev/null ; then
|
elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" > /dev/null 2>&1; then
|
||||||
error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
|
error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -607,17 +609,18 @@ else
|
||||||
cmdoptions="--target ${target}"
|
cmdoptions="--target ${target}"
|
||||||
|
|
||||||
# filterfile to filter list of kernels?
|
# filterfile to filter list of kernels?
|
||||||
if [[ "${filterfile}" ]] ; then
|
if [ -n "${filterfile}" ] ; then
|
||||||
cmdoptions="${cmdoptions} --filterfile ${filterfile}"
|
cmdoptions="${cmdoptions} --filterfile ${filterfile}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kernel_versions_to_build_for="$(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
|
kernel_versions_to_build_for=$(buildsys-build-${repo}-kerneldevpkgs "--${build_kernels}" ${cmdoptions})
|
||||||
returncode=$?
|
returncode=$?
|
||||||
if (( returncode != 0 )); then
|
if [ "$returncode" -ne 0 ]; then
|
||||||
error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: $(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
|
|
||||||
|
error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: ${kernel_versions_to_build_for}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${build_kernels}" == "current" ]] && [[ ! "${noakmod}" ]]; then
|
if [ "${build_kernels}" = "current" ] && [ -z "${noakmod}" ]; then
|
||||||
print_akmodtemplate
|
print_akmodtemplate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
# `configure` is run.
|
# `configure` is run.
|
||||||
#
|
#
|
||||||
|
|
||||||
set -e -u
|
set -eu
|
||||||
|
|
||||||
dist=no
|
dist=no
|
||||||
distdir=.
|
distdir=.
|
||||||
|
@ -34,6 +34,7 @@ do
|
||||||
case $flag in
|
case $flag in
|
||||||
\?) echo "Usage: $0 [-D distdir] [file]" >&2; exit 1;;
|
\?) echo "Usage: $0 [-D distdir] [file]" >&2; exit 1;;
|
||||||
D) dist=yes; distdir=${OPTARG};;
|
D) dist=yes; distdir=${OPTARG};;
|
||||||
|
*) ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
@ -45,6 +46,7 @@ GITREV="${1:-include/zfs_gitrev.h}"
|
||||||
case "${GITREV}" in
|
case "${GITREV}" in
|
||||||
/*) echo "Error: ${GITREV} should be a relative path" >&2
|
/*) echo "Error: ${GITREV} should be a relative path" >&2
|
||||||
exit 1;;
|
exit 1;;
|
||||||
|
*) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
ZFS_GITREV=$({ cd "${top_srcdir}" &&
|
ZFS_GITREV=$({ cd "${top_srcdir}" &&
|
||||||
|
@ -60,7 +62,7 @@ then
|
||||||
'1s/^#define[[:blank:]]ZFS_META_GITREV "\([^"]*\)"$/\1/p' \
|
'1s/^#define[[:blank:]]ZFS_META_GITREV "\([^"]*\)"$/\1/p' \
|
||||||
"${top_srcdir}/${GITREV}")
|
"${top_srcdir}/${GITREV}")
|
||||||
fi
|
fi
|
||||||
elif [ ${dist} = yes ]
|
elif [ "${dist}" = yes ]
|
||||||
then
|
then
|
||||||
# Append -dist when creating distributed sources from a git repository
|
# Append -dist when creating distributed sources from a git repository
|
||||||
ZFS_GITREV="${ZFS_GITREV}-dist"
|
ZFS_GITREV="${ZFS_GITREV}-dist"
|
||||||
|
|
|
@ -40,4 +40,4 @@ if [ x"${OUT}" != x ]; then
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $RET
|
exit "$RET"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# This script is designed to facilitate in-tree development and testing
|
# This script is designed to facilitate in-tree development and testing
|
||||||
# by installing symlinks on your system which refer to in-tree helper
|
# by installing symlinks on your system which refer to in-tree helper
|
||||||
|
@ -85,6 +86,8 @@ while getopts 'hdirv' OPTION; do
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# CDDL HEADER START
|
# CDDL HEADER START
|
||||||
#
|
#
|
||||||
|
@ -422,6 +423,8 @@ while getopts 'hvqxkfScRn:d:s:r:?t:T:u:I:' OPTION; do
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -442,7 +445,7 @@ if [ -n "$SINGLETEST" ]; then
|
||||||
SINGLEQUIET="True"
|
SINGLEQUIET="True"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >$RUNFILE_DIR/$RUNFILES << EOF
|
cat >"${RUNFILE_DIR}/${RUNFILES}" << EOF
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
pre =
|
pre =
|
||||||
quiet = $SINGLEQUIET
|
quiet = $SINGLEQUIET
|
||||||
|
@ -466,7 +469,7 @@ EOF
|
||||||
CLEANUPSCRIPT="cleanup"
|
CLEANUPSCRIPT="cleanup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >>$RUNFILE_DIR/$RUNFILES << EOF
|
cat >>"${RUNFILE_DIR}/${RUNFILES}" << EOF
|
||||||
|
|
||||||
[$SINGLETESTDIR]
|
[$SINGLETESTDIR]
|
||||||
tests = ['$SINGLETESTFILE']
|
tests = ['$SINGLETESTFILE']
|
||||||
|
@ -745,4 +748,4 @@ if [ -n "$SINGLETEST" ]; then
|
||||||
rm -f "$RUNFILES" >/dev/null 2>&1
|
rm -f "$RUNFILES" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit ${RESULT}
|
exit "${RESULT}"
|
||||||
|
|
|
@ -75,6 +75,8 @@ while getopts 'hvruS' OPTION; do
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -271,6 +273,10 @@ if [ "$UNLOAD" = "yes" ]; then
|
||||||
stack_check_linux
|
stack_check_linux
|
||||||
unload_modules_linux
|
unload_modules_linux
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown system: $UNAME" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
if [ "$LOAD" = "yes" ]; then
|
if [ "$LOAD" = "yes" ]; then
|
||||||
|
@ -285,6 +291,10 @@ if [ "$LOAD" = "yes" ]; then
|
||||||
udevadm trigger
|
udevadm trigger
|
||||||
udevadm settle
|
udevadm settle
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown system: $UNAME" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ KEEP="no"
|
||||||
VERBOSE="no"
|
VERBOSE="no"
|
||||||
COLOR="yes"
|
COLOR="yes"
|
||||||
REPO="https://github.com/openzfs"
|
REPO="https://github.com/openzfs"
|
||||||
IMAGES_DIR="$SCRIPTDIR/zfs-images/"
|
IMAGES_DIR="${BASE_DIR}/zfs-images/"
|
||||||
IMAGES_TAR="https://github.com/openzfs/zfs-images/tarball/master"
|
IMAGES_TAR="https://github.com/openzfs/zfs-images/tarball/master"
|
||||||
ERROR=0
|
ERROR=0
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ while getopts 'hvckr:s:i:p:f:o:?' OPTION; do
|
||||||
o)
|
o)
|
||||||
POOL_CREATE_OPTIONS="$OPTARG"
|
POOL_CREATE_OPTIONS="$OPTARG"
|
||||||
;;
|
;;
|
||||||
?)
|
*)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -170,7 +170,7 @@ populate() {
|
||||||
for DIR in $DIRS; do
|
for DIR in $DIRS; do
|
||||||
COUNT=$((RANDOM % MAX_DIR_SIZE))
|
COUNT=$((RANDOM % MAX_DIR_SIZE))
|
||||||
|
|
||||||
for _ in $(seq $COUNT); do
|
for _ in $(seq "$COUNT"); do
|
||||||
FILE=$(mktemp -p "$DIR")
|
FILE=$(mktemp -p "$DIR")
|
||||||
SIZE=$((RANDOM % MAX_FILE_SIZE))
|
SIZE=$((RANDOM % MAX_FILE_SIZE))
|
||||||
dd if=/dev/urandom of="$FILE" bs=1k \
|
dd if=/dev/urandom of="$FILE" bs=1k \
|
||||||
|
@ -471,7 +471,7 @@ for TAG in $POOL_TAGS; do
|
||||||
# Verify 'zpool import' works for all listed source versions.
|
# Verify 'zpool import' works for all listed source versions.
|
||||||
for SRC_TAG in $SRC_TAGS; do
|
for SRC_TAG in $SRC_TAGS; do
|
||||||
|
|
||||||
if [ $SKIP -eq 1 ]; then
|
if [ "$SKIP" -eq 1 ]; then
|
||||||
skip_nonewline
|
skip_nonewline
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -509,4 +509,4 @@ if [ "$KEEP" = "no" ]; then
|
||||||
rm -Rf "$TEST_DIR"
|
rm -Rf "$TEST_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $ERROR
|
exit "$ERROR"
|
||||||
|
|
|
@ -102,10 +102,12 @@ function core_file
|
||||||
|
|
||||||
function core_prog
|
function core_prog
|
||||||
{
|
{
|
||||||
|
# shellcheck disable=SC2154
|
||||||
prog=$ZTEST
|
prog=$ZTEST
|
||||||
core_id=$($GDB --batch -c "$1" | grep "Core was generated by" | \
|
core_id=$($GDB --batch -c "$1" | grep "Core was generated by" | \
|
||||||
tr \' ' ')
|
tr \' ' ')
|
||||||
if [[ "$core_id" == *"zdb "* ]]; then
|
if [[ "$core_id" == *"zdb "* ]]; then
|
||||||
|
# shellcheck disable=SC2154
|
||||||
prog=$ZDB
|
prog=$ZDB
|
||||||
fi
|
fi
|
||||||
printf "%s" "$prog"
|
printf "%s" "$prog"
|
||||||
|
@ -130,7 +132,7 @@ function store_core
|
||||||
or_die mkdir -p "$dest/vdev"
|
or_die mkdir -p "$dest/vdev"
|
||||||
|
|
||||||
if [[ $symlink -ne 0 ]]; then
|
if [[ $symlink -ne 0 ]]; then
|
||||||
or_die ln -sf "$dest" ztest.core.$foundcrashes
|
or_die ln -sf "$dest" "ztest.core.${foundcrashes}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "*** ztest crash found - moving logs to $dest"
|
echo "*** ztest crash found - moving logs to $dest"
|
||||||
|
@ -195,10 +197,10 @@ while getopts ":ht:m:I:s:c:f:l" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
|
t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
|
||||||
m ) [[ $OPTARG -gt 0 ]] && coremax=$OPTARG ;;
|
m ) [[ $OPTARG -gt 0 ]] && coremax=$OPTARG ;;
|
||||||
I ) [[ $OPTARG ]] && iterations=$OPTARG ;;
|
I ) [[ -n $OPTARG ]] && iterations=$OPTARG ;;
|
||||||
s ) [[ $OPTARG ]] && size=$OPTARG ;;
|
s ) [[ -n $OPTARG ]] && size=$OPTARG ;;
|
||||||
c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
|
c ) [[ -n $OPTARG ]] && coredir=$OPTARG ;;
|
||||||
f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
|
f ) [[ -n $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
|
||||||
l ) symlink=1 ;;
|
l ) symlink=1 ;;
|
||||||
h ) usage
|
h ) usage
|
||||||
exit 2
|
exit 2
|
||||||
|
|
Loading…
Reference in New Issue