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

+36 -8
View File
@@ -6,8 +6,17 @@ NO_CACHE=""
KEEP_PKG_CACHE=""
LOCAL_OMARCHY_PATH=""
LOCAL_PKGS_PATH=""
OMARCHY_REGION="${OMARCHY_REGION:-global}"
while [[ $# -gt 0 ]]; do
case $1 in
--region)
OMARCHY_REGION="${2:-}"
if [[ $OMARCHY_REGION != "global" && $OMARCHY_REGION != "cn" ]]; then
echo "Error: --region requires global or cn (ISO 3166-1 alpha-2)." >&2
exit 1
fi
shift 2
;;
--no-cache)
NO_CACHE=1
shift
@@ -57,12 +66,17 @@ while [[ $# -gt 0 ]]; do
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--no-cache] [--keep-pkg-cache] [--no-boot-offer] [--debug] [--edge] [--dev|--rc] [--local-source <omarchy-checkout> <pkgs-checkout>]"
echo "Usage: $0 [--no-cache] [--keep-pkg-cache] [--no-boot-offer] [--debug] [--edge] [--dev|--rc] [--region global|cn] [--local-source <omarchy-checkout> <pkgs-checkout>]"
exit 1
;;
esac
done
if [[ $OMARCHY_REGION != "global" && $OMARCHY_REGION != "cn" ]]; then
echo "Error: unsupported region '$OMARCHY_REGION'. Expected global or cn." >&2
exit 1
fi
if [[ -n $LOCAL_OMARCHY_PATH ]]; then
[[ -d $LOCAL_OMARCHY_PATH ]] || { echo "Error: Omarchy checkout not found at $LOCAL_OMARCHY_PATH" >&2; exit 1; }
[[ -d $LOCAL_PKGS_PATH ]] || { echo "Error: pkgs checkout not found at $LOCAL_PKGS_PATH" >&2; exit 1; }
@@ -116,6 +130,10 @@ BUILD_SCRIPT="builder/build-iso.sh"
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
BUILD_RELEASE_PATH="$BUILD_ROOT/release"
mkdir -p "$BUILD_RELEASE_PATH"
# Each build writes into its own directory, so concurrent builds (such as a
# global and a regional one) never pick up and rename each other's ISO.
BUILD_OUT=$(mktemp -d "$BUILD_RELEASE_PATH/.build-XXXXXX")
trap 'rm -rf "$BUILD_OUT"' EXIT
OMARCHY_ISO_REF="${OMARCHY_ISO_REF:-quattro}"
OMARCHY_MIRROR="${OMARCHY_MIRROR:-stable}"
@@ -125,10 +143,11 @@ DOCKER_ARGS=(
--privileged
-e "OMARCHY_ISO_REF=$OMARCHY_ISO_REF"
-e "OMARCHY_MIRROR=$OMARCHY_MIRROR"
-e "OMARCHY_REGION=$OMARCHY_REGION"
-e "OMARCHY_INSTALL_DEBUG=${OMARCHY_INSTALL_DEBUG:-}"
-e "HOST_UID=$(id -u)"
-e "HOST_GID=$(id -g)"
-v "$BUILD_RELEASE_PATH/:/out/"
-v "$BUILD_OUT/:/out/"
-v "$BUILD_ROOT/$BUILD_SCRIPT:/$BUILD_SCRIPT:ro"
-v "$BUILD_ROOT/archiso:/archiso:ro"
-v "$BUILD_ROOT/builder:/builder:ro"
@@ -146,10 +165,14 @@ if [[ -d /var/cache/pacman/pkg ]]; then
DOCKER_ARGS+=(-v "/var/cache/pacman/pkg:/var/cache/pacman/pkg")
fi
# Mount the build cache directory where packages are downloaded. Channels use
# different package snapshots and must never share an offline mirror cache.
# Channels and regions must not share an offline mirror cache. Keep the
# existing global cache path and artifact suffix unchanged.
region_suffix=""
if [[ $OMARCHY_REGION != "global" ]]; then
region_suffix="-$OMARCHY_REGION"
fi
if [[ -z "$NO_CACHE" ]]; then
OFFLINE_REPO_BUILD_CACHE_DIR="$HOME/.cache/omarchy/iso_${OMARCHY_MIRROR}/airootfs/var/cache/omarchy"
OFFLINE_REPO_BUILD_CACHE_DIR="$HOME/.cache/omarchy/iso_${OMARCHY_MIRROR}${region_suffix}/airootfs/var/cache/omarchy"
mkdir -p "$OFFLINE_REPO_BUILD_CACHE_DIR"
DOCKER_ARGS+=(-v "$OFFLINE_REPO_BUILD_CACHE_DIR:/var/cache/airootfs/var/cache/omarchy")
else
@@ -168,9 +191,14 @@ fi
"${DOCKER[@]}" run "${DOCKER_ARGS[@]}" archlinux/archlinux:latest /$BUILD_SCRIPT
latest_iso=$(\ls -t "$BUILD_RELEASE_PATH"/*.iso | head -n1)
iso_ref="${latest_iso%.*}-$OMARCHY_ISO_REF.iso"
mv -f "$latest_iso" "$iso_ref"
built_isos=("$BUILD_OUT"/*.iso)
if (( ${#built_isos[@]} != 1 )) || [[ ! -f ${built_isos[0]} ]]; then
echo "Error: expected exactly one ISO in $BUILD_OUT" >&2
exit 1
fi
built_iso_name=$(basename "${built_isos[0]}" .iso)
iso_ref="$BUILD_RELEASE_PATH/$built_iso_name-${OMARCHY_ISO_REF}${region_suffix}.iso"
mv -f "${built_isos[0]}" "$iso_ref"
if [[ -z "${NO_BOOT_OFFER:-}" ]]; then
echo
+8 -8
View File
@@ -14,7 +14,7 @@
# Usage: omarchy-iso-test [release/omarchy.iso] [options]
#
# --encrypt Drive the encrypted install flow (default: unencrypted)
# --region REGION Pick global (default) or china on the first screen
# --region REGION Pick global (default) or cn on the first screen
# --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
@@ -87,8 +87,8 @@ if [[ ! -f ${ISO:-} ]]; then
exit 1
fi
if [[ $REGION != "global" && $REGION != "china" ]]; then
echo "--region must be global or china, not $REGION" >&2
if [[ $REGION != "global" && $REGION != "cn" ]]; then
echo "--region must be global or cn, not $REGION" >&2
exit 1
fi
@@ -96,10 +96,10 @@ omarchy-pkg-add qemu-full edk2-ovmf socat imagemagick tesseract tesseract-data-e
# After the region screen a China install reads in Chinese.
OCR_LANGS=eng
[[ $REGION == "china" ]] && OCR_LANGS=eng+chi_sim
[[ $REGION == "cn" ]] && OCR_LANGS=eng+chi_sim
# region_text <english> <chinese> picks the text a screen shows in this run.
region_text() {
if [[ $REGION == "china" ]]; then
if [[ $REGION == "cn" ]]; then
printf '%s' "$2"
else
printf '%s' "$1"
@@ -111,7 +111,7 @@ OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
BASE_NAME="$(basename "$ISO" .iso)"
$ENCRYPT && BASE_NAME+="-encrypted"
[[ $REGION == "china" ]] && BASE_NAME+="-china"
[[ $REGION == "cn" ]] && BASE_NAME+="-cn"
$PROVISION && BASE_NAME+="-provision"
BASE_DIR="$REPO_DIR/test-runs/$BASE_NAME"
RUN_DIR="$BASE_DIR/runs/$(date +%Y%m%d-%H%M%S)"
@@ -262,7 +262,7 @@ ocr_screen() {
[[ -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 == "china" ]]; then
if [[ $REGION == "cn" ]]; 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
@@ -648,7 +648,7 @@ drive_configurator() {
# Region comes first, Global preselected and China one row below.
wait_for_screen "Select region" 300
capture_console "success-installer-01-region"
[[ $REGION == "china" ]] && press down
[[ $REGION == "cn" ]] && press down
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.