1#!/usr/bin/env bash 2 3### 4# Runs the 'tz' tox test environment, which builds the repo against the master 5# branch of the upstream tz database project. 6 7set -e 8 9TMP_DIR=${1} 10REPO_DIR=${2} 11ORIG_DIR=$(pwd) 12CITOOLS_DIR=$REPO_DIR/ci_tools 13 14REPO_TARBALL=${REPO_DIR}/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz 15TMP_TARBALL=${TMP_DIR}/dateutil-zoneinfo.tar.gz 16 17UPSTREAM_URL="https://github.com/eggert/tz.git" 18 19function cleanup { 20 # Since this script modifies the original repo, whether or not 21 # it fails we need to restore the original file so as to not 22 # overwrite the user's local changes. 23 echo "Cleaning up." 24 if [ -f $TMP_TARBALL ]; then 25 cp -p $TMP_TARBALL $REPO_TARBALL 26 fi 27} 28 29trap cleanup EXIT 30 31# Work in a temporary directory 32cd $TMP_DIR 33 34# Clone or update the repo 35DIR_EXISTS=false 36if [ -d tz ]; then 37 cd tz 38 if [[ $(git remote get-url origin) == ${UPSTREAM_URL} ]]; then 39 git fetch origin master 40 git reset --hard origin/master 41 DIR_EXISTS=true 42 else 43 cd .. 44 rm -rf tz 45 fi 46fi 47 48if [ "$DIR_EXISTS" = false ]; then 49 git clone ${UPSTREAM_URL} 50 cd tz 51fi 52 53# Get the version 54make version 55VERSION=$(cat version) 56TARBALL_NAME=tzdata${VERSION}.tar.gz 57 58# Make the tzdata tarball - deactivate errors because 59# I don't know how to make just the .tar.gz and I don't 60# care if the others fail 61set +e 62make traditional_tarballs 63set -e 64 65mv $TARBALL_NAME $ORIG_DIR 66 67# Install everything else 68make TOPDIR=$TMP_DIR/tzdir install 69 70# 71# Make the zoneinfo tarball 72# 73cd $ORIG_DIR 74 75# Put the latest version of zic on the path 76PATH=$TMP_DIR/tzdir/usr/sbin:${PATH} 77 78# Stash the old zoneinfo file in the temporary directory 79mv $REPO_TARBALL $TMP_TARBALL 80 81 82# Make the metadata file 83ZONEFILE_METADATA_NAME=zonefile_metadata_master.json 84${CITOOLS_DIR}/make_zonefile_metadata.py \ 85 $TARBALL_NAME \ 86 $VERSION \ 87 $ZONEFILE_METADATA_NAME 88 89python ${REPO_DIR}/updatezinfo.py $ZONEFILE_METADATA_NAME 90 91# Run the tests 92python -m pytest ${REPO_DIR}/dateutil/test 93 94