Neil Fuller | c1a723a | 2020-08-10 16:55:37 +0100 | [diff] [blame] | 1 | #!/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. |
| 18 | set -e |
| 19 | |
Neil Fuller | e1fd8e7 | 2020-11-17 10:29:34 +0000 | [diff] [blame] | 20 | # Ordered in reverse so duplicate known issues are reported against the smaller |
| 21 | # city file. |
| 22 | CITY_SIZES=(15000 5000 1000 500) |
Neil Fuller | c1a723a | 2020-08-10 16:55:37 +0100 | [diff] [blame] | 23 | EXTERNAL_GEONAMES_DIR=${ANDROID_BUILD_TOP}/external/geonames |
| 24 | SYSTEM_TIMEZONE_DIR=${ANDROID_BUILD_TOP}/system/timezone |
Neil Fuller | 16368bb | 2021-01-27 16:27:24 +0000 | [diff] [blame] | 25 | GEOTZ_DIR=${ANDROID_BUILD_TOP}/packages/modules/GeoTZ |
| 26 | KNOWN_DIFFS_DIR=${GEOTZ_DIR}/validation/geonames/known_diffs |
Neil Fuller | c1a723a | 2020-08-10 16:55:37 +0100 | [diff] [blame] | 27 | TMP_DIR=$(mktemp -d -t geonames-XXXXXXXXXX) |
| 28 | COMPARISON_CMD=geotz_geonames_comparison |
| 29 | |
| 30 | if (( $# < 1 )); then |
Neil Fuller | e1fd8e7 | 2020-11-17 10:29:34 +0000 | [diff] [blame] | 31 | echo "Usage: ${0} [500|1000|5000|15000]" |
Neil Fuller | c1a723a | 2020-08-10 16:55:37 +0100 | [diff] [blame] | 32 | 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 |
| 36 | fi |
| 37 | |
| 38 | CITY_SIZE=$1 |
| 39 | GEONAMES_CITIES_ZIP_FILE=${EXTERNAL_GEONAMES_DIR}/export/dump/cities${CITY_SIZE}.zip |
| 40 | |
| 41 | # Find the Java tool before we begin. |
| 42 | if [[ -z $(which ${COMPARISON_CMD}) ]]; then |
| 43 | echo "${COMPARISON_CMD} not found. Not built?" |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | INPUT_DIR=${TMP_DIR}/input |
| 48 | mkdir ${INPUT_DIR} |
| 49 | |
| 50 | OUTPUT_DIR=${TMP_DIR}/output |
| 51 | mkdir ${OUTPUT_DIR} |
| 52 | |
| 53 | unzip ${GEONAMES_CITIES_ZIP_FILE} -d ${INPUT_DIR} |
| 54 | GEONAMES_CITIES_TXT_FILE=${INPUT_DIR}/cities${CITY_SIZE}.txt |
| 55 | |
| 56 | KNOWN_DIFF_FILES=() |
| 57 | for 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 |
| 64 | done |
| 65 | KNOWN_DIFFS_ARG=$(IFS=,; echo "${KNOWN_DIFF_FILES[*]}") |
| 66 | |
| 67 | ${COMPARISON_CMD} \ |
Neil Fuller | 16368bb | 2021-01-27 16:27:24 +0000 | [diff] [blame] | 68 | ${GEOTZ_DIR}/output_data/odbl/tzs2.dat \ |
Neil Fuller | c1a723a | 2020-08-10 16:55:37 +0100 | [diff] [blame] | 69 | ${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 | |
| 75 | GEONAMES_SHA=$(git --git-dir=${EXTERNAL_GEONAMES_DIR}/.git rev-parse --short HEAD) |
| 76 | echo ${EXTERNAL_GEONAMES_DIR} git SHA is: ${GEONAMES_SHA} |