Merge omacom/omarchy-iso#236 regional ISO builds, as an install-time choice

Every ISO bundles the cn profile; the first-screen pick decides. --region cn
only preselects China and names the artifact. The region value is cn, the cn
timezone is preselected when China is chosen, and the profile packages and
ArchLinuxCN keyring reach the target only for China.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 11:32:14 -04:00
commit 02ee068504
12 files changed
+492 -50

No files matched your search

+3 -3
View File
@@ -116,7 +116,7 @@ else
mkdir -p -m 700 "$cjk_runtime"
rm -f "$cjk_runtime/cjk-console-started" "$cjk_runtime/return-to-vt"
cage_status=0
env -u OMARCHY_CJK_RELAUNCH XDG_RUNTIME_DIR=$cjk_runtime OMARCHY_CJK_CONSOLE=1 OMARCHY_INSTALL_REGION=china \
env -u OMARCHY_CJK_RELAUNCH XDG_RUNTIME_DIR=$cjk_runtime OMARCHY_CJK_CONSOLE=1 OMARCHY_INSTALL_REGION=cn \
LANG=C.UTF-8 WLR_RENDERER=pixman cage -- foot -c /usr/share/omarchy-iso/foot.ini "$0" || cage_status=$?
if [[ -f $cjk_runtime/return-to-vt ]]; then
OMARCHY_INSTALL_REGION=global ./configurator && status=0 || status=$?
@@ -125,7 +125,7 @@ else
else
echo "The Chinese console could not start (cage exit $cage_status); continuing in English."
unset OMARCHY_CJK_RELAUNCH
OMARCHY_INSTALL_REGION=china ./configurator && status=0 || status=$?
OMARCHY_INSTALL_REGION=cn ./configurator && status=0 || status=$?
fi
done
if [[ -n ${OMARCHY_CJK_CONSOLE:-} ]] && ((status == vt_return)); then
@@ -145,7 +145,7 @@ if [[ -f /root/defer-provisioning ]] ||
export OMARCHY_UI_DEFER_PROVISIONING=yes
fi
if [[ -n ${OMARCHY_CJK_CONSOLE:-} && "$(jq -r '.omarchy_install.region // "global"' /root/user_configuration.json)" == "china" ]]; then
if [[ -n ${OMARCHY_CJK_CONSOLE:-} && "$(jq -r '.omarchy_install.region // "global"' /root/user_configuration.json)" == "cn" ]]; then
export OMARCHY_INSTALL_LANG=zh
fi
+18 -7
View File
@@ -91,6 +91,15 @@ OMARCHY_ZH+=(
["Everything will be overwritten. There is no recovery possible."]="磁盘上的一切都会被覆盖,无法恢复。"
["Confirm overwriting %s"]="确认覆盖 %s"
)
# Every ISO carries the cn profile here (builder/prepare-region.sh copies it);
# China preselects its timezone when there is no geo guess, which is every
# offline install.
REGION_TIMEZONE="${REGION_TIMEZONE:-/usr/share/omarchy-iso/region/timezone}"
region_timezone() {
if [[ $region == "cn" ]]; then
head -n 1 "$REGION_TIMEZONE"
fi
}
# Partition creation helpers, shared with test/partition-numbering-test.sh so
# the numbering logic can be exercised without a real disk.
@@ -273,13 +282,13 @@ notice() {
# .automated_script.sh moves China into the CJK console and Global back to the VT, which applies keymaps.
apply_region_language() {
if [[ $region == "china" && -n ${OMARCHY_CJK_RELAUNCH:-} ]]; then
if [[ $region == "cn" && -n ${OMARCHY_CJK_RELAUNCH:-} ]]; then
exit "$OMARCHY_CJK_RELAUNCH"
fi
if [[ $region == "global" && -n ${OMARCHY_VT_RETURN:-} ]]; then
exit "$OMARCHY_VT_RETURN"
fi
if [[ $region == "china" && -n ${OMARCHY_CJK_CONSOLE:-} ]]; then
if [[ $region == "cn" && -n ${OMARCHY_CJK_CONSOLE:-} ]]; then
export OMARCHY_INSTALL_LANG=zh
else
unset OMARCHY_INSTALL_LANG
@@ -363,7 +372,7 @@ user_form() {
omarchy_prompt_identity || return $?
omarchy_prompt_hostname || return $?
omarchy_prompt_timezone || return $?
omarchy_prompt_timezone "$(region_timezone)" || return $?
}
# Returns 0 on confirmed account details, or as soon as the keyboard screen
@@ -384,8 +393,9 @@ user_step() {
fi
# Add manual padding since gum table -p doesn't respect padding
local skipped
local skipped region_label=Global
skipped=$(omarchy_text "[Skipped]")
[[ $region == "cn" ]] && region_label=China
echo -e "$(omarchy_text Field),$(omarchy_text Value)
$(omarchy_text Username),$username
$(omarchy_text Password),$(printf "%${#password}s" | tr ' ' '*')
@@ -394,7 +404,7 @@ $(omarchy_text "Email address"),${email_address:-$skipped}
$(omarchy_text Hostname),$hostname
$(omarchy_text Timezone),$timezone
$(omarchy_text Keyboard),$keyboard
$(omarchy_text Region),$(omarchy_text "${region^}")" |
$(omarchy_text Region),$(omarchy_text "$region_label")" |
gum table -s "," -p | sed "s/^/${PADDING_LEFT_SPACES}/"
echo
@@ -1131,8 +1141,9 @@ select_installation() {
defer_provisioning=false
install_target="full_disk"
# A rerun in the other console arrives with the region already chosen.
region="${OMARCHY_INSTALL_REGION:-global}"
# A rerun in the other console arrives with the region already chosen; a
# regional build preselects its own.
region="${OMARCHY_INSTALL_REGION:-$(<"${ISO_REGION_FILE:-/root/omarchy_region}")}"
# Let the live VT reach its settled width before the first screen so the logo
# isn't measured against the transient 80-column boot console.
@@ -67,8 +67,8 @@ class InstallContext:
# Autoinstall configs written before regions existed install Global.
region = omarchy_install.get("region", "global")
if region not in ("global", "china"):
raise RuntimeError(f"omarchy_install.region must be global or china, not {region!r}")
if region not in ("global", "cn"):
raise RuntimeError(f"omarchy_install.region must be global or cn, not {region!r}")
omarchy_install["region"] = region
if creds_path.exists():
@@ -39,6 +39,32 @@ from .keyboard import configure_keyboard
from .ui import error, info
ISO_REGION_PAYLOAD = Path("/usr/share/omarchy-iso/region")
def _region_packages(ctx: InstallContext) -> list[str]:
if ctx.omarchy_install["region"] != "cn":
return []
lines = (ISO_REGION_PAYLOAD / "packages").read_text().splitlines()
return [s for s in (raw.strip() for raw in lines) if s and not s.startswith("#")]
def _stage_region_defaults(ctx: InstallContext) -> None:
"""Seed the target before useradd, including deferred first-boot users.
Region is a bootstrap default, not a locale or a user-level policy.
Existing home directories are never rewritten by this step.
"""
region = ctx.omarchy_install["region"]
skel = ISO_REGION_PAYLOAD / "skel"
if region == "cn" and skel.is_dir():
shutil.copytree(skel, ctx.target / "etc/skel", dirs_exist_ok=True)
marker = ctx.target / "etc/omarchy/region"
marker.parent.mkdir(parents=True, exist_ok=True)
marker.write_text(region + "\n")
marker.chmod(0o644)
# Package targets are written by builder/build-iso.sh. Stable ISOs use the
# stable package names, while dev/local-source ISOs install the dev package
# names explicitly instead of relying on provides=omarchy resolution.
@@ -286,6 +312,7 @@ def arch_install_system(ctx: InstallContext) -> None:
_install_early_packages(installer)
_configure_limine_boot(ctx, installer, config)
_stage_region_defaults(ctx)
info("› creating user (with /etc/skel populated)")
if config.auth_config and config.auth_config.users:
installer.create_users(config.auth_config.users)
@@ -746,6 +773,7 @@ def _runtime_package_list(ctx: InstallContext) -> list[str]:
continue
if s not in already_installed and s not in pkgs:
pkgs.append(s)
pkgs += [p for p in _region_packages(ctx) if p not in pkgs]
# Local builds live only in this ISO's mirror; a later region switch could not fetch them.
if PINNED_PACKAGES.exists():
pkgs += [p for p in PINNED_PACKAGES.read_text().split() if p not in already_installed and p not in pkgs]
@@ -1138,6 +1166,13 @@ def _run_target_setup_command(ctx: InstallContext, cmd: list[str], *, user: str
def run_system_finalizer(ctx: InstallContext) -> None:
# The runtime package transaction has installed the regional keyring from
# the ISO. Initialize the target's trust database before enabling the online
# community repository; the build container's GPG state is not inherited.
if ctx.omarchy_install["region"] == "cn":
_run_target_setup_command(ctx, ["pacman-key", "--init"])
_run_target_setup_command(ctx, ["pacman-key", "--populate", "archlinux", "archlinuxcn"])
if ctx.defer_provisioning:
cmd = ["/usr/bin/omarchy-apply-system", "--defer-provisioning", "--first-install"]
else: