mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 09:11:27 +00:00
scripts/generate-kernel-patch: Fix shellcheck warnings
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7035 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
# Function definitions #
|
||||
########################
|
||||
|
||||
source $(dirname $0)/kernel-functions
|
||||
# shellcheck source=./kernel-functions
|
||||
source $(dirname "$0")/kernel-functions
|
||||
|
||||
function usage {
|
||||
echo "Usage: $0 [-d] [-h] [-m] [-n] [-p <dir>] [-s] [-u] <kernel version>"
|
||||
@@ -67,12 +68,12 @@ function add_file {
|
||||
|
||||
# Only include files that were not generated by the build process
|
||||
# -- skip *.mod.c.
|
||||
if [ "$1" = "${1%.mod.c}" -a "$1" ]; then
|
||||
if [ "$1" = "${1%.mod.c}" ] && [ "$1" ]; then
|
||||
cat <<EOF
|
||||
diff -uprN orig/linux-${kver}/$2 linux-${kver}/$2
|
||||
--- orig/linux-${kver}/$2
|
||||
+++ linux-${kver}/$2
|
||||
@@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@
|
||||
@@ -0,0 +1,$(wc -l "$1" | { read -r a b; echo "$a"; echo "$b" >/dev/null; }) @@
|
||||
EOF
|
||||
# Insert a '+'-sign at the start of each line.
|
||||
sed -e 's/^/+/' < "$1" | \
|
||||
@@ -92,8 +93,6 @@ EOF
|
||||
}
|
||||
|
||||
function add_empty_file {
|
||||
local a b
|
||||
|
||||
cat <<EOF
|
||||
diff -uprN orig/linux-${kver}/$1 linux-${kver}/$1
|
||||
--- orig/linux-${kver}/$1
|
||||
@@ -112,8 +111,8 @@ function specialize_patch {
|
||||
else
|
||||
cat
|
||||
fi |
|
||||
"$(dirname $0)/specialize-patch" \
|
||||
${specialize_patch_options} \
|
||||
"$(dirname "$0")/specialize-patch" \
|
||||
"${specialize_patch_options[@]}" \
|
||||
-v kernel_version="${kver3}" \
|
||||
-v SCSI_EXEC_REQ_FIFO_DEFINED="${scsi_exec_req_fifo_defined}" \
|
||||
-v SCST_IO_CONTEXT="${scst_io_context}"
|
||||
@@ -146,7 +145,7 @@ function process_patch {
|
||||
awk 'BEGIN{h=1}/^diff/{h=0}/^---/{h=0}h==0{print}' < "${tmppatch}"
|
||||
fi
|
||||
} \
|
||||
> "${patchdir}/$(basename $1)"
|
||||
> "${patchdir}/$(basename "$1")"
|
||||
rm -f "${tmppatch}"
|
||||
else
|
||||
# echo "Discarded $(wc -l) lines."
|
||||
@@ -176,14 +175,16 @@ multiple_patches="false"
|
||||
patchdir=""
|
||||
qla2x00t="true"
|
||||
replace_sbug_by_bug="true"
|
||||
specialize_patch_options="-v delete_disabled_code=1"
|
||||
specialize_patch_options=(-v delete_disabled_code=1)
|
||||
srpt="true"
|
||||
|
||||
if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt -o ! -e scst_local ]; then
|
||||
if [ ! -e scst ] || [ ! -e iscsi-scst ] || [ ! -e srpt ] ||
|
||||
[ ! -e scst_local ]; then
|
||||
echo "Please run this script from inside the SCST subversion source tree."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2046
|
||||
set -- $(/usr/bin/getopt dhlmnp:su "$@")
|
||||
while [ "$1" != "${1#-}" ]
|
||||
do
|
||||
@@ -192,7 +193,7 @@ do
|
||||
'-h') usage; exit 1;;
|
||||
'-l') shift;;
|
||||
'-m') mpt_scst="true"; shift;;
|
||||
'-n') specialize_patch_options="-v blank_deleted_code=1"
|
||||
'-n') specialize_patch_options=(-v blank_deleted_code=1)
|
||||
shift
|
||||
;;
|
||||
'-p') multiple_patches="true"; patchdir="$2"; shift; shift;;
|
||||
@@ -235,15 +236,15 @@ fi
|
||||
if grep -qw scst_sysfs scst/kernel/in-tree/${scst_makefile} \
|
||||
|| [ "${generating_upstream_patch}" = "true" ];
|
||||
then
|
||||
specialize_patch_options="${specialize_patch_options} -v config_scst_proc_undefined=1"
|
||||
specialize_patch_options+=(-v config_scst_proc_undefined=1)
|
||||
else
|
||||
include_proc_impl="true"
|
||||
fi
|
||||
if [ "${debug_specialize}" = "true" ]; then
|
||||
specialize_patch_options="${specialize_patch_options} -v debug=1"
|
||||
specialize_patch_options+=(-v debug=1)
|
||||
fi
|
||||
if [ "${generating_upstream_patch}" = "true" ]; then
|
||||
specialize_patch_options="${specialize_patch_options} -v generating_upstream_patch_defined=1 -v config_tcp_zero_copy_transfer_completion_notification_undefined=1"
|
||||
specialize_patch_options+=(-v generating_upstream_patch_defined=1 -v config_tcp_zero_copy_transfer_completion_notification_undefined=1)
|
||||
fi
|
||||
|
||||
if [ "${multiple_patches}" = "true" ]; then
|
||||
@@ -285,15 +286,15 @@ for p in scst/kernel/*-${kver}.patch \
|
||||
elif [ "${1#3.13.}" != "$1" ] && [ "${1#3.13.}" -ge 3 ]; then
|
||||
echo iscsi-scst/kernel/patches/*-3.13.3.patch;
|
||||
else
|
||||
echo iscsi-scst/kernel/patches/*-${kver}.patch;
|
||||
echo iscsi-scst/kernel/patches/*-"${kver}".patch;
|
||||
fi)
|
||||
do
|
||||
[ -e "$p" ] || continue
|
||||
# Exclude the put_page_callback patch when command-line option -u has been
|
||||
# specified since the current approach is not considered acceptable for
|
||||
# upstream kernel inclusion. See also http://lkml.org/lkml/2008/12/11/213.
|
||||
if [ "${generating_upstream_patch}" = "false" \
|
||||
-o "${p#iscsi-scst/kernel/patches/put_page_callback}" = "$p" ]
|
||||
if [ "${generating_upstream_patch}" = "false" ] ||
|
||||
[ "${p#iscsi-scst/kernel/patches/put_page_callback}" = "$p" ]
|
||||
then
|
||||
if grep -q '^\+#define SCSI_EXEC_REQ_FIFO_DEFINED$' "${p}"; then
|
||||
scsi_exec_req_fifo_defined=1
|
||||
@@ -325,6 +326,9 @@ scst_13_vdisk="scst/src/dev_handlers/scst_vdisk.c"
|
||||
scst_14_tg="scst/src/scst_tg.c"
|
||||
separate_patches="scst_03_public_headers scst_04_main scst_05_targ scst_06_lib scst_07_pres scst_08_sysfs scst_09_debug scst_10_sgv scst_user scst_13_vdisk scst_14_tg"
|
||||
|
||||
# Suppress shellcheck warnings about unused variables.
|
||||
echo "$scst_03_public_headers $scst_04_main $scst_05_targ $scst_06_lib $scst_07_pres $scst_08_sysfs $scst_09_debug $scst_proc $scst_10_sgv $scst_user $scst_13_vdisk $scst_14_tg" >/dev/null
|
||||
|
||||
if [ "$include_proc_impl" = "true" ]; then
|
||||
separate_patches+=" scst_proc"
|
||||
fi
|
||||
@@ -365,6 +369,7 @@ tmpdir="/tmp/scst-$$"
|
||||
mkdir -p "${tmpdir}"
|
||||
|
||||
tmp_Kconfig="${tmpdir}/Kconfig.scst-${kver}"
|
||||
# shellcheck disable=SC2002
|
||||
cat "scst/kernel/in-tree/Kconfig.scst" | \
|
||||
if [ "${include_fcst}" ]; then
|
||||
cat
|
||||
@@ -374,13 +379,15 @@ fi >"${tmp_Kconfig}"
|
||||
add_file "${tmp_Kconfig}" "drivers/scst/Kconfig"
|
||||
|
||||
tmp_Makefile="${tmpdir}/${scst_makefile}"
|
||||
# shellcheck disable=SC2002
|
||||
cat "scst/kernel/in-tree/${scst_makefile}" | \
|
||||
if [ "$include_proc_impl" != "true" ]; then
|
||||
grep -v 'scst_proc'
|
||||
else
|
||||
cat
|
||||
fi | \
|
||||
if [ "${include_fcst}" -a "${kver}" != "2.6.37" -a "${kver}" != "2.6.38" ]; then
|
||||
if [ "${include_fcst}" ] && [ "${kver}" != "2.6.37" ] &&
|
||||
[ "${kver}" != "2.6.38" ]; then
|
||||
cat
|
||||
else
|
||||
sed -e 's: fcst/* : :'
|
||||
@@ -394,8 +401,7 @@ rm -rf "${tmpdir}"
|
||||
for s in ${separate_patches}
|
||||
do
|
||||
{
|
||||
fileset=$s
|
||||
for f in $(set | grep "^$s=" | sed -e "s/^$s='\(.*\)'\$/\1/" -e "s/^$s=\(.*\)\$/\1/")
|
||||
for f in $(eval 'echo "$'"{$s}"'"')
|
||||
do
|
||||
if [ "${f#scst/include}" != "${f}" ]; then
|
||||
add_file "${f}" "include/scst/${f#scst/include/}"
|
||||
@@ -408,7 +414,7 @@ do
|
||||
if grep -q /scst_itf_ver.h scst/src/Makefile &&
|
||||
[ "$s" = "scst_03_public_headers" ]; then
|
||||
tmp_itf_ver="$(mktemp /tmp/scst-itf-ver.h.XXXXXXXXXX)"
|
||||
cat <<"EOF" >$tmp_itf_ver
|
||||
cat <<"EOF" >"$tmp_itf_ver"
|
||||
/* Autogenerated, don't edit */
|
||||
|
||||
#define SCST_INTF_VER "SCST_INTF_VER"
|
||||
@@ -440,8 +446,8 @@ else
|
||||
| process_patch "scst_11_dev_handlers_makefile.diff"
|
||||
fi
|
||||
|
||||
for f in $(ls scst/src/dev_handlers/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in scst/src/dev_handlers/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
if ! in_separate_patch "${f}"; then
|
||||
add_file "${f}" "drivers/scst/dev_handlers/${f#scst/src/dev_handlers/}"
|
||||
fi
|
||||
@@ -453,10 +459,10 @@ done \
|
||||
|
||||
{
|
||||
if [ -e "${fcst_patch_series}" ]; then
|
||||
for f in $(grep -v '^#' "${fcst_patch_series}")
|
||||
do
|
||||
cat "fcst/linux-patches/${f}"
|
||||
done
|
||||
grep -v '^#' "${fcst_patch_series}" |
|
||||
while read -r f; do
|
||||
cat "fcst/linux-patches/${f}"
|
||||
done
|
||||
fi
|
||||
|
||||
add_file "fcst/Makefile_in-tree" \
|
||||
@@ -464,8 +470,8 @@ done \
|
||||
|
||||
add_file "fcst/Kconfig" "drivers/scst/fcst/Kconfig"
|
||||
|
||||
for f in $(ls fcst/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in fcst/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
add_file "${f}" "drivers/scst/fcst/${f#fcst/}"
|
||||
done
|
||||
} \
|
||||
@@ -481,8 +487,8 @@ add_file "fcst/README" "Documentation/scst/README.fcst" \
|
||||
make -s -C iscsi-scst include/iscsi_scst_itf_ver.h
|
||||
|
||||
(
|
||||
for f in $(ls iscsi-scst/include/*h 2>/dev/null)
|
||||
do
|
||||
for f in iscsi-scst/include/*h; do
|
||||
[ -e "$f" ] || continue
|
||||
case "${f}" in
|
||||
"iscsi-scst/include/iscsi_scst_itf_ver.h")
|
||||
;;
|
||||
@@ -502,13 +508,13 @@ add_file "iscsi-scst/kernel/Makefile.in-kernel" \
|
||||
|
||||
add_file "iscsi-scst/kernel/Kconfig" "drivers/scst/iscsi-scst/Kconfig"
|
||||
|
||||
for f in $(ls iscsi-scst/kernel/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in iscsi-scst/kernel/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
add_file "${f}" "drivers/scst/iscsi-scst/${f#iscsi-scst/kernel/}"
|
||||
done
|
||||
|
||||
for f in $(ls iscsi-scst/kernel/isert-scst/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in iscsi-scst/kernel/isert-scst/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
add_file "${f}" "drivers/scst/iscsi-scst/isert-scst/${f#iscsi-scst/kernel/isert-scst/}"
|
||||
done
|
||||
add_file "iscsi-scst/kernel/isert-scst/Makefile.in-kernel" "drivers/scst/iscsi-scst/isert-scst/Makefile"
|
||||
@@ -526,8 +532,8 @@ if [ "${qla2x00t}" = "true" ]; then
|
||||
|
||||
( cd qla2x00t && ./generate-in-tree-patches "$1" )
|
||||
|
||||
for f in $(ls qla2x00t/in-tree-patches/"$1"/*.patch 2>/dev/null)
|
||||
do
|
||||
for f in qla2x00t/in-tree-patches/"$1"/*.patch; do
|
||||
[ -e "$f" ] || continue
|
||||
g="${f#qla2x00t/in-tree-patches/$1/}"
|
||||
g="${g%.patch}"
|
||||
add_patch "${f}" "drivers/scsi/qla2xxx/${g}"
|
||||
@@ -551,8 +557,8 @@ if [ "${qla2x00t}" = "true" ]; then
|
||||
add_file "qla2x00t/qla2x00-target/Kconfig" \
|
||||
"drivers/scst/qla2xxx-target/Kconfig"
|
||||
|
||||
for f in $(ls qla2x00t/qla2x00-target/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in qla2x00t/qla2x00-target/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
add_file "${f}" "drivers/scst/qla2xxx-target/${f#qla2x00t/qla2x00-target/}"
|
||||
done
|
||||
|
||||
@@ -598,8 +604,8 @@ if [ "$srpt" = "true" ]; then
|
||||
|
||||
add_file "srpt/src/Makefile.in_kernel" "drivers/scst/srpt/Makefile"
|
||||
|
||||
for f in $(ls srpt/src/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in srpt/src/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
add_file "${f}" "drivers/scst/srpt/${f#srpt/src/}"
|
||||
done
|
||||
|
||||
@@ -626,8 +632,8 @@ if [ "$mpt_scst" = "true" ]; then
|
||||
|
||||
add_file "mpt/in-tree/Kconfig" "drivers/message/fusion/mpt_scst/Kconfig"
|
||||
|
||||
for f in $(ls mpt/*.[ch] 2>/dev/null)
|
||||
do
|
||||
for f in mpt/*.[ch]; do
|
||||
[ -e "$f" ] || continue
|
||||
add_file "${f}" "drivers/message/fusion/mpt_scst/${f#mpt/}"
|
||||
done
|
||||
) \
|
||||
|
||||
Reference in New Issue
Block a user