summaryrefslogtreecommitdiff
path: root/data/check-timezones.sh
blob: ab3bf0829949f0b2f853015dd238bf659b631ff2 (plain)
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
#!/bin/sh

if test -f /usr/share/zoneinfo/zone.tab; then
	tzdb=/usr/share/zoneinfo/zone.tab
else
	if test -f /usr/share/lib/zoneinfo/tab/zone_sun.tab; then
		tzdb=/usr/share/lib/zoneinfo/tab/zone_sun.tab
	else
		echo "No timezone database found"
		exit 1
	fi
fi

locations=${1:-Locations.xml.in}
used=`mktemp`
correct=`mktemp`

sed -ne 's/.*<tz-hint>\(.*\)<.*/\1/p' $locations | sort -u > $used
awk '{print $3;}' $tzdb  | sort -u > $correct
bad=`comm -13 $correct $used`
rm $correct $used

if [ -n "$bad" ]; then
    echo "Invalid timezones in ${locations}: $bad" 1>&2
    exit 1
fi

used=`mktemp`
obsolete=`mktemp`

sed -ne 's/.*<tz-hint>\(.*\)<.*/\1/p' $locations | sort -u > $used
sed -ne 's/.*<obsoletes>\(.*\)<.*/\1/p' $locations | sort -u > $obsolete
bad=`comm -12 $used $obsolete`
rm $used $obsolete

if [ -n "$bad" ]; then
    echo "Obsolete <tz-hint> timezones in ${locations}: $bad" 1>&2
    exit 1
fi
exit 0