File: update-tzdata.sh

package info (click to toggle)
libdatetime-timezone-perl 1%3A1.20-1%2B2010k
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,508 kB
  • ctags: 2,667
  • sloc: perl: 2,340; sh: 68; makefile: 5
file content (49 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download
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
#!/bin/bash

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

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- ftp://elsie.nci.nih.gov/pub/ | grep tzdata | perl -pe 's/.+".+tzdata(.+)\.tar.gz".+/$1/')

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 $debdbversion (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$debdbversion.tar.gz
    url=ftp://elsie.nci.nih.gov/pub/$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 -Ilib.bak tools/parse_olson --dir debian/tzdata --version $debdbversion --clean