From 1454e04b7f6f663e1e2bc9d438de918dbf668e18 Mon Sep 17 00:00:00 2001 From: Kros Dai Date: Tue, 6 Oct 2026 16:33:24 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(region):=20default=20china=20i?= =?UTF-8?q?nstalls=20to=20`Asia/Shanghai`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - :sparkles: offline China first boots preselect `Asia/Shanghai` from the region profile instead of the top of the list - :memo: profiles may name a `timezone`; first-boot setup reads it for the region in `/etc/omarchy/region` Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SdXqTwm63rRMwotZ1xqLC8 --- bin/omarchy-provision-owner | 17 ++++++++++++++- default/regions/cn/timezone | 1 + docs/regions.md | 3 ++- test/shell.d/region-timezone-test.sh | 32 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 default/regions/cn/timezone create mode 100755 test/shell.d/region-timezone-test.sh diff --git a/bin/omarchy-provision-owner b/bin/omarchy-provision-owner index a1a22559..5b8f0d36 100755 --- a/bin/omarchy-provision-owner +++ b/bin/omarchy-provision-owner @@ -16,6 +16,7 @@ set -euo pipefail PROVISIONING_DIR=/var/lib/omarchy/provisioning OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}" LOG_FILE=/var/log/omarchy-provision-owner.log +REGION_MARKER=/etc/omarchy/region if (( EUID != 0 )); then echo "Error: omarchy-provision-owner must run as root" >&2 @@ -650,7 +651,21 @@ user_form() { omarchy_prompt_hostname || return $? step "Let's set your timezone..." - omarchy_prompt_timezone || return $? + omarchy_prompt_timezone "$(region_timezone)" || return $? +} + +# The zone a region profile preselects when there is no geo guess, which is +# every offline first boot. Reads the marker omarchy-apply-pacman reads; global, +# missing, or malformed regions offer nothing. +region_timezone() { + local region=global profile + if [[ -r $REGION_MARKER ]]; then + region=$(<"$REGION_MARKER") + fi + profile="$OMARCHY_PATH/default/regions/$region/timezone" + if [[ $region =~ ^[a-z]{2}$ && -r $profile ]]; then + head -n 1 "$profile" + fi } confirm_form() { diff --git a/default/regions/cn/timezone b/default/regions/cn/timezone new file mode 100644 index 00000000..421b7a4c --- /dev/null +++ b/default/regions/cn/timezone @@ -0,0 +1 @@ +Asia/Shanghai diff --git a/docs/regions.md b/docs/regions.md index 2bbf3d59..b7f330ff 100644 --- a/docs/regions.md +++ b/docs/regions.md @@ -20,13 +20,14 @@ Regional content comes from the same runtime used by the ISO: either the `--loca - `packages`: additional target packages, one name per line, with blank lines and `#` comments allowed. The builder merges these into the ISO's copy of `omarchy-base.packages`, so they are both included in the offline repository and installed on the target. The source manifest is not modified. - `pacman/`: repository fragments used by the runtime finalizer. The builder also adds the community repository to its writable online config to obtain regional packages; it does not change its Arch channel mirrors. +- `timezone` (optional): one zone name, such as `Asia/Shanghai`. The setup form preselects it in the timezone list when the network geo guess is unavailable, which is always the case offline. Both callers pass it: the ISO configurator from its copy of the profile, and first-boot setup from `default/regions//timezone` for the region in `/etc/omarchy/region`. A successful geo guess still wins, and the person can choose any other zone. - `skel/` (optional): new-user defaults. The ISO installer overlays these onto target `/etc/skel` after the base settings packages and before user creation, including installations that defer user creation until first boot. It never overlays existing home directories. For China, the builder installs `archlinuxcn-keyring` using the existing Arch trust chain before downloading other regional packages. Signature or keyring failures abort the build; no unverified keyserver trust or online signature bypass is added. The keyring is also installed on the target from the offline package set, then initialized and populated before online repositories are enabled. The ISO's existing offline repository verification policy is unchanged. ## Scope of the China profile -The China profile currently provides repository defaults only. System language (Simplified Chinese), timezone (Asia/Shanghai), and input-method defaults are planned as separate changes on top of this mechanism: `packages` and `skel/` carry them into the ISO, and the installer stages `skel/` before any user exists. +The China profile provides repository defaults and preselects `Asia/Shanghai` as the timezone. System language (Simplified Chinese) and input-method defaults are planned as separate changes on top of this mechanism: `packages` and `skel/` carry them into the ISO, and the installer stages `skel/` before any user exists. ## Remaining release validation diff --git a/test/shell.d/region-timezone-test.sh b/test/shell.d/region-timezone-test.sh new file mode 100755 index 00000000..8dea6e0b --- /dev/null +++ b/test/shell.d/region-timezone-test.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -euo pipefail +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +scratch=$(mktemp -d) +trap 'rm -rf "$scratch"' EXIT + +zone=$(<"$ROOT/default/regions/cn/timezone") +[[ $zone == "Asia/Shanghai" ]] || fail "China profile names Asia/Shanghai" +[[ -f /usr/share/zoneinfo/$zone ]] || fail "China profile timezone exists in tzdata" +pass "China profile defaults to an existing Asia/Shanghai zone" + +# Load the real region_timezone() from the first-boot command. +OMARCHY_PATH="$ROOT" +REGION_MARKER="$scratch/region" +eval "$(sed -n '/^region_timezone() {/,/^}/p' "$ROOT/bin/omarchy-provision-owner")" + +[[ -z $(region_timezone) ]] || fail "missing region marker offers no timezone" +for region in global CN ../cn zz ""; do + printf '%s\n' "$region" >"$REGION_MARKER" + [[ -z $(region_timezone) ]] || fail "region '$region' offers no timezone" +done +pass "global, unknown, and malformed regions offer no timezone" + +printf 'cn\n' >"$REGION_MARKER" +[[ $(region_timezone) == "Asia/Shanghai" ]] || fail "cn region offers Asia/Shanghai" +pass "cn region offers its profile timezone" + +grep -qF 'omarchy_prompt_timezone "$(region_timezone)"' "$ROOT/bin/omarchy-provision-owner" || + fail "first-boot setup passes the region timezone to the prompt" +pass "first-boot setup preselects the region timezone"