summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-01-31 04:38:33 -0500
committerbill-auger <mr.j.spam.me@gmail.com>2023-01-31 04:56:13 -0500
commit5dd9b7301d58ffad2e4a3e43cc8bb5a5fd6f746d (patch)
treeaac316895a22787aafec05f58d36c181e8149af0
parent249a8e38967abf9243252f03a4b33100cd636dbb (diff)
housekeeping
-rwxr-xr-xcheck.sh26
1 files changed, 16 insertions, 10 deletions
diff --git a/check.sh b/check.sh
index 448ab2c..3cb7433 100755
--- a/check.sh
+++ b/check.sh
@@ -1,5 +1,6 @@
#!/bin/bash
-# Copyright (C) 2014 Michał Masłowski <mtjm@mtjm.eu>
+# Copyright 2014 Michał Masłowski <mtjm@mtjm.eu>
+# Copyright 2019,2020,2023 bill-auger <bill-auger@programmer.net>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
@@ -8,14 +9,19 @@
# blacklist::check.sh Verify the blacklist entries are correctly formatted.
+readonly BLACKLISTS=( aur-blacklist.txt \
+ blacklist.txt \
+ your-freedom_emu-blacklist.txt \
+ your-init-freedom-blacklist.txt \
+ your-privacy-blacklist.txt )
readonly REF_REGEX='^[^:]*:[^:]*::[^:]*:.*$'
readonly SYNTAX_REGEX='^[^:]*:[^:]*:(debian|fedora|fsf|parabola|savannah)?:[^:]*:.*$'
readonly CSV_CHAR=':'
readonly SEP_CHAR='!'
-readonly LOG_FILE=./check.log ; rm ${LOG_FILE} 2> /dev/null
+readonly LOG_FILE=./check.log ; rm -f ${LOG_FILE} ;
-exit_status=0
+exit_status=0
# TODO: the best sorting results are acheived when the field separator ($CSV_CHAR)
# precedes any valid package name character in ASCII order
@@ -25,7 +31,7 @@ exit_status=0
# if that were done, then the `sort` command alone would yeild
# the same results as this procedure, except for removing empty lines
unsortable="$(
- for blacklist in *.txt
+ for blacklist in "${BLACKLISTS[@]}"
do echo -n "sorting and cleaning: '${blacklist}' ... " >> ${LOG_FILE}
if grep ${SEP_CHAR} ${blacklist}
then echo "ERROR: can not sort - contains '${SEP_CHAR}' char" >> ${LOG_FILE}
@@ -38,30 +44,30 @@ unsortable="$(
done
)"
if [[ -n "$unsortable" ]]
-then printf "\n[Entries containing '%s' char]:\n\n%s\n\n" "${SEP_CHAR}" "$unsortable" >> ${LOG_FILE}
+then printf "\n[Entries containing '%s' char]:\n%s\n\n" "${SEP_CHAR}" "$unsortable" >> ${LOG_FILE}
echo -n "ERROR: one of the data files is unsortable - check can not continue"
echo " - correct the malformed entries, then run this script again"
exit 1
fi
printf "\n\nchecking for entries with syntax errors: ... " >> ${LOG_FILE}
-invalid="$(egrep -v ${SYNTAX_REGEX} *.txt)"
+invalid="$(grep -E -v ${SYNTAX_REGEX} "${BLACKLISTS[@]}")"
if [[ -z "$invalid" ]]
then printf "OK\n" >> ${LOG_FILE}
-else printf "\n[Incorrectly formatted entries]:\n\n%s\n\n" "$invalid" >> ${LOG_FILE}
+else printf "\n[Incorrectly formatted entries]:\n%s\n\n" "$invalid" >> ${LOG_FILE}
exit_status=1
fi
printf "\n\nchecking for entries without reference to detailed description: ... " >> ${LOG_FILE}
-unsourced="$(egrep ${REF_REGEX} *.txt)"
+unsourced="$(grep -E ${REF_REGEX} "${BLACKLISTS[@]}")"
if [[ -z "$unsourced" ]]
then printf "OK\n" >> ${LOG_FILE}
-else printf "\n[citation needed]:\n\n%s\n\n" "$unsourced" >> ${LOG_FILE}
+else printf "\n[citation needed]:\n%s\n\n" "$unsourced" >> ${LOG_FILE}
exit_status=1
fi
# summary
-totals=$(wc -l *.txt | sed 's|\(.*\)|\t\1|')
+totals=$(wc -l "${BLACKLISTS[@]}" | sed 's|\(.*\)|\t\1|')
n_unsourced=$( [[ "${unsourced}" ]] && wc -l <<<${unsourced} || echo 0 )
n_malformed=$( [[ "${invalid}" ]] && wc -l <<<${invalid} || echo 0 )
echo -e "summary:\n\t* number of entries total:\n${totals}"