File: update-tzdata.sh

package info (click to toggle)
libdatetime-timezone-perl 1%3A2.09-1%2B2019c
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 106,872 kB
  • sloc: perl: 2,578; sh: 36; makefile: 10
file content (52 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (6)
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
#!/bin/bash

die () {
    echo "$@" 1>&2
    exit 1
}

HOST=https://www.iana.org/time-zones

dh_testdir debian/changelog || die "You are not in the source package's root directory."

debdbversion=$(head -n1 debian/changelog  | sed 's/^.*+\([0-9a-z]*\)).*$/\1/')
updbversion=$(wget -q -O- ${HOST}/ | grep tzdata | perl -pe 's/.+".+tzdata(.+)\.tar.gz".+/$1/')
dttzversion=$(awk '/version =/ {print $3;}' dist.ini)

if [ "$debdbversion" != "$updbversion" ] ; then
    echo "Debian dbversion $debdbversion != upstream dbversion $updbversion."
    echo "You might want to change the Debian dbversion in debian/changelog."
    read -p "Continue with $updbversion (y/N)? " CONTINUE
    case $CONTINUE in
        y|Y)
            ;;
        *)
            die "Aborted on user request."
            ;;
    esac
fi    

mkdir -p debian/tzdata || die "Cannot mkdir debian/tzdata."

pushd debian/tzdata || die "Cannot cd debian/tzdata."

    file=tzdata$updbversion.tar.gz
    url=${HOST}/repository/releases/$file

    rm -f *
    
    (
        echo "These files were downloaded with debian/tools/update-tzdata.sh script"
        echo "from $url"
        echo "at `date -R` by Debian maintainer" 
    ) > README

    wget $url || die "Cannot download $url."

    tar zxvf $file || die "Cannot unpack tzdata tarball."
    
    rm -f $file || die "Cannot remove tzdata tarball."

popd

perl tools/parse_olson --dir debian/tzdata --version $updbversion --clean