diff --git a/bin/omarchy-iso-test b/bin/omarchy-iso-test index f4b7c4d..c3e08df 100755 --- a/bin/omarchy-iso-test +++ b/bin/omarchy-iso-test @@ -92,7 +92,19 @@ if [[ $REGION != "global" && $REGION != "china" ]]; then exit 1 fi -omarchy-pkg-add qemu-full edk2-ovmf socat imagemagick tesseract tesseract-data-eng +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. +OCR_LANGS=eng +[[ $REGION == "china" ]] && OCR_LANGS=eng+chi_sim +# region_text picks the text a screen shows in this run. +region_text() { + if [[ $REGION == "china" ]]; then + printf '%s' "$2" + else + printf '%s' "$1" + fi +} OVMF_CODE="/usr/share/edk2/x64/OVMF_CODE.4m.fd" OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd" @@ -249,7 +261,7 @@ ocr_screen() { screendump "$shot" [[ -s $shot ]] || return 0 magick "$shot" -colorspace gray -negate -resize 150% "$prepped" 2>/dev/null || return 0 - tesseract "$prepped" - --psm 6 2>/dev/null || true + tesseract "$prepped" - --psm 6 -l "$OCR_LANGS" 2>/dev/null || true } # Wait until the console shows the given text. Saves the offending screen as @@ -633,22 +645,23 @@ drive_configurator() { [[ $REGION == "china" ]] && press down press ret - # Keyboard follows; Ctrl+C there defers provisioning. - wait_for_screen "keyboard layout" 300 + # Keyboard follows; Ctrl+C there defers provisioning. China reruns the + # installer in cage + foot, so the next screens are Chinese. + wait_for_screen "$(region_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 "another owner" 30 + wait_for_screen "$(region_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 "install disk" 60 + wait_for_screen "$(region_text "install disk" "安装磁盘")" 60 capture_console "success-installer-03-prepare-install-disk" press ret - wait_for_screen "recovery possible" 60 + wait_for_screen "$(region_text "recovery possible" "无法恢复")" 60 capture_console "success-installer-04-prepare-disk-warning-encrypted" if ! $ENCRYPT; then press ctrl-c @@ -668,55 +681,55 @@ drive_configurator() { press ret # English (US) is preselected # Normal flow: user step comes before disk selection. - wait_for_screen "Username" 120 + wait_for_screen "$(region_text "Username" "用户名")" 120 type_text "$GUEST_USER" capture_console "success-installer-02-username" press ret - wait_for_screen "Password" 60 + wait_for_screen "$(region_text "Password" "密码")" 60 type_text "$GUEST_PASSWORD" capture_console "success-installer-03-password" press ret - wait_for_screen "Must match" 60 + wait_for_screen "$(region_text "Must match" "确认")" 60 type_text "$GUEST_PASSWORD" capture_console "success-installer-04-password-confirmation" press ret - wait_for_screen "Full name" 60 + wait_for_screen "$(region_text "Full name" "姓名")" 60 type_text "Omarchy Test" capture_console "success-installer-05-full-name" press ret - wait_for_screen "Email address" 60 + wait_for_screen "$(region_text "Email address" "邮箱")" 60 type_text "test@omarchy.org" capture_console "success-installer-06-email" press ret - wait_for_screen "Hostname" 60 + wait_for_screen "$(region_text "Hostname" "主机名")" 60 type_text "$GUEST_HOSTNAME" capture_console "success-installer-07-hostname" press ret - wait_for_screen "Timezone" 180 # tzupdate geo-guess can take a moment + wait_for_screen "$(region_text "Timezone" "时区")" 180 # tzupdate geo-guess can take a moment capture_console "success-installer-08-timezone" press ret - wait_for_screen "look right" 60 + wait_for_screen "$(region_text "look right" "正确")" 60 capture_console "success-installer-09-review" press ret - wait_for_screen "install disk" 60 + wait_for_screen "$(region_text "install disk" "安装磁盘")" 60 capture_console "success-installer-10-install-disk" press ret # the single virtio disk - wait_for_screen "installation mode\|recovery possible" 60 - if ocr_screen | grep -qi "installation mode"; then + wait_for_screen "$(region_text "installation mode\|recovery possible" "安装方式\|无法恢复")" 60 + if ocr_screen | grep -qi "$(region_text "installation mode" "安装方式")"; then capture_console "success-installer-11-install-mode" press ret # "Full disk install" is preselected fi - wait_for_screen "recovery possible" 60 + wait_for_screen "$(region_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 @@ -810,7 +823,7 @@ wait_for_install() { while true; do text=$(ocr_screen) - if grep -qi "Reboot Now" <<<"$text"; then + if grep -qi "$(region_text "Reboot Now" "立即重启")" <<<"$text"; then log "Install finished. Confirming the reboot prompt." capture_console "success-installer-15-reboot" press ret @@ -826,7 +839,7 @@ wait_for_install() { return 0 fi - if grep -qi "installation stopped" <<<"$text"; then + if grep -qi "$(region_text "installation stopped" "安装已停止")" <<<"$text"; then capture_console "failure-installer-installation-stopped" echo "Install failed — screenshot saved to $RUN_DIR" >&2 return 1