aboutsummaryrefslogtreecommitdiffstats
path: root/check/check-icons-listing
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-02-06 07:46:58 +0100
committerMattias Andrée <maandree@kth.se>2024-02-06 07:46:58 +0100
commit8c30c456806ff6d40684a7acf4084f387932db0e (patch)
treef534b0560067677c9813e3214f38bbb49523d449 /check/check-icons-listing
parentAdd some aliases and icons (diff)
downloadsimple-icon-theme-8c30c456806ff6d40684a7acf4084f387932db0e.tar.gz
simple-icon-theme-8c30c456806ff6d40684a7acf4084f387932db0e.tar.bz2
simple-icon-theme-8c30c456806ff6d40684a7acf4084f387932db0e.tar.xz
Big update11
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'check/check-icons-listing')
-rwxr-xr-xcheck/check-icons-listing89
1 files changed, 89 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