carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env bash
2# scripts/update-tzgeo.sh <version>, e.g. 2026b
3#
4# Refreshes internal/geo/data from one IANA tzdata release
5# (nearest-region spec §6.2). zone.tab carries the coordinates; the Link
6# lines resolve the old names browsers still report (Asia/Calcutta). Run it
7# as a release-checklist step beside the Go toolchain bump; a stale table
8# only misses zone names newer than it, and those fall through to IP.
9set -euo pipefail
10# Paul Eggert's tzdata signing key: the only signer this script accepts.
11tz_signer=7E3792A9D8ACF7D633BC1588ED97E90E62AA7E34
12v="${1:?usage: update-tzgeo.sh <tzdata version, e.g. 2026b>}"
13here="$(cd "$(dirname "$0")/.." && pwd)"
14out="$here/internal/geo/data"
15work="$(mktemp -d "${TMPDIR:-/tmp}/tzgeo.XXXXXX")"
16trap 'rm -rf "$work"' EXIT
17base="https://data.iana.org/time-zones/releases"
18curl -fsSL -o "$work/tzdata.tar.gz" "$base/tzdata$v.tar.gz"
19curl -fsSL -o "$work/tzdata.tar.gz.asc" "$base/tzdata$v.tar.gz.asc"
20if command -v gpg >/dev/null; then
21 status="$(gpg --status-fd 1 --verify "$work/tzdata.tar.gz.asc" "$work/tzdata.tar.gz")"
22 # VALIDSIG's 12th field is the signing key's primary fingerprint. An
23 # expired key still gives VALIDSIG, which is fine: the signature predates it.
24 printf '%s\n' "$status" |
25 awk -v fp="$tz_signer" '$2 == "VALIDSIG" && $12 == fp { ok = 1 } END { exit !ok }' || exit 1
26else
27 echo "gpg not found: signature NOT checked" >&2
28 exit 1
29fi
30tar -xzf "$work/tzdata.tar.gz" -C "$work"
31mkdir -p "$out"
32cp "$work/zone.tab" "$out/zone.tab"
33awk '$1 == "Link" { print $2, $3 }' \
34 "$work"/africa "$work"/antarctica "$work"/asia "$work"/australasia \
35 "$work"/backward "$work"/etcetera "$work"/europe "$work"/northamerica \
36 "$work"/southamerica | sort -u > "$out/links.txt"
37printf '%s\n' "$v" > "$out/VERSION"
38echo "internal/geo/data refreshed to tzdata $v"
39