summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2019-02-10 22:37:12 -0500
committerbill-auger <mr.j.spam.me@gmail.com>2019-02-10 23:13:06 -0500
commitb31e025f25e4dfe20e6d4d0ee88a267cf2167264 (patch)
treeb2b9e31fb4f3ba3a878f2fe95b7d9604fa96b3de
parent869340952389eb41135e824e3f4c4d8c9bf1fe8b (diff)
add 'sort-entries' script and non-uniform sort warning to 'check.sh'
-rw-r--r--.gitignore1
-rwxr-xr-xcheck.sh13
-rwxr-xr-xsort-entries22
3 files changed, 36 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 1acfe1f..83a5258 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
!find-replacements
!find-deprecated-pkgs
!README
+!sort-entries
!SYNTAX
!your-freedom_emu-blacklist.txt
!your-privacy-blacklist.txt
diff --git a/check.sh b/check.sh
index fe96b1c..9e84cc7 100755
--- a/check.sh
+++ b/check.sh
@@ -6,6 +6,10 @@
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
+readonly CSV_CHAR=':'
+readonly SEP_CHAR='!'
+
+
# Verify the blacklist entries are correctly formatted.
bad_entries="$(egrep -v '^[^:]*:[^:]*:(sv|debian|parabola|fsf|fedora)?:[^:]*:.*$' *.txt)"
@@ -21,3 +25,12 @@ if [[ ! -z "$unsourced" ]]; then
printf "[citation needed]:\n\n%s\n" "$unsourced" >&2
exit 1
fi
+
+
+# TODO: this could be removed someday - see note in 'sort-entries' script
+unsortable="$(grep ${SEP_CHAR} *.txt)"
+
+if [[ ! -z "$unsortable" ]]; then
+ printf "[non-uniform sorting] entry contains '$s' char" ${SEP_CHAR} >&2
+ exit 1
+fi
diff --git a/sort-entries b/sort-entries
new file mode 100755
index 0000000..f688029
--- /dev/null
+++ b/sort-entries
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# TODO: the best sorting results are acheived when the field separator
+# precedes any valid package name character in ASCII order -
+# the lowest of which is ASCII 43 '+'; so
+# ASCII 33 ('!') serves this purpose quite well -
+# someday, we should re-write the tools to use '!' instead of ':' -
+# then the sort command alone would yeild the same results as this script
+# and the warning could be removed from 'check.sh'
+
+readonly CSV_CHAR=':'
+readonly SEP_CHAR='!'
+
+
+for blacklist in *.txt
+do if grep ${SEP_CHAR} ${blacklist}
+ then echo "can not sort: '${blacklist}' - contains '${SEP_CHAR}' char"
+ else echo "sorting: '${blacklist}'"
+ cat ${blacklist} | tr "${CSV_CHAR}" "${SEP_CHAR}" | sort | uniq | tr "${SEP_CHAR}" "${CSV_CHAR}" > ${blacklist}.temp
+ mv ${blacklist}.temp ${blacklist}
+ fi
+done