scripts: Group source maintenance helpers under source/

Keep source inventory, cleanup and shell lint helpers together. Update the
Makefile, Debian packaging, scstadmin and the kernel, release and existing
checkpatch callers in the same commit so each consumer uses a valid path.

Keep run-shellcheck rooted at scripts/ after the move, preserving its
coverage of all tracked Bash helpers. Source selection and the existing
checkpatch exclusions are unchanged.
This commit is contained in:
Gleb Chesnokov
2026-10-19 10:31:32 +03:00
parent a6167625b0
commit 88b5653b06
13 changed files with 15 additions and 14 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
shopt -s nullglob
usage() {
echo "Usage: $(basename "$0") [ -x <exclude> ]*"
exit 1
}
remove_empty_directories() {
find . -depth -type d |
sed 's|^\./||' |
grep -Ev '^\.$|^\.git/|^\.git$' |
while read -r d; do
for f in "$d"/{*,.*}; do
if ! [ -e "$f" ]; then
rmdir "$d"
fi
break
done
done
}
git_options=(-e TAGS)
while [ "${1#-}" != "$1" ]; do
case "$1" in
-x)
git_options+=(-e "$2")
shift; shift;;
*)
usage;;
esac
done
for d in "${@-.}"; do
(
if cd "$d"; then
if [ -e .git ] || [ -e ../.git ]; then
if ! type -p git >&/dev/null; then
echo "$0: git: not found."
exit 0
fi
git clean -f -d -x "${git_options[@]}" >/dev/null
remove_empty_directories
else
echo "$0: $d: not administered by Git."
fi
fi
)
done
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/gawk -f
############################################################################
#
# Script that takes a patch as input and lists the line numbers of double
# blank lines in the input.
#
# Copyright (C) 2009 Bart Van Assche <bvanassche@acm.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, version 2
# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
############################################################################
BEGIN {
last_is_blank = 0
}
{
is_blank = $0 ~ "^\\+$"
if (last_is_blank && is_blank)
print NR
last_is_blank = is_blank
}
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
export LC_ALL=C
for d in "${@-.}"; do
(
cd "$d" &&
if git branch >&/dev/null; then
exec 3< <(find . -type f | cut -c3- | grep -v '^\.git/' | sort)
git ls-tree -r HEAD | cut -f2 -d' ' | sort |
while read -r f; do
while { read -r g; } <&3 && [ "$g" '<' "$f" ]; do echo "$g"; done
done
while { read -r g; } <&3; do echo "$g"; done
exec 3<&-
else
echo "Ignored directory $PWD"
fi
)
done
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
list_source_files() {
local d r
d="$(cd "$1" && echo "$PWD")"
r="$d"
while [ "$r" != "/" ] && [ ! -e "$r/.git" ]; do
r="$(dirname "$r")"
done
if [ -e "$r/.git" ]; then
subdir="${d#"${r}"}"
if [ "$r" != "" ]; then
( cd "$d" && git ls-tree --name-only -r HEAD ) | sed "s|^$subdir/||"
else
echo "Ignored directory $1" >&2
fi
else
(
cd "$d" &&
find . -type f -o -type l |
sed -e 's/^\.\///' \
-e '/\.depend_\(adm\|d\|f\)$/d' \
-e '/\.o$/d' \
-e '/\.o\.d$/d' \
-e '/\.o\.cmd$/d' \
-e '/\.ko$/d' \
-e '/\.ko\.cmd$/d' \
-e '/\.mod$/d' \
-e '/\.mod\.c$/d' \
-e '/\.mod\.cmd$/d' \
-e '/\/Module\.\(symver\|marker\)s$/d' \
-e '/\/\.Module\.symvers\.cmd$/d' \
-e '/\/\.modules\.order\.cmd$/d' \
-e '/\/\.tmp_versions\(\/\|$\)/d' \
-e '/\/blib\//d' \
-e '/\/conftest\/.*\/build-output-.*\.txt$/d' \
-e '/\/conftest\/.*\/result-.*\.txt$/d' \
-e '/\/modules\.order$/d' \
-e '/\/rpmbuilddir\//d' \
-e '/^iscsi-scst\/usr\/iscsi-scst-adm$/d' \
-e '/^iscsi-scst\/usr\/iscsi-scstd$/d' \
-e '/^rpmbuilddir\//d' \
-e '/^usr\/fileio\/fileio_tgt$/d' \
-e '/^usr\/stpgd\/stpgd$/d' \
-e '/debian\/tmp\//d' \
-e '/~$/d'
)
fi | sort
}
if [ $# = 0 ]; then
list_source_files "$PWD"
else
for d in "$@"; do list_source_files "$d"; done
fi
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
set -euo pipefail
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
if ! command -v shellcheck >/dev/null 2>&1; then
echo "Error: shellcheck has not been installed." >&2
exit 1
fi
scripts_root="$(dirname -- "$script_dir")"
source_files="$("$script_dir/list-source-files" "$scripts_root")"
cd "$scripts_root"
bash_scripts=()
while IFS= read -r file; do
[ -n "$file" ] || continue
IFS= read -r first_line < "$file" || first_line=
case "$first_line" in
'#!'*bash*) bash_scripts+=("$file");;
esac
done <<<"$source_files"
if [ "${#bash_scripts[@]}" -eq 0 ]; then
echo "Error: no Bash scripts found under scripts/." >&2
exit 1
fi
shellcheck -x -P SCRIPTDIR "${bash_scripts[@]}"