Debian Codegraph @

debian/tools/update-tzdata.sh

raw
1 #!/bin/bash
2
3 die () {
4 echo "$@" 1>&2
5 exit 1
6 }
7
8 HOST=https://www.iana.org/time-zones
9
10 dh_testdir debian/changelog || die "You are not in the source package's root directory."
11
12 debdbversion=$(head -n1 debian/changelog | sed 's/^.*+\([0-9a-z]*\)).*$/\1/')
13 updbversion=$(wget -q -O- ${HOST}/ | wget -q -O- https://www.iana.org/time-zones/ | grep /time-zones/releases/ | perl -pe 's{.*/time-zones/releases/(.+)">}{$1}')
14
15 if [ "$debdbversion" != "$updbversion" ] ; then
16 echo "Debian dbversion $debdbversion != upstream dbversion $updbversion."
17 echo "You might want to change the Debian dbversion in debian/changelog."
18 read -p "Continue with $updbversion (y/N)? " CONTINUE
19 case $CONTINUE in
20 y|Y)
21 ;;
22 *)
23 die "Aborted on user request."
24 ;;
25 esac
26 fi
27
28 mkdir -p debian/tzdata || die "Cannot mkdir debian/tzdata."
29
30 pushd debian/tzdata || die "Cannot cd debian/tzdata."
31
32 file=tzdata$updbversion.tar.gz
33 url=${HOST}/repository/releases/$file
34
35 rm -f *
36
37 (
38 echo "These files were downloaded with debian/tools/update-tzdata.sh script"
39 echo "from $url"
40 echo "at `date -R` by Debian maintainer"
41 ) > README
42
43 wget $url || die "Cannot download $url."
44
45 tar zxvf $file || die "Cannot unpack tzdata tarball."
46
47 rm -f $file || die "Cannot remove tzdata tarball."
48
49 popd
50
51 perl tools/parse_olson --dir debian/tzdata --version $updbversion --clean