blob: b2f9507827eb863275c84b5b01133c85df19c3e4 [file] [log] [blame]
Neil Fullerc1a723a2020-08-10 16:55:37 +01001#!/usr/bin/env bash
2
3# Copyright 2020 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Fail fast on any error.
18set -e
19
Neil Fullere1fd8e72020-11-17 10:29:34 +000020# Ordered in reverse so duplicate known issues are reported against the smaller
21# city file.
22CITY_SIZES=(15000 5000 1000 500)
Neil Fullerc1a723a2020-08-10 16:55:37 +010023EXTERNAL_GEONAMES_DIR=${ANDROID_BUILD_TOP}/external/geonames
24SYSTEM_TIMEZONE_DIR=${ANDROID_BUILD_TOP}/system/timezone
Neil Fuller16368bb2021-01-27 16:27:24 +000025GEOTZ_DIR=${ANDROID_BUILD_TOP}/packages/modules/GeoTZ
26KNOWN_DIFFS_DIR=${GEOTZ_DIR}/validation/geonames/known_diffs
Neil Fullerc1a723a2020-08-10 16:55:37 +010027TMP_DIR=$(mktemp -d -t geonames-XXXXXXXXXX)
28COMPARISON_CMD=geotz_geonames_comparison
29
30if (( $# < 1 )); then
Neil Fullere1fd8e72020-11-17 10:29:34 +000031 echo "Usage: ${0} [500|1000|5000|15000]"
Neil Fullerc1a723a2020-08-10 16:55:37 +010032 echo
33 echo " The number determines the geonames file to use (500 means <= 500 population)"
34 echo " 500 is generally fine: This includes 1,000 and 15,000 population too."
35 exit 1
36fi
37
38CITY_SIZE=$1
39GEONAMES_CITIES_ZIP_FILE=${EXTERNAL_GEONAMES_DIR}/export/dump/cities${CITY_SIZE}.zip
40
41# Find the Java tool before we begin.
42if [[ -z $(which ${COMPARISON_CMD}) ]]; then
43 echo "${COMPARISON_CMD} not found. Not built?"
44 exit 1
45fi
46
47INPUT_DIR=${TMP_DIR}/input
48mkdir ${INPUT_DIR}
49
50OUTPUT_DIR=${TMP_DIR}/output
51mkdir ${OUTPUT_DIR}
52
53unzip ${GEONAMES_CITIES_ZIP_FILE} -d ${INPUT_DIR}
54GEONAMES_CITIES_TXT_FILE=${INPUT_DIR}/cities${CITY_SIZE}.txt
55
56KNOWN_DIFF_FILES=()
57for SIZE in ${CITY_SIZES[@]}; do
58 if (( "${SIZE}" >= ${CITY_SIZE} )); then
59 KNOWN_DIFF_FILE=${KNOWN_DIFFS_DIR}/known_diffs${SIZE}.prototxt
60 if [ -f ${KNOWN_DIFF_FILE} ]; then
61 KNOWN_DIFF_FILES+=(${KNOWN_DIFF_FILE})
62 fi
63 fi
64done
65KNOWN_DIFFS_ARG=$(IFS=,; echo "${KNOWN_DIFF_FILES[*]}")
66
67${COMPARISON_CMD} \
Neil Fuller16368bb2021-01-27 16:27:24 +000068 ${GEOTZ_DIR}/output_data/odbl/tzs2.dat \
Neil Fullerc1a723a2020-08-10 16:55:37 +010069 ${SYSTEM_TIMEZONE_DIR}/output_data/android/tzids.prototxt \
70 2020-01-01T00:00:00Z \
71 ${GEONAMES_CITIES_TXT_FILE} \
72 ${OUTPUT_DIR} \
73 "${KNOWN_DIFFS_ARG}"
74
75GEONAMES_SHA=$(git --git-dir=${EXTERNAL_GEONAMES_DIR}/.git rev-parse --short HEAD)
76echo ${EXTERNAL_GEONAMES_DIR} git SHA is: ${GEONAMES_SHA}