blob: 404e089b17ee524f80004043f4dc036cf76d4c08 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
|