Files
scst/scripts/source/list-source-files
T
Gleb Chesnokov 88b5653b06 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.
2026-10-19 10:31:32 +03:00

58 lines
1.4 KiB
Bash
Executable File

#!/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