diff options
author | Mattias Andrée <maandree@kth.se> | 2024-02-06 07:46:58 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-02-06 07:46:58 +0100 |
commit | 8c30c456806ff6d40684a7acf4084f387932db0e (patch) | |
tree | f534b0560067677c9813e3214f38bbb49523d449 /check | |
parent | Add some aliases and icons (diff) | |
download | simple-icon-theme-11.tar.gz simple-icon-theme-11.tar.bz2 simple-icon-theme-11.tar.xz |
Big update11
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'check')
-rwxr-xr-x | check/check-icons-listing | 89 | ||||
-rwxr-xr-x | check/find-errors | 4 | ||||
-rwxr-xr-x | check/find-unlisted-icons | 18 |
3 files changed, 111 insertions, 0 deletions
diff --git a/check/check-icons-listing b/check/check-icons-listing new file mode 100755 index 0000000..404e089 --- /dev/null +++ b/check/check-icons-listing @@ -0,0 +1,89 @@ +#!/bin/sh +set -e + +rel () { + to="$1" + from="$2" + while test $(printf '%s\n' "$to" "$from" | grep / | wc -l) = 2; do + todir="$(printf '%s\n' "$to" | cut -d / -f 1)" + fromdir="$(printf '%s\n' "$from" | cut -d / -f 1)" + if test ! "$todir" = "$fromdir"; then + break + fi + to="$(printf '%s\n' "$to" | cut -d / -f 2-)" + from="$(printf '%s\n' "$frm" | cut -d / -f 2-)" + done + while test -n "$(printf '%s\n' "$from" | grep /)"; do + from="$(printf '%s\n' "$from" | cut -d / -f 2-)" + to="../$to" + done + printf '%s\n' "$to" +} + +lines=$(sed 's/\\$//' < icons.mk | sed '/^\s*\(#.*\|\)$/d' | sed 1d | wc -l) +test ! $lines = 0 + +test $(sed 's/\\$//' < icons.mk | sed '/^\s*\(#.*\|\)$/d' | sed 1d | sed 's/\t/ /g' | grep '^ ' | wc -l) = $lines + +test $(sed 's/\\$//' < icons.mk | sed '/^\s*\(#.*\|\)$/d' | sed '1s/^.*$//' | grep -n ' ' | wc -l) = 0 + +stack="" +i=0 +sed 's/\\$//' < icons.mk | sed '/^\s*\(#.*\|\)$/d' | sed 1d | sed 's/^\t/x/' | while read L; do + i=$(( i + 1 )) + printf 'Checking %i of %i\n\033[A' $i $lines >&2 + tabs=0 + while test ! $(printf '%s\n' "$L" | sed -n '/^x\t/p' | wc -l) = 0; do + L="$(printf '%s\n' "$L" | sed 's/^x\t/x/')" + tabs=$(( tabs + 1 )) + done + L="$(printf '%s\n' "$L" | sed 's/^x//')" + f="scalable/$L.svg" + if test ! $(printf '%s\n' $f | wc -l) = 1; then + printf '\033[K%s contains whitespace\n' "$L" >&2 + exit 1 + fi + tabsplus1=$(( tabs + 1 )) + if test -z "$(printf '%s\n' $stack x | sed -n ${tabsplus1}p)"; then + printf '\033[K%s is overtabulated\n' "$L" >&2 + exit 1 + else + stack="$(printf '%s\n' $stack | head -n $tabs; printf '%s\n' "$L")" + fi + if test ! -e "$f"; then + if test -L "$f"; then + printf '\033[K%s is a dangling symlink\n' "$L" >&2 + else + printf '\033[K%s is listed but does not exist\n' "$L" >&2 + fi + exit 1 + fi + if test $tabs = 0; then + if test -L "$f"; then + printf '\033[K%s is a symlink but not indented\n' "$L" >&2 + exit 1 + fi + else + goal_="$(printf '%s\n' $stack | sed -n "${tabs}p")" + if test ! -L "$f"; then + printf '\033[K%s is not a symlink but listed as linking to %s\n' "$L" "$goal" >&2 + exit 1 + fi + target="$(realpath -- "$f")" + goal="$(realpath -- "scalable/${goal_}.svg")" + if test "$target" = "$goal"; then + diff="same real file" + else + diff="different real file" + fi + target="$(readlink -- "$f")" + goal="$(rel "${goal_}.svg" "$L.svg")" + if test "$target" = "./$goal"; then + ln -sf -- "$target" "$f" + elif test ! "$target" = "$goal"; then + printf '\033[K%s links to %s but should link to %s (%s)\n' "$L" "$target" "$goal" "$diff" >&2 + exit 1 + fi + fi +done +printf '\033[K' >&2 diff --git a/check/find-errors b/check/find-errors new file mode 100755 index 0000000..c557a4b --- /dev/null +++ b/check/find-errors @@ -0,0 +1,4 @@ +#!/bin/sh +! grep -ro '#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' scalable/ \ +| tr 'A-F' 'a-f' \ +| grep -v '#\(bebebe\|ef2929\|f57900\|32a679\|cd656c\|d69553\|ccad47\|32a679\|00a09f\|2495be\|a46eb0\|32a678\)' diff --git a/check/find-unlisted-icons b/check/find-unlisted-icons new file mode 100755 index 0000000..f493178 --- /dev/null +++ b/check/find-unlisted-icons @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +for f in scalable/*/*.svg; do + if test -e "$f"; then + printf '%s\n' "$f" + fi +done | sed 's/^scalable\/\(.*\)\.svg$/\1/' | sort > "/tmp/pid-$$-a" + +sed 's/\\$//' < icons.mk | sed '/^\s*\(#.*\|\)$/d' | sed 1d | tr -d '\t' | sort > "/tmp/pid-$$-b" + +unlisted="$(comm -23 "/tmp/pid-$$-a" "/tmp/pid-$$-b")" +rm "/tmp/pid-$$-a" "/tmp/pid-$$-b" + +if test -n "$unlisted"; then + printf '%s\n' 'The following icons exist but are not listed in icons.mk' "$unlisted" >&2 + exit 1 +fi |