Make the first screen a language choice; Chinese gets the CJK console and zh_CN

The CJK console unpacks Noto Sans Mono CJK from the offline mirror instead
of shipping fonts in the live image, lists only US-keymap keyboards and
preselects Pinyin. The target's LANG comes through locale_config.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 00:15:06 -04:00
1 parent e8715fc888
commit 25cebcf3fd
7 files changed
+107 -74

No files matched your search

+49 -37
View File
@@ -17,7 +17,8 @@
# or Chinese (Simplified, Pinyin)/(Traditional, Zhuyin).
# OMARCHY_PATH must be the source tree used to build the ISO.
# --encrypt Drive the encrypted install flow (default: unencrypted)
# --region REGION Pick global (default) or cn on the first screen
# --language LANG Pick en (default) or zh on the first screen; zh keeps the
# preselected Chinese (Simplified, Pinyin) keyboard
# --provision Drive the deferred-provisioning install flow: no user during install, the
# first boot runs omarchy-provision-owner and creates it there
# --reuse-base Skip the install phase if a base image already exists
@@ -43,7 +44,7 @@ MEMORY=8192
INSTALL_TIMEOUT=2400
BOOT_TIMEOUT=600
ENCRYPT=false
REGION=global
INSTALL_LANGUAGE=en
PROVISION=false
REUSE_BASE=false
INSTALL_ONLY=false
@@ -61,7 +62,7 @@ while (($#)); do
case "$1" in
--keyboard) KEYBOARD_LABEL="$2"; shift ;;
--encrypt) ENCRYPT=true ;;
--region) REGION="$2"; shift ;;
--language) INSTALL_LANGUAGE="$2"; shift ;;
--provision) PROVISION=true ;;
--reuse-base) REUSE_BASE=true ;;
--install-only) INSTALL_ONLY=true ;;
@@ -92,8 +93,12 @@ if [[ ! -f ${ISO:-} ]]; then
exit 1
fi
if [[ $REGION != "global" && $REGION != "cn" ]]; then
echo "--region must be global or cn, not $REGION" >&2
if [[ $INSTALL_LANGUAGE != "en" && $INSTALL_LANGUAGE != "zh" ]]; then
echo "--language must be en or zh, not $INSTALL_LANGUAGE" >&2
exit 1
fi
if [[ $INSTALL_LANGUAGE == "zh" && $KEYBOARD_LABEL != "English (US)" ]]; then
echo "--language zh takes the preselected Pinyin keyboard; drop --keyboard" >&2
exit 1
fi
case "$KEYBOARD_LABEL" in
@@ -103,12 +108,12 @@ esac
omarchy-pkg-add qemu-full edk2-ovmf socat imagemagick tesseract tesseract-data-eng tesseract-data-chi_sim
# After the region screen a China install reads in Chinese.
# After the language screen a Chinese install reads in Chinese.
OCR_LANGS=eng
[[ $REGION == "cn" ]] && OCR_LANGS=eng+chi_sim
# region_text <english> <chinese> picks the text a screen shows in this run.
region_text() {
if [[ $REGION == "cn" ]]; then
[[ $INSTALL_LANGUAGE == "zh" ]] && OCR_LANGS=eng+chi_sim
# lang_text <english> <chinese> picks the text a screen shows in this run.
lang_text() {
if [[ $INSTALL_LANGUAGE == "zh" ]]; then
printf '%s' "$2"
else
printf '%s' "$1"
@@ -123,7 +128,7 @@ if [[ $KEYBOARD_LABEL != "English (US)" ]]; then
BASE_NAME+="-$(printf '%s' "$KEYBOARD_LABEL" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')"
fi
$ENCRYPT && BASE_NAME+="-encrypted"
[[ $REGION == "cn" ]] && BASE_NAME+="-cn"
[[ $INSTALL_LANGUAGE == "zh" ]] && BASE_NAME+="-zh"
$PROVISION && BASE_NAME+="-provision"
BASE_DIR="$REPO_DIR/test-runs/$BASE_NAME"
RUN_DIR="$BASE_DIR/runs/$(date +%Y%m%d-%H%M%S)"
@@ -273,8 +278,8 @@ ocr_screen() {
screendump "$shot"
[[ -s $shot ]] || return 0
magick "$shot" -colorspace gray -negate -resize 150% "$prepped" 2>/dev/null || return 0
# The logo and the black strip under foot throw tesseract off CJK, so China runs also read between them, without spaces.
if [[ $REGION == "cn" ]]; then
# The logo and the black strip under foot throw tesseract off CJK, so Chinese runs also read between them, without spaces.
if [[ $INSTALL_LANGUAGE == "zh" ]]; then
magick "$shot" -gravity north -chop 0x35% -gravity south -chop 0x4% -colorspace gray -negate -resize 150% "$prepped.text.png" 2>/dev/null || return 0
{ tesseract "$prepped" - --psm 6 -l "$OCR_LANGS"; tesseract "$prepped.text.png" - --psm 6 -l "$OCR_LANGS"; } 2>/dev/null | sed 'p; s/ //g' || true
else
@@ -686,28 +691,35 @@ drive_configurator() {
capture_console "success-installer-00-greeter"
press ret
# Region comes first: Global on top, China below, either one preselected.
wait_for_screen "Select region" 300
capture_console "success-installer-01-region"
if [[ $REGION == "cn" ]]; then press end; else press home; fi
# Language comes first: English on top, Chinese below.
wait_for_screen "Select language" 300
capture_console "success-installer-01-language"
if [[ $INSTALL_LANGUAGE == "zh" ]]; then press end; else press home; fi
press ret
# Global asks for the keyboard; China reruns in cage + foot on a bilingual region screen with a US keyboard. Ctrl+C on either defers provisioning.
wait_for_screen "$(region_text "keyboard layout" "选择区域")" 300
# Chinese reruns in cage + foot on a bilingual language screen, Chinese preselected.
if [[ $INSTALL_LANGUAGE == "zh" ]]; then
wait_for_screen "选择语言" 300
capture_console "success-installer-01-language-cjk"
press ret
fi
# The keyboard follows; Ctrl+C there defers provisioning.
wait_for_screen "$(lang_text "keyboard layout" "键盘布局")" 300
capture_console "success-installer-01-keyboard-layout"
if $PROVISION; then
press ctrl-c # arm "prepare for another owner"
wait_for_screen "$(region_text "another owner" "另一位")" 30
wait_for_screen "$(lang_text "another owner" "另一位")" 30
capture_console "success-installer-02-prepare-confirm"
press ret # "Yes, prepare for another owner" is the affirmative default
# Jumps straight to disk selection, then the overwrite confirm.
wait_for_screen "$(region_text "install disk" "安装磁盘")" 60
wait_for_screen "$(lang_text "install disk" "安装磁盘")" 60
capture_console "success-installer-03-prepare-install-disk"
press ret
wait_for_screen "$(region_text "recovery possible" "无法恢复")" 60
wait_for_screen "$(lang_text "recovery possible" "无法恢复")" 60
capture_console "success-installer-04-prepare-disk-warning-encrypted"
if ! $ENCRYPT; then
press ctrl-c
@@ -731,27 +743,27 @@ drive_configurator() {
press ret
# Normal flow: user step comes before disk selection.
wait_for_screen "$(region_text "Username" "用户名")" 120
wait_for_screen "$(lang_text "Username" "用户名")" 120
type_text "$GUEST_USER"
capture_console "success-installer-02-username"
press ret
wait_for_screen "$(region_text "Password" "密码")" 60
wait_for_screen "$(lang_text "Password" "密码")" 60
type_text "$GUEST_PASSWORD"
capture_console "success-installer-03-password"
press ret
wait_for_screen "$(region_text "Must match" "确认")" 60
wait_for_screen "$(lang_text "Must match" "确认")" 60
type_text "$GUEST_PASSWORD"
capture_console "success-installer-04-password-confirmation"
press ret
wait_for_screen "$(region_text "Full name" "姓名")" 60
wait_for_screen "$(lang_text "Full name" "姓名")" 60
type_text "Omarchy Test"
capture_console "success-installer-05-full-name"
press ret
wait_for_screen "$(region_text "Email address" "邮箱")" 60
wait_for_screen "$(lang_text "Email address" "邮箱")" 60
type_text "test"
if [[ $KEYBOARD_LABEL == "Japanese" ]]; then
press bracket_left
@@ -764,30 +776,30 @@ drive_configurator() {
capture_console "success-installer-06-email"
press ret
wait_for_screen "$(region_text "Hostname" "主机名")" 60
wait_for_screen "$(lang_text "Hostname" "主机名")" 60
type_text "$GUEST_HOSTNAME"
capture_console "success-installer-07-hostname"
press ret
wait_for_screen "$(region_text "Timezone" "时区")" 180 # tzupdate geo-guess can take a moment
wait_for_screen "$(lang_text "Timezone" "时区")" 180 # tzupdate geo-guess can take a moment
capture_console "success-installer-08-timezone"
press ret
wait_for_screen "$(region_text "look right" "正确")" 60
wait_for_screen "$(lang_text "look right" "正确")" 60
capture_console "success-installer-09-review"
press ret
wait_for_screen "$(region_text "install disk" "安装磁盘")" 60
wait_for_screen "$(lang_text "install disk" "安装磁盘")" 60
capture_console "success-installer-10-install-disk"
press ret # the single virtio disk
wait_for_screen "$(region_text "installation mode\|recovery possible" "安装方式\|无法恢复")" 60
if ocr_screen | grep -qi "$(region_text "installation mode" "安装方式")"; then
wait_for_screen "$(lang_text "installation mode\|recovery possible" "安装方式\|无法恢复")" 60
if ocr_screen | grep -qi "$(lang_text "installation mode" "安装方式")"; then
capture_console "success-installer-11-install-mode"
press ret # "Full disk install" is preselected
fi
wait_for_screen "$(region_text "recovery possible" "无法恢复")" 60
wait_for_screen "$(lang_text "recovery possible" "无法恢复")" 60
capture_console "success-installer-12-disk-warning-encrypted"
if ! $ENCRYPT; then
press ctrl-c # toggles the confirm to the unencrypted flow
@@ -891,8 +903,8 @@ wait_for_install() {
while true; do
text=$(ocr_screen)
# OCR cannot read the Chinese reboot button, so China matches the title above it.
if grep -qi "$(region_text "Reboot Now" "安装完成")" <<<"$text"; then
# OCR cannot read the Chinese reboot button, so Chinese runs match the title above it.
if grep -qi "$(lang_text "Reboot Now" "安装完成")" <<<"$text"; then
log "Install finished. Confirming the reboot prompt."
capture_console "success-installer-15-reboot"
press ret
@@ -908,7 +920,7 @@ wait_for_install() {
return 0
fi
if grep -qi "$(region_text "installation stopped" "安装已停止")" <<<"$text"; then
if grep -qi "$(lang_text "installation stopped" "安装已停止")" <<<"$text"; then
capture_console "failure-installer-installation-stopped"
echo "Install failed — screenshot saved to $RUN_DIR" >&2
return 1