From 0de49b231aa9bee8d007a0cee8ef43a10acfbe9f Mon Sep 17 00:00:00 2001 From: Kros Dai Date: Thu, 8 Oct 2026 15:03:41 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(region):=20map=20timezones=20t?= =?UTF-8?q?o=20regions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - :sparkles: one iso serves every region, so the installer derives it from the timezone the user already picks - :white_check_mark: reject unknown zones and zones claimed by two regions Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QuATgjU4mnqpqSLAKMQ14g --- default/regions/cn/timezones | 9 +++++++++ test/shell.d/region-pacman-test.sh | 28 ++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 default/regions/cn/timezones diff --git a/default/regions/cn/timezones b/default/regions/cn/timezones new file mode 100644 index 00000000..2520c323 --- /dev/null +++ b/default/regions/cn/timezones @@ -0,0 +1,9 @@ +# Installs in these timezones get this region. The installer's timezone list +# includes tzdata's backward-compatible names, so they are listed too. +Asia/Shanghai +Asia/Urumqi +Asia/Chongqing +Asia/Chungking +Asia/Harbin +Asia/Kashgar +PRC diff --git a/test/shell.d/region-pacman-test.sh b/test/shell.d/region-pacman-test.sh index d183e674..92b394ef 100644 --- a/test/shell.d/region-pacman-test.sh +++ b/test/shell.d/region-pacman-test.sh @@ -91,8 +91,8 @@ cmp "$ROOT/default/pacman/pacman-stable.conf" "$TARGET_ROOT/etc/pacman.conf" cmp "$ROOT/default/pacman/mirrorlist-stable" "$TARGET_ROOT/etc/pacman.d/mirrorlist" pass "users can opt out of regional repository defaults" -# The shipped China profile is repository scaffolding only. Locale, timezone, -# and input defaults are separate changes built on the same mechanism. +# The shipped China profile is repository defaults only. Language, locale, and +# input methods follow the installer's language choice, not the region. python3 - <<'PY' import os from pathlib import Path @@ -103,3 +103,27 @@ assert packages == {"archlinuxcn-keyring"}, packages assert not (region / "skel").exists() PY pass "China profile adds only its repository keyring" + +# The installer derives the region from the chosen timezone, so every profile +# needs a mapping, and no timezone may select two regions. +python3 - <<'PY' +import os +from pathlib import Path + +zoneinfo = Path("/usr/share/zoneinfo") +owners = {} +for profile in sorted((Path(os.environ["ROOT"]) / "default/regions").iterdir()): + lines = (profile / "timezones").read_text().splitlines() + zones = [line.strip() for line in lines if line.strip() and not line.startswith("#")] + assert zones, f"{profile.name} maps no timezones" + for zone in zones: + assert zone not in owners, f"{zone} maps to {owners[zone]} and {profile.name}" + owners[zone] = profile.name + if zoneinfo.is_dir(): + assert (zoneinfo / zone).is_file(), f"{profile.name} lists unknown timezone {zone}" + +china = {zone for zone, region in owners.items() if region == "cn"} +assert {"Asia/Shanghai", "Asia/Urumqi"} <= china, china +assert not china & {"Asia/Hong_Kong", "Asia/Macau", "Asia/Taipei"}, china +PY +pass "region profiles map each timezone to at most one region"