✨ feat(region): map timezones to regions
- ✨ one iso serves every region, so the installer derives it from the timezone the user already picks - ✅ reject unknown zones and zones claimed by two regions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuATgjU4mnqpqSLAKMQ14g
This commit is contained in:
1 parent
3e00a48c00
commit
0de49b231a
2 files changed
+35
-2
No files matched your search
@@ -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
|
||||||
@@ -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"
|
cmp "$ROOT/default/pacman/mirrorlist-stable" "$TARGET_ROOT/etc/pacman.d/mirrorlist"
|
||||||
pass "users can opt out of regional repository defaults"
|
pass "users can opt out of regional repository defaults"
|
||||||
|
|
||||||
# The shipped China profile is repository scaffolding only. Locale, timezone,
|
# The shipped China profile is repository defaults only. Language, locale, and
|
||||||
# and input defaults are separate changes built on the same mechanism.
|
# input methods follow the installer's language choice, not the region.
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -103,3 +103,27 @@ assert packages == {"archlinuxcn-keyring"}, packages
|
|||||||
assert not (region / "skel").exists()
|
assert not (region / "skel").exists()
|
||||||
PY
|
PY
|
||||||
pass "China profile adds only its repository keyring"
|
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"
|
||||||
Reference in new issue
Block a user