118 lines
3.3 KiB
Bash
Executable File
118 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
OUTPUT_DIR="out"
|
|
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
if [[ ! -f "$OUTPUT_DIR/cgi-paths.txt" ]]; then
|
|
find \
|
|
/home/pvv/?/*/web-docs \
|
|
-type f \
|
|
\( \
|
|
-name '*.cgi' \
|
|
-o -name '*.php' \
|
|
-o -name '*.php3' \
|
|
-o -name '*.pm' \
|
|
-o -name '*.pl' \
|
|
-o -name '*.sh' \
|
|
-o -name '*.bash' \
|
|
-o -name '*.phtml' \
|
|
-o -name '*.shtml' \
|
|
-o -name '*.lisp' \
|
|
-o -name '*.cl' \
|
|
\) \
|
|
2>/dev/null \
|
|
| tee "$OUTPUT_DIR/cgi-paths.txt"
|
|
fi
|
|
|
|
if [[ ! -f out/perl-libs.txt ]]; then
|
|
find \
|
|
/home/pvv/?/*/web-docs \
|
|
-type f \
|
|
\( \
|
|
-name '*.pm' \
|
|
-o -name '*.pl' \
|
|
\) \
|
|
-exec rg '^use ([^;]+);' {} -N -o -r '$1' \; \
|
|
2>/dev/null \
|
|
| tee "$OUTPUT_DIR/perl-libs.txt"
|
|
fi
|
|
|
|
cat "$OUTPUT_DIR/perl-libs.txt" | sort > "$OUTPUT_DIR/perl-libs-tmp1.txt"
|
|
|
|
# Remove import specifiers
|
|
sed -E \
|
|
-e 's|\s*(qw)?\s*\(.*\)||g' \
|
|
-e 's|\s*(qw)?\s*\/.*\/||g' \
|
|
"$OUTPUT_DIR/perl-libs-tmp1.txt" | sort > "$OUTPUT_DIR/perl-libs-tmp2.txt"
|
|
|
|
# Remove standard Perl modules
|
|
comm -2 -3 "$OUTPUT_DIR/perl-libs-tmp2.txt" <(cat PERL_STANDARD_MODULES.txt | sort) > "$OUTPUT_DIR/perl-libs-tmp3.txt"
|
|
|
|
# Remove pragmas
|
|
readarray -t PERL_PRAGMAS < PERL_PRAGMAS.txt
|
|
remove_pragmas_regex=$(printf '|^%s' "${PERL_PRAGMAS[@]}")
|
|
remove_pragmas_regex="${remove_pragmas_regex:1}" # remove leading '|
|
|
sed -E "/${remove_pragmas_regex}/d" "$OUTPUT_DIR/perl-libs-tmp3.txt" > "$OUTPUT_DIR/perl-libs-filtered.txt"
|
|
|
|
cat "$OUTPUT_DIR/perl-libs-filtered.txt" | uniq -c | sort -gr > "$OUTPUT_DIR/perl-libs-overview.txt"
|
|
|
|
if [[ ! -f "$OUTPUT_DIR/php-libs.txt" ]]; then
|
|
find \
|
|
/home/pvv/?/*/web-docs \
|
|
-type f \
|
|
\( \
|
|
-name '*.php' \
|
|
-o -name '*.php3' \
|
|
-o -name '*.phtml' \
|
|
\) \
|
|
-exec rg '^use ([^;]+);' {} -N -o -r '$1' \; \
|
|
2>/dev/null \
|
|
| tee "$OUTPUT_DIR/php-libs.txt"
|
|
fi
|
|
|
|
cat "$OUTPUT_DIR/php-libs.txt" | sort | uniq -c | sort -gr > "$OUTPUT_DIR/php-libs-overview.txt"
|
|
|
|
if [[ ! -f "$OUTPUT_DIR/cgi-progs.txt" ]]; then
|
|
readarray -t BIN_LOCATIONS < BIN_LOCATIONS.txt
|
|
bin_locations_regex=$(printf '|%s' "${BIN_LOCATIONS[@]}")
|
|
bin_locations_regex="${bin_locations_regex:1}" # remove leading '|'
|
|
bin_locations_regex="(?:${bin_locations_regex})"
|
|
|
|
find \
|
|
/home/pvv/?/*/web-docs \
|
|
-type f \
|
|
\( \
|
|
-name '*.cgi' \
|
|
-o -name '*.php' \
|
|
-o -name '*.php3' \
|
|
-o -name '*.pm' \
|
|
-o -name '*.pl' \
|
|
-o -name '*.sh' \
|
|
-o -name '*.bash' \
|
|
-o -name '*.phtml' \
|
|
-o -name '*.shtml' \
|
|
-o -name '*.lisp' \
|
|
-o -name '*.cl' \
|
|
\) \
|
|
-exec rg "$bin_locations_regex/(?:env\s*)?(\w+(?:/\w+)*)" {} -N -o -r '$1' \; \
|
|
2>/dev/null \
|
|
| tee "$OUTPUT_DIR/cgi-progs.txt"
|
|
fi
|
|
|
|
cat "$OUTPUT_DIR/cgi-progs.txt" | sort | uniq -c | sort -gr > "$OUTPUT_DIR/cgi-progs-overview.txt"
|
|
|
|
# TODO find lisp libraries
|
|
|
|
# TODO: look through all files in ~/web-docs/cgi-bin (last one case insensitive)
|
|
|
|
# TODO: generally filter out files ending with ~ or starting with #
|
|
|
|
# TODO: generally filter out .git, RCS, and other such files
|
|
|
|
# TODO: generally filter out executables, drop executable .so files
|
|
|
|
# TODO: look for all digits behind '*.php' (i.e. asdf.php4 and asdf.php5)
|
|
|
|
# TODO: extract non-absolute binary references from calls that invoke subprocesses in the various languages
|