Record the installer's region choice during system setup
This commit is contained in:
1 parent
83d158ad07
commit
c86af5cea5
6 files changed
+68
-4
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
run_logged "$OMARCHY_INSTALL/config/region.sh"
|
||||||
run_logged "$OMARCHY_INSTALL/config/theme-system.sh"
|
run_logged "$OMARCHY_INSTALL/config/theme-system.sh"
|
||||||
run_logged "$OMARCHY_INSTALL/config/browser-policy.sh"
|
run_logged "$OMARCHY_INSTALL/config/browser-policy.sh"
|
||||||
run_logged "$OMARCHY_INSTALL/config/increase-lockout-limit.sh"
|
run_logged "$OMARCHY_INSTALL/config/increase-lockout-limit.sh"
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
case ${OMARCHY_REGION:-global} in
|
||||||
|
global)
|
||||||
|
rm -f /etc/omarchy/region
|
||||||
|
;;
|
||||||
|
china)
|
||||||
|
mkdir -p /etc/omarchy
|
||||||
|
echo china >/etc/omarchy/region
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown OMARCHY_REGION: $OMARCHY_REGION" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -18,8 +18,9 @@
|
|||||||
# so it never reaches the shell as SIGINT. Act on the status, never on a trap.
|
# so it never reaches the shell as SIGINT. Act on the status, never on a trap.
|
||||||
#
|
#
|
||||||
# Callers supply `notice <message> <seconds>` for validation feedback, and set
|
# Callers supply `notice <message> <seconds>` for validation feedback, and set
|
||||||
# the variables these prompts write: keyboard, keyboard_label, username,
|
# the variables these prompts write: region, keyboard, keyboard_label,
|
||||||
# password, password_confirmation, full_name, email_address, hostname, timezone.
|
# username, password, password_confirmation, full_name, email_address,
|
||||||
|
# hostname, timezone.
|
||||||
|
|
||||||
OMARCHY_FORM_BACK=1
|
OMARCHY_FORM_BACK=1
|
||||||
OMARCHY_FORM_SIGNAL=130
|
OMARCHY_FORM_SIGNAL=130
|
||||||
@@ -91,6 +92,15 @@ omarchy_username_taken() { return 1; }
|
|||||||
# by `status=$?`: one caller runs under `set -e`, where a cancelled prompt is a
|
# by `status=$?`: one caller runs under `set -e`, where a cancelled prompt is a
|
||||||
# failing assignment that would kill the script before the status is read.
|
# failing assignment that would kill the script before the status is read.
|
||||||
|
|
||||||
|
# China lists the .cn package mirrors first and sets up Chinese input.
|
||||||
|
omarchy_prompt_region() {
|
||||||
|
local choice status
|
||||||
|
choice=$(gum choose --selected "Global" --header "Select region" Global China) && status=0 || status=$?
|
||||||
|
((status == 0)) || return $status
|
||||||
|
|
||||||
|
region=${choice,,}
|
||||||
|
}
|
||||||
|
|
||||||
omarchy_prompt_keyboard() {
|
omarchy_prompt_keyboard() {
|
||||||
local choice status
|
local choice status
|
||||||
choice=$(printf '%s\n' "$OMARCHY_KEYBOARD_LAYOUTS" | cut -d'|' -f1 |
|
choice=$(printf '%s\n' "$OMARCHY_KEYBOARD_LAYOUTS" | cut -d'|' -f1 |
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ Progress source of truth for the `omarchycn` branches of `omarchy`, `omarchy-iso
|
|||||||
|
|
||||||
## Tasks
|
## Tasks
|
||||||
|
|
||||||
- [ ] T0 Branches and this list
|
- [x] T0 Branches and this list
|
||||||
- [ ] T1 China package sources (PRD 1): region state, `omarchy-region` reader, `default/region/china/pacman.sed`, applied by `omarchy-refresh-pacman` and `install/post-install/pacman.sh`; tests
|
- [x] T1 China package sources (PRD 1): region state, `omarchy-region` reader, `default/region/china/pacman.sed`, applied by `omarchy-refresh-pacman` and `install/post-install/pacman.sh`; tests
|
||||||
- [ ] T2 Region choice in the installer (PRD 2): `omarchy_prompt_region` in `setup-form.sh`, ISO configurator screen, orchestrator passes `OMARCHY_REGION`, `install/config/region.sh` records it
|
- [ ] T2 Region choice in the installer (PRD 2): `omarchy_prompt_region` in `setup-form.sh`, ISO configurator screen, orchestrator passes `OMARCHY_REGION`, `install/config/region.sh` records it
|
||||||
- [ ] T3 Input method (PRD 3): rime-ice-installer patch and PKGBUILD in omarchy-pkgs, IME packages in `omarchy-other.packages`, install-time package add, user step runs the installer from bundled assets, ISO build bundles assets and the package
|
- [ ] T3 Input method (PRD 3): rime-ice-installer patch and PKGBUILD in omarchy-pkgs, IME packages in `omarchy-other.packages`, install-time package add, user step runs the installer from bundled assets, ISO build bundles assets and the package
|
||||||
- [ ] T4 CJK fontconfig fix (PRD 4): rebuild PR 9693 on the current base
|
- [ ] T4 CJK fontconfig fix (PRD 4): rebuild PR 9693 on the current base
|
||||||
|
|||||||
@@ -54,3 +54,23 @@ if output=$("$region_bin" 2>&1); then
|
|||||||
fi
|
fi
|
||||||
[[ $output == "Unknown region in $region_file: mars" ]] || fail "an unknown region names the file and value" "$output"
|
[[ $output == "Unknown region in $region_file: mars" ]] || fail "an unknown region names the file and value" "$output"
|
||||||
pass "an unknown region fails and names the file and value"
|
pass "an unknown region fails and names the file and value"
|
||||||
|
|
||||||
|
region_setup="$test_tmp/region.sh"
|
||||||
|
sed "s|/etc/omarchy|$test_tmp/etc-omarchy|g" "$ROOT/install/config/region.sh" >"$region_setup"
|
||||||
|
|
||||||
|
OMARCHY_REGION=china bash -e "$region_setup"
|
||||||
|
[[ $(<"$test_tmp/etc-omarchy/region") == "china" ]] || fail "install records the China region"
|
||||||
|
pass "install records the China region"
|
||||||
|
|
||||||
|
OMARCHY_REGION=global bash -e "$region_setup"
|
||||||
|
[[ ! -e $test_tmp/etc-omarchy/region ]] || fail "install records Global by leaving no region file"
|
||||||
|
OMARCHY_REGION=china bash -e "$region_setup"
|
||||||
|
env -u OMARCHY_REGION bash -e "$region_setup"
|
||||||
|
[[ ! -e $test_tmp/etc-omarchy/region ]] || fail "an installer that passes no region installs Global"
|
||||||
|
pass "Global and an unset region leave no region file"
|
||||||
|
|
||||||
|
if output=$(OMARCHY_REGION=mars bash -e "$region_setup" 2>&1); then
|
||||||
|
fail "install rejects an unknown region" "$output"
|
||||||
|
fi
|
||||||
|
[[ $output == "Unknown OMARCHY_REGION: mars" ]] || fail "install names the unknown region" "$output"
|
||||||
|
pass "install rejects an unknown region"
|
||||||
@@ -61,6 +61,7 @@ trap 'if [[ ${FUNCNAME[0]:-} == "$PROMPT_FN" ]]; then printf "returned\n" >>"$MA
|
|||||||
|
|
||||||
"$PROMPT_FN"
|
"$PROMPT_FN"
|
||||||
|
|
||||||
|
printf 'region=%s\n' "${region:-}"
|
||||||
printf 'keyboard=%s\n' "${keyboard:-}"
|
printf 'keyboard=%s\n' "${keyboard:-}"
|
||||||
printf 'keyboard_label=%s\n' "${keyboard_label:-}"
|
printf 'keyboard_label=%s\n' "${keyboard_label:-}"
|
||||||
printf 'username=%s\n' "${username:-}"
|
printf 'username=%s\n' "${username:-}"
|
||||||
@@ -123,6 +124,25 @@ source "$ROOT/install/provisioning/setup-form.sh"
|
|||||||
fail "English (US) leads the keyboard layouts so gum choose opens on the default"
|
fail "English (US) leads the keyboard layouts so gum choose opens on the default"
|
||||||
pass "the form publishes the 0/1/130 status contract and leads with English (US)"
|
pass "the form publishes the 0/1/130 status contract and leads with English (US)"
|
||||||
|
|
||||||
|
# Region
|
||||||
|
|
||||||
|
run_prompt omarchy_prompt_region "0:China"
|
||||||
|
assert_status 0 "region prompt succeeds"
|
||||||
|
[[ $(field region) == "china" ]] || fail "region prompt stores China as china"
|
||||||
|
grep -qxF -- 'choose --selected Global --header Select region Global China' "$GUM_ARGS" || fail "region prompt offers Global then China and preselects Global"
|
||||||
|
run_prompt omarchy_prompt_region "0:Global"
|
||||||
|
[[ $(field region) == "global" ]] || fail "region prompt stores Global as global"
|
||||||
|
pass "region prompt maps Global and China to the stored region"
|
||||||
|
|
||||||
|
run_prompt omarchy_prompt_region "1:"
|
||||||
|
assert_status "$OMARCHY_FORM_BACK" "region prompt reports Esc as back"
|
||||||
|
assert_returned "region prompt survives Esc under set -e"
|
||||||
|
|
||||||
|
run_prompt omarchy_prompt_region "130:"
|
||||||
|
assert_status "$OMARCHY_FORM_SIGNAL" "region prompt reports Ctrl+C as the caller's signal"
|
||||||
|
assert_returned "region prompt survives Ctrl+C under set -e"
|
||||||
|
pass "region prompt propagates Esc and Ctrl+C without dying under set -e"
|
||||||
|
|
||||||
# Keyboard
|
# Keyboard
|
||||||
|
|
||||||
run_prompt omarchy_prompt_keyboard "0:German"
|
run_prompt omarchy_prompt_keyboard "0:German"
|
||||||
|
|||||||
Reference in new issue
Block a user