diff options
Diffstat (limited to 'data/check-timezones.sh')
-rwxr-xr-x | data/check-timezones.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/data/check-timezones.sh b/data/check-timezones.sh new file mode 100755 index 0000000..ab3bf08 --- /dev/null +++ b/data/check-timezones.sh @@ -0,0 +1,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 |