Compare commits
83
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
595d38cb04 | ||
|
|
073f7b2fc0 | ||
|
|
d02dee7e73 | ||
|
|
36b072ce76 | ||
|
|
fe133bd419 | ||
|
|
89a34f7885 | ||
|
|
37f71a0efb | ||
|
|
84149ef33b | ||
|
|
57df34ddfc | ||
|
|
6aef3008c1 | ||
|
|
1ad8872146 | ||
|
|
e7774eeeaf | ||
|
|
82d5693395 | ||
|
|
1ca5e5a7a3 | ||
|
|
86c07785cb | ||
|
|
9373d0e139 | ||
|
|
555c364221 | ||
|
|
7cfb7111a0 | ||
|
|
1daf1202d4 | ||
|
|
47426693de | ||
|
|
b507a20b7e | ||
|
|
447f6d2e58 | ||
|
|
a23f8d464d | ||
|
|
6f5ab0bcd1 | ||
|
|
2f5af06895 | ||
|
|
2673c613d9 | ||
|
|
d6e4060d56 | ||
|
|
100a41f7fd | ||
|
|
f9be60b24b | ||
|
|
222a742daf | ||
|
|
9900e63bd4 | ||
|
|
37fd3c4305 | ||
|
|
e89c0796f7 | ||
|
|
0b2739a55d | ||
|
|
9a7325e3a6 | ||
|
|
bba81a6ec5 | ||
|
|
6b5ce68f25 | ||
|
|
02f8d1cf50 | ||
|
|
3559b2bc9d | ||
|
|
d2e764d317 | ||
|
|
268bac16d3 | ||
|
|
6d02625f7f | ||
|
|
df80b320cb | ||
|
|
0c1333837f | ||
|
|
10bd6632d3 | ||
|
|
174dd82b15 | ||
|
|
7d3b01eae9 | ||
|
|
7c50d72f40 | ||
|
|
d6cd2d30a6 | ||
|
|
be618cc73b | ||
|
|
a6a442b9a0 | ||
|
|
e5f2b466ef | ||
|
|
a12bfea7a8 | ||
|
|
8b3dcc68b2 | ||
|
|
22eb81ebf5 | ||
|
|
8858ac2544 | ||
|
|
6b2f8a6ac7 | ||
|
|
6004e80485 | ||
|
|
0339b13d12 | ||
|
|
4d10233371 | ||
|
|
c9d445cf33 | ||
|
|
f11a70c6ba | ||
|
|
be68a76a44 | ||
|
|
69ec1b4b8e | ||
|
|
dd5c53cd3c | ||
|
|
e8a7e3cfce | ||
|
|
7e782bb7cf | ||
|
|
5f601f2c54 | ||
|
|
b323a4cf08 | ||
|
|
a4ec97d174 | ||
|
|
f5aa88b06c | ||
|
|
f66b6fc28e | ||
|
|
17532793fd | ||
|
|
0b4d74f6af | ||
|
|
a76f599eaa | ||
|
|
64152dda3f | ||
|
|
56eb451b92 | ||
|
|
d64ffb0e00 | ||
|
|
5b626d2a92 | ||
|
|
3efdb5c94b | ||
|
|
b3cf0c6f29 | ||
|
|
0631c0530a | ||
|
|
ed710a3b41 |
No files matched your search
@@ -0,0 +1,118 @@
|
||||
name: Install test comment
|
||||
|
||||
# Posts the install test's numbers on the pull request as one comment, kept
|
||||
# up to date on every run, next to quattro's latest numbers. GitHub runs
|
||||
# workflow_run workflows from the default branch, with write access even for
|
||||
# pull requests from forks, so this job never checks out or runs pull request
|
||||
# code: it only reads the finished run's artifact, as data.
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Install test"]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
REPO: ${{ github.repository }}
|
||||
RUN_ID: ${{ github.event.workflow_run.id }}
|
||||
RUN_URL: ${{ github.event.workflow_run.html_url }}
|
||||
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
|
||||
steps:
|
||||
# A rerun keeps earlier attempts' artifacts under the same run, so take
|
||||
# exactly the attempt that finished (and the baseline's latest attempt).
|
||||
- name: Fetch this run's numbers and quattro's latest
|
||||
env:
|
||||
ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
|
||||
run: |
|
||||
gh run download "$RUN_ID" -R "$REPO" -n "install-test-$RUN_ID-$ATTEMPT" -D pr || true
|
||||
base=$(gh run list -R "$REPO" --workflow install-test.yml --branch quattro --event push \
|
||||
--status success -L 1 --json databaseId -q '.[0].databaseId')
|
||||
if [ -n "$base" ]; then
|
||||
base_attempt=$(gh api "repos/$REPO/actions/runs/$base" -q .run_attempt)
|
||||
gh run download "$base" -R "$REPO" -n "install-test-$base-$base_attempt" -D base || true
|
||||
fi
|
||||
|
||||
- name: Comment on the pull request
|
||||
run: |
|
||||
set -euo pipefail
|
||||
marker='<!-- omarchy-install-test -->'
|
||||
|
||||
# The number comes from the pull request's own run, so trust it only
|
||||
# when that pull request's head is the commit this run tested.
|
||||
pr=$({ find pr -name pr-number -exec cat {} + 2>/dev/null || true; } | head -1 | tr -dc 0-9)
|
||||
[ -n "$pr" ] || { echo "No pull request number in the artifact"; exit 0; }
|
||||
[ "$(gh api "repos/$REPO/pulls/$pr" -q .head.sha)" = "$HEAD_SHA" ] ||
|
||||
{ echo "PR #$pr has moved past $HEAD_SHA; not commenting"; exit 0; }
|
||||
|
||||
# Every lookup prints nothing rather than failing, so a missing baseline (none
|
||||
# yet, or expired) shows as "–" instead of ending the script under set -e.
|
||||
timing() { { find "$1" -name omarchy-install-timing.json 2>/dev/null || true; } | head -1; }
|
||||
install_s() { [ -n "$1" ] || return 0; jq -r '.finished_at - .started_at' "$1" 2>/dev/null || true; }
|
||||
# "Startup finished in … = 1min 2.3s" or "= 12.104s" -> seconds
|
||||
boot_s() {
|
||||
local f
|
||||
f=$({ find "$1" -path "$2" 2>/dev/null || true; } | head -1)
|
||||
[ -n "$f" ] || return 0
|
||||
head -1 "$f" | sed -n 's/.*= *//p' |
|
||||
awk '{t=0; for (i=1;i<=NF;i++) { if ($i ~ /min$/) t+=60*$i; else if ($i ~ /ms$/) t+=$i/1000; else t+=$i } printf "%.3f", t}'
|
||||
}
|
||||
cell() { [ -n "$1" ] && awk -v x="$1" 'BEGIN{printf "%.1f s", x}' || echo "–"; }
|
||||
change() {
|
||||
[ -n "$1" ] && [ -n "$2" ] || { echo "–"; return; }
|
||||
awk -v a="$1" -v b="$2" 'BEGIN{d=a-b; printf "%s%.1f s", (d>=0?"+":"−"), (d<0?-d:d)}'
|
||||
}
|
||||
|
||||
pt=$(timing pr); bt=$(timing base)
|
||||
rows=(
|
||||
"Install|$(install_s "$pt")|$(install_s "$bt")"
|
||||
"First boot|$(boot_s pr '*/first-boot-systemd-analyze.txt')|$(boot_s base '*/first-boot-systemd-analyze.txt')"
|
||||
"Everyday boot|$(boot_s pr '*-boot/systemd-analyze.txt')|$(boot_s base '*-boot/systemd-analyze.txt')"
|
||||
)
|
||||
|
||||
status="passed"; [ "$CONCLUSION" = success ] || status="**${CONCLUSION}**"
|
||||
{
|
||||
echo "$marker"
|
||||
echo "### Install test $status"
|
||||
echo
|
||||
echo "| | This PR | quattro | Change |"
|
||||
echo "| --- | ---: | ---: | ---: |"
|
||||
for row in "${rows[@]}"; do
|
||||
IFS='|' read -r name this base_v <<<"$row"
|
||||
echo "| $name | $(cell "$this") | $(cell "$base_v") | $(change "$this" "$base_v") |"
|
||||
done
|
||||
if [ -n "$pt" ]; then
|
||||
echo
|
||||
echo "<details><summary>Install phases</summary>"
|
||||
echo
|
||||
echo "| Phase | This PR | quattro |"
|
||||
echo "| --- | ---: | ---: |"
|
||||
# Phase names come from the pull request's installer: keep them to plain text.
|
||||
jq -r --slurpfile b <( [ -n "$bt" ] && cat "$bt" || echo '{"phases":[]}' ) '
|
||||
($b[0].phases | map({key: .name, value: .elapsed}) | from_entries) as $base
|
||||
| .phases[]
|
||||
| "| \(.name | gsub("[^A-Za-z0-9 +&/().-]"; "") | .[0:60]) | \(.elapsed * 10 | round / 10) s | \(($base[.name] // null) | if . == null then "–" else "\(. * 10 | round / 10) s" end) |"
|
||||
' "$pt"
|
||||
echo
|
||||
echo "</details>"
|
||||
fi
|
||||
echo
|
||||
echo "[Run]($RUN_URL) · ${HEAD_SHA:0:8}"
|
||||
} > comment.md
|
||||
|
||||
existing=$(gh api "repos/$REPO/issues/$pr/comments" --paginate \
|
||||
-q ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -1)
|
||||
if [ -n "$existing" ]; then
|
||||
gh api -X PATCH "repos/$REPO/issues/comments/$existing" -F body=@comment.md >/dev/null
|
||||
else
|
||||
gh api "repos/$REPO/issues/$pr/comments" -F body=@comment.md >/dev/null
|
||||
fi
|
||||
cat comment.md
|
||||
@@ -0,0 +1,117 @@
|
||||
name: Install test
|
||||
|
||||
# Builds the ISO a pull request produces, installs it unattended in a KVM
|
||||
# guest, boots the installed system again, and reports how long the install
|
||||
# and both boots took. Every later change to the installer is measured
|
||||
# against these numbers in its own PR.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
# Each merge records quattro's numbers, which PR comments compare against.
|
||||
push:
|
||||
branches: [quattro]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: install-test-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
install:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 75
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
||||
|
||||
# The hosted runner has far more disk than the build needs (145 GB,
|
||||
# ~86 GB free); fail early and loudly if that ever changes.
|
||||
- name: Check disk space
|
||||
run: |
|
||||
df -h /
|
||||
avail_gb=$(df -BG --output=avail / | tail -1 | tr -dc 0-9)
|
||||
[ "$avail_gb" -ge 40 ] || { echo "::error::only ${avail_gb} GB free, the ISO build and install test need ~40 GB"; exit 1; }
|
||||
|
||||
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
|
||||
|
||||
- name: Build the ISO
|
||||
run: NO_BOOT_OFFER=1 ./bin/omarchy-iso-make
|
||||
|
||||
# The harness runs in an Arch container: Arch's current QEMU and OVMF
|
||||
# (QEMU 11) instead of Ubuntu 24.04's QEMU 8.2, at the paths the
|
||||
# harness expects, the same as on an Omarchy workstation.
|
||||
- name: Install unattended, then boot the installed system
|
||||
run: |
|
||||
sudo chmod 0666 /dev/kvm
|
||||
docker run --rm --device /dev/kvm -v "$PWD:/w" -w /w \
|
||||
-e OMARCHY_INTEGRATION_DISK_CACHE=none \
|
||||
archlinux:latest bash -euo pipefail -c '
|
||||
pacman -Syu --noconfirm --needed qemu-system-x86 qemu-hw-display-virtio-gpu qemu-hw-display-virtio-vga qemu-img edk2-ovmf socat \
|
||||
imagemagick tesseract tesseract-data-eng mtools dosfstools jq openssh openssl python curl >/dev/null
|
||||
# test/integration installs its tools through Omarchy'"'"'s helper; they are installed above.
|
||||
printf "#!/bin/sh\nexit 0\n" >/usr/local/bin/omarchy-pkg-add
|
||||
chmod 0755 /usr/local/bin/omarchy-pkg-add
|
||||
qemu-system-x86_64 --version | head -1
|
||||
./test/integration release/*.iso boot --no-preview --memory 8192 --timeout 1800
|
||||
'
|
||||
|
||||
# The harness ran as root in its container: test-runs and what QEMU
|
||||
# wrote there (the serial logs) belong to root until this step.
|
||||
- name: Hand the results to the runner's user
|
||||
if: always()
|
||||
run: |
|
||||
mkdir -p test-runs
|
||||
sudo chown -R "$(id -u):$(id -g)" test-runs
|
||||
|
||||
- name: Report times
|
||||
if: always()
|
||||
run: |
|
||||
base=$(ls -d test-runs/*-integration 2>/dev/null | head -1)
|
||||
[ -n "$base" ] || { echo "No test run to report" >> "$GITHUB_STEP_SUMMARY"; exit 0; }
|
||||
{
|
||||
echo "## Install test"
|
||||
echo
|
||||
if [ -f "$base/omarchy-install-timing.json" ]; then
|
||||
jq -r '"**Install:** \((.finished_at - .started_at) * 10 | round / 10) s across \(.phases | length) phases"' "$base/omarchy-install-timing.json"
|
||||
echo
|
||||
echo "| Phase | Seconds |"
|
||||
echo "| --- | ---: |"
|
||||
jq -r '.phases[] | "| \(.name) | \(.elapsed * 10 | round / 10) |"' "$base/omarchy-install-timing.json"
|
||||
echo
|
||||
fi
|
||||
if [ -f "$base/first-boot-systemd-analyze.txt" ]; then
|
||||
echo "**First boot:** $(head -1 "$base/first-boot-systemd-analyze.txt")"
|
||||
echo
|
||||
fi
|
||||
boot_dir=$(ls -d "$base"/runs/*-boot 2>/dev/null | tail -1)
|
||||
if [ -n "$boot_dir" ] && [ -f "$boot_dir/systemd-analyze.txt" ]; then
|
||||
echo "**Everyday boot:** $(head -1 "$boot_dir/systemd-analyze.txt")"
|
||||
echo
|
||||
echo "System state: $(jq -r .system_state "$boot_dir/boot-timing.json" 2>/dev/null)"
|
||||
fi
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
# The comment workflow runs from quattro and reads only this artifact;
|
||||
# it needs the PR number, which a workflow_run event omits for forks.
|
||||
- name: Record the pull request
|
||||
if: always() && github.event_name == 'pull_request'
|
||||
run: echo "${{ github.event.pull_request.number }}" > test-runs/pr-number
|
||||
|
||||
- name: Upload test artifacts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: install-test-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: |
|
||||
test-runs/pr-number
|
||||
test-runs/*/omarchy-install-timing.json
|
||||
test-runs/*/omarchy-install.log
|
||||
test-runs/*/first-boot-systemd-analyze.txt
|
||||
test-runs/*/runs/**/*.png
|
||||
test-runs/*/runs/**/*.txt
|
||||
test-runs/*/runs/**/*.json
|
||||
test-runs/*/runs/**/*.log
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
@@ -2,40 +2,34 @@ name: Nightly ISO Build
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '1 0 * * *' # Daily at 00:01 UTC
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
- cron: "1 0 * * *" # Daily at 00:01 UTC
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
|
||||
jobs:
|
||||
build-iso:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
image: archlinux/archlinux:latest
|
||||
options: --privileged
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build ISO in Arch Linux container
|
||||
run: |
|
||||
docker run --rm \
|
||||
--privileged \
|
||||
-v "${{ github.workspace }}:/workspace" \
|
||||
-w /workspace \
|
||||
archlinux:latest \
|
||||
bash -c "
|
||||
pacman -Syu --noconfirm && \
|
||||
chmod +x build_iso.sh && \
|
||||
./build_iso.sh
|
||||
"
|
||||
|
||||
- name: Upload ISO artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: omarchy-iso-${{ github.run_number }}
|
||||
path: out/*.iso
|
||||
retention-days: 30
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Free Disk Space
|
||||
uses: jlumbroso/free-disk-space@v1.3.1
|
||||
|
||||
- name: Build ISO
|
||||
run: NO_BOOT_OFFER=1 ./bin/omarchy-iso-make
|
||||
|
||||
- name: Delete previously uploaded ISO artifact
|
||||
uses: philips-labs/action-delete-artifacts@v1.0.0
|
||||
with:
|
||||
workflow: nightly-build.yml
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload newly built ISO artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: omarchy-iso-${{ github.run_number }}
|
||||
path: ./release/*.iso
|
||||
retention-days: 1
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Unit tests
|
||||
|
||||
# The fast, VM-free tests under test/unit/: cidata autoinstall loading and the
|
||||
# orchestrator's phases. Seconds per run, no ISO build; the install test
|
||||
# covers the rest.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [quattro]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
unit:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
||||
|
||||
# The tests run where the code they cover runs: on Arch, the same as
|
||||
# the live ISO and an Omarchy workstation. The container boots systemd
|
||||
# because the keyboard tests ask the real localectl for its keymaps, and
|
||||
# the tests run as an ordinary user because some of them check what
|
||||
# happens when a file cannot be written.
|
||||
#
|
||||
# A privileged container shares the host's consoles and devices, so the
|
||||
# units that would claim them are masked before systemd starts: without
|
||||
# that, its getty, udev and vconsole setup take over the host's.
|
||||
- name: Run ./test/all in an Arch container
|
||||
run: |
|
||||
docker run -d --name unit --privileged --cgroupns=host \
|
||||
-v /sys/fs/cgroup:/sys/fs/cgroup:rw --tmpfs /run --tmpfs /tmp:exec \
|
||||
-v "$PWD:/src:ro" archlinux:latest bash -c '
|
||||
systemctl mask getty.target console-getty.service \
|
||||
systemd-udev-trigger.service systemd-udevd.service \
|
||||
systemd-vconsole-setup.service
|
||||
exec /usr/lib/systemd/systemd
|
||||
'
|
||||
docker exec unit bash -euo pipefail -c '
|
||||
for i in $(seq 1 60); do
|
||||
state=$(systemctl is-system-running 2>/dev/null || true)
|
||||
case $state in running | degraded) break ;; esac
|
||||
sleep 1
|
||||
done
|
||||
echo "systemd: $state"
|
||||
pacman -Syu --noconfirm --needed python parted >/dev/null
|
||||
useradd -m tester
|
||||
cp -r /src /home/tester/omarchy-iso
|
||||
chown -R tester /home/tester/omarchy-iso
|
||||
cd /home/tester/omarchy-iso
|
||||
setpriv --reuid=tester --regid=tester --init-groups ./test/all
|
||||
'
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Anton Hvornum
|
||||
Copyright (c) 2026 Anton Hvornum
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -6,6 +6,14 @@ The Omarchy ISO is the only supported way to install Omarchy. It ships the Omarc
|
||||
|
||||
See the ISO link on [omarchy.org](https://omarchy.org).
|
||||
|
||||
Every published ISO has a `.sha256` beside it at the same URL. Download both into the same directory and check the ISO before writing it to a USB stick:
|
||||
|
||||
```bash
|
||||
sha256sum -c omarchy-3.0.iso.sha256
|
||||
```
|
||||
|
||||
Corruption anywhere in the ISO is worth catching before the write, and corruption in the bundled package mirror is worth catching most: the mirror lives inside the ISO and the installer reads it straight off the medium, so those bytes surface minutes into the install as a pacman "invalid or corrupted package" error rather than as anything that names the download. Corruption elsewhere is louder and earlier — it stops the medium booting or mounting. There is a `.sig` beside the ISO too for anyone who wants to verify it against the Omarchy signing key.
|
||||
|
||||
## Creating the ISO
|
||||
|
||||
Run `./bin/omarchy-iso-make`; output goes into `./release`. By default the ISO uses the Omarchy packages and tracks the `quattro` branch, from the stable mirror. Pass `--edge` to use `omarchy-dev` and `omarchy-settings-dev` from the edge mirror.
|
||||
@@ -20,10 +28,74 @@ Despite the local folder name, the first argument is the Omarchy source checkout
|
||||
|
||||
Use `--dev` or `--rc` to build against those package channels. Both `--dev` and `--edge` select the dev packages from the edge mirror.
|
||||
|
||||
## Autoinstall
|
||||
|
||||
The shipped ISO installs itself with no keyboard when it finds its configuration on a second drive. Attach a drive labeled `cidata` alongside the ISO and the installer copies the config off it and skips the configurator; with no such drive, nothing changes and the wizard runs as usual. No rebuild, no extra boot entry.
|
||||
|
||||
`cidata` is the cloud-init `NoCloud` label, so Proxmox, libvirt, and Packer already know how to attach one.
|
||||
|
||||
### Configuration files
|
||||
|
||||
These are the configurator's own output files, so the way to get a starting set is to run one interactive install and copy what it wrote into `/root`.
|
||||
|
||||
| File | Required | Purpose |
|
||||
|------|----------|---------|
|
||||
| `user_configuration.json` | Yes | archinstall config: disk, hostname, timezone, keyboard |
|
||||
| `user_credentials.json` | Yes | Username and password hash |
|
||||
| `user_full_name.txt` | No | Git full name |
|
||||
| `user_email_address.txt` | No | Git email |
|
||||
| `user_encrypt_installation.txt` | No | `true` when `user_configuration.json` carries a `disk_encryption` block; defaults to false |
|
||||
| `authorized_keys` | No | SSH public keys in sshd's own format, one per line |
|
||||
| `tailscale_authkey` | No | Tailscale auth key; the machine joins your tailnet on first boot |
|
||||
|
||||
Both required files must be present or the installer falls back to the configurator. Generate the password hash for `user_credentials.json` with `openssl passwd -6 "yourpassword"`.
|
||||
|
||||
Encryption itself is configured by the `disk_encryption` block inside `user_configuration.json` — which carries the passphrase in plaintext, so treat a drive built from an encrypted install accordingly. The flag file must match it: it drives the encrypted install's SDDM autologin and the final boot validation, not the encryption.
|
||||
|
||||
`authorized_keys` is the same file sshd reads — copy your own or write one key per line:
|
||||
|
||||
```
|
||||
ssh-ed25519 AAAA... you@host
|
||||
```
|
||||
|
||||
When `authorized_keys` is present, autoinstall installs it as the user's `~/.ssh/authorized_keys`, enables `sshd`, and adds a `ufw allow ssh` rule — a stock Omarchy install ships openssh with the service disabled and its firewall opens neither port 22 nor anything else beyond LocalSend. Networking needs nothing extra; NetworkManager is already enabled with DHCP. Password SSH authentication is left at the distro default. An `authorized_keys` with no usable keys fails the install rather than producing a machine nobody can reach.
|
||||
|
||||
When `tailscale_authkey` is present (one key, blank lines and `#` comments ignored), the install adds the `tailscale` package from the ISO's bundled mirror — nothing is fetched from the network at install or boot — and stages the join for first boot: the key lands at `/etc/tailscale/authkey` (root-only), `tailscaled` is enabled, ufw allows traffic in on `tailscale0`, and a background unit runs `tailscale up` once the network is actually up, retrying until it succeeds without holding up the boot. After a successful join the key is deleted and the unit disables itself; until then both survive reboots, so a machine installed offline joins whenever it first gets connectivity. The node appears on the tailnet under the configured hostname. Use a reusable, pre-authorized (tagged) key so one drive image serves many machines — or an ephemeral key for disposable VMs.
|
||||
|
||||
### Building the drive
|
||||
|
||||
```bash
|
||||
mkdir cidata
|
||||
cp user_configuration.json user_credentials.json authorized_keys cidata/
|
||||
genisoimage -output cidata.iso -volid cidata -joliet -rock cidata/
|
||||
```
|
||||
|
||||
### Proxmox example
|
||||
|
||||
```bash
|
||||
qm create 101 --name my-omarchy \
|
||||
--bios ovmf --machine q35 --cpu host --cores 4 --memory 8192 \
|
||||
--ostype l26 --scsihw virtio-scsi-single \
|
||||
--efidisk0 local-lvm:0,efitype=4m,pre-enrolled-keys=0 \
|
||||
--scsi0 local-lvm:40,discard=on,iothread=1 \
|
||||
--net0 virtio,bridge=vmbr0 --vga virtio --serial0 socket \
|
||||
--ide2 local:iso/omarchy.iso,media=cdrom \
|
||||
--ide3 local:iso/cidata.iso,media=cdrom \
|
||||
--boot order='scsi0;ide2'
|
||||
|
||||
qm start 101
|
||||
```
|
||||
|
||||
Boot order is disk first: the empty disk falls through to the ISO on the first boot, and the installed system boots from disk afterwards. The machine reboots into Omarchy on its own when the install finishes.
|
||||
|
||||
Encrypted autoinstalls are not fully unattended — the LUKS passphrase prompt still needs someone at the first boot.
|
||||
|
||||
## Testing the ISO
|
||||
|
||||
Run `./bin/omarchy-iso-boot [release/omarchy.iso]`.
|
||||
|
||||
Run `./test/all` for the fast, VM-free tests under `test/unit/`, which cover cidata autoinstall loading and the orchestrator's phases without needing a built ISO.
|
||||
|
||||
To exercise installation alongside existing Windows-style partitions, run
|
||||
`./bin/omarchy-iso-test-windows-disk [release/omarchy.iso]`. It creates a
|
||||
synthetic disk in `/tmp` with an existing ESP and data partition plus ample
|
||||
@@ -46,13 +118,27 @@ The harness syncs the acceptance suite from `$OMARCHY_PATH` when it is available
|
||||
|
||||
Pass `--encrypt` to drive the encrypted install flow (including typing the LUKS passphrase at boot) instead of the unencrypted one. Pass `--no-preview` to collect the same visual artifacts without opening them in `imv` when the run finishes.
|
||||
|
||||
## Integration testing the ISO
|
||||
|
||||
Scenarios under `test/integration.d/` boot a real ISO install in QEMU and assert on what the running system actually does. The runner installs the ISO once — unattended, from a generated cidata drive — and saves the result as a reusable base image; every scenario then boots a throwaway overlay of that base with its own copy of the firmware vars, so neither disk nor NVRAM state leaks between runs. Shared machinery (VM lifecycle, QMP screendump + OCR console driving, virtual keystrokes, guest SSH, the cidata build) lives in `test/integration.d/base-test.sh`, so a new scenario is one file.
|
||||
|
||||
```bash
|
||||
./test/integration release/omarchy.iso # install once, run all scenarios
|
||||
./test/integration release/omarchy.iso --reuse-base # fast loop against the saved base
|
||||
./test/integration release/omarchy.iso factory-reset # a single named scenario
|
||||
```
|
||||
|
||||
The first scenario is `factory-reset`: it proves `omarchy-system-factory-reset` hands a machine on without destroying a shared ESP. The installed ESP gets a Windows entry with payload plus a second Linux cloned under a foreign machine-id with its own boot directory and UKIs; a real factory reset is then driven through a guest pty, and the harness asserts the foreign entries survive both the staged reset and first-boot provisioning, that the old Omarchy identity is fully retired, and that the machine reaches first-boot setup unattended.
|
||||
|
||||
Artifacts — screenshots, the fixtured/staged/final `limine.conf`, the reset typescript, and the factory-reset log — land under `test-runs/<iso>-integration/runs/<timestamp>-<scenario>/`, and `--no-preview` skips the `imv` review just like the acceptance harness.
|
||||
|
||||
## Signing the ISO
|
||||
|
||||
Run `./bin/omarchy-iso-sign [release/omarchy.iso]`. The signing key is retrieved from the shared Omarchy vault with the 1Password CLI.
|
||||
|
||||
## Uploading the ISO
|
||||
|
||||
Run `./bin/omarchy-iso-upload [release/omarchy.iso]`. This requires rclone configuration (`rclone config`).
|
||||
Run `./bin/omarchy-iso-upload [release/omarchy.iso]`. This requires rclone configuration (`rclone config`). The `.sig` and `.sha256` sidecars go up with the ISO when they exist beside it.
|
||||
|
||||
## Full release of the ISO
|
||||
|
||||
|
||||
+25
-4
@@ -3,6 +3,7 @@
|
||||
set -e
|
||||
|
||||
NO_CACHE=""
|
||||
KEEP_PKG_CACHE=""
|
||||
LOCAL_OMARCHY_PATH=""
|
||||
LOCAL_PKGS_PATH=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
@@ -11,6 +12,10 @@ while [[ $# -gt 0 ]]; do
|
||||
NO_CACHE=1
|
||||
shift
|
||||
;;
|
||||
--keep-pkg-cache)
|
||||
KEEP_PKG_CACHE=1
|
||||
shift
|
||||
;;
|
||||
--no-boot-offer)
|
||||
NO_BOOT_OFFER=1
|
||||
shift
|
||||
@@ -52,7 +57,7 @@ while [[ $# -gt 0 ]]; do
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--no-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] [--local-source <omarchy-checkout> <pkgs-checkout>]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -100,7 +105,11 @@ lint_file_permissions() {
|
||||
|
||||
lint_file_permissions
|
||||
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
# Purging the host package cache needs interactive sudo; --keep-pkg-cache
|
||||
# skips it so unattended builds (test rigs, agents) can run without a prompt.
|
||||
if [[ -z $KEEP_PKG_CACHE ]]; then
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
fi
|
||||
git submodule update --init --recursive --jobs=8
|
||||
|
||||
BUILD_SCRIPT="builder/build-iso.sh"
|
||||
@@ -143,9 +152,21 @@ if [[ -z "$NO_CACHE" ]]; then
|
||||
OFFLINE_REPO_BUILD_CACHE_DIR="$HOME/.cache/omarchy/iso_${OMARCHY_MIRROR}/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
|
||||
# The locally cached :latest image is a cache too — docker run never
|
||||
# re-checks the registry for it, so refresh it when building cold.
|
||||
DOCKER_ARGS+=(--pull=always)
|
||||
fi
|
||||
|
||||
docker run "${DOCKER_ARGS[@]}" archlinux/archlinux:latest /$BUILD_SCRIPT
|
||||
# The docker group is root-equivalent, so Omarchy operators stay out of it on
|
||||
# purpose. When the socket refuses the calling user, run the client through
|
||||
# sudo instead of requiring group membership.
|
||||
DOCKER=(docker)
|
||||
if ! docker version &>/dev/null; then
|
||||
DOCKER=(sudo docker)
|
||||
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"
|
||||
@@ -153,5 +174,5 @@ mv -f "$latest_iso" "$iso_ref"
|
||||
|
||||
if [[ -z "${NO_BOOT_OFFER:-}" ]]; then
|
||||
echo
|
||||
gum confirm "Boot $iso_ref?" && omarchy-iso-boot "$iso_ref"
|
||||
gum confirm "Boot $iso_ref?" && "$BUILD_ROOT/bin/omarchy-iso-boot" "$iso_ref"
|
||||
fi
|
||||
@@ -1,5 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A failed step must stop the release: without this, a make that dies (say,
|
||||
# docker permission denied) falls through to signing and uploading whatever
|
||||
# stale ISO release/ already holds, under the new release's name.
|
||||
set -e
|
||||
|
||||
MAKE_ARGS=()
|
||||
ISO_REF=quattro
|
||||
RELEASE_SUFFIX=""
|
||||
@@ -37,6 +42,14 @@ if [[ -z "${BUILD_VERSION-}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# A version that already numbers its candidate (4.0.2rc2) is the complete
|
||||
# artifact name; the bare -rc suffix exists only for an unnumbered candidate.
|
||||
# Without this, every candidate of a train uploads over the same
|
||||
# omarchy-X.Y.Z-rc.iso and testers cannot tell which rc they are holding.
|
||||
if [[ $BUILD_VERSION == *rc* ]]; then
|
||||
RELEASE_SUFFIX=""
|
||||
fi
|
||||
|
||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||
BUILD_RELEASE_PATH="$BUILD_ROOT/release"
|
||||
|
||||
@@ -56,7 +69,23 @@ cp "$latest_iso" "$release_iso"
|
||||
echo -e "\e[32mSigning $ISO_REF ISO\e[0m"
|
||||
omarchy-iso-sign "$release_iso"
|
||||
|
||||
# The checksum sidecar names the ISO alone, never the build path: it is
|
||||
# downloaded next to the ISO and has to verify with `sha256sum -c` from
|
||||
# whatever directory the person who downloaded it happens to be in. A release
|
||||
# that cannot write it stops here, because the sidecar left over from the last
|
||||
# release reads as a checksum for this one.
|
||||
iso_sha=$(sha256sum "$release_iso")
|
||||
iso_sha=${iso_sha%% *}
|
||||
if [[ -z $iso_sha ]] || ! printf '%s %s\n' "$iso_sha" "${release_iso##*/}" >"$release_iso.sha256"; then
|
||||
echo -e "\e[31mCould not write the checksum for $release_iso\e[0m" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\e[32mSHA256 for $ISO_REF ISO: $iso_sha\e[0m"
|
||||
|
||||
omarchy-iso-upload "$release_iso"
|
||||
|
||||
# The whole point of a release is handing someone this pair.
|
||||
echo -e "\e[32mReleased $ISO_REF ISO $BUILD_VERSION\e[0m"
|
||||
echo " URL: https://iso.omarchy.org/${release_iso##*/}"
|
||||
echo " SHA256: $iso_sha"
|
||||
echo " Local: $release_iso"
|
||||
+332
-46
@@ -13,12 +13,18 @@
|
||||
#
|
||||
# Usage: omarchy-iso-test [release/omarchy.iso] [options]
|
||||
#
|
||||
# --keyboard LABEL English (US/UK), Japanese, Japanese (US keyboard), Korean,
|
||||
# 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)
|
||||
# --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
|
||||
# --install-only Stop after producing the installed base image
|
||||
# --sync-omarchy DIR Push DIR's test/acceptance into the guest before running
|
||||
# --sync-omarchy DIR Push DIR's test suite into the guest before running
|
||||
# (defaults to OMARCHY_PATH when the suite is present)
|
||||
# --sync-all DIR Push all of DIR (bin/config/shell/test) into the guest
|
||||
# and also run the CLI and shell suites there
|
||||
# --port PORT Host port forwarded to guest SSH (default 2222)
|
||||
# --memory MB VM memory (default 8192)
|
||||
# --timeout SECS Install timeout (default 2400)
|
||||
@@ -36,6 +42,7 @@ MEMORY=8192
|
||||
INSTALL_TIMEOUT=2400
|
||||
BOOT_TIMEOUT=600
|
||||
ENCRYPT=false
|
||||
PROVISION=false
|
||||
REUSE_BASE=false
|
||||
INSTALL_ONLY=false
|
||||
KEEP_RUNNING=false
|
||||
@@ -43,13 +50,16 @@ NO_PREVIEW=false
|
||||
SYNC_DIR=""
|
||||
SYNC_ALL=false
|
||||
|
||||
KEYBOARD_LABEL="English (US)"
|
||||
GUEST_USER="omarchy"
|
||||
GUEST_PASSWORD="omarchy"
|
||||
GUEST_HOSTNAME="omarchy-test"
|
||||
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--keyboard) KEYBOARD_LABEL="$2"; shift ;;
|
||||
--encrypt) ENCRYPT=true ;;
|
||||
--provision) PROVISION=true ;;
|
||||
--reuse-base) REUSE_BASE=true ;;
|
||||
--install-only) INSTALL_ONLY=true ;;
|
||||
--keep-running) KEEP_RUNNING=true ;;
|
||||
@@ -79,13 +89,22 @@ if [[ ! -f ${ISO:-} ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$KEYBOARD_LABEL" in
|
||||
"English (US)" | "English (UK)" | "Japanese" | "Japanese (US keyboard)" | "Korean" | "Chinese (Simplified, Pinyin)" | "Chinese (Traditional, Zhuyin)") ;;
|
||||
*) echo "The VM harness cannot type credentials with keyboard: $KEYBOARD_LABEL" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
omarchy-pkg-add qemu-full edk2-ovmf socat imagemagick tesseract tesseract-data-eng
|
||||
|
||||
OVMF_CODE="/usr/share/edk2/x64/OVMF_CODE.4m.fd"
|
||||
OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
|
||||
|
||||
BASE_NAME="$(basename "$ISO" .iso)"
|
||||
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"
|
||||
$PROVISION && BASE_NAME+="-provision"
|
||||
BASE_DIR="$REPO_DIR/test-runs/$BASE_NAME"
|
||||
RUN_DIR="$BASE_DIR/runs/$(date +%Y%m%d-%H%M%S)"
|
||||
BASE_DISK="$BASE_DIR/base.qcow2"
|
||||
@@ -96,7 +115,9 @@ HTTP_PID=""
|
||||
|
||||
mkdir -p "$BASE_DIR" "$RUN_DIR"
|
||||
|
||||
QMP_SOCK="$RUN_DIR/qmp.sock"
|
||||
# Unix socket paths are capped at ~108 bytes, which a run directory nested in
|
||||
# test-runs/<iso-name>/runs/<timestamp> can exceed. Keep the socket in /tmp.
|
||||
QMP_SOCK=$(mktemp -u "${TMPDIR:-/tmp}/omarchy-iso-test-qmp.XXXXXX.sock")
|
||||
PIDFILE="$RUN_DIR/qemu.pid"
|
||||
|
||||
log() {
|
||||
@@ -194,6 +215,11 @@ start_vm() {
|
||||
local disk="$1" serial="$2"
|
||||
shift 2
|
||||
|
||||
# A viewer that resizes the guest display breaks the console driving: OCR
|
||||
# cannot read the shrunken font, and a resize during early boot can wedge
|
||||
# virtio-gpu before the system comes up.
|
||||
log "Watch (do not resize): vncviewer -RemoteResize=0 127.0.0.1:5905"
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-cpu host -enable-kvm -machine q35,accel=kvm \
|
||||
-smp "$(nproc)" \
|
||||
@@ -204,6 +230,7 @@ start_vm() {
|
||||
-device virtio-blk-pci,drive=drive0,bootindex=1 \
|
||||
-device virtio-vga \
|
||||
-display none \
|
||||
-vnc 127.0.0.1:5 \
|
||||
-usb -device usb-tablet \
|
||||
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:$SSH_PORT-:22 \
|
||||
-device virtio-net-pci,netdev=net0 \
|
||||
@@ -286,6 +313,28 @@ type_text() {
|
||||
:) press shift-semicolon ;;
|
||||
@) press shift-2 ;;
|
||||
\|) press shift-backslash ;;
|
||||
";") press semicolon ;;
|
||||
"'") press apostrophe ;;
|
||||
'"') press shift-apostrophe ;;
|
||||
"=") press equal ;;
|
||||
"+") press shift-equal ;;
|
||||
"%") press shift-5 ;;
|
||||
"&") press shift-7 ;;
|
||||
"*") press shift-8 ;;
|
||||
"(") press shift-9 ;;
|
||||
")") press shift-0 ;;
|
||||
"<") press shift-comma ;;
|
||||
">") press shift-dot ;;
|
||||
"!") press shift-1 ;;
|
||||
"#") press shift-3 ;;
|
||||
'$') press shift-4 ;;
|
||||
"?") press shift-slash ;;
|
||||
"~") press shift-grave_accent ;;
|
||||
"\\") press backslash ;;
|
||||
"[") press bracket_left ;;
|
||||
"]") press bracket_right ;;
|
||||
"{") press shift-bracket_left ;;
|
||||
"}") press shift-bracket_right ;;
|
||||
*) echo "type_text: unsupported character: $ch" >&2; return 1 ;;
|
||||
esac
|
||||
sleep 0.05
|
||||
@@ -297,6 +346,7 @@ type_text() {
|
||||
ssh_guest() {
|
||||
ssh -i "$SSH_KEY" -p "$SSH_PORT" \
|
||||
-o BatchMode=yes \
|
||||
-o IdentitiesOnly=yes \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=/dev/null \
|
||||
-o ConnectTimeout=5 \
|
||||
@@ -370,7 +420,7 @@ guest_layer_absent() {
|
||||
}
|
||||
|
||||
cleanup_shortcut_state() {
|
||||
ssh_session 'for plugin in omarchy.launcher omarchy.menu omarchy.emojis omarchy.clipboard omarchy.audio; do
|
||||
ssh_session 'for plugin in omarchy.menu omarchy.emojis omarchy.clipboard omarchy.audio; do
|
||||
omarchy-shell shell hide "$plugin" >/dev/null 2>&1 || true
|
||||
done
|
||||
while read -r address; do
|
||||
@@ -547,8 +597,8 @@ shortcut_smoke_phase() {
|
||||
|
||||
local status=0
|
||||
local name chord namespace plugin
|
||||
local shortcuts='launcher|meta_l-spc|omarchy-launcher|omarchy.launcher
|
||||
menu|meta_l-alt-spc|omarchy-menu|omarchy.menu
|
||||
local shortcuts='menu|meta_l-spc|omarchy-menu|omarchy.menu
|
||||
apps-menu|meta_l-alt-spc|omarchy-menu|omarchy.menu
|
||||
emojis|meta_l-ctrl-e|omarchy-emojis|omarchy.emojis
|
||||
clipboard|meta_l-ctrl-v|omarchy-clipboard|omarchy.clipboard
|
||||
audio-panel|meta_l-ctrl-a|omarchy-keyboard-panel|omarchy.audio'
|
||||
@@ -573,13 +623,83 @@ audio-panel|meta_l-ctrl-a|omarchy-keyboard-panel|omarchy.audio'
|
||||
|
||||
# ----------------------------------------------------- driving the installer
|
||||
|
||||
select_keyboard() {
|
||||
local label="$1" index direction="down"
|
||||
# gum choose uses arrows, not a searchable text field. Read the same ordered
|
||||
# choices the ISO vendors from the runtime rather than hard-code row numbers.
|
||||
index=$(OMARCHY_TEST_KEYBOARD="$label" python - <<'PYTHON'
|
||||
import os, re
|
||||
from pathlib import Path
|
||||
source = Path(os.environ.get("OMARCHY_PATH", "")) / "install/provisioning/setup-form.sh"
|
||||
if not source.is_file():
|
||||
raise SystemExit("Set OMARCHY_PATH to the source tree used to build this ISO")
|
||||
text = source.read_text()
|
||||
rows = re.search(r"OMARCHY_KEYBOARD_LAYOUTS=\$'(.*?)'\n", text, re.S).group(1).splitlines()
|
||||
labels = [row.split("|")[0] for row in rows]
|
||||
label = os.environ["OMARCHY_TEST_KEYBOARD"]
|
||||
if label not in labels:
|
||||
raise SystemExit(f"Keyboard choice is absent from the ISO source: {label}")
|
||||
print(labels.index(label) - labels.index("English (US)"))
|
||||
PYTHON
|
||||
) || return 1
|
||||
if (( index < 0 )); then
|
||||
direction="up"
|
||||
index=$((-index))
|
||||
fi
|
||||
for (( i = 0; i < index; i++ )); do
|
||||
press "$direction"
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
drive_configurator() {
|
||||
log "Driving the installer wizard"
|
||||
|
||||
# A greeter (animated logo + tagline) opens the installer; Return begins.
|
||||
wait_for_screen "Linux by DHH" 300
|
||||
capture_console "success-installer-00-greeter"
|
||||
press ret
|
||||
|
||||
# Keyboard is the first screen. Ctrl+C there is the hidden entry into deferred provisioning
|
||||
# mode; a normal install just selects the layout.
|
||||
wait_for_screen "keyboard layout" 300
|
||||
capture_console "success-installer-01-keyboard-layout"
|
||||
press ret # English (US) is preselected
|
||||
|
||||
if $PROVISION; then
|
||||
press ctrl-c # arm "prepare for another owner"
|
||||
wait_for_screen "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
|
||||
capture_console "success-installer-03-prepare-install-disk"
|
||||
press ret
|
||||
|
||||
wait_for_screen "recovery possible" 60
|
||||
capture_console "success-installer-04-prepare-disk-warning-encrypted"
|
||||
if ! $ENCRYPT; then
|
||||
press ctrl-c
|
||||
# The toggled confirm ("Yes, install without encryption") is a highlighted
|
||||
# button OCR cannot read, so don't wait for it. A failed toggle still
|
||||
# surfaces: the encrypted install stalls at the LUKS prompt on first boot
|
||||
# and SSH never comes up.
|
||||
sleep 2
|
||||
capture_console "success-installer-05-prepare-disk-warning-unencrypted"
|
||||
fi
|
||||
press ret
|
||||
sleep 2
|
||||
capture_console "success-installer-13-install-started"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $KEYBOARD_LABEL != "English (US)" ]]; then
|
||||
select_keyboard "$KEYBOARD_LABEL"
|
||||
capture_console "success-installer-01-selected-keyboard"
|
||||
fi
|
||||
press ret
|
||||
|
||||
# Normal flow: user step comes before disk selection.
|
||||
wait_for_screen "Username" 120
|
||||
type_text "$GUEST_USER"
|
||||
capture_console "success-installer-02-username"
|
||||
@@ -601,7 +721,15 @@ drive_configurator() {
|
||||
press ret
|
||||
|
||||
wait_for_screen "Email address" 60
|
||||
type_text "test@omarchy.org"
|
||||
type_text "test"
|
||||
if [[ $KEYBOARD_LABEL == "Japanese" ]]; then
|
||||
press bracket_left
|
||||
elif [[ $KEYBOARD_LABEL == "English (UK)" ]]; then
|
||||
press shift-apostrophe
|
||||
else
|
||||
press shift-2
|
||||
fi
|
||||
type_text "omarchy.org"
|
||||
capture_console "success-installer-06-email"
|
||||
press ret
|
||||
|
||||
@@ -622,17 +750,107 @@ drive_configurator() {
|
||||
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
|
||||
capture_console "success-installer-11-install-mode"
|
||||
press ret # "Full disk install" is preselected
|
||||
fi
|
||||
|
||||
wait_for_screen "recovery possible" 60
|
||||
capture_console "success-installer-11-disk-warning-encrypted"
|
||||
capture_console "success-installer-12-disk-warning-encrypted"
|
||||
if ! $ENCRYPT; then
|
||||
press ctrl-c # toggles the confirm to the unencrypted flow
|
||||
wait_for_screen "without encryption" 30
|
||||
capture_console "success-installer-12-disk-warning-unencrypted"
|
||||
# The toggled confirm ("Yes, install without encryption") is a highlighted
|
||||
# button OCR cannot read, so don't wait for it. A failed toggle still
|
||||
# surfaces: the encrypted install stalls at the LUKS prompt on first boot
|
||||
# and SSH never comes up.
|
||||
sleep 2
|
||||
capture_console "success-installer-13-disk-warning-unencrypted"
|
||||
fi
|
||||
press ret
|
||||
|
||||
sleep 2
|
||||
capture_console "success-installer-13-install-started"
|
||||
capture_console "success-installer-14-install-started"
|
||||
}
|
||||
|
||||
# The deferred-provisioning first boot runs the user form on tty1 (omarchy-provision-owner) before
|
||||
# SDDM. Encrypted deferred-provisioning installs auto-unlock from the staged keyfile, so there
|
||||
# is no LUKS prompt to answer here either way.
|
||||
drive_provision_owner() {
|
||||
log "Driving the deferred-provisioning first-boot setup"
|
||||
|
||||
# Deferred provisioning defers the keyboard step to first boot; it comes before the user form.
|
||||
# Pick English (UK) (one row below the preselected English (US), which leads
|
||||
# the list) so the verifier can prove the deferred step applied a non-default
|
||||
# layout — UK leaves every letter identical to US, so the typed password (sent
|
||||
# as raw keycodes) still matches the literal one the harness pipes to sudo.
|
||||
# A greeter (animated logo + tagline) opens first boot; Return begins.
|
||||
wait_for_screen "Linux by DHH" 600
|
||||
capture_console "success-provision-00-greeter"
|
||||
press ret
|
||||
|
||||
wait_for_screen "keyboard layout" 120
|
||||
if [[ $KEYBOARD_LABEL == "English (US)" ]]; then
|
||||
press down # preserve the harness's default UK provisioning coverage
|
||||
else
|
||||
select_keyboard "$KEYBOARD_LABEL"
|
||||
fi
|
||||
capture_console "success-provision-01-keyboard-layout"
|
||||
press ret
|
||||
|
||||
wait_for_screen "Username" 120
|
||||
capture_console "success-provision-02-username"
|
||||
type_text "$GUEST_USER"
|
||||
press ret
|
||||
|
||||
wait_for_screen "Password" 60
|
||||
type_text "$GUEST_PASSWORD"
|
||||
capture_console "success-provision-03-password"
|
||||
press ret
|
||||
|
||||
wait_for_screen "Conf *irm" 60
|
||||
type_text "$GUEST_PASSWORD"
|
||||
press ret
|
||||
|
||||
wait_for_screen "Full name" 60
|
||||
type_text "Omarchy Test"
|
||||
press ret
|
||||
|
||||
wait_for_screen "Email address" 60
|
||||
# The keyboard step above applied English (UK), where '@' is Shift+' (not
|
||||
# Shift+2 as on US); send that keycode so the typed email is correct under
|
||||
# the new layout — itself further proof the deferred keymap took effect.
|
||||
type_text "test"
|
||||
if [[ $KEYBOARD_LABEL == "English (US)" || $KEYBOARD_LABEL == "English (UK)" ]]; then
|
||||
press shift-apostrophe
|
||||
elif [[ $KEYBOARD_LABEL == "Japanese" ]]; then
|
||||
press bracket_left
|
||||
else
|
||||
press shift-2
|
||||
fi
|
||||
type_text "omarchy.org"
|
||||
capture_console "success-provision-04-email"
|
||||
press ret
|
||||
|
||||
# Hostname is deferred to first boot too.
|
||||
wait_for_screen "Hostname" 60
|
||||
type_text "$GUEST_HOSTNAME"
|
||||
capture_console "success-provision-05-hostname"
|
||||
press ret
|
||||
|
||||
# Timezone is deferred to first boot too; accept the geo-guessed default.
|
||||
# Generous timeout: the tzupdate geo-guess over first-boot networking can lag.
|
||||
wait_for_screen "Timezone" 180
|
||||
capture_console "success-provision-06-timezone"
|
||||
press ret
|
||||
|
||||
wait_for_screen "look right" 60
|
||||
capture_console "success-provision-07-review"
|
||||
press ret
|
||||
|
||||
# Finalization (offline Node unpack, LUKS re-key on encrypted installs)
|
||||
# runs before SDDM appears.
|
||||
capture_console "success-provision-08-finalizing"
|
||||
}
|
||||
|
||||
wait_for_install() {
|
||||
@@ -649,6 +867,15 @@ wait_for_install() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Deferred-provisioning installs skip the celebration and reboot on their own
|
||||
# (no Reboot Now prompt); the first-boot greeter tagline appearing means the
|
||||
# install finished and rebooted into setup.
|
||||
if $PROVISION && grep -qi "Linux by DHH" <<<"$text"; then
|
||||
log "Install finished and auto-rebooted into first-boot setup."
|
||||
capture_console "success-installer-15-autoreboot"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if grep -qi "installation stopped" <<<"$text"; then
|
||||
capture_console "failure-installer-installation-stopped"
|
||||
echo "Install failed — screenshot saved to $RUN_DIR" >&2
|
||||
@@ -727,40 +954,39 @@ EOF
|
||||
(cd "$BASE_DIR/www" && exec python3 -m http.server "$HTTP_PORT" --bind 127.0.0.1 >/dev/null 2>&1) &
|
||||
HTTP_PID=$!
|
||||
|
||||
local waited=0
|
||||
while true; do
|
||||
# Type the login blind: a VNC viewer that resizes the framebuffer makes the
|
||||
# console font unreadable to OCR, and the real gate is SSH coming up anyway.
|
||||
# Getty re-prompts after a failed login, so a whole-sequence retry recovers
|
||||
# from typing before the prompt was ready.
|
||||
sleep 15 # give first boot time to reach getty
|
||||
local attempt
|
||||
for attempt in 1 2 3; do
|
||||
press ctrl-alt-f3
|
||||
sleep 8
|
||||
press ret # settle a half-typed prompt from a previous attempt
|
||||
sleep 2
|
||||
type_text "$GUEST_USER"
|
||||
capture_console "success-first-boot-03-console-username"
|
||||
press ret
|
||||
sleep 3
|
||||
type_text "$GUEST_PASSWORD"
|
||||
press ret
|
||||
sleep 4
|
||||
ocr_screen | grep -qi "login:" && break
|
||||
((waited += 8))
|
||||
type_text "curl -fsS http://10.0.2.2:$HTTP_PORT/bootstrap -o /tmp/bs && bash /tmp/bs"
|
||||
capture_console "success-first-boot-05-bootstrap-command"
|
||||
press ret
|
||||
|
||||
if ((waited >= 300)); then
|
||||
capture_console "failure-first-boot-console-timeout"
|
||||
echo "Timed out waiting for a console login prompt" >&2
|
||||
return 1
|
||||
if wait_for_ssh 120 "failure-first-boot-ssh-timeout-$attempt"; then
|
||||
capture_console "success-first-boot-06-bootstrap-complete"
|
||||
kill "$HTTP_PID" 2>/dev/null || true
|
||||
HTTP_PID=""
|
||||
press ctrl-alt-f1
|
||||
return 0
|
||||
fi
|
||||
sleep 4
|
||||
done
|
||||
|
||||
type_text "$GUEST_USER"
|
||||
capture_console "success-first-boot-03-console-username"
|
||||
press ret
|
||||
wait_for_screen "Password" 60
|
||||
type_text "$GUEST_PASSWORD"
|
||||
capture_console "success-first-boot-04-console-password"
|
||||
press ret
|
||||
sleep 3
|
||||
|
||||
type_text "curl -fsS http://10.0.2.2:$HTTP_PORT/bootstrap | bash"
|
||||
capture_console "success-first-boot-05-bootstrap-command"
|
||||
press ret
|
||||
|
||||
wait_for_ssh 180 "failure-first-boot-ssh-timeout"
|
||||
capture_console "success-first-boot-06-bootstrap-complete"
|
||||
|
||||
kill "$HTTP_PID" 2>/dev/null || true
|
||||
HTTP_PID=""
|
||||
press ctrl-alt-f1
|
||||
echo "Console bootstrap did not produce SSH access after 3 attempts" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
# Get a freshly booted system to a running Hyprland session, typing at the
|
||||
@@ -835,11 +1061,63 @@ install_phase() {
|
||||
drive_configurator
|
||||
wait_for_install
|
||||
|
||||
if $ENCRYPT; then
|
||||
if $PROVISION; then
|
||||
drive_provision_owner
|
||||
elif $ENCRYPT; then
|
||||
unlock_luks
|
||||
fi
|
||||
bootstrap_ssh
|
||||
|
||||
# SSH can come up (console bootstrap logs in on a spare TTY) while
|
||||
# omarchy-provision-owner is still finalizing the user and re-keying LUKS. Saving
|
||||
# the base mid-finalization produces a flaky image, so wait for the pending
|
||||
# flag to clear before powering off.
|
||||
if $PROVISION; then
|
||||
log "Waiting for provisioning first-boot setup to finish"
|
||||
local waited=0 rc
|
||||
while true; do
|
||||
# Capture rc via `|| rc=$?` so a non-zero result doesn't trip `set -e`
|
||||
# (this command is intentionally allowed to "fail" — that's the signal).
|
||||
rc=0
|
||||
ssh_guest "test -f /var/lib/omarchy/provisioning/pending" 2>/dev/null || rc=$?
|
||||
# rc 0 = flag still present; rc 255 = SSH not up yet (finalization may
|
||||
# still be running) — keep waiting. Only a clean "file absent" (rc 1)
|
||||
# means provisioning finished, so we don't snapshot mid-finalization on a
|
||||
# transient SSH blip.
|
||||
(( rc == 0 || rc == 255 )) || break
|
||||
if ((waited >= 900)); then
|
||||
capture_console "failure-provision-finalization-timeout"
|
||||
echo "Timed out waiting for provisioning first-boot setup to complete" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 10
|
||||
((waited += 10))
|
||||
done
|
||||
|
||||
# The owner's hostname and timezone are set at first boot now, not baked
|
||||
# into the install — confirm they actually landed on the running system.
|
||||
# Hostname is deterministic (we typed it), so a mismatch is a hard failure;
|
||||
# timezone is geo-guessed, so just report what landed.
|
||||
local got_host="" got_tz=""
|
||||
got_host=$(ssh_guest "cat /etc/hostname" 2>/dev/null | tr -d '\r\n') || got_host=""
|
||||
got_tz=$(ssh_guest "timedatectl show -p Timezone --value" 2>/dev/null | tr -d '\r\n') || got_tz=""
|
||||
if [[ $got_host != "$GUEST_HOSTNAME" ]]; then
|
||||
capture_console "failure-provision-hostname-not-applied"
|
||||
echo "First-boot hostname is '${got_host:-<empty>}', expected '$GUEST_HOSTNAME'" >&2
|
||||
return 1
|
||||
fi
|
||||
log "hostname applied at first boot: $got_host"
|
||||
if [[ -n $got_tz && $got_tz != "UTC" ]]; then
|
||||
log "timezone applied at first boot: $got_tz"
|
||||
else
|
||||
echo "WARN: timezone is '${got_tz:-<empty>}' (expected the owner's choice, not UTC)" >&2
|
||||
fi
|
||||
|
||||
# Deferred first-boot setup hands straight off to SDDM once the oneshot
|
||||
# service exits — no celebration screen, no Start Omarchy button to confirm.
|
||||
capture_console "success-provision-09-handoff"
|
||||
fi
|
||||
|
||||
ssh_guest "echo $GUEST_PASSWORD | sudo -S cat /var/log/omarchy-install-timing.json 2>/dev/null" \
|
||||
>"$RUN_DIR/omarchy-install-timing.json" 2>/dev/null || true
|
||||
ssh_guest "echo $GUEST_PASSWORD | sudo -S cat /var/log/pacman.log 2>/dev/null" \
|
||||
@@ -858,17 +1136,14 @@ sync_omarchy() {
|
||||
log "Syncing $SYNC_DIR into the guest"
|
||||
tar -C "$SYNC_DIR" --exclude .git -cf - . | ssh_guest "mkdir -p $target && tar -C $target -xf -"
|
||||
else
|
||||
log "Syncing $SYNC_DIR/test/acceptance into the guest"
|
||||
tar -C "$SYNC_DIR/test" -cf - acceptance acceptance.d | ssh_guest "mkdir -p $target/test && tar -C $target/test -xf -"
|
||||
log "Syncing $SYNC_DIR/test into the guest"
|
||||
tar -C "$SYNC_DIR" -cf - test | ssh_guest "mkdir -p $target && tar -C $target -xf -"
|
||||
fi
|
||||
}
|
||||
|
||||
acceptance_phase() {
|
||||
log "Booting acceptance VM from base image overlay"
|
||||
|
||||
local guest_omarchy_path="/usr/share/omarchy"
|
||||
$SYNC_ALL && guest_omarchy_path=".local/share/omarchy"
|
||||
|
||||
qemu-img create -f qcow2 -b "$BASE_DISK" -F qcow2 "$RUN_DIR/run.qcow2" >/dev/null
|
||||
start_vm "$RUN_DIR/run.qcow2" "$RUN_DIR/serial.log"
|
||||
|
||||
@@ -878,8 +1153,19 @@ acceptance_phase() {
|
||||
local status=0
|
||||
shortcut_smoke_phase || status=1
|
||||
|
||||
# The synced tree is a full checkout under --sync-all; run the host-style
|
||||
# CLI and shell suites in the guest too before the graphical acceptance
|
||||
# run. They derive their root from their own location in the synced tree.
|
||||
if $SYNC_ALL; then
|
||||
log "Running CLI and shell suites in the guest"
|
||||
ssh_guest "bash .local/share/omarchy/test/all" || status=$?
|
||||
fi
|
||||
|
||||
# The product under test is always the installed tree — VM runs verify the
|
||||
# finished product, never a dev-linked checkout.
|
||||
log "Running acceptance suite"
|
||||
ssh_guest "OMARCHY_PATH=$guest_omarchy_path OMARCHY_ACCEPTANCE_DIR=/tmp/omarchy-acceptance bash .local/share/omarchy/test/acceptance" || status=$?
|
||||
ssh_guest "OMARCHY_PATH=/usr/share/omarchy OMARCHY_ACCEPTANCE_DIR=/tmp/omarchy-acceptance \
|
||||
OMARCHY_ACCEPTANCE_SUDO_PASSWORD=$GUEST_PASSWORD bash .local/share/omarchy/test/acceptance" || status=$?
|
||||
|
||||
log "Collecting artifacts into $RUN_DIR"
|
||||
ssh_guest "tar -C /tmp -cf - omarchy-acceptance 2>/dev/null" | tar -C "$RUN_DIR" -xf - || true
|
||||
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Stop the VM a `omarchy-iso-test --keep-running` run left behind: graceful
|
||||
# guest poweroff over SSH first, escalating to TERM then KILL. The base image
|
||||
# is untouched either way; only the throwaway run overlay is affected.
|
||||
#
|
||||
# Usage: omarchy-iso-test-stop [--kill] [--port PORT]
|
||||
#
|
||||
# --kill Skip the graceful poweroff and kill the VM immediately
|
||||
# --port PORT Host port forwarded to guest SSH (default 2222)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
GUEST_USER="omarchy"
|
||||
GUEST_PASSWORD="omarchy"
|
||||
SSH_PORT=2222
|
||||
GRACEFUL=true
|
||||
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--kill) GRACEFUL=false ;;
|
||||
--port) SSH_PORT="$2"; shift ;;
|
||||
-h | --help)
|
||||
sed -n '3,10p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
|
||||
exit 0
|
||||
;;
|
||||
*) echo "Unknown option: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# The newest run dir whose qemu is still alive is the VM to stop.
|
||||
PID=""
|
||||
PIDFILE=""
|
||||
while IFS= read -r candidate; do
|
||||
pid=$(<"$candidate")
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
PID="$pid"
|
||||
PIDFILE="$candidate"
|
||||
break
|
||||
fi
|
||||
done < <(ls -t "$REPO_DIR"/test-runs/*/runs/*/qemu.pid 2>/dev/null)
|
||||
|
||||
if [[ -z $PID ]]; then
|
||||
echo "No running omarchy-iso-test VM found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASE_DIR="$(dirname "$(dirname "$(dirname "$PIDFILE")")")"
|
||||
SSH_KEY="$BASE_DIR/id_ed25519"
|
||||
|
||||
# A harness that is still driving this VM dies with it; make sure that is
|
||||
# what the caller wants before pulling anything down.
|
||||
if [[ -t 0 ]]; then
|
||||
if pgrep -f "bin/omarchy-iso-test .*\.iso" >/dev/null; then
|
||||
echo "Warning: an omarchy-iso-test run appears to be in progress."
|
||||
fi
|
||||
if ! gum confirm "Stop test VM (pid $PID, ${PIDFILE#$REPO_DIR/})?"; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Stopping test VM (pid $PID, ${PIDFILE#$REPO_DIR/})"
|
||||
|
||||
if $GRACEFUL && [[ -f $SSH_KEY ]]; then
|
||||
ssh -i "$SSH_KEY" -p "$SSH_PORT" \
|
||||
-o BatchMode=yes \
|
||||
-o IdentitiesOnly=yes \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=/dev/null \
|
||||
-o ConnectTimeout=5 \
|
||||
-o LogLevel=ERROR \
|
||||
"$GUEST_USER@127.0.0.1" \
|
||||
"echo $GUEST_PASSWORD | sudo -S systemctl poweroff" >/dev/null 2>&1 || true
|
||||
|
||||
waited=0
|
||||
while kill -0 "$PID" 2>/dev/null && ((waited < 15)); do
|
||||
sleep 1
|
||||
((waited += 1))
|
||||
done
|
||||
fi
|
||||
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
kill "$PID" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
kill -9 "$PID" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo "VM (pid $PID) refused to die." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "VM stopped; port $SSH_PORT is free."
|
||||
@@ -5,11 +5,10 @@ set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
TEST_DISK="${OMARCHY_ISO_TEST_WINDOWS_DISK:-/tmp/omarchy-iso-test-windows.qcow2}"
|
||||
TEST_OVMF_VARS="${OMARCHY_ISO_TEST_WINDOWS_OVMF_VARS:-/tmp/OVMF_VARS.omarchy-iso-test-windows.fd}"
|
||||
DISK_SIZE_GIB=96
|
||||
MIN_FREE_GIB=64
|
||||
RECREATE=0
|
||||
GAP=0
|
||||
ISO=""
|
||||
|
||||
ACTIVE_NBD=""
|
||||
@@ -19,7 +18,7 @@ TEMPORARY_DISK=""
|
||||
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: omarchy-iso-test-windows-disk [--recreate] [release/omarchy.iso]
|
||||
Usage: omarchy-iso-test-windows-disk [--recreate] [--gap] [release/omarchy.iso]
|
||||
|
||||
Creates or validates a synthetic Windows-style test disk with:
|
||||
- a 512MiB EFI partition containing EFI/Microsoft
|
||||
@@ -29,8 +28,16 @@ Creates or validates a synthetic Windows-style test disk with:
|
||||
This exercises Windows partition detection and preservation; it is not a
|
||||
bootable Windows installation.
|
||||
|
||||
--gap builds the same fixture with a hole in the partition numbering: a third
|
||||
partition is created and then deleted, leaving slot 3 free while slot 4 stays
|
||||
in use. parted fills the lowest free slot, so the installer must create its
|
||||
partitions as 3 and 5 and read those numbers back. The contiguous fixture
|
||||
cannot catch that class of bug, because there "lowest free" and "highest + 1"
|
||||
are the same number.
|
||||
|
||||
Options:
|
||||
--recreate Replace the existing test fixture
|
||||
--gap Build the numbering-hole variant (separate disk image)
|
||||
-h, --help Show this help
|
||||
|
||||
Paths can be overridden with:
|
||||
@@ -45,6 +52,10 @@ while (( $# > 0 )); do
|
||||
RECREATE=1
|
||||
shift
|
||||
;;
|
||||
--gap)
|
||||
GAP=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -66,6 +77,18 @@ while (( $# > 0 )); do
|
||||
esac
|
||||
done
|
||||
|
||||
# Separate images per layout so the two fixtures can coexist and neither has
|
||||
# to be rebuilt to run the other.
|
||||
if (( GAP )); then
|
||||
TEST_DISK="${OMARCHY_ISO_TEST_WINDOWS_DISK:-/tmp/omarchy-iso-test-windows-gap.qcow2}"
|
||||
TEST_OVMF_VARS="${OMARCHY_ISO_TEST_WINDOWS_OVMF_VARS:-/tmp/OVMF_VARS.omarchy-iso-test-windows-gap.fd}"
|
||||
LAYOUT_LABEL="512MiB Windows ESP + data + deleted slot 3 + data + 64GiB+ free"
|
||||
else
|
||||
TEST_DISK="${OMARCHY_ISO_TEST_WINDOWS_DISK:-/tmp/omarchy-iso-test-windows.qcow2}"
|
||||
TEST_OVMF_VARS="${OMARCHY_ISO_TEST_WINDOWS_OVMF_VARS:-/tmp/OVMF_VARS.omarchy-iso-test-windows.fd}"
|
||||
LAYOUT_LABEL="512MiB Windows ESP + existing data + 64GiB+ free"
|
||||
fi
|
||||
|
||||
cleanup_mount() {
|
||||
if (( MOUNTED )); then
|
||||
sudo umount "$MOUNT_DIR" >/dev/null 2>&1 || true
|
||||
@@ -149,7 +172,7 @@ largest_free_region() {
|
||||
}
|
||||
|
||||
validate_test_disk() {
|
||||
local part_count pttype free_space_b min_free_b
|
||||
local part_count pttype free_space_b min_free_b want_parts numbers
|
||||
local esp data valid=1
|
||||
|
||||
[[ -f $TEST_DISK ]] || return 1
|
||||
@@ -162,9 +185,17 @@ validate_test_disk() {
|
||||
pttype=$(lsblk -dnro PTTYPE "$ACTIVE_NBD" 2>/dev/null || true)
|
||||
free_space_b=$(largest_free_region "$ACTIVE_NBD")
|
||||
min_free_b=$((MIN_FREE_GIB * 1024 * 1024 * 1024))
|
||||
want_parts=2
|
||||
(( GAP )) && want_parts=3
|
||||
|
||||
[[ $pttype == gpt ]] || valid=0
|
||||
(( part_count == 2 )) || valid=0
|
||||
(( part_count == want_parts )) || valid=0
|
||||
|
||||
# The whole point of the gap fixture: slot 3 free, slot 4 in use.
|
||||
if (( GAP )); then
|
||||
numbers=$(sudo parted -ms "$ACTIVE_NBD" unit B print 2>/dev/null | tail -n +3 | cut -d: -f1 | sort | tr '\n' ' ')
|
||||
[[ $numbers == "1 2 4 " ]] || valid=0
|
||||
fi
|
||||
(( free_space_b >= min_free_b )) || valid=0
|
||||
[[ $(sudo blkid -s TYPE -o value "$esp" 2>/dev/null || true) == vfat ]] || valid=0
|
||||
[[ $(sudo blkid -s LABEL -o value "$esp" 2>/dev/null || true) == WINDOWS_ESP ]] || valid=0
|
||||
@@ -206,6 +237,18 @@ create_test_disk() {
|
||||
sudo parted --script "$ACTIVE_NBD" mkpart WINDOWS_ESP fat32 1MiB 513MiB
|
||||
sudo parted --script "$ACTIVE_NBD" set 1 esp on
|
||||
sudo parted --script "$ACTIVE_NBD" mkpart WINDOWS_DATA ext4 513MiB 20GiB
|
||||
|
||||
if (( GAP )); then
|
||||
# Slot 3 is created and deleted, slot 4 stays. parted then fills 3 before
|
||||
# 5, so an installer that assumes "highest + 1" (which would be 5 and 6)
|
||||
# writes to device nodes that do not exist. The deleted region is
|
||||
# deliberately smaller than the trailing free space so the installer still
|
||||
# picks the tail as its largest free region.
|
||||
sudo parted --script "$ACTIVE_NBD" mkpart SCRATCH ext4 20GiB 28GiB
|
||||
sudo parted --script "$ACTIVE_NBD" mkpart WINDOWS_MORE ext4 28GiB 30GiB
|
||||
sudo parted --script "$ACTIVE_NBD" rm 3
|
||||
fi
|
||||
|
||||
sudo partprobe "$ACTIVE_NBD"
|
||||
sudo udevadm settle
|
||||
|
||||
@@ -281,7 +324,7 @@ cp /usr/share/edk2/x64/OVMF_VARS.4m.fd "$TEST_OVMF_VARS"
|
||||
gum style --border rounded --padding "0 1" --border-foreground 6 \
|
||||
"Synthetic Windows disk ready" \
|
||||
"Disk: $TEST_DISK" \
|
||||
"Layout: 512MiB Windows ESP + existing data + 64GiB+ free"
|
||||
"Layout: $LAYOUT_LABEL"
|
||||
|
||||
if gum confirm "Start installation on this disk?"; then
|
||||
ISO="$(select_iso)"
|
||||
|
||||
+19
-3
@@ -10,8 +10,24 @@ if [[ ! -f ~/.config/rclone/rclone.conf ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rclone copy $1 Omarchy:omarchy/ -P
|
||||
# Every copy reports, and one failure fails the upload. Without the tally the
|
||||
# last copy decides the exit status, so a signature that never made it is
|
||||
# hidden by a checksum that did.
|
||||
status=0
|
||||
|
||||
if [[ -f $1.sig ]]; then
|
||||
rclone copy $1.sig Omarchy:omarchy/ -P
|
||||
rclone copy "$1" Omarchy:omarchy/ -P || status=1
|
||||
|
||||
# The signature and the checksum are only worth anything to someone who can
|
||||
# reach them beside the ISO, so they go up in the same run rather than a step
|
||||
# a release can finish without.
|
||||
for sidecar in "$1.sig" "$1.sha256"; do
|
||||
if [[ -f $sidecar ]]; then
|
||||
rclone copy "$sidecar" Omarchy:omarchy/ -P || status=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -f $1.sha256 ]]; then
|
||||
echo "Warning: no $1.sha256 to publish, so nobody can verify this download" >&2
|
||||
fi
|
||||
|
||||
exit $status
|
||||
@@ -12,3 +12,4 @@ openssh
|
||||
pipewire
|
||||
snapper
|
||||
sof-firmware
|
||||
tailscale
|
||||
+107
-45
@@ -5,12 +5,13 @@ set -e
|
||||
OMARCHY_ISO_REF="${OMARCHY_ISO_REF:-quattro}"
|
||||
OMARCHY_MIRROR="${OMARCHY_MIRROR:-stable}"
|
||||
|
||||
# Quattro, edge, dev, and local-source ISOs install the dev packages explicitly.
|
||||
# Those package recipes track the quattro branch. This avoids relying on
|
||||
# pacman's provides=omarchy resolution and shows the real package names being
|
||||
# tested in the offline mirror and target install.
|
||||
# Edge, dev, and local-source ISOs install the dev packages explicitly. Those
|
||||
# package recipes track the quattro branch. This avoids relying on pacman's
|
||||
# provides=omarchy resolution and shows the real package names being tested in
|
||||
# the offline mirror and target install. Every other ref, the default quattro
|
||||
# build included, installs the published omarchy packages.
|
||||
case "$OMARCHY_ISO_REF" in
|
||||
quattro|edge|dev|local)
|
||||
edge|dev|local)
|
||||
: "${OMARCHY_RUNTIME_PACKAGE:=omarchy-dev}"
|
||||
: "${OMARCHY_SETTINGS_PACKAGE:=omarchy-settings-dev}"
|
||||
;;
|
||||
@@ -25,7 +26,11 @@ export OMARCHY_RUNTIME_PACKAGE OMARCHY_SETTINGS_PACKAGE OMARCHY_NVIM_PACKAGE
|
||||
# Packages installed into the Arch container used to build the ISO.
|
||||
pacman-key --init
|
||||
pacman --noconfirm -Sy archlinux-keyring
|
||||
pacman --noconfirm -Sy archiso git sudo base-devel jq grub imagemagick neovim nodejs npm tree-sitter-cli
|
||||
# Full upgrade, not just -Sy: docker never re-pulls :latest once it's cached,
|
||||
# so this container can be months behind the mirror it installs from. A plain
|
||||
# -Sy install is then a partial upgrade — new packages linked against a glibc
|
||||
# the container doesn't have yet.
|
||||
pacman --noconfirm -Syu archiso git sudo base-devel jq grub imagemagick neovim nodejs npm tree-sitter-cli
|
||||
|
||||
# Pre-import the omarchy signing key (so pacman trusts our [omarchy] repo
|
||||
# during the build without keyserver lookups).
|
||||
@@ -113,15 +118,29 @@ cp "/tmp/$NODE_FILENAME" "$build_cache_dir/airootfs/opt/packages/"
|
||||
# The selected omarchy-settings package is needed here so its post_install hook
|
||||
# drops Omarchy's plymouthd.conf into /etc/plymouth before mkarchiso builds the
|
||||
# live initramfs.
|
||||
arch_packages=(linux-t2 git gum jq openssl plymouth python-terminaltexteffects tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted)
|
||||
arch_packages=(linux-t2 git gum jq openssl plymouth ttfx tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted)
|
||||
printf '%s\n' "${arch_packages[@]}" >> "$build_cache_dir/packages.x86_64"
|
||||
|
||||
# The live ISO boots linux-t2 (see airootfs/etc/mkinitcpio.d/linux-t2.preset), so
|
||||
# stock linux is a second kernel nobody boots: ~147MB of ISO, plus its own archiso
|
||||
# initramfs, copied into both the ISO tree and the size-constrained FAT EFI image.
|
||||
#
|
||||
# It cannot just be deleted — releng's broadcom-wl hard-depends on it, and it is
|
||||
# the only releng package that does, so pacman would drag the kernel straight back
|
||||
# in. broadcom-wl is a prebuilt module for stock linux and cannot load on the
|
||||
# kernel we boot, so it has done nothing since we started booting T2 anyway. The
|
||||
# install is entirely offline and the live environment needs no Wi-Fi driver.
|
||||
#
|
||||
# Anchored so linux-t2 and linux-firmware are untouched.
|
||||
sed -i -E '/^(linux|broadcom-wl)$/d' "$build_cache_dir/packages.x86_64"
|
||||
|
||||
# Build the offline mirror: everything pacstrap might want during the target
|
||||
# install. With --local-source, the omarchy* packages we just built are
|
||||
# already in the mirror and we filter them out below. Without it, pacman -Syw
|
||||
# pulls the published omarchy* from the network mirror like any other package.
|
||||
if [[ -d /omarchy-source ]]; then
|
||||
base_pkg_lists=(/omarchy-source/install/omarchy-base.packages /omarchy-source/install/omarchy-other.packages)
|
||||
setup_form=/omarchy-source/install/provisioning/setup-form.sh
|
||||
else
|
||||
# Pull the same package lists out of the freshly-downloaded Omarchy runtime
|
||||
# package so we don't need a local checkout in the non-local-source path.
|
||||
@@ -137,12 +156,37 @@ else
|
||||
mkdir -p /tmp/omarchy-pkglists
|
||||
bsdtar -xf "$omarchy_pkg" -C /tmp/omarchy-pkglists usr/share/omarchy/install/omarchy-base.packages usr/share/omarchy/install/omarchy-other.packages
|
||||
base_pkg_lists=(/tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-base.packages /tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-other.packages)
|
||||
# Extracted on its own, tolerating a miss: bsdtar exits non-zero for a member
|
||||
# it can't find, so asking for this alongside the package lists would abort the
|
||||
# build here (set -e) with a bare "Not found in archive" instead of the
|
||||
# actionable error below.
|
||||
bsdtar -xf "$omarchy_pkg" -C /tmp/omarchy-pkglists usr/share/omarchy/install/provisioning/setup-form.sh 2>/dev/null || true
|
||||
setup_form=/tmp/omarchy-pkglists/usr/share/omarchy/install/provisioning/setup-form.sh
|
||||
fi
|
||||
|
||||
mkdir -p "$build_cache_dir/airootfs/usr/share/omarchy-iso"
|
||||
cp "${base_pkg_lists[0]}" "$build_cache_dir/airootfs/usr/share/omarchy-iso/omarchy-base.packages"
|
||||
cp "${base_pkg_lists[1]}" "$build_cache_dir/airootfs/usr/share/omarchy-iso/omarchy-other.packages"
|
||||
|
||||
# The configurator's setup form comes from the runtime this ISO bundles, so the
|
||||
# installer and the first-boot setup that finishes a deferred install can never
|
||||
# disagree. A runtime predating the split ships no such file, which would leave
|
||||
# the configurator with no prompts at all.
|
||||
if [[ ! -f $setup_form ]]; then
|
||||
if [[ -d /omarchy-source ]]; then
|
||||
echo "ERROR: the --local-source checkout ships no install/provisioning/setup-form.sh" >&2
|
||||
remedy="Update the checkout to a revision carrying the shared setup form."
|
||||
else
|
||||
echo "ERROR: $OMARCHY_RUNTIME_PACKAGE does not ship install/provisioning/setup-form.sh" >&2
|
||||
remedy="Publish a runtime carrying the shared setup form, or build with --local-source against a checkout that has it."
|
||||
fi
|
||||
echo " The configurator sources its prompts from that file, so this ISO" >&2
|
||||
echo " would boot into an installer with no questions to ask." >&2
|
||||
echo " $remedy" >&2
|
||||
exit 1
|
||||
fi
|
||||
cp "$setup_form" "$build_cache_dir/airootfs/usr/share/omarchy-iso/setup-form.sh"
|
||||
|
||||
# Collect every package we want available in the offline mirror.
|
||||
declare -a all_packages
|
||||
mapfile -t all_packages < <(
|
||||
@@ -156,6 +200,23 @@ mapfile -t all_packages < <(
|
||||
} | sort -u
|
||||
)
|
||||
|
||||
# Arch dropped the prebuilt broadcom-wl on 2026-09-02 and rebuilt broadcom-wl-dkms
|
||||
# with replaces=(broadcom-wl). A replaces entry only helps upgrades of an already
|
||||
# installed package; as an explicit pacman target the old name now fails with
|
||||
# "target not found". Published Omarchy runtime packages that predate the rename
|
||||
# still list it in omarchy-other.packages, so map it here until every channel
|
||||
# ships a runtime that names broadcom-wl-dkms itself.
|
||||
# arch-mact2 dropped apple-bcm-firmware on 2026-09-16 in favour of
|
||||
# apple-bcm-firmware-fetcher, which does the same job (pull the T2 Wi-Fi and
|
||||
# Bluetooth firmware off the macOS volume) but only conflicts with the old name
|
||||
# rather than replacing it, so pacman cannot follow the rename on its own.
|
||||
mapfile -t all_packages < <(
|
||||
printf '%s\n' "${all_packages[@]}" |
|
||||
sed -e 's/^broadcom-wl$/broadcom-wl-dkms/' \
|
||||
-e 's/^apple-bcm-firmware$/apple-bcm-firmware-fetcher/' |
|
||||
sort -u
|
||||
)
|
||||
|
||||
# With --local-source we already built these omarchy* packages directly into
|
||||
# the mirror; strip them from the pacman -Syw list so it doesn't try to fetch
|
||||
# the published versions on top.
|
||||
@@ -184,48 +245,49 @@ if ! download_offline_packages; then
|
||||
download_offline_packages
|
||||
fi
|
||||
|
||||
prune_stale_package_versions() {
|
||||
local dir="$1"
|
||||
local pkgfile name version cmp
|
||||
local -a stale=()
|
||||
declare -A newest_file=()
|
||||
declare -A newest_version=()
|
||||
# Resolve the exact filenames chosen by the same synced package databases used
|
||||
# for the download. Pruning by this transaction (rather than merely keeping the
|
||||
# newest version of every cached package name) removes packages that have left
|
||||
# the lists or dependency closure, such as an old Electron major version.
|
||||
if ! resolved_package_files="$(
|
||||
pacman --config "/configs/pacman-online-${OMARCHY_MIRROR}.conf" --noconfirm \
|
||||
--dbpath /tmp/offlinedb -S --print --print-format '%f' "${all_packages[@]}"
|
||||
)"; then
|
||||
echo "ERROR: could not resolve the package files required by the offline mirror" >&2
|
||||
exit 1
|
||||
fi
|
||||
mapfile -t required_package_files <<< "$resolved_package_files"
|
||||
|
||||
while IFS= read -r pkgfile; do
|
||||
read -r name version < <(pacman -Qp "$pkgfile" 2>/dev/null) || continue
|
||||
[[ -n $name && -n $version ]] || continue
|
||||
|
||||
if [[ -z ${newest_version[$name]+x} ]]; then
|
||||
newest_version[$name]="$version"
|
||||
newest_file[$name]="$pkgfile"
|
||||
continue
|
||||
fi
|
||||
|
||||
cmp=$(vercmp "$version" "${newest_version[$name]}")
|
||||
if (( cmp > 0 )); then
|
||||
stale+=("${newest_file[$name]}")
|
||||
newest_version[$name]="$version"
|
||||
newest_file[$name]="$pkgfile"
|
||||
else
|
||||
stale+=("$pkgfile")
|
||||
fi
|
||||
done < <(find "$dir" -maxdepth 1 -type f -name '*.pkg.tar.*' ! -name '*.sig' -print | sort)
|
||||
|
||||
if (( ${#stale[@]} > 0 )); then
|
||||
echo "Pruning stale package versions from offline mirror:"
|
||||
for pkgfile in "${stale[@]}"; do
|
||||
echo " $(basename "$pkgfile")"
|
||||
rm -f "$pkgfile" "$pkgfile.sig"
|
||||
# The online transaction intentionally excludes packages built from the local
|
||||
# checkouts. Add those exact artifacts back to the keep-set after verifying
|
||||
# that the local build left exactly one file for each selected package name.
|
||||
if [[ -n ${LOCAL_OMARCHY_BUILD:-} ]]; then
|
||||
for local_package_name in \
|
||||
"$OMARCHY_RUNTIME_PACKAGE" "$OMARCHY_SETTINGS_PACKAGE" "$OMARCHY_NVIM_PACKAGE"; do
|
||||
local_package_file=""
|
||||
for candidate in "$offline_mirror_dir/$local_package_name-"*.pkg.tar.*; do
|
||||
[[ -f $candidate && $candidate != *.sig ]] || continue
|
||||
read -r candidate_name _ < <(pacman -Qp "$candidate" 2>/dev/null) || continue
|
||||
[[ $candidate_name == "$local_package_name" ]] || continue
|
||||
if [[ -n $local_package_file ]]; then
|
||||
echo "ERROR: multiple local builds found for $local_package_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
local_package_file="${candidate##*/}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
if [[ -z $local_package_file ]]; then
|
||||
echo "ERROR: local build not found for $local_package_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
required_package_files+=("$local_package_file")
|
||||
done
|
||||
fi
|
||||
|
||||
printf '%s\n' "${required_package_files[@]}" |
|
||||
bash /builder/prune-offline-mirror.sh "$offline_mirror_dir"
|
||||
|
||||
# Rebuild the offline repo db from scratch so size/checksum/depends entries
|
||||
# always reflect the current package files. The persistent cache can contain
|
||||
# multiple versions of the same package; repo-add keeps the last one it sees,
|
||||
# which is lexical glob order, not version order (e.g. pkgrel -9 can override
|
||||
# -15). Prune to one newest version per package before indexing.
|
||||
prune_stale_package_versions "$offline_mirror_dir"
|
||||
# always reflect only the package files selected for this build.
|
||||
rm -f "$offline_mirror_dir"/offline.db* "$offline_mirror_dir"/offline.files*
|
||||
repo-add "$offline_mirror_dir/offline.db.tar.gz" "$offline_mirror_dir/"*.pkg.tar.zst
|
||||
|
||||
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
offline_mirror_dir="${1:-}"
|
||||
if [[ -z $offline_mirror_dir ]]; then
|
||||
echo "Usage: prune-offline-mirror.sh <offline-mirror-dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d $offline_mirror_dir ]]; then
|
||||
echo "ERROR: offline mirror directory not found: $offline_mirror_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read the exact package filenames selected by pacman on stdin. Validate the
|
||||
# complete selection before deleting anything: an empty/partial resolution must
|
||||
# never turn a warm-cache build into a broken mirror.
|
||||
declare -A required=()
|
||||
while IFS= read -r filename; do
|
||||
[[ -n $filename ]] || continue
|
||||
if [[ $filename == */* || $filename != *.pkg.tar.* || $filename == *.sig ]]; then
|
||||
echo "ERROR: invalid required package filename: $filename" >&2
|
||||
exit 1
|
||||
fi
|
||||
required["$filename"]=1
|
||||
done
|
||||
|
||||
if (( ${#required[@]} == 0 )); then
|
||||
echo "ERROR: refusing to prune the offline mirror with an empty package selection" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
missing=()
|
||||
for filename in "${!required[@]}"; do
|
||||
[[ -f "$offline_mirror_dir/$filename" ]] || missing+=("$filename")
|
||||
done
|
||||
if (( ${#missing[@]} > 0 )); then
|
||||
echo "ERROR: refusing to prune; selected packages are missing from the mirror:" >&2
|
||||
printf ' %s\n' "${missing[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stale=()
|
||||
while IFS= read -r -d '' package_file; do
|
||||
filename="${package_file##*/}"
|
||||
[[ -n ${required[$filename]+x} ]] || stale+=("$package_file")
|
||||
done < <(
|
||||
find "$offline_mirror_dir" -maxdepth 1 -type f \
|
||||
-name '*.pkg.tar.*' ! -name '*.sig' -print0
|
||||
)
|
||||
|
||||
if (( ${#stale[@]} > 0 )); then
|
||||
echo "Pruning package archives not selected for the offline mirror:"
|
||||
for package_file in "${stale[@]}"; do
|
||||
echo " $(basename "$package_file")"
|
||||
rm -f -- "$package_file" "$package_file.sig"
|
||||
done
|
||||
fi
|
||||
|
||||
# A failed or interrupted download can leave a signature without its archive.
|
||||
# It cannot be indexed and only wastes space in the ISO.
|
||||
while IFS= read -r -d '' signature_file; do
|
||||
[[ -f ${signature_file%.sig} ]] || rm -f -- "$signature_file"
|
||||
done < <(
|
||||
find "$offline_mirror_dir" -maxdepth 1 -type f \
|
||||
-name '*.pkg.tar.*.sig' -print0
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
# mkinitcpio preset file for the 'linux-t2' package on archiso
|
||||
#
|
||||
# The filename is the pkgbase, and that is load-bearing. Kernel packages ship
|
||||
# nothing in /boot — they only install usr/lib/modules/<kver>/vmlinuz — so
|
||||
# mkinitcpio's alpm hook sources /etc/mkinitcpio.d/<pkgbase>.preset and copies
|
||||
# THAT package's kernel to whatever ALL_kver names (is_kernelcopy in
|
||||
# /usr/share/libalpm/scripts/mkinitcpio). Named linux.preset, this pointed the
|
||||
# stock kernel at the T2 filenames, so the ISO booted stock Arch while every
|
||||
# boot entry said linux-t2 and T2 Macs got no keyboard or trackpad.
|
||||
#
|
||||
# releng ships its own linux.preset for the stock kernel; leave it alone.
|
||||
|
||||
PRESETS=('archiso')
|
||||
|
||||
ALL_kver='/boot/vmlinuz-linux-t2'
|
||||
archiso_config='/etc/mkinitcpio.conf.d/archiso.conf'
|
||||
|
||||
archiso_image="/boot/initramfs-linux-t2.img"
|
||||
@@ -1,9 +0,0 @@
|
||||
# mkinitcpio preset file for the 'linux' package on archiso
|
||||
|
||||
PRESETS=('archiso')
|
||||
|
||||
ALL_kver='/boot/vmlinuz-linux-t2'
|
||||
archiso_config='/etc/mkinitcpio.conf.d/archiso.conf'
|
||||
|
||||
archiso_image="/boot/initramfs-linux-t2.img"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# linux-t2 ships for every machine, and on a pre-T2 Mac its applesmc oopses
|
||||
# registering the keyboard-backlight LED, wedging udev. Nothing here needs the SMC.
|
||||
blacklist applesmc
|
||||
@@ -91,7 +91,25 @@ warm_pid=$!
|
||||
trap 'kill "$warm_pid" 2>/dev/null' EXIT
|
||||
|
||||
cd /root
|
||||
./configurator
|
||||
# Autoinstall: a cidata drive carrying the configurator's own output files
|
||||
# stands in for the wizard. omarchy-cidata-load copies them into /root and
|
||||
# everything downstream runs the ordinary path against ordinary inputs.
|
||||
if /usr/local/bin/omarchy-cidata-load; then
|
||||
echo "Autoinstall configuration found on cidata drive; skipping the configurator."
|
||||
export OMARCHY_UI_INTERACTIVE=no
|
||||
else
|
||||
./configurator
|
||||
fi
|
||||
|
||||
# Deferred-provisioning installs skip the celebration/reboot prompt and reboot on
|
||||
# their own — the owner completes setup at first boot. Signalled by the config's
|
||||
# defer_provisioning flag (interactive) or the defer-provisioning marker (cidata).
|
||||
# Parse the flag with jq (the same JSON semantics the orchestrator uses) rather
|
||||
# than a line regex, so a reformatted config can't read as a direct install.
|
||||
if [[ -f /root/defer-provisioning ]] ||
|
||||
[[ "$(jq -r '.omarchy_install.defer_provisioning // false' /root/user_configuration.json 2>/dev/null)" == "true" ]]; then
|
||||
export OMARCHY_UI_DEFER_PROVISIONING=yes
|
||||
fi
|
||||
|
||||
# The foreground dashboard is now the sole visible install UI owner. It starts
|
||||
# the actual installer as a non-interactive child, logs child output, waits for
|
||||
@@ -107,4 +125,7 @@ rm -f /run/omarchy-install/state.json
|
||||
--creds /root/user_credentials.json \
|
||||
--full-name-file /root/user_full_name.txt \
|
||||
--email-file /root/user_email_address.txt \
|
||||
--encrypt-file /root/user_encrypt_installation.txt
|
||||
--encrypt-file /root/user_encrypt_installation.txt \
|
||||
--authorized-keys-file /root/authorized_keys \
|
||||
--tailscale-authkey-file /root/tailscale_authkey \
|
||||
--defer-provisioning-file /root/defer-provisioning
|
||||
+422
-199
@@ -9,6 +9,32 @@ OMARCHY_SETTINGS_PACKAGE="${OMARCHY_SETTINGS_PACKAGE:-omarchy-settings}"
|
||||
|
||||
LOGO_PATH="$OMARCHY_PATH/logo.txt"
|
||||
|
||||
# The setup form — keyboard, account, hostname, and timezone questions, plus the
|
||||
# rules their answers are checked against — shared verbatim with the first-boot
|
||||
# owner setup that finishes a deferred install. build-iso.sh vendors it out of
|
||||
# the runtime package this ISO bundles, so the two can never offer different
|
||||
# layouts or accept different usernames. On the ISO that vendored copy is what
|
||||
# loads; a dry run outside the ISO falls back to the omarchy checkout
|
||||
# bin/omarchy-iso-configurator already points OMARCHY_PATH at.
|
||||
SETUP_FORM="${SETUP_FORM:-/usr/share/omarchy-iso/setup-form.sh}"
|
||||
[[ -r $SETUP_FORM ]] || SETUP_FORM="$OMARCHY_PATH/install/provisioning/setup-form.sh"
|
||||
if [[ ! -r $SETUP_FORM ]]; then
|
||||
echo "ERROR: shared setup form not found at $SETUP_FORM" >&2
|
||||
exit 1
|
||||
fi
|
||||
source "$SETUP_FORM"
|
||||
|
||||
# Partition creation helpers, shared with test/partition-numbering-test.sh so
|
||||
# the numbering logic can be exercised without a real disk.
|
||||
DISK_PARTITIONING="${DISK_PARTITIONING:-/usr/share/omarchy-iso/disk-partitioning.sh}"
|
||||
[[ -r $DISK_PARTITIONING ]] ||
|
||||
DISK_PARTITIONING="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../usr/share/omarchy-iso/disk-partitioning.sh"
|
||||
if [[ ! -r $DISK_PARTITIONING ]]; then
|
||||
echo "ERROR: disk partitioning helpers not found at $DISK_PARTITIONING" >&2
|
||||
exit 1
|
||||
fi
|
||||
source "$DISK_PARTITIONING"
|
||||
|
||||
LOGO_WIDTH=$(awk '{ if (length > max) max = length } END { print max+0 }' "$LOGO_PATH")
|
||||
|
||||
export GUM_CONFIRM_PROMPT_FOREGROUND="6"
|
||||
@@ -38,12 +64,117 @@ measure_terminal() {
|
||||
}
|
||||
measure_terminal
|
||||
|
||||
# The live VT resizes late during boot: tty1 starts as the 80-column boot
|
||||
# console and only grows once the kernel framebuffer/KMS takes over (noticeably
|
||||
# late in VMs). The logo is wider than 80 columns, so a first draw against that
|
||||
# transient narrow console wraps the logo ("smushed") and can't center it
|
||||
# (padding clamps to 0, so it hugs the left). A terminal emulator (or sudo's
|
||||
# pty) has the same problem the other way: it reports a stale 24x80 for a few
|
||||
# hundred ms after start before its real winsize is set. Either way, hold the
|
||||
# first draw until the width settles at (or above) the logo width. A real VT
|
||||
# that never widens (e.g. nomodeset) still proceeds after the cap.
|
||||
wait_for_stable_terminal() {
|
||||
local width last="" stable=0 waited=0
|
||||
while (( waited < 5000 )); do
|
||||
width=$(stty size 2>/dev/null </dev/tty | awk '{print $2}')
|
||||
[[ $width =~ ^[0-9]+$ ]] || width=0
|
||||
if [[ $width == "$last" ]] && (( width >= LOGO_WIDTH )); then
|
||||
(( ++stable >= 3 )) && break
|
||||
else
|
||||
stable=0
|
||||
fi
|
||||
last=$width
|
||||
sleep 0.2
|
||||
(( waited += 200 ))
|
||||
done
|
||||
}
|
||||
|
||||
clear_logo() {
|
||||
measure_terminal
|
||||
printf "\033[H\033[2J"
|
||||
gum style --foreground 2 --padding "1 0 0 $PADDING_LEFT" "$(<"$LOGO_PATH")"
|
||||
}
|
||||
|
||||
# Vertically-centered welcome shown once before the keyboard step — the same
|
||||
# frame the deferred-provisioning first boot opens on, so install and first boot
|
||||
# bookend the setup identically. Logo, the Omarchy tagline, and a single button,
|
||||
# centered like the boot logo. No animation.
|
||||
greeter() {
|
||||
measure_terminal
|
||||
|
||||
local rows logo_h content_h top cols logo_row tagline_row hint_row
|
||||
local tagline hint tpad hpad anim
|
||||
cols=$TERM_WIDTH
|
||||
rows=$(stty size 2>/dev/null </dev/tty | awk '{print $1}')
|
||||
[[ $rows =~ ^[0-9]+$ ]] || rows=${LINES:-24}
|
||||
logo_h=$(wc -l <"$LOGO_PATH")
|
||||
|
||||
# logo + blank + tagline + blank + hint
|
||||
content_h=$((logo_h + 4))
|
||||
top=$(((rows - content_h) / 2))
|
||||
(( top < 0 )) && top=0
|
||||
logo_row=$((top + 1))
|
||||
tagline_row=$((top + logo_h + 2))
|
||||
hint_row=$((top + logo_h + 4))
|
||||
|
||||
printf '\033[?25l\033[H\033[2J'
|
||||
|
||||
printf '\033[%d;1H' "$logo_row"
|
||||
gum style --foreground 2 --padding "0 0 0 $PADDING_LEFT" "$(<"$LOGO_PATH")"
|
||||
|
||||
tagline="Beautiful, Fun & Agentic Linux by DHH"
|
||||
tpad=$(((cols - ${#tagline}) / 2)); (( tpad < 0 )) && tpad=0
|
||||
printf '\033[%d;%dH%s' "$tagline_row" "$((tpad + 1))" "$tagline"
|
||||
|
||||
hint="Press Return to Start Install"
|
||||
hpad=$(((cols - ${#hint}) / 2)); (( hpad < 0 )) && hpad=0
|
||||
printf '\033[%d;%dH\033[2m%s\033[0m' "$hint_row" "$((hpad + 1))" "$hint"
|
||||
|
||||
# ColorShift the logo: a green base (indexed color 2) with a cyan accent (6)
|
||||
# drifting through, settling on green. Indexed ANSI colors, not hex — the
|
||||
# framebuffer console can't render truecolor faithfully (it crushes the
|
||||
# palette to a muddy lavender), but the 16 indexed colors map to the Tokyo
|
||||
# Night palette and render true. --xterm-colors is what keeps them indexed:
|
||||
# ttfx resolves even indexed stops to truecolor otherwise, which would put the
|
||||
# settle color out of step with the `gum style --foreground 2` logo underneath.
|
||||
# One long-running invocation (many cycles) so it never restarts — a restart is
|
||||
# what flashed. The effect reads from /dev/null so it never swallows the
|
||||
# Return; --reuse-canvas paints upward from the saved cursor, anchored one row
|
||||
# below the logo.
|
||||
printf '\033[%d;1H\0337' "$((logo_row + logo_h))"
|
||||
# Run ttfx directly (not inside a `while` subshell) so $anim is ttfx's own
|
||||
# PID: killing a wrapping subshell would orphan ttfx, which then keeps
|
||||
# painting the logo over the keyboard step. --cycles is high enough that it
|
||||
# never ends on its own before Return.
|
||||
# Two columns narrower than the console: ttfx centers its text two columns
|
||||
# right of plain centering, so a full-width canvas would sit the animated
|
||||
# logo a column off the gum-drawn one underneath it.
|
||||
ttfx -i "$LOGO_PATH" \
|
||||
--canvas-width "$((cols > 2 ? cols - 2 : cols))" \
|
||||
--anchor-text c \
|
||||
--frame-rate 60 \
|
||||
--reuse-canvas \
|
||||
--xterm-colors \
|
||||
colorshift \
|
||||
--gradient-stops 2 10 6 10 \
|
||||
--gradient-frames 3 \
|
||||
--cycles 1000 \
|
||||
--final-gradient-stops 2 \
|
||||
</dev/null >/dev/tty 2>/dev/null &
|
||||
anim=$!
|
||||
|
||||
IFS= read -r _ </dev/tty || true
|
||||
# Tolerate ttfx's kill signal in `wait` so a future `set -e` here can't abort.
|
||||
kill "$anim" 2>/dev/null
|
||||
wait "$anim" 2>/dev/null || true
|
||||
# ttfx leaves the tty in raw/no-echo mode when killed; restore it or the gum
|
||||
# prompts in the keyboard step that follows silently die.
|
||||
stty sane </dev/tty 2>/dev/null || true
|
||||
# Reset the screen so the leftover animation frame doesn't linger under the
|
||||
# keyboard step that follows.
|
||||
printf '\033[0m\033[H\033[2J\033[?25h'
|
||||
}
|
||||
|
||||
abort() {
|
||||
gum style "${1:-Aborted installation}"
|
||||
echo
|
||||
@@ -73,59 +204,33 @@ notice() {
|
||||
# STEP 1: KEYBOARD LAYOUT
|
||||
|
||||
keyboard_form() {
|
||||
step "Let's setup your machine..."
|
||||
keyboards=$'Azerbaijani|azerty
|
||||
Belarusian|by
|
||||
Belgian|be-latin1
|
||||
Bosnian|ba
|
||||
Bulgarian|bg-cp1251
|
||||
Croatian|croat
|
||||
Czech|cz
|
||||
Danish|dk-latin1
|
||||
Dutch|nl
|
||||
English (UK)|uk
|
||||
English (US)|us
|
||||
English (US, Dvorak)|dvorak
|
||||
English (US, Colemak)|colemak
|
||||
Estonian|et
|
||||
Finnish|fi
|
||||
French|fr
|
||||
French (Canada)|cf
|
||||
French (Switzerland)|fr_CH
|
||||
Georgian|ge
|
||||
German|de
|
||||
German (Switzerland)|de_CH-latin1
|
||||
Greek|gr
|
||||
Hebrew|il
|
||||
Hungarian|hu
|
||||
Icelandic|is-latin1
|
||||
Irish|ie
|
||||
Italian|it
|
||||
Japanese|jp106
|
||||
Kazakh|kazakh
|
||||
Khmer (Cambodia)|khmer
|
||||
Kyrgyz|kyrgyz
|
||||
Lao|la-latin1
|
||||
Latvian|lv
|
||||
Lithuanian|lt
|
||||
Macedonian|mk-utf
|
||||
Norwegian|no-latin1
|
||||
Polish|pl
|
||||
Portuguese|pt-latin1
|
||||
Portuguese (Brazil)|br-abnt2
|
||||
Romanian|ro
|
||||
Russian|ru
|
||||
Serbian|sr-latin
|
||||
Slovak|sk-qwertz
|
||||
Slovenian|slovene
|
||||
Spanish|es
|
||||
Spanish (Latin American)|la-latin1
|
||||
Swedish|sv-latin1
|
||||
Tajik|tj_alt-UTF8
|
||||
Turkish|trq
|
||||
Ukrainian|ua'
|
||||
choice=$(printf '%s\n' "$keyboards" | cut -d'|' -f1 | gum choose --height 10 --selected "English (US)" --header "Select keyboard layout") || abort
|
||||
keyboard=$(printf '%s\n' "$keyboards" | awk -F'|' -v c="$choice" '$1==c{print $2; exit}')
|
||||
# Ctrl+C is the hidden entry into deferred provisioning, offered on every
|
||||
# visit: the user step unwinds back here and nothing is on disk yet. Callers
|
||||
# re-check defer_provisioning after this returns.
|
||||
local status
|
||||
|
||||
while true; do
|
||||
clear_logo
|
||||
echo
|
||||
say "Let's setup your machine..."
|
||||
say --foreground 8 "Press Ctrl+C to prepare this machine for another owner."
|
||||
echo
|
||||
|
||||
omarchy_prompt_keyboard && status=0 || status=$?
|
||||
((status == 0)) && break
|
||||
|
||||
# Esc means "back", and nothing precedes the first screen, so re-ask.
|
||||
((status == OMARCHY_FORM_BACK)) && continue
|
||||
|
||||
if ((status == OMARCHY_FORM_SIGNAL)); then
|
||||
if confirm_prepare_for_another_owner; then
|
||||
defer_provisioning=true
|
||||
return 0
|
||||
fi
|
||||
continue # declined: back to the keyboard picker
|
||||
fi
|
||||
abort
|
||||
done
|
||||
|
||||
# Only attempt to load keyboard layout if we're on a real console
|
||||
# loadkeys only works on Linux virtual consoles (tty), not in terminal emulators
|
||||
@@ -134,70 +239,59 @@ Ukrainian|ua'
|
||||
fi
|
||||
}
|
||||
|
||||
keyboard_form
|
||||
# Ctrl+C on the first screen offers to prepare the machine for another owner.
|
||||
# Confirm it before committing, so an accidental Ctrl+C doesn't silently switch
|
||||
# the whole install.
|
||||
confirm_prepare_for_another_owner() {
|
||||
clear_logo
|
||||
echo
|
||||
say "This prepares the machine for another owner."
|
||||
say --foreground 8 "The system installs now, but setup is delayed until first boot."
|
||||
echo
|
||||
gum confirm --affirmative "Yes, prepare for another owner" --negative "No, keep setting up" \
|
||||
"Prepare this machine for another owner?"
|
||||
}
|
||||
|
||||
# STEP 2: USER
|
||||
# The user step. Deferred-provisioning installs skip it entirely — the machine's first owner
|
||||
# picks their keyboard and creates their user in the first-boot setup, so the
|
||||
# operator sets nothing user-specific.
|
||||
|
||||
user_form() {
|
||||
step "Let's setup your user account..."
|
||||
|
||||
while true; do
|
||||
username=$(gum input --placeholder "Alphanumeric without spaces (like dhh)" --prompt.foreground="#845DF9" --prompt "Username> ") || abort
|
||||
# Each prompt reports 0 (set), OMARCHY_FORM_BACK (Esc), or OMARCHY_FORM_SIGNAL
|
||||
# (Ctrl+C). Both non-zero cases unwind to user_step, which decides what they
|
||||
# mean here; the form itself never aborts.
|
||||
omarchy_prompt_username || return $?
|
||||
omarchy_prompt_password || return $?
|
||||
|
||||
if [[ "$username" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then
|
||||
break
|
||||
else
|
||||
notice "Username must be alphanumeric with no spaces" 1
|
||||
fi
|
||||
done
|
||||
|
||||
while true; do
|
||||
password=$(gum input --placeholder "Used for user + root, and disk encryption when enabled" --prompt.foreground="#845DF9" --password --prompt "Password> ") || abort
|
||||
password_confirmation=$(gum input --placeholder "Must match the password you just typed" --prompt.foreground="#845DF9" --password --prompt "Confirm> ") || abort
|
||||
|
||||
if [[ -n "$password" && "$password" == "$password_confirmation" ]]; then
|
||||
break
|
||||
elif [[ -z "$password" ]]; then
|
||||
notice "Your password can't be blank!" 1
|
||||
else
|
||||
notice "Passwords didn't match!" 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Hash the password using yescrypt
|
||||
# Hash the password with SHA-512 crypt ($6$), which is what openssl passwd offers
|
||||
password_hash=$(printf '%s' "$password" | openssl passwd -6 -stdin)
|
||||
|
||||
full_name=$(gum input --placeholder "Used for git authentication (hit return to skip)" --prompt.foreground="#845DF9" --prompt "Full name> ")
|
||||
email_address=$(gum input --placeholder "Used for git authentication (hit return to skip)" --prompt.foreground="#845DF9" --prompt "Email address> ")
|
||||
|
||||
while true; do
|
||||
hostname=$(gum input --placeholder "Letters, digits, and dashes (or return for 'omarchy')" --prompt.foreground="#845DF9" --prompt "Hostname> ")
|
||||
|
||||
if [[ "$hostname" =~ ^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?$ ]]; then
|
||||
break
|
||||
elif [[ -z $hostname ]]; then
|
||||
hostname="omarchy"
|
||||
break
|
||||
else
|
||||
notice "Hostname must be 1-63 letters, digits, or dashes, and cannot start or end with a dash" 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Pick timezone
|
||||
geo_guessed_timezone=$(tzupdate -p 2>/dev/null)
|
||||
|
||||
if [[ -n $geo_guessed_timezone ]]; then
|
||||
timezone=$(timedatectl list-timezones | gum choose --height 10 --selected "$geo_guessed_timezone" --header "Timezone") || abort
|
||||
else
|
||||
timezone=$(timedatectl list-timezones | gum filter --height 10 --header "Timezone") || abort
|
||||
fi
|
||||
omarchy_prompt_identity || return $?
|
||||
omarchy_prompt_hostname || return $?
|
||||
omarchy_prompt_timezone || return $?
|
||||
}
|
||||
|
||||
user_form
|
||||
# Returns 0 on confirmed account details, or as soon as the keyboard screen
|
||||
# arms deferred provisioning.
|
||||
user_step() {
|
||||
local status
|
||||
|
||||
while true; do
|
||||
# Add manual padding since gum table -p doesn't respect padding
|
||||
echo -e "Field,Value
|
||||
while true; do
|
||||
user_form && status=0 || status=$?
|
||||
if ((status != 0)); then
|
||||
# Esc unwinds to the start of the form. Ctrl+C has no side channel in the
|
||||
# user step (only the keyboard and disk screens give it a meaning), so it
|
||||
# keeps its long-standing behaviour of ending the install.
|
||||
((status == OMARCHY_FORM_BACK)) || abort
|
||||
keyboard_form
|
||||
$defer_provisioning && return 0
|
||||
continue
|
||||
fi
|
||||
|
||||
# Add manual padding since gum table -p doesn't respect padding
|
||||
echo -e "Field,Value
|
||||
Username,$username
|
||||
Password,$(printf "%${#password}s" | tr ' ' '*')
|
||||
Full name,${full_name:-[Skipped]}
|
||||
@@ -205,16 +299,17 @@ Email address,${email_address:-[Skipped]}
|
||||
Hostname,$hostname
|
||||
Timezone,$timezone
|
||||
Keyboard,$keyboard" |
|
||||
gum table -s "," -p | sed "s/^/${PADDING_LEFT_SPACES}/"
|
||||
gum table -s "," -p | sed "s/^/${PADDING_LEFT_SPACES}/"
|
||||
|
||||
echo
|
||||
if gum confirm --negative "No, change it" "Does this look right?"; then
|
||||
break
|
||||
else
|
||||
keyboard_form
|
||||
user_form
|
||||
fi
|
||||
done
|
||||
echo
|
||||
if gum confirm --negative "No, change it" "Does this look right?"; then
|
||||
break
|
||||
else
|
||||
keyboard_form
|
||||
$defer_provisioning && return 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# STEP 3: DISK
|
||||
|
||||
@@ -277,15 +372,7 @@ get_root_disk() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Compute partition device path, handling NVMe/mmcblk's pN naming.
|
||||
partition_path() {
|
||||
local _disk="$1" _num="$2"
|
||||
if [[ "$_disk" == *nvme* || "$_disk" == *mmcblk* ]]; then
|
||||
echo "${_disk}p${_num}"
|
||||
else
|
||||
echo "${_disk}${_num}"
|
||||
fi
|
||||
}
|
||||
# partition_path lives in disk-partitioning.sh alongside the creation helpers.
|
||||
|
||||
# BitLocker writes the "-FVE-FS-" signature at offset 3 of the partition.
|
||||
detect_bitlocker() {
|
||||
@@ -328,26 +415,44 @@ detect_kernel() {
|
||||
if lspci -nn 2>/dev/null | grep -q "106b:180[12]"; then
|
||||
echo "linux-t2"
|
||||
else
|
||||
echo "linux"
|
||||
echo "linux-omarchy"
|
||||
fi
|
||||
}
|
||||
|
||||
# Give udev a moment to create a device node after partitioning.
|
||||
wait_for_device() {
|
||||
local i
|
||||
for i in 1 2 3 4 5; do
|
||||
[[ -b "$1" ]] && return 0
|
||||
sleep 1
|
||||
done
|
||||
# wait_for_device lives in disk-partitioning.sh: it now reports failure, and
|
||||
# every caller here aborts on it.
|
||||
|
||||
# disk_step and create_partition fail through this rather than abort() so a
|
||||
# half-built layout is undone before the user is handed back their disk.
|
||||
disk_abort_hook() {
|
||||
# Release the target before reclaiming its partitions: a mounted filesystem
|
||||
# or an open LUKS mapping would keep parted from removing them.
|
||||
umount -R /mnt 2>/dev/null || true
|
||||
umount /mnt/btrfs-root 2>/dev/null || true
|
||||
rmdir /mnt/btrfs-root 2>/dev/null || true
|
||||
cryptsetup close omarchy_root 2>/dev/null || true
|
||||
rollback_created_parts "$disk"
|
||||
abort "$1"
|
||||
}
|
||||
|
||||
# Save the configurator answers the installer consumes: git identity and
|
||||
# encryption choice as plain files, account details as archinstall credentials.
|
||||
# Deferred-provisioning installs defer the user to first boot: no credentials, and on encrypted
|
||||
# targets the orchestrator generates a throwaway LUKS passphrase itself.
|
||||
write_user_files() {
|
||||
echo "$full_name" >user_full_name.txt
|
||||
echo "$email_address" >user_email_address.txt
|
||||
printf '%s\n' "$encrypt_installation" >user_encrypt_installation.txt
|
||||
|
||||
if $defer_provisioning; then
|
||||
cat <<-_EOF_ >user_credentials.json
|
||||
{
|
||||
"users": []
|
||||
}
|
||||
_EOF_
|
||||
return
|
||||
fi
|
||||
|
||||
local password_escaped password_hash_escaped username_escaped
|
||||
password_escaped=$(echo -n "$password" | jq -Rsa)
|
||||
password_hash_escaped=$(echo -n "$password_hash" | jq -Rsa)
|
||||
@@ -409,17 +514,18 @@ not_enough_space() {
|
||||
return 1
|
||||
}
|
||||
|
||||
run_partition_install() {
|
||||
local dry=false
|
||||
[[ "${1:-}" == "dry" ]] && dry=true
|
||||
|
||||
# Decide half of the free-space install: checks, free-space analysis, and the
|
||||
# encryption confirm. Sets the globals run_partition_execute needs. Returns 1
|
||||
# to fall back to the install-mode picker.
|
||||
run_partition_decide() {
|
||||
step "Checking for BitLocker on $disk"
|
||||
local bl_part
|
||||
bl_part=$(detect_bitlocker || true)
|
||||
if [[ -n "$bl_part" ]]; then
|
||||
say --foreground 1 "BitLocker signature detected on $bl_part."
|
||||
say "Suspend or disable BitLocker in Windows before installing alongside it."
|
||||
abort "Aborted: BitLocker is active on this disk."
|
||||
say "Turn BitLocker off in Windows and wait for the drive to finish decrypting, then try again."
|
||||
say "Suspending BitLocker is not enough — the drive stays encrypted."
|
||||
abort "Aborted: BitLocker is enabled on this disk."
|
||||
fi
|
||||
|
||||
# Omarchy always creates its own dedicated ESP in free space and never
|
||||
@@ -444,7 +550,8 @@ run_partition_install() {
|
||||
|
||||
# An unlabeled disk has no partition table for parted to scan, so we
|
||||
# synthesize a whole-disk free region and mklabel gpt before mkpart.
|
||||
local FREE_SPACE_INFO needs_mklabel=false pt_type disk_size_b
|
||||
local FREE_SPACE_INFO pt_type disk_size_b
|
||||
needs_mklabel=false
|
||||
pt_type=$(lsblk -dno PTTYPE "$disk" 2>/dev/null)
|
||||
if [[ -z "$pt_type" ]]; then
|
||||
disk_size_b=$(lsblk -bdno SIZE "$disk" 2>/dev/null)
|
||||
@@ -487,7 +594,6 @@ run_partition_install() {
|
||||
local EFI_SIZE_B=$((2 * gib))
|
||||
local MIN_INSTALL_B=$((32 * gib)) # Minimum total Omarchy allocation
|
||||
|
||||
local EFI_START_B EFI_END_B ROOT_START_B ROOT_END_B
|
||||
EFI_START_B=$(( (FREE_START_B + ALIGN - 1) / ALIGN * ALIGN ))
|
||||
EFI_END_B=$((EFI_START_B + EFI_SIZE_B))
|
||||
ROOT_START_B=$(( (EFI_END_B + 1 + ALIGN - 1) / ALIGN * ALIGN ))
|
||||
@@ -550,7 +656,6 @@ run_partition_install() {
|
||||
esac
|
||||
done
|
||||
|
||||
local esp_mount_in_target
|
||||
if [[ "$encrypt_installation" == "true" ]]; then
|
||||
esp_mount_in_target=/boot
|
||||
else
|
||||
@@ -559,81 +664,123 @@ run_partition_install() {
|
||||
|
||||
kernel_choice=$(detect_kernel)
|
||||
|
||||
local last_part efi_part_num root_part_num
|
||||
last_part=$(lsblk -n -o PARTN "$disk" 2>/dev/null | grep -E '^[0-9]+$' | sort -n | tail -1)
|
||||
efi_part_num=$(( ${last_part:-0} + 1 ))
|
||||
root_part_num=$(( efi_part_num + 1 ))
|
||||
|
||||
local efi_dev root_partition_device root_mapper
|
||||
efi_dev=$(partition_path "$disk" "$efi_part_num")
|
||||
root_partition_device=$(partition_path "$disk" "$root_part_num")
|
||||
# Partition numbers are not knowable until parted assigns them (it fills the
|
||||
# lowest free GPT slot, and freeing space by deleting a partition leaves one
|
||||
# below the highest). run_partition_execute reads them back after creation;
|
||||
# a dry run has nothing to read.
|
||||
efi_part_num=""
|
||||
root_part_num=""
|
||||
efi_dev="<assigned at creation>"
|
||||
root_partition_device="<assigned at creation>"
|
||||
root_mapper="<assigned at creation>"
|
||||
if [[ "$encrypt_installation" == "true" ]]; then
|
||||
root_mapper="/dev/mapper/omarchy_root"
|
||||
else
|
||||
root_mapper="$root_partition_device"
|
||||
fi
|
||||
}
|
||||
|
||||
# Execute half of the free-space install: partition, format, mount, and write
|
||||
# the pre-mounted (protected) install configuration. Runs after the user step
|
||||
# so LUKS can be formatted with the user's password.
|
||||
run_partition_execute() {
|
||||
local dry=false subvol
|
||||
[[ "${1:-}" == "dry" ]] && dry=true
|
||||
|
||||
if $dry; then
|
||||
$needs_mklabel && say "[dry] would initialize GPT on $disk"
|
||||
say "[dry] would create root partition at $root_partition_device"
|
||||
say "[dry] would create EFI partition at $efi_dev"
|
||||
say "[dry] would create an EFI partition and a root partition in the free region"
|
||||
say "[dry] partition numbers are assigned by parted at creation, then read back"
|
||||
say "[dry] encrypted=$encrypt_installation kernel=$kernel_choice"
|
||||
else
|
||||
step "Creating partitions on $disk"
|
||||
if $needs_mklabel; then
|
||||
parted --script "$disk" mklabel gpt
|
||||
disk_step "initializing GPT on $disk" parted --script "$disk" mklabel gpt
|
||||
partprobe "$disk" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
parted --script "$disk" mkpart primary fat32 "${EFI_START_B}B" "${EFI_END_B}B"
|
||||
parted --script "$disk" set "$efi_part_num" esp on
|
||||
parted --script "$disk" name "$efi_part_num" "OMARCHY_EFI"
|
||||
parted --script "$disk" mkpart primary btrfs "${ROOT_START_B}B" "${ROOT_END_B}B"
|
||||
parted --script "$disk" name "$root_part_num" "OMARCHY_ROOT"
|
||||
|
||||
# create_partition reports the number parted actually used; nothing here
|
||||
# may assume it. It sets created_partition_number rather than printing so
|
||||
# the rollback bookkeeping survives (a $(...) would subshell it away).
|
||||
create_partition "$disk" "$EFI_START_B" "$EFI_END_B" fat32 OMARCHY_EFI ||
|
||||
disk_abort_hook "Could not create the EFI partition on $disk"
|
||||
efi_part_num="$created_partition_number"
|
||||
|
||||
create_partition "$disk" "$ROOT_START_B" "$ROOT_END_B" btrfs OMARCHY_ROOT ||
|
||||
disk_abort_hook "Could not create the root partition on $disk"
|
||||
root_part_num="$created_partition_number"
|
||||
|
||||
disk_step "flagging partition $efi_part_num as ESP" \
|
||||
parted --script "$disk" set "$efi_part_num" esp on
|
||||
|
||||
efi_dev=$(partition_path "$disk" "$efi_part_num")
|
||||
root_partition_device=$(partition_path "$disk" "$root_part_num")
|
||||
|
||||
partprobe "$disk"
|
||||
sync
|
||||
sleep 2
|
||||
|
||||
wait_for_device "$efi_dev"
|
||||
wait_for_device "$root_partition_device"
|
||||
wait_for_device "$efi_dev" || disk_abort_hook "EFI partition $efi_dev never appeared"
|
||||
wait_for_device "$root_partition_device" ||
|
||||
disk_abort_hook "Root partition $root_partition_device never appeared"
|
||||
|
||||
# Both partitions are ours and brand new, but the space they occupy may
|
||||
# carry signatures from whatever was deleted to free it.
|
||||
disk_step "clearing stale signatures on $efi_dev" wipefs -af "$efi_dev"
|
||||
disk_step "clearing stale signatures on $root_partition_device" wipefs -af "$root_partition_device"
|
||||
|
||||
if [[ "$encrypt_installation" == "true" ]]; then
|
||||
step "Setting up LUKS2 on $root_partition_device"
|
||||
printf "%s" "$password" | cryptsetup luksFormat --type luks2 --batch-mode "$root_partition_device" -
|
||||
printf "%s" "$password" | cryptsetup open "$root_partition_device" omarchy_root -
|
||||
# Kept as pipes rather than routed through disk_step: the passphrase must
|
||||
# not become an argv the process table can show. Folding stderr into
|
||||
# stdout still lands any error in the install log.
|
||||
if ! printf "%s" "$password" |
|
||||
cryptsetup luksFormat --type luks2 --batch-mode "$root_partition_device" - 2>&1; then
|
||||
disk_abort_hook "Formatting LUKS2 on $root_partition_device failed"
|
||||
fi
|
||||
if ! printf "%s" "$password" |
|
||||
cryptsetup open "$root_partition_device" omarchy_root - 2>&1; then
|
||||
disk_abort_hook "Opening the encrypted root on $root_partition_device failed"
|
||||
fi
|
||||
root_mapper="/dev/mapper/omarchy_root"
|
||||
else
|
||||
wipefs -af "$root_partition_device"
|
||||
root_mapper="$root_partition_device"
|
||||
fi
|
||||
|
||||
step "Creating Btrfs filesystem and subvolumes"
|
||||
mkfs.btrfs -f -L OMARCHY "$root_mapper"
|
||||
wait_for_device "$root_mapper"
|
||||
disk_step "creating the Btrfs filesystem on $root_mapper" \
|
||||
mkfs.btrfs -f -L OMARCHY "$root_mapper"
|
||||
wait_for_device "$root_mapper" || disk_abort_hook "Root device $root_mapper never appeared"
|
||||
|
||||
mkdir -p /mnt/btrfs-root
|
||||
mount "$root_mapper" /mnt/btrfs-root
|
||||
btrfs subvolume create /mnt/btrfs-root/@
|
||||
btrfs subvolume create /mnt/btrfs-root/@home
|
||||
btrfs subvolume create /mnt/btrfs-root/@log
|
||||
btrfs subvolume create /mnt/btrfs-root/@pkg
|
||||
disk_step "mounting $root_mapper" mount "$root_mapper" /mnt/btrfs-root
|
||||
for subvol in @ @home @log @pkg; do
|
||||
disk_step "creating subvolume $subvol" btrfs subvolume create "/mnt/btrfs-root/$subvol"
|
||||
done
|
||||
umount /mnt/btrfs-root
|
||||
rmdir /mnt/btrfs-root
|
||||
|
||||
mount -o noatime,compress=zstd,subvol=@ "$root_mapper" /mnt
|
||||
disk_step "mounting the target root" \
|
||||
mount -o noatime,compress=zstd,subvol=@ "$root_mapper" /mnt
|
||||
mkdir -p /mnt/home /mnt/var/log /mnt/var/cache/pacman/pkg /mnt"$esp_mount_in_target"
|
||||
mount -o noatime,compress=zstd,subvol=@home "$root_mapper" /mnt/home
|
||||
mount -o noatime,compress=zstd,subvol=@log "$root_mapper" /mnt/var/log
|
||||
mount -o noatime,compress=zstd,subvol=@pkg "$root_mapper" /mnt/var/cache/pacman/pkg
|
||||
disk_step "mounting /home" \
|
||||
mount -o noatime,compress=zstd,subvol=@home "$root_mapper" /mnt/home
|
||||
disk_step "mounting /var/log" \
|
||||
mount -o noatime,compress=zstd,subvol=@log "$root_mapper" /mnt/var/log
|
||||
disk_step "mounting the package cache" \
|
||||
mount -o noatime,compress=zstd,subvol=@pkg "$root_mapper" /mnt/var/cache/pacman/pkg
|
||||
|
||||
mkfs.fat -F32 -n OMARCHY_EFI "$efi_dev"
|
||||
mount "$efi_dev" /mnt"$esp_mount_in_target"
|
||||
disk_step "creating the ESP filesystem on $efi_dev" mkfs.fat -F32 -n OMARCHY_EFI "$efi_dev"
|
||||
disk_step "mounting the ESP" mount "$efi_dev" /mnt"$esp_mount_in_target"
|
||||
|
||||
# The orchestrator's first act is to verify this handoff. Check it here so
|
||||
# a failure names the step that broke rather than surfacing later as
|
||||
# "protected mode: /mnt is not a mountpoint".
|
||||
mountpoint -q /mnt ||
|
||||
disk_abort_hook "Target /mnt is not mounted; not starting the installer"
|
||||
mountpoint -q "/mnt$esp_mount_in_target" ||
|
||||
disk_abort_hook "ESP is not mounted at /mnt$esp_mount_in_target"
|
||||
fi
|
||||
|
||||
clear
|
||||
|
||||
write_user_files
|
||||
|
||||
local luks_uuid_json="null" luks_uuid
|
||||
if [[ "$encrypt_installation" == "true" ]]; then
|
||||
if $dry; then
|
||||
@@ -653,6 +800,8 @@ run_partition_install() {
|
||||
"bootloader_config": { "bootloader": "Limine", "uki": false, "removable": false },
|
||||
"custom_commands": [],
|
||||
"omarchy_install": {
|
||||
"input_method": "${keyboard_input_method:-none}",
|
||||
"input_xkb_layout": "${keyboard_xkb_layout:-}",
|
||||
"mode": "protected",
|
||||
"target_mount": "/mnt",
|
||||
"boot": {
|
||||
@@ -712,10 +861,6 @@ run_partition_install() {
|
||||
"version": "3.0.9"
|
||||
}
|
||||
_EOF_
|
||||
|
||||
if $dry; then
|
||||
print_dry_run_files
|
||||
fi
|
||||
}
|
||||
|
||||
disk_form() {
|
||||
@@ -767,8 +912,7 @@ open_partition_tool() {
|
||||
}
|
||||
|
||||
# If the disk has no partition table or no unallocated free space, the only
|
||||
# viable path is a full-disk install. Skip the install-mode picker and go
|
||||
# straight to confirmation.
|
||||
# viable paths write the whole disk, so the free-space mode is not offered.
|
||||
requires_full_disk_install() {
|
||||
local pt_type free_space_b
|
||||
pt_type=$(lsblk -dno PTTYPE "$disk" 2>/dev/null)
|
||||
@@ -795,7 +939,7 @@ install_mode_form() {
|
||||
|
||||
# The free-space/protected path registers an EFI boot entry and is UEFI-only.
|
||||
# Full-disk installs still support BIOS through the orchestrator's BIOS branch.
|
||||
if [[ -d /sys/firmware/efi ]]; then
|
||||
if [[ -d /sys/firmware/efi ]] && ! $full_disk_only; then
|
||||
choices+=("Free space install (alongside existing data)")
|
||||
fi
|
||||
choices+=("Choose a different disk")
|
||||
@@ -842,30 +986,43 @@ confirm_disk_overwrite() {
|
||||
done
|
||||
}
|
||||
|
||||
# Decide what and how to install: sets install_target (full_disk|free_space),
|
||||
# install_target and encrypt_installation. Nothing is written to disk yet —
|
||||
# the user step runs between this and the execution below. (deferred provisioning never
|
||||
# reaches here; it's armed by Ctrl+C on the keyboard screen and goes straight to
|
||||
# disk selection.)
|
||||
select_installation() {
|
||||
local full_disk_only
|
||||
|
||||
while true; do
|
||||
if requires_full_disk_install; then
|
||||
full_disk_only=true
|
||||
install_mode="Full disk install"
|
||||
else
|
||||
full_disk_only=false
|
||||
fi
|
||||
|
||||
# With no free-space option to offer, a full-disk install is the only
|
||||
# mode, so skip the picker and go straight to the overwrite confirm.
|
||||
if $full_disk_only; then
|
||||
install_mode="Full disk install"
|
||||
else
|
||||
install_mode_form
|
||||
fi
|
||||
|
||||
case "$install_mode" in
|
||||
"Full disk install")
|
||||
if confirm_disk_overwrite; then
|
||||
install_target="full_disk"
|
||||
return 0
|
||||
fi
|
||||
if $full_disk_only; then
|
||||
disk_form
|
||||
fi
|
||||
# When the picker was skipped, declining the overwrite means the user
|
||||
# wants a different disk.
|
||||
$full_disk_only && disk_form
|
||||
;;
|
||||
"Free space install (alongside existing data)")
|
||||
if run_partition_install "$@"; then
|
||||
exit 0
|
||||
"Free space install"*)
|
||||
if run_partition_decide; then
|
||||
install_target="free_space"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"Choose a different disk")
|
||||
@@ -875,13 +1032,69 @@ select_installation() {
|
||||
done
|
||||
}
|
||||
|
||||
disk_form
|
||||
select_installation "$@"
|
||||
# STEP 1: KEYBOARD (Ctrl+C here arms deferred provisioning and jumps to disk selection)
|
||||
|
||||
defer_provisioning=false
|
||||
install_target="full_disk"
|
||||
|
||||
# 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.
|
||||
wait_for_stable_terminal
|
||||
|
||||
greeter
|
||||
|
||||
keyboard_form
|
||||
|
||||
# Normal install: keyboard (loaded above, so the LUKS passphrase is typed under
|
||||
# the right layout) → user → disk → install mode. The user step can unwind to
|
||||
# the keyboard screen and arm deferral there, hence the second check.
|
||||
if ! $defer_provisioning; then
|
||||
user_step
|
||||
fi
|
||||
|
||||
if $defer_provisioning; then
|
||||
# Deferred provisioning: no user setup, and the keyboard is deferred to the machine's first
|
||||
# boot. A defined default keymap so it boots before then; the owner picks
|
||||
# their real layout in the OOBE, which re-keys the console and, on encrypted
|
||||
# installs, rebuilds the initramfs so the LUKS prompt matches.
|
||||
keyboard="us"
|
||||
keyboard_input_method="none"
|
||||
keyboard_xkb_layout=""
|
||||
username=""
|
||||
password=""
|
||||
password_hash=""
|
||||
full_name=""
|
||||
email_address=""
|
||||
# Neutral defaults for the install; the owner overwrites both in the
|
||||
# first-boot OOBE (omarchy-provision-owner).
|
||||
hostname="omarchy"
|
||||
timezone="UTC"
|
||||
|
||||
# Jump straight to disk selection + overwrite confirmation (encrypted by
|
||||
# default, Ctrl+C toggles unencrypted). deferred provisioning is always a full-disk install.
|
||||
disk_form
|
||||
until confirm_disk_overwrite; do
|
||||
disk_form
|
||||
done
|
||||
install_target="full_disk"
|
||||
else
|
||||
disk_form
|
||||
select_installation
|
||||
fi
|
||||
|
||||
clear
|
||||
|
||||
write_user_files
|
||||
|
||||
if [[ $install_target == "free_space" ]]; then
|
||||
run_partition_execute "$@"
|
||||
|
||||
if [[ ${1:-} == "dry" ]]; then
|
||||
print_dry_run_files
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Setup partition layout
|
||||
disk_size=$(lsblk -bdno SIZE "$disk")
|
||||
mib=$((1024 * 1024))
|
||||
@@ -898,14 +1111,21 @@ main_partition_size=$((disk_size_in_mib - main_partition_start - gpt_backup_rese
|
||||
kernel_choice=$(detect_kernel)
|
||||
|
||||
if [[ $encrypt_installation == true ]]; then
|
||||
# Deferred-provisioning installs carry no password: the orchestrator generates a throwaway
|
||||
# LUKS passphrase and stages it for the first-boot re-key.
|
||||
if $defer_provisioning; then
|
||||
encryption_password_line=""
|
||||
else
|
||||
encryption_password_line=",
|
||||
\"encryption_password\": $(echo -n "$password" | jq -Rsa)"
|
||||
fi
|
||||
disk_encryption_config=$(cat <<-_EOF_
|
||||
,
|
||||
"disk_encryption": {
|
||||
"encryption_type": "luks",
|
||||
"lvm_volumes": [],
|
||||
"iter_time": 2000,
|
||||
"partitions": [ "8c2c2b92-1070-455d-b76a-56263bab24aa" ],
|
||||
"encryption_password": $(echo -n "$password" | jq -Rsa)
|
||||
"partitions": [ "8c2c2b92-1070-455d-b76a-56263bab24aa" ]$encryption_password_line
|
||||
}
|
||||
_EOF_
|
||||
)
|
||||
@@ -922,7 +1142,10 @@ cat <<-_EOF_ >user_configuration.json
|
||||
"bootloader_config": { "bootloader": "Limine", "uki": false, "removable": false },
|
||||
"custom_commands": [],
|
||||
"omarchy_install": {
|
||||
"input_method": "${keyboard_input_method:-none}",
|
||||
"input_xkb_layout": "${keyboard_xkb_layout:-}",
|
||||
"mode": "full_disk",
|
||||
"defer_provisioning": $defer_provisioning,
|
||||
"target_mount": "/mnt",
|
||||
"boot": {
|
||||
"esp_mount": "/boot",
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Autoinstall: a drive labeled cidata (the cloud-init NoCloud label, so Proxmox,
|
||||
# libvirt and Packer all know how to attach one) carrying the configurator's own
|
||||
# output files stands in for the wizard. Copy those files into /root and
|
||||
# everything downstream runs the ordinary path against ordinary inputs.
|
||||
#
|
||||
# Exits 0 when an autoinstall drive was loaded and the configurator can be
|
||||
# skipped. The required pair is the same one the orchestrator treats as
|
||||
# mandatory; the rest are optional there too, so don't be stricter here.
|
||||
# Anything less than the pair means this isn't an autoinstall drive, and the
|
||||
# caller falls back to the wizard.
|
||||
#
|
||||
# A `defer-provisioning` marker file stands in for user_credentials.json: deferred-provisioning
|
||||
# installs defer user creation to first boot, so imaging rigs ship no credentials.
|
||||
#
|
||||
# The optional argument prefixes every path the script touches; tests use it to
|
||||
# run against a sandbox instead of the live system.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
root=${1:-}
|
||||
by_label=$root/dev/disk/by-label
|
||||
dest=$root/root
|
||||
mnt=$root/run/cidata
|
||||
|
||||
# The by-label symlinks come from udev, and on a fast boot this can run before
|
||||
# device enumeration has finished. Wait for the queue to drain instead of
|
||||
# racing it and silently dropping a headless install into the wizard.
|
||||
udevadm settle 2>/dev/null || true
|
||||
|
||||
device=""
|
||||
for label in cidata CIDATA; do
|
||||
[[ -e $by_label/$label ]] && { device=$by_label/$label; break; }
|
||||
done
|
||||
[[ -n $device ]] || exit 1
|
||||
|
||||
mkdir -p "$mnt"
|
||||
mount -o ro "$device" "$mnt" || exit 1
|
||||
|
||||
# Clear any inputs a previous load in this live session left in /root before
|
||||
# copying the current drive: a stale `defer-provisioning` marker or credentials file would
|
||||
# otherwise force a fresh drive back into deferred provisioning or hand it an old
|
||||
# LUKS passphrase. The interactive wizard writes these same names, but a
|
||||
# cidata load always precedes it, so nothing of the user's is discarded here.
|
||||
optional_inputs=(user_credentials.json defer-provisioning user_full_name.txt user_email_address.txt user_encrypt_installation.txt authorized_keys tailscale_authkey)
|
||||
for file in user_configuration.json "${optional_inputs[@]}"; do
|
||||
rm -f "$dest/$file"
|
||||
done
|
||||
|
||||
loaded=1
|
||||
if [[ -f $mnt/user_configuration.json ]] && [[ -f $mnt/user_credentials.json || -f $mnt/defer-provisioning ]]; then
|
||||
files=("$mnt"/user_configuration.json)
|
||||
for file in "${optional_inputs[@]}"; do
|
||||
[[ -f $mnt/$file ]] && files+=("$mnt/$file")
|
||||
done
|
||||
if cp "${files[@]}" "$dest"/; then
|
||||
loaded=0
|
||||
else
|
||||
# A partial copy must not leave files behind: the wizard cleans up only
|
||||
# what it writes itself, so a half-copied authorized_keys would leak into
|
||||
# the interactive install that follows.
|
||||
for file in "${files[@]}"; do
|
||||
rm -f "$dest/${file##*/}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
umount "$mnt"
|
||||
exit $loaded
|
||||
@@ -23,6 +23,12 @@ INSTALL_CMD=("$@")
|
||||
|
||||
TTY_PATH="${OMARCHY_DASHBOARD_TTY:-/dev/tty}"
|
||||
LOGO_PATH="${OMARCHY_PATH:-/usr/share/omarchy}/logo.txt"
|
||||
|
||||
# Autoinstall has no one at the keyboard, and every prompt this dashboard owns
|
||||
# reads from the TTY, so each would hang forever. Suppress them here rather than
|
||||
# in the scripts they live in: this process is the only owner of the visible UI.
|
||||
interactive() { [[ ${OMARCHY_UI_INTERACTIVE:-} != "no" ]]; }
|
||||
|
||||
CSI=$'\033['
|
||||
RESET="${CSI}0m"
|
||||
DIM="${CSI}2m"
|
||||
@@ -32,9 +38,7 @@ CLEAR="${CSI}2J${CSI}H"
|
||||
CLEAR_LINE="${CSI}2K"
|
||||
CLEAR_TO_END="${CSI}J"
|
||||
GREEN="${CSI}32m"
|
||||
WHITE="${CSI}37m"
|
||||
RED="${CSI}31m"
|
||||
DARK="${CSI}90m"
|
||||
|
||||
# The dashboard owns the final reboot prompt now, so keep the gum confirm
|
||||
# styling that used to come from install/helpers/presentation.sh.
|
||||
@@ -47,6 +51,22 @@ export GUM_CONFIRM_UNSELECTED_BACKGROUND="${GUM_CONFIRM_UNSELECTED_BACKGROUND:-0
|
||||
child_pid=""
|
||||
child_pgid=""
|
||||
|
||||
whimsy=(
|
||||
"delivering delightful defaults"
|
||||
"saving setup struggles"
|
||||
"picking polished packages"
|
||||
"curating cohesive colors"
|
||||
"preparing pleasant pixels"
|
||||
"hyping happy hyprland"
|
||||
"integrating intuitive interfaces"
|
||||
"bootstrapping beautiful boxes"
|
||||
"crafting cozy commands"
|
||||
"making machines marvelous"
|
||||
"polishing pretty pixels"
|
||||
"tuning tasteful terminals"
|
||||
"weaving wonderful workflows"
|
||||
)
|
||||
|
||||
tips=(
|
||||
"Super + Space opens the Omarchy menu for apps, settings, and more"
|
||||
"Super + K shows all the key bindings"
|
||||
@@ -109,15 +129,72 @@ trap 'interrupt 143' TERM
|
||||
term_size() { stty size 2>/dev/null <"$TTY_PATH" || printf '24 80\n'; }
|
||||
term_cols() { local size; size="$(term_size)"; printf '%s\n' "${size#* }"; }
|
||||
|
||||
repeat() {
|
||||
local char="$1" count="$2" out="" i
|
||||
for ((i=0; i<count; i++)); do out+="$char"; done
|
||||
printf '%s' "$out"
|
||||
# Read the actual character dimensions instead of assuming an 8 x 16 font.
|
||||
# Linux VTs expose the font through KDFONTOP; desktop terminals may expose
|
||||
# pixels in their window size or answer the standard cell-size query.
|
||||
term_cell_size() {
|
||||
python3 - "$TTY_PATH" <<'PY'
|
||||
import fcntl
|
||||
import os
|
||||
import re
|
||||
import select
|
||||
import struct
|
||||
import sys
|
||||
import termios
|
||||
import time
|
||||
import tty
|
||||
|
||||
with open(sys.argv[1], "r+b", buffering=0) as terminal:
|
||||
fd = terminal.fileno()
|
||||
rows, cols, width, height = struct.unpack(
|
||||
"HHHH", fcntl.ioctl(fd, termios.TIOCGWINSZ, bytes(8)))
|
||||
if rows and cols and width and height:
|
||||
print(round(width / cols), round(height / rows))
|
||||
sys.exit()
|
||||
try:
|
||||
font = bytearray(struct.pack("@5IP", 1, 0, 0, 0, 0, 0))
|
||||
fcntl.ioctl(fd, 0x4B72, font) # KDFONTOP / KD_FONT_OP_GET, no glyph data
|
||||
_, _, width, height, _ = struct.unpack_from("@5I", font)
|
||||
if width and height:
|
||||
print(width, height)
|
||||
sys.exit()
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
settings = termios.tcgetattr(fd)
|
||||
try:
|
||||
tty.setcbreak(fd, termios.TCSANOW)
|
||||
os.write(fd, b"\x1b[16t")
|
||||
response = b""
|
||||
deadline = time.monotonic() + 0.15
|
||||
while select.select([fd], [], [], max(0, deadline - time.monotonic()))[0]:
|
||||
response += os.read(fd, 64)
|
||||
match = re.search(rb"\x1b\[6;(\d+);(\d+)t", response)
|
||||
if match:
|
||||
height, width = map(int, match.groups())
|
||||
if width and height:
|
||||
print(width, height)
|
||||
sys.exit()
|
||||
if time.monotonic() >= deadline:
|
||||
break
|
||||
finally:
|
||||
termios.tcsetattr(fd, termios.TCSANOW, settings)
|
||||
print(8, 16) # Conventional console font when dimensions aren't available.
|
||||
PY
|
||||
}
|
||||
|
||||
logo_width() {
|
||||
if [[ -f $LOGO_PATH ]]; then
|
||||
awk '{ if (length > max) max = length } END { print max+0 }' "$LOGO_PATH"
|
||||
# The logo is drawn in box-drawing glyphs, three bytes each in UTF-8, so
|
||||
# awk's `length` returns 197 rather than 81 unless the locale happens to be
|
||||
# UTF-8 — and a width wider than the console makes left_padding clamp to
|
||||
# zero, which puts the logo flush left. Count bytes deliberately (LC_ALL=C)
|
||||
# and drop the continuation bytes instead, so the answer is columns in every
|
||||
# locale rather than only in the ones that have a charset.
|
||||
LC_ALL=C awk '
|
||||
{ gsub(/[\200-\277]/, ""); if (length > max) max = length }
|
||||
END { print max+0 }
|
||||
' "$LOGO_PATH"
|
||||
else
|
||||
printf '81\n'
|
||||
fi
|
||||
@@ -136,12 +213,16 @@ LOGO_HEIGHT="$(logo_height)"
|
||||
(( LOGO_WIDTH > 0 )) || LOGO_WIDTH=81
|
||||
(( LOGO_HEIGHT > 0 )) || LOGO_HEIGHT=1
|
||||
CONTENT_WIDTH="$LOGO_WIDTH"
|
||||
DYNAMIC_ROW=$((LOGO_HEIGHT + 3))
|
||||
TOP_ROW=1
|
||||
LAST_SIZE=""
|
||||
LAST_PM=10
|
||||
# Wordmark, blank, title, and the three rows gum confirm uses.
|
||||
FINISH_HEIGHT=$((LOGO_HEIGHT + 5))
|
||||
FINISH_TOP_ROW=2
|
||||
|
||||
# ── Install progress ─────────────────────────────────────────────────────────
|
||||
#
|
||||
# Position = max(floor, work), both non-decreasing, in per-mille of the bar.
|
||||
# Position = max(floor, work), both non-decreasing, in per-mille of the drawing.
|
||||
#
|
||||
# floor lo + (span-1) * t / (t+tau), on time since this process saw the
|
||||
# phase. Asymptotic, so it approaches the band end without reaching it.
|
||||
@@ -164,8 +245,8 @@ fi
|
||||
# A wrong denominator is worse than none: it never triggers the fallback.
|
||||
(( PKG_TOTAL < 300 || PKG_TOTAL > 5000 )) && PKG_TOTAL=0
|
||||
|
||||
PKG_BONUS_MAX_PM=100 # cap on how far the bar may run ahead of the count
|
||||
PKG_TAIL_PM=40 # band held back so a stalled bar has somewhere to go
|
||||
PKG_BONUS_MAX_PM=100 # cap on how far progress may run ahead of the count
|
||||
PKG_TAIL_PM=40 # band held back so stalled progress has somewhere to go
|
||||
PKG_FLOOR_TAU=900 # with a work signal, time is only a backstop until the
|
||||
# first package, so slow it until it cannot outrun data
|
||||
|
||||
@@ -238,13 +319,161 @@ render_logo() {
|
||||
fi
|
||||
}
|
||||
|
||||
progress_bar() {
|
||||
local pm="$1" width="${2:-34}" filled empty
|
||||
(( pm < 0 )) && pm=0
|
||||
(( pm > 1000 )) && pm=1000
|
||||
filled=$(( pm * width / 1000 ))
|
||||
empty=$(( width - filled ))
|
||||
printf '%s%s%s%s%s' "$WHITE" "$(repeat █ "$filled")" "$DARK" "$(repeat ░ "$empty")" "$RESET"
|
||||
# The icon uses half-block glyphs, scaled to the terminal's actual cell aspect
|
||||
# ratio so its square silhouette stays square. No graphics protocol is needed.
|
||||
# Coordinates follow the 15 x 15 grid of Omarchy's icon.svg. Each segment
|
||||
# paints the full stroke width, starting at the bottom middle of the outer ring.
|
||||
ICON_WIDTH=30
|
||||
ICON_HEIGHT=15
|
||||
CELL_WIDTH=8
|
||||
CELL_HEIGHT=16
|
||||
ICON_LEFT=1
|
||||
ICON_STEPS=0
|
||||
ICON_DRAWN=0
|
||||
DISPLAY_PM=0
|
||||
ICON_FRAME=""
|
||||
declare -a ICON_ORDER=() ICON_TRACE=() ICON_FILL=()
|
||||
|
||||
icon_segment() {
|
||||
local scale="$1" x1="$2" y1="$3" x2="$4" y2="$5"
|
||||
local x y from to
|
||||
if (( y1 == y2 )); then
|
||||
from=$(( (x1 * ICON_WIDTH + 14) / 15 ))
|
||||
to=$(( ((x2 + 1) * ICON_WIDTH + 14) / 15 ))
|
||||
if (( x2 < x1 )); then
|
||||
from=$(( ((x1 + 1) * ICON_WIDTH + 14) / 15 - 1 ))
|
||||
to=$(( (x2 * ICON_WIDTH + 14) / 15 - 1 ))
|
||||
fi
|
||||
for ((x=from; x!=to; x+=(x2 >= x1 ? 1 : -1))); do
|
||||
for ((y=y1 * scale; y<(y1 + 1) * scale; y++)); do
|
||||
icon_pixel "$((y * ICON_WIDTH + x))"
|
||||
done
|
||||
done
|
||||
else
|
||||
from=$(( y1 * scale ))
|
||||
to=$(( (y2 + 1) * scale ))
|
||||
if (( y2 < y1 )); then
|
||||
from=$(( (y1 + 1) * scale - 1 ))
|
||||
to=$(( y2 * scale - 1 ))
|
||||
fi
|
||||
for ((y=from; y!=to; y+=(y2 >= y1 ? 1 : -1))); do
|
||||
for ((x=(x1 * ICON_WIDTH + 14) / 15; x<((x1 + 1) * ICON_WIDTH + 14) / 15; x++)); do
|
||||
icon_pixel "$((y * ICON_WIDTH + x))"
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
icon_pixel() {
|
||||
local pixel="$1"
|
||||
if [[ ! -v ICON_TRACE[pixel] ]]; then
|
||||
ICON_ORDER+=("$pixel")
|
||||
ICON_TRACE[pixel]=${#ICON_ORDER[@]}
|
||||
fi
|
||||
}
|
||||
|
||||
build_icon() {
|
||||
local scale="$1" x y row
|
||||
local -a mask=(
|
||||
111111111111111
|
||||
100000010000001
|
||||
101111110001101
|
||||
101000000000101
|
||||
101000000000101
|
||||
101000000000101
|
||||
101000000000101
|
||||
111000000000101
|
||||
101000000000101
|
||||
101000000000101
|
||||
101000000000101
|
||||
101000000000101
|
||||
101111111111101
|
||||
100000010000001
|
||||
111111110111111
|
||||
)
|
||||
ICON_WIDTH=$(( (15 * scale * CELL_HEIGHT + CELL_WIDTH) / (2 * CELL_WIDTH) ))
|
||||
ICON_HEIGHT=$(((15 * scale + 1) / 2))
|
||||
ICON_ORDER=() ICON_TRACE=() ICON_FILL=()
|
||||
ICON_DRAWN=0
|
||||
# Start at the bottom middle, follow the outer left edge to the top cross,
|
||||
# then descend into the inner shape. Fill its two bridges as we reach them.
|
||||
icon_segment "$scale" 7 14 0 14
|
||||
icon_segment "$scale" 0 14 0 0
|
||||
icon_segment "$scale" 0 0 7 0
|
||||
icon_segment "$scale" 7 0 7 2
|
||||
icon_segment "$scale" 7 2 2 2
|
||||
icon_segment "$scale" 2 2 2 7
|
||||
icon_segment "$scale" 2 7 0 7
|
||||
icon_segment "$scale" 2 7 2 12
|
||||
icon_segment "$scale" 2 12 7 12
|
||||
icon_segment "$scale" 7 12 7 14
|
||||
icon_segment "$scale" 7 12 12 12
|
||||
icon_segment "$scale" 12 12 12 2
|
||||
icon_segment "$scale" 12 2 11 2
|
||||
# Finish from the top cross: right along the outside, down, then left.
|
||||
icon_segment "$scale" 7 0 14 0
|
||||
icon_segment "$scale" 14 0 14 14
|
||||
icon_segment "$scale" 14 14 9 14
|
||||
ICON_STEPS=${#ICON_ORDER[@]}
|
||||
for ((y=0; y<15 * scale; y++)); do
|
||||
row=${mask[y / scale]}
|
||||
for ((x=0; x<ICON_WIDTH; x++)); do
|
||||
ICON_FILL[y * ICON_WIDTH + x]=${row:x * 15 / ICON_WIDTH:1}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Append one cell with independently colored upper/lower pixels. This also
|
||||
# handles a green tracing tip sharing a cell with the still-dark outline.
|
||||
icon_cell() {
|
||||
local pixel="$1" drawn="$2" solid="$3" upper=0 lower=0 step
|
||||
if (( solid )); then
|
||||
(( ICON_FILL[pixel] )) && upper=32
|
||||
(( ${ICON_FILL[pixel + ICON_WIDTH]:-0} )) && lower=32
|
||||
else
|
||||
step=${ICON_TRACE[pixel]:-0}
|
||||
(( step > 0 )) && upper=90
|
||||
(( step > 0 && step <= drawn )) && upper=32
|
||||
step=${ICON_TRACE[pixel + ICON_WIDTH]:-0}
|
||||
(( step > 0 )) && lower=90
|
||||
(( step > 0 && step <= drawn )) && lower=32
|
||||
fi
|
||||
if (( upper == 0 && lower == 0 )); then
|
||||
ICON_FRAME+="${RESET} "
|
||||
elif (( upper == lower )); then
|
||||
ICON_FRAME+="${CSI}${upper};49m█"
|
||||
elif (( lower == 0 )); then
|
||||
ICON_FRAME+="${CSI}${upper};49m▀"
|
||||
elif (( upper == 0 )); then
|
||||
ICON_FRAME+="${CSI}${lower};49m▄"
|
||||
else
|
||||
ICON_FRAME+="${CSI}${upper};$((lower + 10))m▀"
|
||||
fi
|
||||
}
|
||||
|
||||
render_icon() {
|
||||
local pm="$1" full="${2:-0}" drawn i pixel row col
|
||||
drawn=$((pm * ICON_STEPS / 1000))
|
||||
ICON_FRAME=""
|
||||
if (( full || pm == 1000 )); then
|
||||
for ((row=0; row<ICON_HEIGHT; row++)); do
|
||||
ICON_FRAME+="${CSI}$((TOP_ROW + row));${ICON_LEFT}H"
|
||||
for ((col=0; col<ICON_WIDTH; col++)); do
|
||||
icon_cell "$((row * 2 * ICON_WIDTH + col))" "$drawn" "$((pm == 1000))"
|
||||
done
|
||||
done
|
||||
else
|
||||
# Between layout changes, repaint only newly traced pixels. This keeps the
|
||||
# animation cheap even while pacstrap saturates the disk.
|
||||
for ((i=ICON_DRAWN; i<drawn; i++)); do
|
||||
pixel=${ICON_ORDER[i]}
|
||||
row=$((pixel / ICON_WIDTH / 2)) col=$((pixel % ICON_WIDTH))
|
||||
ICON_FRAME+="${CSI}$((TOP_ROW + row));$((ICON_LEFT + col))H"
|
||||
icon_cell "$((row * 2 * ICON_WIDTH + col))" "$drawn" 0
|
||||
done
|
||||
fi
|
||||
printf '%s%s' "$ICON_FRAME" "$RESET"
|
||||
ICON_DRAWN=$drawn
|
||||
}
|
||||
|
||||
# Packages libalpm has finished installing. local/ holds one directory per
|
||||
@@ -265,7 +494,7 @@ count_packages() {
|
||||
|
||||
# Sets PROGRESS_PM. Never call in a command substitution: POS, the phase timer
|
||||
# and the package counters must survive between frames. Print nothing — output
|
||||
# here would land on the TTY between the cursor escape and the bar.
|
||||
# here would land on the TTY between the cursor escape and the drawing.
|
||||
install_progress() {
|
||||
local phase finished index total target
|
||||
local lo hi tau span t pos work gap n pkg_signal=0
|
||||
@@ -315,11 +544,13 @@ install_progress() {
|
||||
"Installing Arch + Omarchy") lo=65 hi=700 tau=150 pkg_signal=1 ;;
|
||||
"Configuring hibernation") lo=700 hi=720 tau=10 ;;
|
||||
"Configuring system") lo=720 hi=850 tau=120 ;;
|
||||
"Finalizing Limine boot") lo=850 hi=950 tau=90 ;;
|
||||
"Staging provisioning") lo=850 hi=855 tau=5 ;;
|
||||
"Finalizing Limine boot") lo=855 hi=950 tau=90 ;;
|
||||
"Finalizing user") lo=950 hi=978 tau=30 ;;
|
||||
"Configuring login") lo=978 hi=988 tau=5 ;;
|
||||
"Configuring DNS resolver") lo=988 hi=994 tau=5 ;;
|
||||
"Validating boot setup") lo=994 hi=1000 tau=5 ;;
|
||||
"Validating boot setup") lo=994 hi=998 tau=5 ;;
|
||||
"Creating factory snapshot") lo=998 hi=1000 tau=5 ;;
|
||||
*)
|
||||
# Unknown names used to inherit a 1->99 sweep. Derive an even band from
|
||||
# the published index instead; with no index, a bounded slice, so a
|
||||
@@ -350,7 +581,7 @@ install_progress() {
|
||||
PKG_DB_DIR="$target/var/lib/pacman/local"
|
||||
count_packages
|
||||
# Baseline on first sight: a target that already holds packages would
|
||||
# otherwise pin the bar at the band ceiling for the whole phase.
|
||||
# otherwise pin progress at the band ceiling for the whole phase.
|
||||
(( PKG_BASE < 0 )) && PKG_BASE=$PKG_COUNT
|
||||
n=$(( PKG_COUNT - PKG_BASE ))
|
||||
(( n < 0 )) && n=0
|
||||
@@ -374,39 +605,85 @@ install_progress() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# One tip per 8 seconds, in order. On elapsed time, not a frame counter: a frame
|
||||
# is 0.5s of sleep plus a render, which stretches under pacstrap I/O — on the
|
||||
# machine where the tips, not the bar, are carrying liveness.
|
||||
# Keep the original loading messages on their own clock, so progress jumps
|
||||
# cannot skip phrases and animation frame rate does not change their cadence.
|
||||
current_whimsy() {
|
||||
printf '%s' "${whimsy[$(( (NOW - DASH_T0) / 4 % ${#whimsy[@]} ))]}"
|
||||
}
|
||||
|
||||
# One tip per 8 seconds, in order. Use elapsed time, since rendering can stretch
|
||||
# under pacstrap I/O, when the tips may be the most visible sign of activity.
|
||||
current_tip() {
|
||||
printf '%s' "${tips[$(( (NOW - DASH_T0) / 8 % ${#tips[@]} ))]}"
|
||||
}
|
||||
|
||||
render_static() {
|
||||
printf '%s' "$CLEAR"
|
||||
blank_line
|
||||
render_logo
|
||||
blank_line
|
||||
# Vertically center a block of the given height, echoing the row it starts on.
|
||||
# Center both the progress icon and the final wordmark on the console.
|
||||
centered_top_row() {
|
||||
local height="$1" rows top
|
||||
rows="$(term_size)"
|
||||
rows="${rows%% *}"
|
||||
[[ $rows =~ ^[0-9]+$ ]] || rows=24
|
||||
top=$(( (rows - height) / 2 ))
|
||||
(( top < 0 )) && top=0
|
||||
printf '%d' "$(( top + 1 ))"
|
||||
}
|
||||
|
||||
render_dynamic() {
|
||||
local pm
|
||||
measure_progress_layout() {
|
||||
local rows cols scale=1
|
||||
LAST_SIZE="$(term_size)"
|
||||
read -r rows cols <<<"$LAST_SIZE"
|
||||
read -r CELL_WIDTH CELL_HEIGHT < <(term_cell_size 2>/dev/null || printf '8 16\n')
|
||||
(( rows >= 34 && cols >= 49 )) && scale=2
|
||||
(( rows >= 50 && cols >= 64 )) && scale=3
|
||||
while (( scale > 1 && (15 * scale * CELL_HEIGHT + CELL_WIDTH) / (2 * CELL_WIDTH) > cols - 4 )); do
|
||||
scale=$((scale - 1))
|
||||
done
|
||||
build_icon "$scale"
|
||||
TOP_ROW="$(centered_top_row "$((ICON_HEIGHT + 6))")"
|
||||
ICON_LEFT=$(( (cols - ICON_WIDTH) / 2 + 1 ))
|
||||
(( ICON_LEFT < 1 )) && ICON_LEFT=1
|
||||
PROGRESS_TEXT_WIDTH=$((cols - 2))
|
||||
(( PROGRESS_TEXT_WIDTH > CONTENT_WIDTH )) && PROGRESS_TEXT_WIDTH=$CONTENT_WIDTH
|
||||
return 0
|
||||
}
|
||||
|
||||
render_static() {
|
||||
measure_progress_layout
|
||||
printf '%s' "$CLEAR"
|
||||
render_icon "$DISPLAY_PM" 1
|
||||
}
|
||||
|
||||
update_progress() {
|
||||
set_now
|
||||
install_progress
|
||||
pm=$PROGRESS_PM
|
||||
local pm=$PROGRESS_PM
|
||||
[[ $pm =~ ^[0-9]+$ ]] || pm=$LAST_PM
|
||||
(( pm > 1000 )) && pm=1000
|
||||
# Only the child's successful exit can complete the drawing.
|
||||
(( pm > 999 )) && pm=999
|
||||
# POS is monotone by construction; this is a guard, not the mechanism.
|
||||
(( pm < LAST_PM )) && pm=$LAST_PM
|
||||
LAST_PM=$pm
|
||||
}
|
||||
|
||||
printf '%s%d;1H' "$CSI" "$DYNAMIC_ROW"
|
||||
center "Installing Omarchy" "$CONTENT_WIDTH"
|
||||
render_dynamic() {
|
||||
local step message tip
|
||||
# The framebuffer can settle late in VMs. Rebuild at the new size, preserving
|
||||
# progress, instead of leaving the drawing at the old screen coordinates.
|
||||
[[ "$(term_size)" == "$LAST_SIZE" ]] || render_static
|
||||
# Ease phase jumps over several frames, with the percentage following the
|
||||
# same position as the trace. The measured progress still never goes back.
|
||||
step=$(( (LAST_PM - DISPLAY_PM + 3) / 4 ))
|
||||
DISPLAY_PM=$((DISPLAY_PM + step))
|
||||
render_icon "$DISPLAY_PM"
|
||||
|
||||
message="$(truncate_for_width "$(current_whimsy)" "$PROGRESS_TEXT_WIDTH")"
|
||||
tip="$(truncate_for_width "Tip: $(current_tip)" "$PROGRESS_TEXT_WIDTH")"
|
||||
printf '%s%d;1H' "$CSI" "$((TOP_ROW + ICON_HEIGHT + 1))"
|
||||
center "${GREEN}$((DISPLAY_PM / 10))%${RESET}" "$PROGRESS_TEXT_WIDTH"
|
||||
center "${GREEN}${message}${RESET}" "$PROGRESS_TEXT_WIDTH"
|
||||
blank_line
|
||||
line_at "$CONTENT_WIDTH" $(( (CONTENT_WIDTH - 34) / 2 )) ""
|
||||
progress_bar "$pm" 34
|
||||
printf '\n'
|
||||
blank_line
|
||||
center "${DIM}Tip:${RESET} ${GREEN}$(current_tip)${RESET}" "$CONTENT_WIDTH"
|
||||
center "${DIM}${tip}${RESET}" "$PROGRESS_TEXT_WIDTH"
|
||||
printf '%s' "$CLEAR_TO_END"
|
||||
}
|
||||
|
||||
@@ -441,41 +718,63 @@ install_duration() {
|
||||
}
|
||||
|
||||
render_finish() {
|
||||
local duration effect_canvas_width
|
||||
local duration effect_canvas_width title="Installed Omarchy"
|
||||
duration="$(install_duration || true)"
|
||||
duration="${duration:-Complete}"
|
||||
[[ -n $duration ]] && title+=" in ${duration}"
|
||||
# ttfx centers its text two columns right of plain centering. A canvas two
|
||||
# columns narrower aligns the animation with the title and fallback logo.
|
||||
effect_canvas_width="$(term_cols)"
|
||||
(( effect_canvas_width > 1 )) && effect_canvas_width=$((effect_canvas_width - 1))
|
||||
(( effect_canvas_width > 2 )) && effect_canvas_width=$((effect_canvas_width - 2))
|
||||
|
||||
# Set before anything that can fail, so reboot_prompt still lands on the
|
||||
# button row even if the logo or the effect below never renders.
|
||||
FINISH_TOP_ROW="$(centered_top_row "$FINISH_HEIGHT")"
|
||||
|
||||
{
|
||||
printf '%s%s' "$SHOW_CURSOR" "$CLEAR"
|
||||
blank_line
|
||||
render_logo
|
||||
blank_line
|
||||
center "Installed Omarchy in ${duration}" "$CONTENT_WIDTH"
|
||||
# Leave the wordmark area blank: laseretch reveals it for the first time.
|
||||
printf '%s%s%s%d;1H' "$HIDE_CURSOR" "$CLEAR" "$CSI" "$((FINISH_TOP_ROW + LOGO_HEIGHT + 1))"
|
||||
center "$title" "$CONTENT_WIDTH"
|
||||
blank_line
|
||||
} >"$TTY_PATH"
|
||||
|
||||
if command -v tte >/dev/null 2>&1 && command -v timeout >/dev/null 2>&1 && [[ -f $LOGO_PATH ]]; then
|
||||
# TTE reuse mode restores a saved cursor before moving up over its input.
|
||||
# Save this anchor so the effect redraws the same logo rows shown above.
|
||||
printf '%s%d;1H\0337' "$CSI" "$((LOGO_HEIGHT + 2))" >"$TTY_PATH"
|
||||
timeout 8s tte -i "$LOGO_PATH" \
|
||||
if [[ -f $LOGO_PATH ]]; then
|
||||
# Reuse mode restores a saved cursor before moving up over its input. Save
|
||||
# this anchor so the effect occupies the reserved wordmark rows.
|
||||
printf '%s%d;1H\0337' "$CSI" "$((FINISH_TOP_ROW + LOGO_HEIGHT))" >"$TTY_PATH"
|
||||
# Laseretch runs ~4s at 260fps, so the 8s cap is a stuck-process guard rather
|
||||
# than a trim. --xterm-colors keeps the whole effect in the 256-index palette
|
||||
# the way the greeter does, since the console reduces indexed codes well and
|
||||
# truecolor ones badly. It settles on indexed 2, the Tokyo Night green used
|
||||
# throughout the installer. The laser and sparks keep their own hot palette.
|
||||
timeout 8s ttfx -i "$LOGO_PATH" \
|
||||
--canvas-width "$effect_canvas_width" \
|
||||
--anchor-text c \
|
||||
--frame-rate 260 \
|
||||
--reuse-canvas \
|
||||
--xterm-colors \
|
||||
laseretch \
|
||||
>"$TTY_PATH" 2>/dev/null || true
|
||||
printf '%s%d;1H' "$CSI" "$((LOGO_HEIGHT + 8))" >"$TTY_PATH"
|
||||
--final-gradient-stops 2 \
|
||||
>"$TTY_PATH" 2>/dev/null || {
|
||||
dashboard_log "logo effect skipped (ttfx exited $?)"
|
||||
{ printf '%s%d;1H' "$CSI" "$FINISH_TOP_ROW"; render_logo; } >"$TTY_PATH"
|
||||
}
|
||||
else
|
||||
{ printf '%s%d;1H' "$CSI" "$FINISH_TOP_ROW"; render_logo; } >"$TTY_PATH"
|
||||
fi
|
||||
printf '%s%s%d;1H' "$SHOW_CURSOR" "$CSI" "$((FINISH_TOP_ROW + LOGO_HEIGHT + 5))" >"$TTY_PATH"
|
||||
}
|
||||
|
||||
reboot_prompt() {
|
||||
local prompt_pad
|
||||
|
||||
# Position the cursor one blank line below the title so the button sits right there.
|
||||
printf '%s%d;1H%s' "$CSI" "$((LOGO_HEIGHT + 5))" "$CLEAR_LINE" >"$TTY_PATH"
|
||||
# Nobody to confirm; the OMARCHY_UI_AUTO_REBOOT check at the call site still
|
||||
# applies, so setting both stops on the finish screen without a keyboard.
|
||||
interactive || return 0
|
||||
|
||||
# gum paints its prompt row at the cursor and the button two rows under it, so
|
||||
# anchor on the row right below the title to put the button as close to it as
|
||||
# gum allows. FINISH_HEIGHT budgets for the same three rows.
|
||||
printf '%s%d;1H%s' "$CSI" "$((FINISH_TOP_ROW + LOGO_HEIGHT + 2))" "$CLEAR_LINE" >"$TTY_PATH"
|
||||
|
||||
prompt_pad=$(( ( $(term_cols) - 18 ) / 2 ))
|
||||
(( prompt_pad < 0 )) && prompt_pad=0
|
||||
@@ -498,10 +797,13 @@ truncate_for_width() {
|
||||
}
|
||||
|
||||
render_failure_log_tail() {
|
||||
local rows lines width line tail_log label
|
||||
# The caller passes the rows it spent above this point that the constant below
|
||||
# does not know about, so the tail gives way rather than pushing the top of
|
||||
# the screen off a short console.
|
||||
local reserved="${1:-0}" rows lines width line tail_log label
|
||||
rows=$(term_size)
|
||||
rows=${rows%% *}
|
||||
lines=$((rows - LOGO_HEIGHT - 18))
|
||||
lines=$((rows - LOGO_HEIGHT - 18 - reserved))
|
||||
(( lines < 6 )) && lines=6
|
||||
(( lines > 14 )) && lines=14
|
||||
width=$((CONTENT_WIDTH - 4))
|
||||
@@ -570,8 +872,52 @@ view_failure_log() {
|
||||
fi
|
||||
}
|
||||
|
||||
# A failure the medium explains is worth saying before the log tail, because
|
||||
# the tail is where "invalid or corrupted package" already scrolled past
|
||||
# without ever naming the USB stick it came off.
|
||||
diagnose_media() {
|
||||
local logs=("$LOG_FILE")
|
||||
|
||||
[[ -f /mnt/var/log/omarchy-install.log ]] && logs+=(/mnt/var/log/omarchy-install.log)
|
||||
[[ -n ${OMARCHY_FAILURE_TAIL_LOG:-} ]] && logs+=("$OMARCHY_FAILURE_TAIL_LOG")
|
||||
|
||||
omarchy-install-diagnose-media "${logs[@]}" 2>/dev/null
|
||||
}
|
||||
|
||||
# Rows the diagnosis occupies, its leading blank included.
|
||||
media_diagnosis_rows() {
|
||||
local diagnosis="$1"
|
||||
|
||||
if [[ -z $diagnosis ]]; then
|
||||
printf '0\n'
|
||||
else
|
||||
printf '%s\n' "$(( $(grep -c '' <<<"$diagnosis") + 1 ))"
|
||||
fi
|
||||
}
|
||||
|
||||
render_media_diagnosis() {
|
||||
local diagnosis="$1" line first=1
|
||||
|
||||
[[ -n $diagnosis ]] || return 0
|
||||
blank_line
|
||||
while IFS= read -r line; do
|
||||
# A blank line inside the diagnosis is deliberate: it separates what
|
||||
# happened from what to do about it, so it is drawn rather than skipped.
|
||||
if [[ -z $line ]]; then
|
||||
blank_line
|
||||
continue
|
||||
fi
|
||||
if (( first )); then
|
||||
center "${RED}$(truncate_for_width "$line" "$CONTENT_WIDTH")${RESET}" "$CONTENT_WIDTH"
|
||||
first=0
|
||||
else
|
||||
center "$(truncate_for_width "$line" "$CONTENT_WIDTH")" "$CONTENT_WIDTH"
|
||||
fi
|
||||
done <<<"$diagnosis"
|
||||
}
|
||||
|
||||
render_failure() {
|
||||
local status="$1" state_summary="${2:-}" line
|
||||
local status="$1" state_summary="${2:-}" media_diagnosis="${3:-}" line
|
||||
printf '%s%s' "$SHOW_CURSOR" "$CLEAR"
|
||||
blank_line
|
||||
render_logo
|
||||
@@ -579,6 +925,8 @@ render_failure() {
|
||||
center "${RED}Omarchy installation stopped${RESET}" "$CONTENT_WIDTH"
|
||||
center "Installer exited with status $status" "$CONTENT_WIDTH"
|
||||
|
||||
render_media_diagnosis "$media_diagnosis"
|
||||
|
||||
if [[ -n $state_summary ]]; then
|
||||
blank_line
|
||||
while IFS= read -r line; do
|
||||
@@ -588,7 +936,7 @@ render_failure() {
|
||||
fi
|
||||
|
||||
blank_line
|
||||
render_failure_log_tail
|
||||
render_failure_log_tail "$(media_diagnosis_rows "$media_diagnosis")"
|
||||
blank_line
|
||||
center "${DIM}Get help at https://omarchy.org/discord${RESET}" "$CONTENT_WIDTH"
|
||||
blank_line
|
||||
@@ -598,6 +946,9 @@ failure_menu() {
|
||||
local choice uploader
|
||||
|
||||
[[ ${OMARCHY_UI_FAILURE_ACTION:-} == "exit" ]] && return 0
|
||||
# The failure screen and log tail have already rendered; exit with the
|
||||
# installer's status instead of blocking on a menu nobody can answer.
|
||||
interactive || return 0
|
||||
|
||||
while true; do
|
||||
uploader=""
|
||||
@@ -626,11 +977,11 @@ failure_menu() {
|
||||
case "$choice" in
|
||||
"Upload log for support")
|
||||
upload_failure_log
|
||||
render_failure "${failure_status:-1}" "${failure_summary:-}" >"$TTY_PATH" 2>/dev/null || true
|
||||
render_failure "${failure_status:-1}" "${failure_summary:-}" "${failure_media_diagnosis:-}" >"$TTY_PATH" 2>/dev/null || true
|
||||
;;
|
||||
"View full log")
|
||||
view_failure_log
|
||||
render_failure "${failure_status:-1}" "${failure_summary:-}" >"$TTY_PATH" 2>/dev/null || true
|
||||
render_failure "${failure_status:-1}" "${failure_summary:-}" "${failure_media_diagnosis:-}" >"$TTY_PATH" 2>/dev/null || true
|
||||
;;
|
||||
"Reboot")
|
||||
reboot 2>/dev/null || systemctl reboot 2>/dev/null || true
|
||||
@@ -680,9 +1031,13 @@ PHASE_T0=$NOW
|
||||
PKG_LAST_CHANGE=$NOW
|
||||
launch_child
|
||||
|
||||
frame=0
|
||||
while jobs -pr | grep -qx "$child_pid"; do
|
||||
# Keep package counting/state reads at 2 Hz; animate the trace at 10 Hz.
|
||||
(( frame % 5 == 0 )) && update_progress
|
||||
render_dynamic >"$TTY_PATH" 2>/dev/null || true
|
||||
sleep 0.5
|
||||
frame=$((frame + 1))
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
set +e
|
||||
@@ -695,8 +1050,14 @@ child_pgid=""
|
||||
dashboard_log "installer child exited with status $status"
|
||||
|
||||
if (( status == 0 )); then
|
||||
# finished_at lands microseconds before the child exits, so the 0.5s poll
|
||||
# rarely renders a full bar before the finish screen replaces it.
|
||||
# Finish the trace even when a short-lived child exits between state polls.
|
||||
LAST_PM=1000
|
||||
PHASE_NAME="Installation complete"
|
||||
while (( DISPLAY_PM < 999 )); do
|
||||
render_dynamic >"$TTY_PATH" 2>/dev/null || true
|
||||
sleep 0.05
|
||||
done
|
||||
DISPLAY_PM=1000
|
||||
render_dynamic >"$TTY_PATH" 2>/dev/null || true
|
||||
sleep 0.4
|
||||
fi
|
||||
@@ -716,11 +1077,30 @@ if (( status != 0 )); then
|
||||
done <<<"$failure_summary"
|
||||
fi
|
||||
fi
|
||||
render_failure "$failure_status" "$failure_summary" >"$TTY_PATH" 2>/dev/null || true
|
||||
failure_media_diagnosis="$(diagnose_media || true)"
|
||||
render_failure "$failure_status" "$failure_summary" "$failure_media_diagnosis" >"$TTY_PATH" 2>/dev/null || true
|
||||
# Recorded after the screen is drawn, not before: the log tail on that screen
|
||||
# reads this same file, and the diagnosis printed twice reads as two findings.
|
||||
if [[ -n $failure_media_diagnosis ]]; then
|
||||
while IFS= read -r line; do
|
||||
[[ -n $line ]] && dashboard_log "$line"
|
||||
done <<<"$failure_media_diagnosis"
|
||||
fi
|
||||
failure_menu
|
||||
exit "$failure_status"
|
||||
fi
|
||||
|
||||
# Deferred-provisioning installs finish silently and reboot on their own — the
|
||||
# owner completes setup (and sees the send-off) at first boot, so the "Installed
|
||||
# Omarchy in ..." celebration and the Reboot Now prompt belong to a direct
|
||||
# install only.
|
||||
if [[ ${OMARCHY_UI_DEFER_PROVISIONING:-} == "yes" ]]; then
|
||||
printf '%s' "$CLEAR" >"$TTY_PATH" 2>/dev/null || true
|
||||
[[ ${OMARCHY_UI_AUTO_REBOOT:-} == "no" ]] && exit 0
|
||||
reboot 2>/dev/null || systemctl reboot 2>/dev/null || true
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set +e
|
||||
render_finish
|
||||
finish_render_status=$?
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Say whether an install failure was the install medium, and say it in words
|
||||
# that name the fix.
|
||||
#
|
||||
# The ISO's offline mirror is bind-mounted onto the target's package cache for
|
||||
# the duration of pacstrap (see _mount_offline_package_cache), so a package
|
||||
# pacman calls corrupt under that path is a byte that came off the medium --
|
||||
# nothing else ever writes there. That much is certain, and it is the part
|
||||
# worth saying out loud, because the failure screen otherwise ends at "get help
|
||||
# at discord" with the word USB nowhere on it.
|
||||
#
|
||||
# What is not certain is which way the medium failed. Bytes written wrong and
|
||||
# bytes read wrong produce the same checksum mismatch, and pacstrap runs with
|
||||
# --noconfirm, which answers yes to pacman's "delete it?" and unlinks the
|
||||
# package through the bind mount before anything here can weigh it. So the
|
||||
# usual verdict names the medium and gives both remedies in the order worth
|
||||
# trying. When the package does survive, its checksum in the mirror's database
|
||||
# tells the two apart, and then this says which.
|
||||
#
|
||||
# Prints the diagnosis on stdout, one line per line, headline first. Exits 1
|
||||
# with no output when there is nothing here to diagnose, so the caller can ask
|
||||
# unconditionally.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
TARGET_PACKAGE_CACHE="${OMARCHY_TARGET_PACKAGE_CACHE:-/mnt/var/cache/pacman/pkg}"
|
||||
OFFLINE_MIRROR="${OMARCHY_OFFLINE_MIRROR:-/var/cache/omarchy/mirror/offline}"
|
||||
|
||||
if (( $# == 0 )); then
|
||||
echo "Usage: omarchy-install-diagnose-media <log-file>..." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Only packages under the target cache count. A corrupt package anywhere else
|
||||
# was not read off this ISO, and guessing wrong here sends someone to buy a USB
|
||||
# stick they did not need.
|
||||
corrupt_package() {
|
||||
local log match package=""
|
||||
|
||||
for log in "$@"; do
|
||||
[[ -f $log ]] || continue
|
||||
match=$(sed -n "s|.*${TARGET_PACKAGE_CACHE}/\([^ ]*\) is corrupted.*|\1|p" "$log" | tail -n 1)
|
||||
[[ -n $match ]] && package="$match"
|
||||
done
|
||||
|
||||
printf '%s' "$package"
|
||||
}
|
||||
|
||||
expected_checksum() {
|
||||
local package="$1" reader
|
||||
|
||||
[[ -f $OFFLINE_MIRROR/offline.db ]] || return 1
|
||||
|
||||
if command -v bsdtar >/dev/null 2>&1; then
|
||||
reader=(bsdtar -xOf "$OFFLINE_MIRROR/offline.db")
|
||||
else
|
||||
reader=(tar -xOzf "$OFFLINE_MIRROR/offline.db")
|
||||
fi
|
||||
|
||||
# repo-add writes %FILENAME% before %SHA256SUM% in every desc record, so the
|
||||
# name in hand when a checksum arrives is the name it belongs to. The wanted
|
||||
# name comes through the environment rather than -v, which would read a
|
||||
# backslash in a package version as an escape sequence.
|
||||
"${reader[@]}" 2>/dev/null | want="$package" awk '
|
||||
BEGIN { want = ENVIRON["want"] }
|
||||
$0 == "%FILENAME%" { getline name; next }
|
||||
$0 == "%SHA256SUM%" { getline sha; if (name == want) { print sha; exit } }
|
||||
'
|
||||
}
|
||||
|
||||
actual_checksum() {
|
||||
local package="$1" sum
|
||||
|
||||
[[ -f $OFFLINE_MIRROR/$package ]] || return 1
|
||||
sum=$(sha256sum "$OFFLINE_MIRROR/$package" 2>/dev/null) || return 1
|
||||
printf '%s' "${sum%% *}"
|
||||
}
|
||||
|
||||
package=$(corrupt_package "$@")
|
||||
if [[ -z $package ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The name reaches a terminal, and a package version may legally hold a
|
||||
# backslash that the renderer would read as an escape. Strip anything a package
|
||||
# filename has no business containing before printing it.
|
||||
display_package="${package//[^A-Za-z0-9._+:@%-]/}"
|
||||
|
||||
expected=$(expected_checksum "$package")
|
||||
actual=$(actual_checksum "$package")
|
||||
|
||||
# The package name goes on a line of its own throughout. Names run past fifty
|
||||
# characters and the screen is only as wide as the logo, so a name sharing a
|
||||
# line with the sentence that explains it truncates the explanation away. The
|
||||
# blank line after it separates what happened from what to do about it.
|
||||
if [[ -n $expected && -n $actual ]]; then
|
||||
if [[ $expected == "$actual" ]]; then
|
||||
# Intact now, so the bytes were misread rather than written wrong, and
|
||||
# re-downloading fixes neither of the things that could have done it.
|
||||
echo "The install medium was misread"
|
||||
echo "This package is intact on this ISO, so the download and the write were fine:"
|
||||
echo "$display_package"
|
||||
echo
|
||||
echo "Try another USB port or another stick, and test this machine's memory"
|
||||
else
|
||||
echo "The install medium is damaged"
|
||||
echo "This package no longer matches the checksum it was built with:"
|
||||
echo "$display_package"
|
||||
echo
|
||||
echo "Re-download the ISO, verify it with sha256sum, and write the USB again"
|
||||
echo "If a verified ISO fails here too, the USB stick itself is the problem"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# The usual case: pacman deleted the package it rejected, so the medium is the
|
||||
# answer but the manner of its failure is not recoverable from here.
|
||||
echo "The install medium is damaged or misread"
|
||||
echo "pacman rejected this package, read straight off this ISO:"
|
||||
echo "$display_package"
|
||||
echo
|
||||
echo "Verify your download with sha256sum, then write the USB again"
|
||||
echo "If the download verifies, the stick or this machine's memory is at fault"
|
||||
@@ -11,12 +11,15 @@ set -eEo pipefail
|
||||
# doesn't choke on flags it doesn't recognize.
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--config) export OMARCHY_INSTALL_CONFIG="$2"; shift 2 ;;
|
||||
--creds) export OMARCHY_INSTALL_CREDS="$2"; shift 2 ;;
|
||||
--full-name-file) export OMARCHY_INSTALL_FULL_NAME_FILE="$2"; shift 2 ;;
|
||||
--email-file) export OMARCHY_INSTALL_EMAIL_FILE="$2"; shift 2 ;;
|
||||
--encrypt-file) export OMARCHY_INSTALL_ENCRYPT_FILE="$2"; shift 2 ;;
|
||||
*) echo "omarchy-iso-install: unknown arg $1" >&2; exit 2 ;;
|
||||
--config) export OMARCHY_INSTALL_CONFIG="$2"; shift 2 ;;
|
||||
--creds) export OMARCHY_INSTALL_CREDS="$2"; shift 2 ;;
|
||||
--full-name-file) export OMARCHY_INSTALL_FULL_NAME_FILE="$2"; shift 2 ;;
|
||||
--email-file) export OMARCHY_INSTALL_EMAIL_FILE="$2"; shift 2 ;;
|
||||
--encrypt-file) export OMARCHY_INSTALL_ENCRYPT_FILE="$2"; shift 2 ;;
|
||||
--authorized-keys-file) export OMARCHY_INSTALL_AUTHORIZED_KEYS_FILE="$2"; shift 2 ;;
|
||||
--tailscale-authkey-file) export OMARCHY_INSTALL_TAILSCALE_AUTHKEY_FILE="$2"; shift 2 ;;
|
||||
--defer-provisioning-file) export OMARCHY_INSTALL_DEFER_PROVISIONING_FILE="$2"; shift 2 ;;
|
||||
*) echo "omarchy-iso-install: unknown arg $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
# Disk partitioning helpers, shared by the ISO configurator and its tests.
|
||||
#
|
||||
# The rule here is: never predict a partition number. parted fills the lowest
|
||||
# free GPT slot, not "highest existing + 1", so any disk whose numbering has a
|
||||
# hole — exactly what deleting a partition to free space leaves behind, which
|
||||
# is what our own partition tool tells the user to do — hands back a number we
|
||||
# did not choose. Everything below reads back what was actually created.
|
||||
#
|
||||
# Sourced, not executed. The configurator defines abort() and
|
||||
# disk_abort_hook(); tests get the plain fallbacks.
|
||||
|
||||
# Partitions this run created, in creation order. rollback_created_parts()
|
||||
# undoes exactly these and nothing else.
|
||||
created_parts=()
|
||||
|
||||
# Set by create_partition() instead of being printed: a command substitution
|
||||
# would run it in a subshell and lose the created_parts bookkeeping.
|
||||
created_partition_number=""
|
||||
|
||||
# Compute partition device path, handling NVMe/mmcblk's pN naming.
|
||||
partition_path() {
|
||||
local _disk="$1" _num="$2"
|
||||
if [[ "$_disk" == *nvme* || "$_disk" == *mmcblk* ]]; then
|
||||
echo "${_disk}p${_num}"
|
||||
else
|
||||
echo "${_disk}${_num}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Partition numbers as the on-disk GPT reports them. parted rather than lsblk
|
||||
# on purpose: this is the table parted itself is about to modify, so discovery
|
||||
# never depends on the kernel having re-read the partition table yet — and the
|
||||
# same code works against an image file in tests, where lsblk sees nothing.
|
||||
partition_numbers() {
|
||||
parted -ms "$1" unit B print 2>/dev/null | tail -n +3 | cut -d: -f1
|
||||
}
|
||||
|
||||
partition_size_bytes() {
|
||||
parted -ms "$1" unit B print 2>/dev/null |
|
||||
awk -F: -v n="$2" '$1 == n { gsub(/B/, "", $4); print $4; exit }'
|
||||
}
|
||||
|
||||
# Fail loudly. The former version looped over sleep and returned its status,
|
||||
# so a device that never appeared was indistinguishable from one that did.
|
||||
wait_for_device() {
|
||||
local i
|
||||
for i in $(seq 1 10); do
|
||||
[[ -b "$1" ]] && return 0
|
||||
udevadm settle 2>/dev/null || true
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
_disk_abort() {
|
||||
if declare -F disk_abort_hook >/dev/null; then
|
||||
disk_abort_hook "$1"
|
||||
elif declare -F abort >/dev/null; then
|
||||
abort "$1"
|
||||
fi
|
||||
echo "Error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Run a disk-writing command, fold its stderr into stdout, and abort on a
|
||||
# non-zero exit. The fold matters: .automated_script.sh tees stdout into
|
||||
# /var/log/omarchy-install.log but sends stderr straight to the tty (gum draws
|
||||
# its TUI there), so an unwrapped failure leaves no trace in the log the user
|
||||
# uploads — and the configurator's next screen clears it off the display too.
|
||||
disk_step() {
|
||||
local desc="$1"
|
||||
shift
|
||||
local output status=0
|
||||
output=$("$@" 2>&1) || status=$?
|
||||
[[ -n $output ]] && printf '%s\n' "$output"
|
||||
(( status == 0 )) && return 0
|
||||
_disk_abort "$desc failed (exit $status)"
|
||||
}
|
||||
|
||||
# Create one partition and report the number parted actually assigned.
|
||||
# Returns non-zero without touching created_parts if anything looks wrong;
|
||||
# the caller decides how loudly to fail.
|
||||
create_partition() {
|
||||
local disk="$1" start="$2" end="$3" fstype="$4" name="$5"
|
||||
local before after num actual want tolerance
|
||||
|
||||
created_partition_number=""
|
||||
|
||||
# Lexicographic sort on both sides: comm needs its inputs ordered the same
|
||||
# way it compares them, and `sort -n` (1, 2, 10) is not that order.
|
||||
before=$(partition_numbers "$disk" | sort)
|
||||
|
||||
parted --script "$disk" mkpart primary "$fstype" "${start}B" "${end}B" || return 1
|
||||
partprobe "$disk" 2>/dev/null || true
|
||||
udevadm settle 2>/dev/null || true
|
||||
|
||||
after=$(partition_numbers "$disk" | sort)
|
||||
num=$(comm -13 <(printf '%s\n' "$before") <(printf '%s\n' "$after") | head -1)
|
||||
[[ -n $num ]] || return 1
|
||||
|
||||
# The number must be genuinely new. This is the safety property that keeps a
|
||||
# numbering mistake from ever formatting a partition somebody else is using;
|
||||
# it is cheaper and more reliable than sniffing the target for signatures,
|
||||
# which would false-positive on remnants left in freed space.
|
||||
grep -qx "$num" <<<"$before" && return 1
|
||||
|
||||
actual=$(partition_size_bytes "$disk" "$num")
|
||||
[[ -n $actual ]] || return 1
|
||||
want=$((end - start))
|
||||
tolerance=$((1024 * 1024))
|
||||
(( actual >= want - tolerance && actual <= want + tolerance )) || return 1
|
||||
|
||||
parted --script "$disk" name "$num" "$name" || true
|
||||
|
||||
created_parts+=("$num")
|
||||
created_partition_number="$num"
|
||||
}
|
||||
|
||||
# Undo the partitions this run created, highest number first. Scoped strictly
|
||||
# to created_parts: without this, a failed install leaves the user's freed
|
||||
# space occupied by orphans, and the retry reports "not enough free space"
|
||||
# with no way to connect that to what just happened.
|
||||
rollback_created_parts() {
|
||||
local disk="$1" n
|
||||
(( ${#created_parts[@]} > 0 )) || return 0
|
||||
for n in $(printf '%s\n' "${created_parts[@]}" | sort -rn); do
|
||||
parted --script "$disk" rm "$n" >/dev/null 2>&1 || true
|
||||
done
|
||||
partprobe "$disk" 2>/dev/null || true
|
||||
created_parts=()
|
||||
}
|
||||
@@ -13,7 +13,7 @@ The canonical call sequence (mirrored from archinstall.scripts.guided.py) is:
|
||||
# configs do their own mounting before the Installer context opens.
|
||||
if disk_config.config_type != DiskLayoutType.Pre_mount:
|
||||
inst.mount_ordered_layout()
|
||||
inst.sanity_check(offline=, skip_ntp=, skip_wkd=)
|
||||
sanity_check(inst)
|
||||
inst.generate_key_files() # encrypted only
|
||||
inst.set_mirrors(handler, mirror_config, on_target=False)
|
||||
inst.minimal_installation(...) # base + linux pacstrap
|
||||
@@ -214,6 +214,14 @@ def _method_accepts(method, name: str) -> bool:
|
||||
return name in (*positional, *kwonly)
|
||||
|
||||
|
||||
def sanity_check(installer) -> None:
|
||||
"""Archinstall 4.5 removed offline; retain it for older releases."""
|
||||
options = {"skip_ntp": True, "skip_wkd": True}
|
||||
if _method_accepts(installer.sanity_check, "offline"):
|
||||
options["offline"] = True
|
||||
installer.sanity_check(**options)
|
||||
|
||||
|
||||
def _method_accepts_users(method) -> bool:
|
||||
return _method_accepts(method, "users")
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
r"""Reading text out of the commands the installer shells out to.
|
||||
|
||||
Firmware and filesystem metadata reach the orchestrator as command output, and
|
||||
neither is obliged to be UTF-8: an HP ProBook's NVRAM held a legacy BBS entry
|
||||
whose device path began `BBS(HD,\x80\x7f\xff\x04`, efibootmgr printed those
|
||||
bytes verbatim, and subprocess's strict text decoding turned a boot entry
|
||||
nothing here reads into a failed install.
|
||||
|
||||
So capture() replaces what it cannot decode, and the boot-entry parsing that
|
||||
reads its output stays tolerant on purpose: an entry's text is its label and its
|
||||
device path together, and the junk lives in the path, so refusing one would abort
|
||||
the install this exists to let finish. Nothing mangled reaches efibootmgr from
|
||||
there either way — only four-digit ASCII boot numbers become arguments, and a
|
||||
boot order is filtered through the entries that parsed — so a label that loses a
|
||||
byte costs a stale entry left behind rather than a broken system.
|
||||
|
||||
An identifier is the other case entirely: require_text() refuses a UUID or a
|
||||
device name that came through mangled, because that one is written into fstab and
|
||||
the kernel cmdline, or handed to mount.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
|
||||
REPLACEMENT = "\ufffd"
|
||||
|
||||
|
||||
def capture(cmd: list[str], *, check: bool = False) -> subprocess.CompletedProcess:
|
||||
"""Run cmd and return it with stdout/stderr decoded, bad bytes replaced."""
|
||||
return subprocess.run(
|
||||
cmd,
|
||||
check=check,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
errors="replace",
|
||||
)
|
||||
|
||||
|
||||
def require_text(value: str, what: str) -> str:
|
||||
"""Refuse a value the installed system depends on if bytes were replaced in it.
|
||||
|
||||
Validation reads these back from the same command that wrote them, so a
|
||||
mangled UUID agrees with itself and ships a machine that cannot find its
|
||||
root at boot. Stopping here says why while someone is still watching.
|
||||
"""
|
||||
if REPLACEMENT in value:
|
||||
raise RuntimeError(f"{what} is not valid text: {value!r}")
|
||||
return value
|
||||
|
||||
|
||||
def capture_identifier(cmd: list[str], what: str) -> str:
|
||||
"""Capture a single value the installed system will depend on."""
|
||||
return require_text(capture(cmd, check=True).stdout.strip(), what)
|
||||
@@ -6,10 +6,13 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import secrets
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from .keyboard import validate_input_selection
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallContext:
|
||||
@@ -18,11 +21,14 @@ class InstallContext:
|
||||
full_name: str
|
||||
email: str
|
||||
encrypt: bool
|
||||
authorized_keys_path: Path | None
|
||||
tailscale_authkey_path: Path | None
|
||||
|
||||
user_configuration: dict
|
||||
user_credentials: dict
|
||||
arch_config_path: Path
|
||||
omarchy_install: dict[str, Any]
|
||||
defer_provisioning: bool = False
|
||||
|
||||
target: Path = Path("/mnt")
|
||||
omarchy_path: Path = Path("/usr/share/omarchy")
|
||||
@@ -46,10 +52,63 @@ class InstallContext:
|
||||
user_configuration = json.loads(config_path.read_text())
|
||||
omarchy_install = user_configuration.get("omarchy_install") or _default_omarchy_install(user_configuration)
|
||||
|
||||
# Autoinstall configs may omit kernels, which makes archinstall default
|
||||
# to stock linux. Apply the same hardware default as the configurator,
|
||||
# while honoring an explicit selection (including storage-only configs).
|
||||
if not user_configuration.get("kernels"):
|
||||
kernel = (omarchy_install.get("storage") or {}).get("kernel") or _default_kernel()
|
||||
user_configuration["kernels"] = [kernel]
|
||||
|
||||
validate_input_selection(omarchy_install.get("input_method"), omarchy_install.get("input_xkb_layout", ""))
|
||||
|
||||
# Deferred provisioning: the whole system installs but user creation is deferred to
|
||||
# first boot. Selected by the configurator (omarchy_install.defer_provisioning) or by
|
||||
# an `defer-provisioning` marker file on an autoinstall drive, which also replaces the
|
||||
# user_credentials.json requirement.
|
||||
defer_provisioning_marker = _optional_path(os.environ.get("OMARCHY_INSTALL_DEFER_PROVISIONING_FILE"))
|
||||
defer_provisioning = bool(omarchy_install.get("defer_provisioning")) or defer_provisioning_marker is not None
|
||||
omarchy_install["defer_provisioning"] = defer_provisioning
|
||||
|
||||
if creds_path.exists():
|
||||
user_credentials = json.loads(creds_path.read_text())
|
||||
elif defer_provisioning:
|
||||
user_credentials = {"users": []}
|
||||
else:
|
||||
raise RuntimeError(f"credentials file missing: {creds_path}")
|
||||
|
||||
if defer_provisioning:
|
||||
# Deferred provisioning promises no account until first boot. A supplied
|
||||
# credentials file (a rig handing over its LUKS passphrase) must
|
||||
# not smuggle in users or a root password.
|
||||
encryption_password = user_credentials.get("encryption_password")
|
||||
user_credentials = {"users": []}
|
||||
if encryption_password:
|
||||
user_credentials["encryption_password"] = encryption_password
|
||||
|
||||
arch_configuration = dict(user_configuration)
|
||||
arch_configuration.pop("omarchy_install", None)
|
||||
|
||||
if defer_provisioning:
|
||||
# The userless invariant covers the archinstall config too: a
|
||||
# combined/legacy config could carry account authentication that
|
||||
# archinstall would still act on (users, a root password). Strip
|
||||
# every such field so no account is created before first boot.
|
||||
_strip_account_fields(arch_configuration)
|
||||
|
||||
state_dir = Path(os.environ.get("OMARCHY_INSTALL_STATE_DIR", "/run/omarchy-install"))
|
||||
state_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if defer_provisioning:
|
||||
# Encrypted deferred-provisioning installs have no user password to protect LUKS
|
||||
# with. Generate a throwaway passphrase (staged for first-boot
|
||||
# re-key by the stage_provisioning_state phase) and hand it to archinstall
|
||||
# through both places it may look: the disk_encryption block and
|
||||
# the credentials file.
|
||||
_inject_provisioning_encryption_password(arch_configuration, user_credentials)
|
||||
creds_path = state_dir / "provisioning-user_credentials.json"
|
||||
creds_path.write_text(json.dumps(user_credentials, indent=2) + "\n")
|
||||
creds_path.chmod(0o600)
|
||||
|
||||
arch_config_path = state_dir / "archinstall-user_configuration.json"
|
||||
arch_config_path.write_text(json.dumps(arch_configuration, indent=2) + "\n")
|
||||
|
||||
@@ -59,10 +118,13 @@ class InstallContext:
|
||||
full_name=_read_text(os.environ.get("OMARCHY_INSTALL_FULL_NAME_FILE")),
|
||||
email=_read_text(os.environ.get("OMARCHY_INSTALL_EMAIL_FILE")),
|
||||
encrypt=_read_text(os.environ.get("OMARCHY_INSTALL_ENCRYPT_FILE")).lower() in ("true", "yes", "1"),
|
||||
authorized_keys_path=_optional_path(os.environ.get("OMARCHY_INSTALL_AUTHORIZED_KEYS_FILE")),
|
||||
tailscale_authkey_path=_optional_path(os.environ.get("OMARCHY_INSTALL_TAILSCALE_AUTHKEY_FILE")),
|
||||
user_configuration=user_configuration,
|
||||
user_credentials=json.loads(creds_path.read_text()),
|
||||
user_credentials=user_credentials,
|
||||
arch_config_path=arch_config_path,
|
||||
omarchy_install=omarchy_install,
|
||||
defer_provisioning=defer_provisioning,
|
||||
state_dir=state_dir,
|
||||
)
|
||||
disk_config = user_configuration.get("disk_config", {})
|
||||
@@ -73,7 +135,12 @@ class InstallContext:
|
||||
|
||||
@property
|
||||
def username(self) -> str:
|
||||
return self.user_credentials["users"][0]["username"]
|
||||
users = self.user_credentials.get("users") or []
|
||||
if users:
|
||||
return users[0]["username"]
|
||||
if self.defer_provisioning:
|
||||
return ""
|
||||
raise RuntimeError("user_credentials.json contains no users")
|
||||
|
||||
@property
|
||||
def mode(self) -> str:
|
||||
@@ -87,6 +154,50 @@ class InstallContext:
|
||||
return self.mode == "protected"
|
||||
|
||||
|
||||
def _strip_account_fields(arch_configuration: dict) -> None:
|
||||
"""Remove every field archinstall reads to create users or set a root
|
||||
password, so it cannot ship a hidden provisioning account.
|
||||
Encryption material lives elsewhere (disk_config.disk_encryption) and is
|
||||
untouched."""
|
||||
for key in ("!users", "!root-password", "root_enc_password", "users"):
|
||||
arch_configuration.pop(key, None)
|
||||
|
||||
auth = arch_configuration.get("auth_config")
|
||||
if isinstance(auth, dict):
|
||||
for key in ("users", "root_enc_password"):
|
||||
auth.pop(key, None)
|
||||
|
||||
|
||||
def _inject_provisioning_encryption_password(arch_configuration: dict, user_credentials: dict) -> None:
|
||||
"""Ensure an encrypted deferred-provisioning install has a LUKS passphrase archinstall can
|
||||
use. Reuse one the input already carries (an autoinstall rig may supply
|
||||
its own); otherwise generate a throwaway. Mutates the disk_encryption
|
||||
block in place — arch_configuration shares it with user_configuration, so
|
||||
the stage_provisioning_state phase can read the effective passphrase back."""
|
||||
disk_encryption = (arch_configuration.get("disk_config") or {}).get("disk_encryption")
|
||||
if disk_encryption is None:
|
||||
return
|
||||
|
||||
password = disk_encryption.get("encryption_password") or user_credentials.get("encryption_password")
|
||||
if not password:
|
||||
password = secrets.token_urlsafe(24)
|
||||
|
||||
disk_encryption["encryption_password"] = password
|
||||
user_credentials["encryption_password"] = password
|
||||
|
||||
|
||||
def _default_kernel(pci_devices: Path = Path("/sys/bus/pci/devices")) -> str:
|
||||
for device in pci_devices.glob("*"):
|
||||
try:
|
||||
vendor = (device / "vendor").read_text().strip().lower()
|
||||
device_id = (device / "device").read_text().strip().lower()
|
||||
except OSError:
|
||||
continue
|
||||
if vendor == "0x106b" and device_id in {"0x1801", "0x1802"}:
|
||||
return "linux-t2"
|
||||
return "linux-omarchy"
|
||||
|
||||
|
||||
def _default_omarchy_install(user_configuration: dict) -> dict[str, Any]:
|
||||
disk_config = user_configuration.get("disk_config", {})
|
||||
mode = "protected" if disk_config.get("config_type") == "pre_mounted_config" else "full_disk"
|
||||
@@ -103,6 +214,16 @@ def _default_omarchy_install(user_configuration: dict) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _optional_path(path: str | None) -> Path | None:
|
||||
"""A path the caller always passes but that need not exist. The live ISO
|
||||
passes --authorized-keys-file on every install; only autoinstall drives put
|
||||
a file there."""
|
||||
if not path:
|
||||
return None
|
||||
p = Path(path)
|
||||
return p if p.exists() else None
|
||||
|
||||
|
||||
def _read_text(path: str | None) -> str:
|
||||
if not path:
|
||||
return ""
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
"""Offline target keyboard configuration.
|
||||
|
||||
archinstall's set_keyboard_language boots the installed system in a
|
||||
systemd-nspawn container just to run localectl. systemd-firstboot --root
|
||||
produces the part of that output Omarchy actually consumes — KEYMAP for the
|
||||
console plus the XKB* settings in vconsole.conf that omarchy's
|
||||
detect-keyboard-layout.sh copies into Hyprland's kb_layout — without booting
|
||||
anything. The Xorg 00-keyboard.conf that localectl also writes is not
|
||||
generated: nothing on an Omarchy system reads it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from .command import capture
|
||||
|
||||
|
||||
def configure_keyboard(target: Path, language: str, input_method: str | None = None, xkb_layout: str = "") -> bool:
|
||||
"""Write the console keymap into a mounted target without booting it.
|
||||
|
||||
Returns False for layouts localectl doesn't know, matching archinstall:
|
||||
warn and keep the default. Every layout the configurator offers is known;
|
||||
the guard is for the kb_layout an autoinstall drive can name freely.
|
||||
"""
|
||||
validate_input_selection(input_method, xkb_layout)
|
||||
if not language.strip():
|
||||
if input_method is None:
|
||||
return True
|
||||
language = "us"
|
||||
|
||||
# Input engines are separate from real console keymaps. The shared picker
|
||||
# uses US for Chinese/Korean and carries its preference in omarchy_install.
|
||||
if input_method is None:
|
||||
input_method = "mozc" if language == "jp106" else "none"
|
||||
|
||||
result = capture(["localectl", "--no-pager", "list-keymaps"])
|
||||
if result.returncode != 0:
|
||||
detail = result.stderr.strip() or "localectl returned an error"
|
||||
raise RuntimeError(f"Unable to list keyboard layouts: {detail}")
|
||||
if language.lower() not in {layout.lower() for layout in result.stdout.splitlines()}:
|
||||
if input_method != "none":
|
||||
raise ValueError(f"Unknown keyboard language: {language}")
|
||||
return False
|
||||
|
||||
# systemd-firstboot --force rewrites vconsole.conf wholesale, dropping the
|
||||
# FONT= line archinstall's set_vconsole wrote earlier.
|
||||
vconsole_path = target / "etc" / "vconsole.conf"
|
||||
font = None
|
||||
if vconsole_path.exists():
|
||||
font = next(
|
||||
(line for line in vconsole_path.read_text().splitlines() if line.startswith("FONT=")),
|
||||
None,
|
||||
)
|
||||
|
||||
result = capture(["systemd-firstboot", f"--root={target}", f"--keymap={language}", "--force"])
|
||||
if result.returncode != 0:
|
||||
detail = result.stderr.strip() or "systemd-firstboot returned an error"
|
||||
raise RuntimeError(f"Unable to configure keyboard layout {language}: {detail}")
|
||||
|
||||
if font:
|
||||
vconsole_path.write_text(vconsole_path.read_text() + font + "\n")
|
||||
|
||||
preference = target / "etc/omarchy/input-method"
|
||||
preference.parent.mkdir(parents=True, exist_ok=True)
|
||||
preference.write_text(f"INPUT_METHOD={input_method}\nXKB_LAYOUT={xkb_layout}\n")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def validate_input_selection(input_method: str | None, xkb_layout: str) -> None:
|
||||
if input_method is not None and input_method not in {"none", "mozc", "hangul", "pinyin", "chewing"}:
|
||||
raise ValueError(f"Unknown input method: {input_method}")
|
||||
if xkb_layout not in {"", "kr"}:
|
||||
raise ValueError(f"Unknown input keyboard layout: {xkb_layout}")
|
||||
@@ -34,11 +34,15 @@ def build_phases(ctx: InstallContext):
|
||||
arch_install_system,
|
||||
configure_hibernation,
|
||||
run_system_finalizer,
|
||||
stage_provisioning_state,
|
||||
finalize_limine_boot,
|
||||
run_chroot_finalizer,
|
||||
configure_dns_resolver,
|
||||
configure_login,
|
||||
configure_ssh_access,
|
||||
configure_tailscale,
|
||||
validate_boot,
|
||||
create_factory_snapshot,
|
||||
)
|
||||
|
||||
return [
|
||||
@@ -47,11 +51,17 @@ def build_phases(ctx: InstallContext):
|
||||
("Installing Arch + Omarchy", arch_install_system),
|
||||
("Configuring hibernation", configure_hibernation),
|
||||
("Configuring system", run_system_finalizer),
|
||||
# Before finalize_limine_boot: the deferred-provisioning cryptkey drop-in and keyfile
|
||||
# must be in place for the final UKI build.
|
||||
("Staging provisioning", stage_provisioning_state),
|
||||
("Finalizing Limine boot", finalize_limine_boot),
|
||||
("Finalizing user", run_chroot_finalizer),
|
||||
("Configuring login", configure_login),
|
||||
("Configuring SSH access", configure_ssh_access),
|
||||
("Configuring Tailscale", configure_tailscale),
|
||||
("Configuring DNS resolver", configure_dns_resolver),
|
||||
("Validating boot setup", validate_boot),
|
||||
("Creating factory snapshot", create_factory_snapshot),
|
||||
]
|
||||
|
||||
|
||||
@@ -62,7 +72,8 @@ def main() -> int:
|
||||
error(f"Configuration error: {e}")
|
||||
return 2
|
||||
|
||||
info(f"Installing Omarchy for {ctx.username} → {ctx.target}")
|
||||
who = ctx.username or "deferred provisioning (user created at first boot)"
|
||||
info(f"Installing Omarchy for {who} → {ctx.target}")
|
||||
|
||||
from .phases_impl import (
|
||||
boost_cpu_governor,
|
||||
|
||||
@@ -11,10 +11,12 @@ Phase ordering (full-disk and protected/pre-mounted):
|
||||
base install, early Omarchy packages, Limine setup,
|
||||
useradd, runtime Omarchy packages, fstab
|
||||
configure_hibernation → root-owned swap/resume drop-ins
|
||||
run_system_finalizer → arch-chroot root omarchy-setup-system, including Snapper
|
||||
run_system_finalizer → arch-chroot root omarchy-apply-system, including Snapper
|
||||
finalize_limine_boot → final Limine config/UKI build after hardware drop-ins
|
||||
run_chroot_finalizer → arch-chroot -u user omarchy-finalize-user
|
||||
run_chroot_finalizer → arch-chroot -u user omarchy-provision-user
|
||||
configure_login → sddm state + encrypted-install autologin
|
||||
configure_ssh_access → authorized_keys for autoinstall; no-op otherwise
|
||||
configure_tailscale → tailnet join staged for first boot; no-op otherwise
|
||||
validate_boot → assert UKI / limine.conf / kernel cmdline are sane
|
||||
"""
|
||||
|
||||
@@ -27,11 +29,14 @@ import shutil
|
||||
import subprocess
|
||||
import textwrap
|
||||
import time
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
|
||||
from . import archinstall_adapter as arch
|
||||
from .command import capture, capture_identifier, require_text
|
||||
from .context import InstallContext
|
||||
from .ui import info
|
||||
from .keyboard import configure_keyboard
|
||||
from .ui import error, info
|
||||
|
||||
|
||||
# Package targets are written by builder/build-iso.sh. Stable ISOs use the
|
||||
@@ -230,11 +235,7 @@ def arch_install_system(ctx: InstallContext) -> None:
|
||||
if not pre_mounted:
|
||||
installer.mount_ordered_layout()
|
||||
|
||||
installer.sanity_check(
|
||||
offline=True,
|
||||
skip_ntp=True,
|
||||
skip_wkd=True,
|
||||
)
|
||||
arch.sanity_check(installer)
|
||||
|
||||
if not pre_mounted and arch.is_encrypted(config):
|
||||
installer.generate_key_files()
|
||||
@@ -246,6 +247,10 @@ def arch_install_system(ctx: InstallContext) -> None:
|
||||
_mask_mkinitcpio_pacman_hooks(ctx)
|
||||
try:
|
||||
info("› installing base system (mkinitcpio deferred to final Limine UKI build)")
|
||||
# An empty kb_layout makes archinstall's set_keyboard_language skip
|
||||
# booting the target in a container just to run localectl; the
|
||||
# keymap is configured offline right after instead.
|
||||
kb_layout = config.locale_config.kb_layout if config.locale_config else ""
|
||||
installer.minimal_installation(
|
||||
optional_repositories=(
|
||||
config.mirror_config.optional_repositories
|
||||
@@ -253,10 +258,25 @@ def arch_install_system(ctx: InstallContext) -> None:
|
||||
),
|
||||
mkinitcpio=False,
|
||||
hostname=config.hostname,
|
||||
locale_config=config.locale_config,
|
||||
locale_config=(
|
||||
replace(config.locale_config, kb_layout="")
|
||||
if config.locale_config else None
|
||||
),
|
||||
pacman_config=config.pacman_config,
|
||||
)
|
||||
|
||||
# Headers are optional kernel dependencies. Install them before any
|
||||
# DKMS package so generic installs have them too, and module builds
|
||||
# use the target kernel instead of the live ISO's kernel.
|
||||
installer.add_additional_packages([f"{kernel}-headers" for kernel in config.kernels])
|
||||
|
||||
if not configure_keyboard(
|
||||
installer.target, kb_layout,
|
||||
ctx.omarchy_install.get("input_method"),
|
||||
ctx.omarchy_install.get("input_xkb_layout", ""),
|
||||
):
|
||||
error(f"Invalid keyboard language specified: {kb_layout}")
|
||||
|
||||
if config.mirror_config:
|
||||
installer.set_mirrors(mirror_handler, config.mirror_config, on_target=True)
|
||||
|
||||
@@ -277,6 +297,14 @@ def arch_install_system(ctx: InstallContext) -> None:
|
||||
|
||||
info("› installing Omarchy runtime + omarchy-base.packages")
|
||||
installer.add_additional_packages(_runtime_package_list(ctx))
|
||||
|
||||
# Tailscale is bundled in the offline mirror but only installed
|
||||
# when an autoinstall drive staged an auth key; must happen here,
|
||||
# while the mirror is still bind-mounted, not in the phase that
|
||||
# configures the join.
|
||||
if ctx.tailscale_authkey_path is not None:
|
||||
info("› installing tailscale (auth key staged for first boot)")
|
||||
installer.add_additional_packages(["tailscale"])
|
||||
finally:
|
||||
_unmask_mkinitcpio_pacman_hooks(ctx)
|
||||
_unmount_offline_package_cache(ctx)
|
||||
@@ -437,7 +465,13 @@ def _register_limine_efi_entry(
|
||||
raise RuntimeError("efibootmgr --create reported success but no Limine entry found")
|
||||
limine_num = new_limine[0]
|
||||
|
||||
keep = [num for num in pre_state["order"] if num not in stale_limine and num != limine_num]
|
||||
keep = [
|
||||
num
|
||||
for num in pre_state["order"]
|
||||
if num not in stale_limine
|
||||
and num != limine_num
|
||||
and num in pre_state["entries"]
|
||||
]
|
||||
subprocess.run(
|
||||
["efibootmgr", "--bootorder", ",".join([limine_num, *keep])],
|
||||
check=True, capture_output=True,
|
||||
@@ -570,7 +604,7 @@ DEFERRED_BOOT_HOOKS = (
|
||||
# limine-entry-tool's 90-mkinitcpio-install.hook triggers on usr/lib/firmware/*,
|
||||
# usr/src/*/dkms.conf and usr/lib/modules/*/pkgbase, and anything but a
|
||||
# usr/lib/modules path makes it rebuild the initramfs and UKI for EVERY
|
||||
# installed kernel. omarchy-setup-system's hardware scripts routinely install
|
||||
# installed kernel. omarchy-apply-system's hardware scripts routinely install
|
||||
# such packages (sof-firmware on Intel audio, nvidia-open-dkms, linux-ptl on
|
||||
# Panther Lake, linux-t2 on Macs), so the phase can pay for several full UKI
|
||||
# builds. finalize_limine_boot runs limine-update right after, which pipes
|
||||
@@ -737,33 +771,35 @@ def _storage_intent(ctx: InstallContext) -> dict:
|
||||
|
||||
def verify_protected_mounts(ctx: InstallContext) -> None:
|
||||
target = ctx.target
|
||||
if not _is_mountpoint(target):
|
||||
raise RuntimeError(f"protected mode: {target} is not a mountpoint")
|
||||
|
||||
boot = _boot_intent(ctx)
|
||||
storage = _storage_intent(ctx)
|
||||
|
||||
# Devices before the mountpoint: when the configurator hands over paths for
|
||||
# partitions that do not exist, "root_device /dev/nvme0n1p12 does not
|
||||
# exist" is diagnosable from the log alone, where "/mnt is not a
|
||||
# mountpoint" sends everyone looking at the mount instead of the paths.
|
||||
for key in ("esp_device", "root_device"):
|
||||
if not storage.get(key):
|
||||
device = storage.get(key)
|
||||
if not device:
|
||||
raise RuntimeError(f"protected mode: omarchy_install.storage.{key} missing")
|
||||
if not Path(device).exists():
|
||||
raise RuntimeError(f"protected mode: {key} {device} does not exist")
|
||||
|
||||
if not _is_mountpoint(target):
|
||||
raise RuntimeError(f"protected mode: {target} is not a mountpoint")
|
||||
|
||||
esp_mp = target / boot["esp_mount"].lstrip("/")
|
||||
if not _is_mountpoint(esp_mp):
|
||||
esp_dev = storage["esp_device"]
|
||||
if not Path(esp_dev).exists():
|
||||
raise RuntimeError(f"protected mode: ESP device {esp_dev} does not exist")
|
||||
info(f"› remounting protected ESP {esp_dev} at {esp_mp}")
|
||||
esp_mp.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.run(["mount", esp_dev, str(esp_mp)], check=True)
|
||||
|
||||
info(f"› protected target verified: kernel={storage.get('kernel', 'linux')} esp={boot['esp_mount']}")
|
||||
info(f"› protected target verified: kernel={storage.get('kernel', 'linux-omarchy')} esp={boot['esp_mount']}")
|
||||
|
||||
|
||||
def _is_mountpoint(path: Path) -> bool:
|
||||
res = subprocess.run(
|
||||
["findmnt", "-rn", str(path)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
res = capture(["findmnt", "-rn", str(path)])
|
||||
return res.returncode == 0 and bool(res.stdout.strip())
|
||||
|
||||
|
||||
@@ -777,11 +813,9 @@ def _btrfs_root_device(ctx: InstallContext) -> str:
|
||||
|
||||
|
||||
def _blkid_uuid(device: str) -> str:
|
||||
res = subprocess.run(
|
||||
["blkid", "-s", "UUID", "-o", "value", device],
|
||||
capture_output=True, text=True, check=True,
|
||||
uuid = capture_identifier(
|
||||
["blkid", "-s", "UUID", "-o", "value", device], f"the UUID of {device}"
|
||||
)
|
||||
uuid = res.stdout.strip()
|
||||
if not uuid:
|
||||
raise RuntimeError(f"blkid returned no UUID for {device}")
|
||||
return uuid
|
||||
@@ -794,11 +828,9 @@ def _esp_device(ctx: InstallContext) -> str:
|
||||
|
||||
boot = _boot_intent(ctx)
|
||||
esp_mp = ctx.target / boot["esp_mount"].lstrip("/")
|
||||
res = subprocess.run(
|
||||
["findmnt", "-n", "-o", "SOURCE", str(esp_mp)],
|
||||
capture_output=True, text=True, check=True,
|
||||
dev = capture_identifier(
|
||||
["findmnt", "-n", "-o", "SOURCE", str(esp_mp)], f"the ESP device at {esp_mp}"
|
||||
)
|
||||
dev = res.stdout.strip()
|
||||
if not dev:
|
||||
raise RuntimeError(f"could not resolve ESP device at {esp_mp}")
|
||||
return dev
|
||||
@@ -870,10 +902,7 @@ _BOOT_ORDER_RE = re.compile(r"^BootOrder:\s*(.*)$")
|
||||
|
||||
|
||||
def _read_efibootmgr() -> dict:
|
||||
res = subprocess.run(
|
||||
["efibootmgr"],
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
res = capture(["efibootmgr"], check=True)
|
||||
entries: dict[str, str] = {}
|
||||
order: list[str] = []
|
||||
for line in res.stdout.splitlines():
|
||||
@@ -892,16 +921,14 @@ def _find_label_entries(entries: dict[str, str], needle: str) -> list[str]:
|
||||
|
||||
|
||||
def _split_partition_device(part_dev: str) -> tuple[str, int]:
|
||||
parent = subprocess.run(
|
||||
["lsblk", "-ndo", "PKNAME", part_dev],
|
||||
capture_output=True, text=True, check=True,
|
||||
).stdout.strip()
|
||||
parent = capture_identifier(
|
||||
["lsblk", "-ndo", "PKNAME", part_dev], f"the parent disk of {part_dev}"
|
||||
)
|
||||
if not parent:
|
||||
raise RuntimeError(f"could not find parent disk for {part_dev}")
|
||||
part_num = subprocess.run(
|
||||
["lsblk", "-ndo", "PARTN", part_dev],
|
||||
capture_output=True, text=True, check=True,
|
||||
).stdout.strip()
|
||||
part_num = capture_identifier(
|
||||
["lsblk", "-ndo", "PARTN", part_dev], f"the partition number of {part_dev}"
|
||||
)
|
||||
if not part_num:
|
||||
raise RuntimeError(f"could not find partition number for {part_dev}")
|
||||
return f"/dev/{parent}", int(part_num)
|
||||
@@ -960,7 +987,7 @@ def _debug_run(ctx: InstallContext, cmd: list[str]) -> None:
|
||||
if not _install_debug_enabled():
|
||||
return
|
||||
_debug_log(ctx, "+ " + " ".join(cmd))
|
||||
proc = subprocess.run(cmd, check=False, text=True, capture_output=True)
|
||||
proc = capture(cmd)
|
||||
if proc.stdout:
|
||||
with ctx.log_path.open("a", encoding="utf-8") as log:
|
||||
for line in proc.stdout.splitlines():
|
||||
@@ -977,8 +1004,8 @@ def _debug_run(ctx: InstallContext, cmd: list[str]) -> None:
|
||||
# 1. point the target at the offline pacman.conf
|
||||
# 2. bind-mount the offline mirror + /opt/packages into /mnt for target pacman
|
||||
# and bundled language runtimes
|
||||
# 3. arch-chroot as root → omarchy-setup-system --first-install
|
||||
# 4. arch-chroot as user → omarchy-finalize-user --first-install
|
||||
# 3. arch-chroot as root → omarchy-apply-system --first-install
|
||||
# 4. arch-chroot as user → omarchy-provision-user --first-install
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
def _prepare_target_setup(ctx: InstallContext) -> None:
|
||||
@@ -1108,16 +1135,142 @@ def _run_target_setup_command(ctx: InstallContext, cmd: list[str], *, user: str
|
||||
|
||||
|
||||
def run_system_finalizer(ctx: InstallContext) -> None:
|
||||
if ctx.defer_provisioning:
|
||||
cmd = ["/usr/bin/omarchy-apply-system", "--defer-provisioning", "--first-install"]
|
||||
else:
|
||||
cmd = ["/usr/bin/omarchy-apply-system", "--install-user", ctx.username, "--first-install"]
|
||||
|
||||
_mask_mkinitcpio_pacman_hooks(ctx, ctx.target, TARGET_DEFERRED_BOOT_HOOKS)
|
||||
try:
|
||||
_run_target_setup_command(
|
||||
ctx,
|
||||
["/usr/bin/omarchy-setup-system", "--install-user", ctx.username, "--first-install"],
|
||||
)
|
||||
_run_target_setup_command(ctx, cmd)
|
||||
finally:
|
||||
_unmask_mkinitcpio_pacman_hooks(ctx, ctx.target, TARGET_DEFERRED_BOOT_HOOKS)
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# stage_provisioning_state: produce the on-disk "provisioning state" the runtime's first-boot
|
||||
# setup (omarchy-provision-owner) and factory reset (omarchy-system-factory-reset) consume.
|
||||
#
|
||||
# Every install stashes the bundled Node tarball in /var/lib/omarchy/provisioning/
|
||||
# so a later factory reset can finalize the new owner's user offline. deferred-provisioning
|
||||
# installs additionally arm the first-boot setup service and, on encrypted
|
||||
# targets, stage the throwaway LUKS passphrase: the keyfile embedded in the
|
||||
# initramfs auto-unlocks boot during the provisioning window, and first-boot setup
|
||||
# re-keys the volume to the owner's password and removes it.
|
||||
#
|
||||
# Runs before finalize_limine_boot so the cryptkey cmdline drop-in and the
|
||||
# keyfile land in the final UKI build.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
PROVISION_STATE_DIR = "var/lib/omarchy/provisioning"
|
||||
PROVISION_KEYFILE = "etc/omarchy/provisioning.key"
|
||||
NODE_PACKAGES_DIR = Path("/opt/packages")
|
||||
|
||||
|
||||
def stage_provisioning_state(ctx: InstallContext) -> None:
|
||||
# World-readable: first-boot finalization reads the Node tarball as the
|
||||
# new user. The only secret inside (luks-key) is itself 0600 root.
|
||||
provisioning_dir = ctx.target / PROVISION_STATE_DIR
|
||||
provisioning_dir.mkdir(parents=True, exist_ok=True)
|
||||
provisioning_dir.chmod(0o755)
|
||||
|
||||
_stage_node_tarball(ctx, provisioning_dir)
|
||||
|
||||
if not ctx.defer_provisioning:
|
||||
return
|
||||
|
||||
service_src = ctx.target / "usr/share/omarchy/install/provisioning/omarchy-provision-owner.service"
|
||||
setup_bin = ctx.target / "usr/bin/omarchy-provision-owner"
|
||||
if not service_src.exists() or not setup_bin.exists():
|
||||
raise RuntimeError(
|
||||
"deferred-provisioning install requested, but the installed Omarchy runtime does not ship "
|
||||
"first-boot setup (omarchy-provision-owner + install/provisioning/omarchy-provision-owner.service). "
|
||||
"Update the runtime package this ISO bundles before installing in deferred provisioning."
|
||||
)
|
||||
|
||||
info("› arming first-boot setup")
|
||||
(provisioning_dir / "pending").touch()
|
||||
|
||||
unit_dst = ctx.target / "etc/systemd/system/omarchy-provision-owner.service"
|
||||
unit_dst.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(service_src, unit_dst)
|
||||
wants_dir = ctx.target / "etc/systemd/system/multi-user.target.wants"
|
||||
wants_dir.mkdir(parents=True, exist_ok=True)
|
||||
link = wants_dir / "omarchy-provision-owner.service"
|
||||
link.unlink(missing_ok=True)
|
||||
link.symlink_to("/etc/systemd/system/omarchy-provision-owner.service")
|
||||
|
||||
if _provision_install_encrypted(ctx):
|
||||
_stage_provisioning_luks_unlock(ctx, provisioning_dir)
|
||||
|
||||
|
||||
def _stage_node_tarball(ctx: InstallContext, provisioning_dir) -> None:
|
||||
tarballs = sorted(NODE_PACKAGES_DIR.glob("node-v*-linux-x64.tar.gz"))
|
||||
if not tarballs:
|
||||
# Hard error on every install, not just deferred-provisioning installs: the stash is what lets a
|
||||
# later factory reset finalize the next owner offline, and an ISO
|
||||
# build always bundles the tarball — its absence means a broken build.
|
||||
raise RuntimeError(
|
||||
f"no bundled Node tarball in {NODE_PACKAGES_DIR} — first-boot setup "
|
||||
"and factory reset could not finalize a user offline"
|
||||
)
|
||||
|
||||
packages_dir = provisioning_dir / "packages"
|
||||
packages_dir.mkdir(parents=True, exist_ok=True)
|
||||
target_tarball = packages_dir / tarballs[0].name
|
||||
if not target_tarball.exists():
|
||||
info("› stashing Node tarball for offline first-boot setup")
|
||||
shutil.copy2(tarballs[0], target_tarball)
|
||||
|
||||
|
||||
def _provision_install_encrypted(ctx: InstallContext) -> bool:
|
||||
if _storage_intent(ctx).get("luks_uuid"):
|
||||
return True
|
||||
disk_encryption = (ctx.user_configuration.get("disk_config") or {}).get("disk_encryption")
|
||||
if disk_encryption and disk_encryption.get("encryption_type", "luks") != "no_encryption":
|
||||
return True
|
||||
return ctx.encrypt
|
||||
|
||||
|
||||
def _provision_encryption_password(ctx: InstallContext) -> str | None:
|
||||
disk_encryption = (ctx.user_configuration.get("disk_config") or {}).get("disk_encryption") or {}
|
||||
return disk_encryption.get("encryption_password") or ctx.user_credentials.get("encryption_password")
|
||||
|
||||
|
||||
def _stage_provisioning_luks_unlock(ctx: InstallContext, provisioning_dir) -> None:
|
||||
password = _provision_encryption_password(ctx)
|
||||
if not password:
|
||||
# Full-disk deferred-provisioning installs get a generated passphrase injected by
|
||||
# InstallContext; only a pre-mounted (rig-partitioned) LUKS target can
|
||||
# land here, and it must hand over the passphrase it formatted with.
|
||||
raise RuntimeError(
|
||||
"deferred-provisioning install on a pre-encrypted target requires the LUKS passphrase "
|
||||
"in user_credentials.json (encryption_password) so first boot can re-key"
|
||||
)
|
||||
|
||||
info("› staging LUKS auto-unlock for the provisioning window")
|
||||
|
||||
# Byte-for-byte the slot passphrase: no trailing newline anywhere.
|
||||
luks_key = provisioning_dir / "luks-key"
|
||||
luks_key.write_text(password)
|
||||
luks_key.chmod(0o600)
|
||||
|
||||
keyfile = ctx.target / PROVISION_KEYFILE
|
||||
keyfile.parent.mkdir(parents=True, exist_ok=True)
|
||||
keyfile.write_text(password)
|
||||
keyfile.chmod(0o600)
|
||||
|
||||
cmdline_dropin = ctx.target / "etc/limine-entry-tool.d/99-omarchy-provisioning-unlock.conf"
|
||||
cmdline_dropin.parent.mkdir(parents=True, exist_ok=True)
|
||||
cmdline_dropin.write_text(
|
||||
'KERNEL_CMDLINE[default]+=" cryptkey=rootfs:/etc/omarchy/provisioning.key"\n'
|
||||
)
|
||||
|
||||
files_dropin = ctx.target / "etc/mkinitcpio.conf.d/99-omarchy-provisioning-key.conf"
|
||||
files_dropin.parent.mkdir(parents=True, exist_ok=True)
|
||||
files_dropin.write_text("FILES+=(/etc/omarchy/provisioning.key)\n")
|
||||
|
||||
|
||||
def finalize_limine_boot(ctx: InstallContext) -> None:
|
||||
"""Finalize Limine after target system setup has written all dynamic
|
||||
boot drop-ins (hibernation, hardware quirks, protected-mode ESP settings).
|
||||
@@ -1211,9 +1364,13 @@ def _limine_kernel_cmdline(config_text: str) -> str:
|
||||
|
||||
|
||||
def run_chroot_finalizer(ctx: InstallContext) -> None:
|
||||
if ctx.defer_provisioning:
|
||||
info("› deferred-provisioning install: user finalization deferred to first boot")
|
||||
return
|
||||
|
||||
_run_target_setup_command(
|
||||
ctx,
|
||||
["/usr/bin/omarchy-finalize-user", "--force", "--first-install"],
|
||||
["/usr/bin/omarchy-provision-user", "--force", "--first-install"],
|
||||
user=ctx.username,
|
||||
)
|
||||
|
||||
@@ -1257,35 +1414,233 @@ def configure_login(ctx: InstallContext) -> None:
|
||||
)
|
||||
|
||||
autologin_conf = sddm_dir / "autologin.conf"
|
||||
if ctx.encrypt:
|
||||
if ctx.encrypt and not ctx.defer_provisioning:
|
||||
autologin_conf.write_text(
|
||||
"[Autologin]\n"
|
||||
f"User={ctx.username}\n"
|
||||
"Session=omarchy.desktop\n"
|
||||
)
|
||||
else:
|
||||
# deferred-provisioning installs have no user yet; omarchy-provision-owner writes autologin
|
||||
# and SDDM state at first boot once the owner exists.
|
||||
autologin_conf.unlink(missing_ok=True)
|
||||
|
||||
state_dir = ctx.target / "var" / "lib" / "sddm"
|
||||
state_dir.mkdir(parents=True, exist_ok=True)
|
||||
(state_dir / "state.conf").write_text(
|
||||
f"[Last]\nSession=omarchy.desktop\nUser={ctx.username}\n"
|
||||
)
|
||||
if not ctx.defer_provisioning:
|
||||
state_dir = ctx.target / "var" / "lib" / "sddm"
|
||||
state_dir.mkdir(parents=True, exist_ok=True)
|
||||
(state_dir / "state.conf").write_text(
|
||||
f"[Last]\nSession=omarchy.desktop\nUser={ctx.username}\n"
|
||||
)
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "chown", "sddm:sddm",
|
||||
"/var/lib/sddm", "/var/lib/sddm/state.conf"],
|
||||
check=False, capture_output=True,
|
||||
)
|
||||
|
||||
autologin = ctx.target / "etc" / "systemd" / "system" / "getty@tty1.service.d" / "autologin.conf"
|
||||
autologin.unlink(missing_ok=True)
|
||||
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "chown", "sddm:sddm",
|
||||
"/var/lib/sddm", "/var/lib/sddm/state.conf"],
|
||||
check=False, capture_output=True,
|
||||
)
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "systemctl", "enable", "sddm.service"],
|
||||
check=False, capture_output=True,
|
||||
)
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# configure_ssh_access: make the installed machine reachable over SSH with the
|
||||
# keys an autoinstall drive supplied. A stock Omarchy install ships openssh but
|
||||
# leaves sshd disabled, and its firewall.sh opens only LocalSend and docker DNS,
|
||||
# so all three pieces -- keys, service, firewall -- have to be done here.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
def configure_ssh_access(ctx: InstallContext) -> None:
|
||||
if ctx.authorized_keys_path is None:
|
||||
return
|
||||
|
||||
keys = _authorized_keys(ctx.authorized_keys_path)
|
||||
|
||||
if ctx.defer_provisioning:
|
||||
# No user to authorize yet. Stage the keys in provisioning state for
|
||||
# omarchy-provision-owner to install once first boot creates the owner, and
|
||||
# still open the door (sshd + ufw) below.
|
||||
info(f"› staging {len(keys)} SSH key(s) for the first-boot user")
|
||||
provisioning_dir = ctx.target / PROVISION_STATE_DIR
|
||||
provisioning_dir.mkdir(parents=True, exist_ok=True)
|
||||
staged = provisioning_dir / "authorized_keys"
|
||||
staged.write_text("".join(f"{key}\n" for key in keys))
|
||||
staged.chmod(0o600)
|
||||
else:
|
||||
info(f"› installing {len(keys)} SSH key(s) for {ctx.username}")
|
||||
|
||||
ssh_dir = ctx.target / "home" / ctx.username / ".ssh"
|
||||
ssh_dir.mkdir(parents=True, exist_ok=True)
|
||||
ssh_dir.chmod(0o700)
|
||||
|
||||
authorized_keys = ssh_dir / "authorized_keys"
|
||||
authorized_keys.write_text("".join(f"{key}\n" for key in keys))
|
||||
authorized_keys.chmod(0o600)
|
||||
|
||||
# Ask the target for the uid rather than assuming the first user is 1000.
|
||||
# Uncaptured so a failure shows up in the install log, and checked because
|
||||
# a root-owned authorized_keys is one sshd refuses to read.
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "chown", "-R",
|
||||
f"{ctx.username}:{ctx.username}", f"/home/{ctx.username}/.ssh"],
|
||||
check=True,
|
||||
)
|
||||
|
||||
info("› enabling sshd")
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "systemctl", "enable", "sshd.service"],
|
||||
check=True,
|
||||
)
|
||||
|
||||
# Open port 22 in the target's ufw, which runs default-deny incoming, so an
|
||||
# enabled sshd is still unreachable -- connections time out rather than
|
||||
# being refused.
|
||||
#
|
||||
# ufw cannot reach netfilter from inside the chroot and exits non-zero
|
||||
# saying so, but it writes the rule to user.rules first, and that file is
|
||||
# what ufw.service loads on first boot. So the exit status is the wrong
|
||||
# thing to check here; the rule landing in the file is the thing that
|
||||
# matters.
|
||||
info("› allowing SSH through ufw")
|
||||
subprocess.run(["arch-chroot", str(ctx.target), "ufw", "allow", "ssh"], check=False)
|
||||
|
||||
rules = ctx.target / "etc" / "ufw" / "user.rules"
|
||||
text = rules.read_text() if rules.exists() else ""
|
||||
if "--dport 22 -j ACCEPT" not in text:
|
||||
raise RuntimeError(f"ufw did not record an allow rule for port 22 in {rules}")
|
||||
|
||||
|
||||
def _authorized_keys(path: Path) -> list[str]:
|
||||
"""Read the autoinstall authorized_keys: sshd's own format, one public key
|
||||
per line, with blank lines and # comments dropped.
|
||||
|
||||
Raise rather than skip on anything unusable. An install that "succeeds"
|
||||
into a machine nobody can log into is worse than one that stops with the
|
||||
reason on screen.
|
||||
"""
|
||||
try:
|
||||
lines = path.read_text().splitlines()
|
||||
except OSError as exc:
|
||||
raise RuntimeError(f"{path} is not readable: {exc}") from exc
|
||||
|
||||
keys = [line.strip() for line in lines]
|
||||
keys = [key for key in keys if key and not key.startswith("#")]
|
||||
if not keys:
|
||||
raise RuntimeError(f"{path} contains no SSH keys")
|
||||
|
||||
return keys
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# configure_tailscale: stage the tailnet join an autoinstall drive asked for.
|
||||
# `tailscale up` needs a running tailscaled and there is no systemd in the
|
||||
# chroot, so the install only stages: the key, the enabled services, and a
|
||||
# oneshot first-boot unit that performs the join once the network is really
|
||||
# there. The package itself was installed from the offline mirror during
|
||||
# arch_install_system -- nothing is fetched at boot.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
TAILSCALE_AUTHKEY_TARGET = "/etc/tailscale/authkey"
|
||||
|
||||
# systemd expands $VAR in ExecStart, so the retry loop avoids `$` entirely.
|
||||
# network-online.target can be reached before there is real connectivity, so
|
||||
# retry inside the boot -- but NOT as a oneshot: target units implicitly gain
|
||||
# After= for their Wants=, so a oneshot in multi-user.target holds the whole
|
||||
# boot (SDDM included) hostage until it finishes. Type=simple counts as
|
||||
# started the moment it forks, letting boot proceed while the join retries in
|
||||
# the background for as long as the boot lasts. Cleanup lives inside the
|
||||
# script because it must only run after a successful join: the key is removed
|
||||
# and the unit disabled on success, while on a boot with no connectivity both
|
||||
# survive -- so a machine installed offline joins on the first boot that can.
|
||||
TAILSCALE_JOIN_UNIT = f"""\
|
||||
[Unit]
|
||||
Description=Join the tailnet with the auth key staged by autoinstall
|
||||
Wants=network-online.target
|
||||
After=network-online.target tailscaled.service
|
||||
Requires=tailscaled.service
|
||||
ConditionPathExists={TAILSCALE_AUTHKEY_TARGET}
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/sh -c 'until tailscale up --auth-key file:{TAILSCALE_AUTHKEY_TARGET}; do sleep 15; done; rm -f {TAILSCALE_AUTHKEY_TARGET}; systemctl disable omarchy-tailscale-join.service'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
"""
|
||||
|
||||
|
||||
def configure_tailscale(ctx: InstallContext) -> None:
|
||||
if ctx.tailscale_authkey_path is None:
|
||||
return
|
||||
|
||||
key = _tailscale_authkey(ctx.tailscale_authkey_path)
|
||||
|
||||
# An ISO built before tailscale was bundled installs nothing, and a staged
|
||||
# key with no binary would fail silently forever on first boot.
|
||||
if not (ctx.target / "usr" / "bin" / "tailscale").exists():
|
||||
raise RuntimeError("tailscale is not installed on the target; this ISO does not bundle it")
|
||||
|
||||
info("› staging Tailscale auth key")
|
||||
ts_dir = ctx.target / "etc" / "tailscale"
|
||||
ts_dir.mkdir(parents=True, exist_ok=True)
|
||||
ts_dir.chmod(0o700)
|
||||
authkey = ts_dir / "authkey"
|
||||
authkey.write_text(f"{key}\n")
|
||||
authkey.chmod(0o600)
|
||||
|
||||
info("› enabling tailscaled and the first-boot join")
|
||||
unit = ctx.target / "etc" / "systemd" / "system" / "omarchy-tailscale-join.service"
|
||||
unit.parent.mkdir(parents=True, exist_ok=True)
|
||||
unit.write_text(TAILSCALE_JOIN_UNIT)
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "systemctl", "enable",
|
||||
"tailscaled.service", "omarchy-tailscale-join.service"],
|
||||
check=True,
|
||||
)
|
||||
|
||||
# Same dance as configure_ssh_access: ufw cannot reach netfilter from the
|
||||
# chroot and exits non-zero, but it records the rule in user.rules first,
|
||||
# and that file is what ufw.service loads on first boot. Without the rule
|
||||
# the node joins the tailnet and is then unreachable over it.
|
||||
info("› allowing tailnet traffic through ufw")
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "ufw", "allow", "in", "on", "tailscale0"],
|
||||
check=False,
|
||||
)
|
||||
|
||||
rules = ctx.target / "etc" / "ufw" / "user.rules"
|
||||
text = rules.read_text() if rules.exists() else ""
|
||||
if "-i tailscale0 -j ACCEPT" not in text:
|
||||
raise RuntimeError(f"ufw did not record an allow rule for tailscale0 in {rules}")
|
||||
|
||||
|
||||
def _tailscale_authkey(path: Path) -> str:
|
||||
"""Read the autoinstall tailscale_authkey: exactly one key, with blank
|
||||
lines and # comments dropped. No format validation beyond that -- key
|
||||
formats are Tailscale's to change.
|
||||
|
||||
Raise rather than skip on anything unusable, same reasoning as
|
||||
_authorized_keys: a machine that "succeeds" into never joining the
|
||||
tailnet is worse than one that stops with the reason on screen.
|
||||
"""
|
||||
try:
|
||||
lines = path.read_text().splitlines()
|
||||
except OSError as exc:
|
||||
raise RuntimeError(f"{path} is not readable: {exc}") from exc
|
||||
|
||||
keys = [line.strip() for line in lines]
|
||||
keys = [key for key in keys if key and not key.startswith("#")]
|
||||
if not keys:
|
||||
raise RuntimeError(f"{path} contains no auth key")
|
||||
if len(keys) > 1:
|
||||
raise RuntimeError(f"{path} contains {len(keys)} keys; expected exactly one")
|
||||
|
||||
return keys[0]
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# validate_boot: hard checks before reboot. If the install ran but produced a
|
||||
# boot config or UKI that can't actually boot, halt here rather than surprise
|
||||
@@ -1294,6 +1649,7 @@ def configure_login(ctx: InstallContext) -> None:
|
||||
|
||||
def validate_boot(ctx: InstallContext) -> None:
|
||||
_assert_boot_hooks_restored(ctx)
|
||||
_validate_kernel_headers(ctx)
|
||||
|
||||
boot = _boot_intent(ctx)
|
||||
storage = _storage_intent(ctx)
|
||||
@@ -1316,7 +1672,7 @@ def validate_boot(ctx: InstallContext) -> None:
|
||||
default_limine = ctx.target / "etc" / "default" / "limine"
|
||||
config_text = _limine_combined_config_text(ctx, default_limine.read_text())
|
||||
uki_prefix = _limine_setting(config_text, "CUSTOM_UKI_NAME", "omarchy") or "omarchy"
|
||||
kernel = storage.get("kernel") or (ctx.user_configuration.get("kernels") or ["linux"])[0]
|
||||
kernel = storage.get("kernel") or (ctx.user_configuration.get("kernels") or ["linux-omarchy"])[0]
|
||||
|
||||
if arch.has_uefi():
|
||||
limine_binary = esp_mount / boot.get("esp_path", "/EFI/limine").lstrip("/") / boot.get("efi_binary", "limine_x64.efi")
|
||||
@@ -1339,6 +1695,34 @@ def validate_boot(ctx: InstallContext) -> None:
|
||||
if ctx.is_protected:
|
||||
_validate_pre_mounted_filesystems(ctx)
|
||||
|
||||
if ctx.defer_provisioning:
|
||||
_validate_provisioning_state(ctx)
|
||||
|
||||
|
||||
def _validate_provisioning_state(ctx: InstallContext) -> None:
|
||||
"""An deferred-provisioning install that boots without a working first-boot setup is a
|
||||
user-less brick; insist the armed state is complete before reboot."""
|
||||
provisioning_dir = ctx.target / PROVISION_STATE_DIR
|
||||
if not (provisioning_dir / "pending").exists():
|
||||
raise RuntimeError(f"deferred-provisioning install but {provisioning_dir / 'pending'} is missing")
|
||||
|
||||
link = ctx.target / "etc/systemd/system/multi-user.target.wants/omarchy-provision-owner.service"
|
||||
if not link.is_symlink():
|
||||
raise RuntimeError("deferred-provisioning install but omarchy-provision-owner.service is not enabled")
|
||||
|
||||
if not list((provisioning_dir / "packages").glob("node-v*.tar.gz")):
|
||||
raise RuntimeError(f"deferred-provisioning install but no Node tarball staged in {provisioning_dir / 'packages'}")
|
||||
|
||||
if _provision_install_encrypted(ctx):
|
||||
for required in (provisioning_dir / "luks-key", ctx.target / PROVISION_KEYFILE):
|
||||
if not required.exists():
|
||||
raise RuntimeError(f"encrypted deferred-provisioning install but {required} is missing")
|
||||
limine_conf_text = (
|
||||
ctx.target / _boot_intent(ctx)["esp_mount"].lstrip("/") / "limine.conf"
|
||||
).read_text()
|
||||
if "cryptkey=rootfs:" not in limine_conf_text:
|
||||
raise RuntimeError("encrypted deferred-provisioning install but limine.conf has no cryptkey= for auto-unlock")
|
||||
|
||||
|
||||
def _assert_boot_hooks_restored(ctx: InstallContext) -> None:
|
||||
"""Never hand over a system whose UKI rebuild hook is still masked.
|
||||
@@ -1364,6 +1748,19 @@ def _assert_boot_hooks_restored(ctx: InstallContext) -> None:
|
||||
raise RuntimeError(f"{path} is missing — future kernel updates would ship no UKI")
|
||||
|
||||
|
||||
def _validate_kernel_headers(ctx: InstallContext) -> None:
|
||||
kernels = sorted((ctx.target / "usr/lib/modules").glob("*/pkgbase"))
|
||||
if not kernels:
|
||||
raise RuntimeError("no installed kernel found in target")
|
||||
for pkgbase in kernels:
|
||||
release = pkgbase.parent.name
|
||||
header_release = pkgbase.parent / "build/include/config/kernel.release"
|
||||
if not header_release.is_file():
|
||||
raise RuntimeError(f"{pkgbase.read_text().strip()} ({release}) has no kernel headers")
|
||||
if header_release.read_text().strip() != release:
|
||||
raise RuntimeError(f"{pkgbase.read_text().strip()} headers do not match kernel {release}")
|
||||
|
||||
|
||||
# Every kernel package leaves its pkgbase next to its modules, which is also
|
||||
# the name limine-mkinitcpio-hook builds the UKI under.
|
||||
def _installed_kernels(ctx: InstallContext) -> list[str]:
|
||||
@@ -1396,6 +1793,90 @@ def _validate_pre_mounted_filesystems(ctx: InstallContext) -> None:
|
||||
raise RuntimeError(f"{crypttab} missing LUKS UUID {storage['luks_uuid']}")
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# create_factory_snapshot: read-only snapshot of @ kept at the btrfs top level
|
||||
# as @factory — outside snapper's .snapshots, so cleanup timers and the Limine
|
||||
# snapshot menu never touch it. Zero bytes at creation; grows only with drift.
|
||||
# Taken at the end of every install, it is what makes omarchy-system-factory-reset a
|
||||
# true factory reset.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
def create_factory_snapshot(ctx: InstallContext) -> None:
|
||||
fstype = _findmnt_value(ctx.target, "FSTYPE")
|
||||
if fstype != "btrfs":
|
||||
info(f"› target root is {fstype or 'unknown'}, not btrfs; skipping factory snapshot")
|
||||
return
|
||||
|
||||
options = (_findmnt_value(ctx.target, "OPTIONS") or "").split(",")
|
||||
if not any(opt in ("subvol=/@", "subvol=@") for opt in options):
|
||||
info("› target root is not the @ subvolume; skipping factory snapshot")
|
||||
return
|
||||
|
||||
device = require_text(
|
||||
(_findmnt_value(ctx.target, "SOURCE") or "").split("[")[0],
|
||||
f"the btrfs device backing {ctx.target}",
|
||||
)
|
||||
if not device:
|
||||
raise RuntimeError(f"could not determine the btrfs device backing {ctx.target}")
|
||||
|
||||
top = ctx.state_dir / "factory-top"
|
||||
top.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.run(["mount", "-o", "subvolid=5", device, str(top)], check=True)
|
||||
try:
|
||||
root_subvol = top / "@"
|
||||
if not root_subvol.is_dir():
|
||||
raise RuntimeError(f"no @ subvolume at the top level of {device}")
|
||||
|
||||
factory = top / "@factory"
|
||||
if factory.exists():
|
||||
subprocess.run(
|
||||
["btrfs", "subvolume", "delete", str(factory)],
|
||||
check=True, capture_output=True,
|
||||
)
|
||||
|
||||
info("› snapshotting @ as @factory (read-only)")
|
||||
subprocess.run(
|
||||
["btrfs", "subvolume", "snapshot", str(root_subvol), str(factory)],
|
||||
check=True,
|
||||
)
|
||||
_scrub_factory_snapshot(factory)
|
||||
subprocess.run(
|
||||
["btrfs", "property", "set", "-ts", str(factory), "ro", "true"],
|
||||
check=True,
|
||||
)
|
||||
finally:
|
||||
subprocess.run(["umount", str(top)], check=False, capture_output=True)
|
||||
|
||||
|
||||
# Provisioning credentials staged for THIS deployment's first boot must not
|
||||
# survive into the factory image: a reset years later would otherwise hand the
|
||||
# next owner the original deployment's SSH keys or rejoin its tailnet, and a
|
||||
# stale LUKS key (dead after the first re-key) has no business lingering.
|
||||
# The mkinitcpio/cmdline drop-ins go with the keyfile — a reset rebuild would
|
||||
# otherwise fail on FILES pointing at a scrubbed path.
|
||||
FACTORY_SCRUB_PATHS = (
|
||||
"var/lib/omarchy/provisioning/authorized_keys",
|
||||
"var/lib/omarchy/provisioning/luks-key",
|
||||
"etc/omarchy/provisioning.key",
|
||||
"etc/limine-entry-tool.d/99-omarchy-provisioning-unlock.conf",
|
||||
"etc/mkinitcpio.conf.d/99-omarchy-provisioning-key.conf",
|
||||
"etc/tailscale/authkey",
|
||||
"etc/systemd/system/omarchy-tailscale-join.service",
|
||||
"etc/systemd/system/multi-user.target.wants/omarchy-tailscale-join.service",
|
||||
)
|
||||
|
||||
|
||||
def _scrub_factory_snapshot(factory: Path) -> None:
|
||||
for rel in FACTORY_SCRUB_PATHS:
|
||||
(factory / rel).unlink(missing_ok=True)
|
||||
|
||||
|
||||
def _findmnt_value(path: Path, column: str) -> str | None:
|
||||
res = capture(["findmnt", "-no", column, str(path)])
|
||||
value = res.stdout.strip()
|
||||
return value if res.returncode == 0 and value else None
|
||||
|
||||
|
||||
CPU_SYSFS = Path("/sys/devices/system/cpu")
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
[omarchy]
|
||||
SigLevel = Optional TrustAll
|
||||
Server = https://pkgs.omarchy.org/edge/$arch
|
||||
Server = https://pkgs.omarchy.org/rc/$arch
|
||||
|
||||
[arch-mact2]
|
||||
Server = https://mirror.funami.tech/arch-mact2/os/x86_64
|
||||
|
||||
@@ -36,8 +36,10 @@ file_permissions=(
|
||||
["/root/.gnupg"]="0:0:700"
|
||||
["/root/configurator"]="0:0:755"
|
||||
["/usr/local/bin/choose-mirror"]="0:0:755"
|
||||
["/usr/local/bin/omarchy-cidata-load"]="0:0:755"
|
||||
["/usr/local/bin/omarchy-iso-cleanup-disk"]="0:0:755"
|
||||
["/usr/local/bin/omarchy-install-dashboard"]="0:0:755"
|
||||
["/usr/local/bin/omarchy-install-diagnose-media"]="0:0:755"
|
||||
["/usr/local/bin/omarchy-iso-install"]="0:0:755"
|
||||
["/usr/local/bin/omarchy-upload-log"]="0:0:755"
|
||||
["/var/cache/omarchy/mirror/offline/"]="0:0:775"
|
||||
|
||||
@@ -3763,7 +3763,6 @@
|
||||
"kservice",
|
||||
"ktextwidgets",
|
||||
"kvantum",
|
||||
"kvantum-qt5",
|
||||
"kwallet",
|
||||
"kwidgetsaddons",
|
||||
"kwindowsystem",
|
||||
@@ -4212,12 +4211,6 @@
|
||||
"qpdf",
|
||||
"qqc2-desktop-style",
|
||||
"qrcodegencpp-cmake",
|
||||
"qt5-base",
|
||||
"qt5-declarative",
|
||||
"qt5-svg",
|
||||
"qt5-translations",
|
||||
"qt5-wayland",
|
||||
"qt5-x11extras",
|
||||
"qt6-5compat",
|
||||
"qt6-base",
|
||||
"qt6-declarative",
|
||||
@@ -4485,7 +4478,7 @@
|
||||
"jq",
|
||||
"kdenlive",
|
||||
"kernel-modules-hook",
|
||||
"kvantum-qt5",
|
||||
"kvantum",
|
||||
"lazydocker",
|
||||
"lazygit",
|
||||
"less",
|
||||
@@ -4531,7 +4524,6 @@
|
||||
"python-poetry-core",
|
||||
"python-terminaltexteffects",
|
||||
"qemu-user-static-binfmt",
|
||||
"qt5-wayland",
|
||||
"quickshell",
|
||||
"ripgrep",
|
||||
"ruby",
|
||||
@@ -4639,7 +4631,7 @@
|
||||
"jq",
|
||||
"kdenlive",
|
||||
"kernel-modules-hook",
|
||||
"kvantum-qt5",
|
||||
"kvantum",
|
||||
"lazydocker",
|
||||
"lazygit",
|
||||
"less",
|
||||
@@ -4685,7 +4677,6 @@
|
||||
"python-poetry-core",
|
||||
"python-terminaltexteffects",
|
||||
"qemu-user-static-binfmt",
|
||||
"qt5-wayland",
|
||||
"quickshell",
|
||||
"ripgrep",
|
||||
"ruby",
|
||||
@@ -5026,7 +5017,6 @@
|
||||
"kservice",
|
||||
"ktextwidgets",
|
||||
"kvantum",
|
||||
"kvantum-qt5",
|
||||
"kwallet",
|
||||
"kwidgetsaddons",
|
||||
"kwindowsystem",
|
||||
@@ -5475,12 +5465,6 @@
|
||||
"qpdf",
|
||||
"qqc2-desktop-style",
|
||||
"qrcodegencpp-cmake",
|
||||
"qt5-base",
|
||||
"qt5-declarative",
|
||||
"qt5-svg",
|
||||
"qt5-translations",
|
||||
"qt5-wayland",
|
||||
"qt5-x11extras",
|
||||
"qt6-5compat",
|
||||
"qt6-base",
|
||||
"qt6-declarative",
|
||||
@@ -5976,7 +5960,6 @@
|
||||
"kservice": "6.26.0-1",
|
||||
"ktextwidgets": "6.26.0-1",
|
||||
"kvantum": "1.1.7-1",
|
||||
"kvantum-qt5": "1.1.7-1",
|
||||
"kwallet": "6.26.0-1",
|
||||
"kwidgetsaddons": "6.26.0-1",
|
||||
"kwindowsystem": "6.26.0-1",
|
||||
@@ -6426,12 +6409,6 @@
|
||||
"qpdf": "12.3.2-2",
|
||||
"qqc2-desktop-style": "6.26.0-1",
|
||||
"qrcodegencpp-cmake": "1.8.0-4",
|
||||
"qt5-base": "5.15.19+kde+r96-1",
|
||||
"qt5-declarative": "5.15.19+kde+r23-1",
|
||||
"qt5-svg": "5.15.19+kde+r5-1",
|
||||
"qt5-translations": "5.15.19-1",
|
||||
"qt5-wayland": "5.15.19+kde+r55-1",
|
||||
"qt5-x11extras": "5.15.19-1",
|
||||
"qt6-5compat": "6.11.1-1",
|
||||
"qt6-base": "6.11.1-1",
|
||||
"qt6-declarative": "6.11.1-2",
|
||||
|
||||
+2
-25
@@ -3016,7 +3016,6 @@
|
||||
"kservice",
|
||||
"ktextwidgets",
|
||||
"kvantum",
|
||||
"kvantum-qt5",
|
||||
"kwallet",
|
||||
"kwidgetsaddons",
|
||||
"kwindowsystem",
|
||||
@@ -3465,12 +3464,6 @@
|
||||
"qpdf",
|
||||
"qqc2-desktop-style",
|
||||
"qrcodegencpp-cmake",
|
||||
"qt5-base",
|
||||
"qt5-declarative",
|
||||
"qt5-svg",
|
||||
"qt5-translations",
|
||||
"qt5-wayland",
|
||||
"qt5-x11extras",
|
||||
"qt6-5compat",
|
||||
"qt6-base",
|
||||
"qt6-declarative",
|
||||
@@ -3738,7 +3731,7 @@
|
||||
"jq",
|
||||
"kdenlive",
|
||||
"kernel-modules-hook",
|
||||
"kvantum-qt5",
|
||||
"kvantum",
|
||||
"lazydocker",
|
||||
"lazygit",
|
||||
"less",
|
||||
@@ -3784,7 +3777,6 @@
|
||||
"python-poetry-core",
|
||||
"python-terminaltexteffects",
|
||||
"qemu-user-static-binfmt",
|
||||
"qt5-wayland",
|
||||
"quickshell",
|
||||
"ripgrep",
|
||||
"ruby",
|
||||
@@ -3892,7 +3884,7 @@
|
||||
"jq",
|
||||
"kdenlive",
|
||||
"kernel-modules-hook",
|
||||
"kvantum-qt5",
|
||||
"kvantum",
|
||||
"lazydocker",
|
||||
"lazygit",
|
||||
"less",
|
||||
@@ -3938,7 +3930,6 @@
|
||||
"python-poetry-core",
|
||||
"python-terminaltexteffects",
|
||||
"qemu-user-static-binfmt",
|
||||
"qt5-wayland",
|
||||
"quickshell",
|
||||
"ripgrep",
|
||||
"ruby",
|
||||
@@ -4279,7 +4270,6 @@
|
||||
"kservice",
|
||||
"ktextwidgets",
|
||||
"kvantum",
|
||||
"kvantum-qt5",
|
||||
"kwallet",
|
||||
"kwidgetsaddons",
|
||||
"kwindowsystem",
|
||||
@@ -4728,12 +4718,6 @@
|
||||
"qpdf",
|
||||
"qqc2-desktop-style",
|
||||
"qrcodegencpp-cmake",
|
||||
"qt5-base",
|
||||
"qt5-declarative",
|
||||
"qt5-svg",
|
||||
"qt5-translations",
|
||||
"qt5-wayland",
|
||||
"qt5-x11extras",
|
||||
"qt6-5compat",
|
||||
"qt6-base",
|
||||
"qt6-declarative",
|
||||
@@ -5229,7 +5213,6 @@
|
||||
"kservice": "6.26.0-1",
|
||||
"ktextwidgets": "6.26.0-1",
|
||||
"kvantum": "1.1.7-1",
|
||||
"kvantum-qt5": "1.1.7-1",
|
||||
"kwallet": "6.26.0-1",
|
||||
"kwidgetsaddons": "6.26.0-1",
|
||||
"kwindowsystem": "6.26.0-1",
|
||||
@@ -5679,12 +5662,6 @@
|
||||
"qpdf": "12.3.2-2",
|
||||
"qqc2-desktop-style": "6.26.0-1",
|
||||
"qrcodegencpp-cmake": "1.8.0-4",
|
||||
"qt5-base": "5.15.19+kde+r96-1",
|
||||
"qt5-declarative": "5.15.19+kde+r23-1",
|
||||
"qt5-svg": "5.15.19+kde+r5-1",
|
||||
"qt5-translations": "5.15.19-1",
|
||||
"qt5-wayland": "5.15.19+kde+r55-1",
|
||||
"qt5-x11extras": "5.15.19-1",
|
||||
"qt6-5compat": "6.11.1-1",
|
||||
"qt6-base": "6.11.1-1",
|
||||
"qt6-declarative": "6.11.1-2",
|
||||
|
||||
@@ -76,9 +76,9 @@ aarch64 has no BIOS — only UEFI. Drop the syslinux path entirely on ARM.
|
||||
|
||||
The cleanest cut: keep one `grub.cfg` shared, strip the x86 shell/memtest fragments at build time when `OMARCHY_ARCH=aarch64`. Don't fork the file.
|
||||
|
||||
### 6. mkinitcpio preset — `configs/airootfs/etc/mkinitcpio.d/linux.preset`
|
||||
### 6. mkinitcpio preset — `configs/airootfs/etc/mkinitcpio.d/linux-t2.preset`
|
||||
|
||||
References `vmlinuz-linux-t2` and `initramfs-linux-t2.img` (lines 5, 8). For aarch64, swap to `vmlinuz-linux` / `initramfs-linux.img`. Generate the file at build time from a template, keyed on arch.
|
||||
Names `vmlinuz-linux-t2` and `initramfs-linux-t2.img`. The filename is the pkgbase and the alpm hook keys off it, so aarch64 does not rename this file — it simply does not ship it, and releng's own `linux.preset` covers the stock kernel. Drop `linux-t2` from `arch_packages` on aarch64 and the boot entries point at `vmlinuz-linux` / `initramfs-linux.img`.
|
||||
|
||||
### 7. Configurator — `configs/airootfs/root/configurator`
|
||||
|
||||
@@ -145,7 +145,7 @@ Code:
|
||||
- `configs/efiboot/loader/loader.conf` — per-arch default entry
|
||||
- `configs/efiboot/loader/entries/01-archiso-x86_64-linux.conf` — generate aarch64 sibling at build time
|
||||
- `configs/grub/grub.cfg`, `loopback.cfg` — strip x86-only fragments on aarch64
|
||||
- `configs/airootfs/etc/mkinitcpio.d/linux.preset` — template by arch (drop linux-t2 on aarch64)
|
||||
- `configs/airootfs/etc/mkinitcpio.d/linux-t2.preset` — omit on aarch64 (drop linux-t2 there; releng's linux.preset covers the stock kernel)
|
||||
- `configs/airootfs/root/configurator` — branch archinstall JSON mirror list on `uname -m`; optionally guard lspci T2 probe
|
||||
- `.github/workflows/nightly-build.yml` — matrix x86_64/aarch64
|
||||
|
||||
|
||||
@@ -6,6 +6,17 @@ Support Omarchy installs on consumer laptops that ship with UEFI Secure Boot ena
|
||||
|
||||
This plan targets normal consumer hardware, especially Windows dual-boot machines. OEM-controlled hardware with Omarchy-owned firmware keys is a separate path.
|
||||
|
||||
## Current State (August 2026)
|
||||
|
||||
Where the repo stands today, and what that changes about this plan:
|
||||
|
||||
- The ISO builds with `bootmodes=('bios.syslinux' 'uefi.grub')` (`configs/profiledef.sh`): an unsigned GRUB as `BOOTX64.EFI` loading an unsigned kernel and initramfs. Firmware that trusts only the Microsoft UEFI CA rejects the ISO at the first stage, so Secure Boot must be disabled today.
|
||||
- The vendored mkarchiso already supports a `uefi.systemd-boot` bootmode (mutually exclusive with `uefi.grub`), so the live-ISO half of `shim -> systemd-boot -> UKI` needs no archiso surgery — a bootmode switch plus signing.
|
||||
- The installed system already boots a UKI: the orchestrator's `finalize_limine_boot` phase has mkinitcpio build the UKI onto the ESP, and `validate_boot` asserts it exists. "Build an installed UKI" is no longer new work; the new work is signing that UKI and choosing a second stage that enforces signatures.
|
||||
- Kernel updates already regenerate the UKI through the target's mkinitcpio pacman hooks. The update flow below reduces to adding a signing step and fallback retention to machinery that exists.
|
||||
|
||||
The critical path is external: the Microsoft-signed shim. That requires an EV code-signing certificate for the Omarchy org, a shim built from a reviewed upstream release with Omarchy SBAT identity and NX compatibility, and a `shim-review` submission — historically weeks to months of calendar time, with standing obligations afterward (SBAT revocation response, resubmission when the embedded cert or shim version changes). Start it first; every phase below except release signing can proceed in parallel on dev test keys in QEMU.
|
||||
|
||||
## Core Architecture
|
||||
|
||||
Use a Microsoft-signed first-stage shim, then boot only signed Omarchy-controlled artifacts.
|
||||
@@ -51,7 +62,7 @@ This preserves offline tamper resistance for `/boot` while avoiding any central
|
||||
|
||||
## Bootloader Decision
|
||||
|
||||
Signing Limine as an EFI binary is not sufficient if Limine can then boot unsigned kernels, initrds, or configs. For v1 Secure Boot support, use a boot path with a small, enforceable verification surface:
|
||||
Installed systems already boot a UKI through Limine, so the boot *artifact* needs no change. But signing Limine as an EFI binary is not sufficient if Limine will then load unsigned payloads or take direction from an unsigned `limine.conf`. For v1 Secure Boot support, use a boot path with a small, enforceable verification surface:
|
||||
|
||||
```text
|
||||
shim -> systemd-boot -> signed UKI
|
||||
@@ -104,12 +115,13 @@ bin/omarchy-iso-make --secure-boot
|
||||
|
||||
Build behavior:
|
||||
|
||||
1. Add Microsoft-signed Omarchy shim artifacts to the ISO UEFI boot path.
|
||||
2. Build the live environment boot payload as a UKI.
|
||||
3. Sign the live UKI with the Omarchy release key in official builds.
|
||||
4. Sign any second-stage EFI binary with the Omarchy release key.
|
||||
5. Assert that every Secure Boot UEFI entry uses the signed shim path.
|
||||
6. Assert that no unsigned kernel/initramfs path is offered in Secure Boot UEFI mode.
|
||||
1. Switch the UEFI bootmode from `uefi.grub` to `uefi.systemd-boot` in `configs/profiledef.sh` (mkarchiso forbids running both). BIOS syslinux stays as-is; Secure Boot is UEFI-only.
|
||||
2. Add Microsoft-signed Omarchy shim artifacts to the ISO UEFI boot path.
|
||||
3. Build the live environment boot payload as a UKI.
|
||||
4. Sign the live UKI with the Omarchy release key in official builds.
|
||||
5. Sign any second-stage EFI binary with the Omarchy release key.
|
||||
6. Assert that every Secure Boot UEFI entry uses the signed shim path.
|
||||
7. Assert that no unsigned kernel/initramfs path is offered in Secure Boot UEFI mode.
|
||||
|
||||
Local developer builds should support a dev-signing mode for QEMU validation:
|
||||
|
||||
@@ -124,7 +136,7 @@ Dev mode creates local test keys and is only expected to boot in QEMU firmware e
|
||||
When the live installer detects Secure Boot enabled:
|
||||
|
||||
1. Show a Secure Boot explanation before disk mutation.
|
||||
2. If Windows is detected, warn the user to suspend BitLocker and have the recovery key available.
|
||||
2. If Windows is detected, follow the shipped dual-boot BitLocker policy (decrypt, not suspend — see the configurator's existing checks) and warn the user to have the recovery key available.
|
||||
3. Install Omarchy's shim to its own ESP directory, for example `EFI/Omarchy`.
|
||||
4. Do not modify `EFI/Microsoft`.
|
||||
5. Generate a machine-local MOK keypair under the installed encrypted root.
|
||||
@@ -145,13 +157,11 @@ Firmware -> Omarchy shim -> MokManager -> user enrolls Omarchy machine key -> re
|
||||
|
||||
Secure Boot installs need deterministic UKI regeneration and signing after kernel or initramfs changes.
|
||||
|
||||
Add a target-system hook that:
|
||||
The regeneration half already exists: the target's mkinitcpio pacman hooks rebuild the UKI on kernel or initramfs changes. Add the signing half — a hook ordered after the UKI build that:
|
||||
|
||||
1. Regenerates the initramfs.
|
||||
2. Rebuilds the UKI.
|
||||
3. Signs the UKI with the machine-local MOK private key.
|
||||
4. Writes it atomically to the ESP.
|
||||
5. Keeps at least one previously booted signed UKI as fallback.
|
||||
1. Signs the freshly built UKI with the machine-local MOK private key.
|
||||
2. Writes it atomically to the ESP.
|
||||
3. Keeps at least one previously booted signed UKI as fallback.
|
||||
|
||||
Failure policy:
|
||||
|
||||
@@ -199,10 +209,9 @@ Do not store private keys in this directory.
|
||||
Add Secure Boot detection and UX:
|
||||
|
||||
- Detect UEFI Secure Boot state through efivars and/or `mokutil --sb-state`.
|
||||
- Detect Windows through ESP vendor paths and partition metadata.
|
||||
- Warn about BitLocker recovery risk when Windows is present.
|
||||
- Detect Windows through ESP vendor paths and partition metadata (the dual-boot path's `detect_windows_esp` and BitLocker checks already exist — extend, don't duplicate).
|
||||
- Explain one-time MokManager enrollment.
|
||||
- Write `secure_boot.sh` with simple shell state for `.automated_script.sh`.
|
||||
- Write `secure_boot.sh` with simple shell state for the install orchestrator.
|
||||
|
||||
Example state:
|
||||
|
||||
@@ -214,17 +223,18 @@ SECURE_BOOT_UKI=true
|
||||
SECURE_BOOT_MOK_COMMON_NAME="Omarchy Machine Owner Key"
|
||||
```
|
||||
|
||||
### `configs/airootfs/root/.automated_script.sh`
|
||||
### `configs/airootfs/usr/share/omarchy-iso/orchestrator/`
|
||||
|
||||
Add Secure Boot install support:
|
||||
Add Secure Boot install support to the install phases:
|
||||
|
||||
- Source `secure_boot.sh` after configurator runs.
|
||||
- Install the Secure Boot boot path when `SECURE_BOOT_INSTALL=true`.
|
||||
- Generate machine-local MOK keypair in the installed encrypted root.
|
||||
- Build and sign UKI.
|
||||
- Read the `secure_boot.sh` state the configurator wrote.
|
||||
- When `SECURE_BOOT_INSTALL=true`, install the shim boot path and the enforcing second stage instead of (or in front of) the plain Limine setup in `_configure_limine_boot`.
|
||||
- Generate the machine-local MOK keypair on the installed encrypted root.
|
||||
- Sign the UKI that `finalize_limine_boot` already builds.
|
||||
- Schedule MOK enrollment with `mokutil --import`.
|
||||
- Install kernel-update hooks for UKI rebuild/signing.
|
||||
- Install the UKI signing hook alongside the existing mkinitcpio hooks.
|
||||
- Preserve dual-boot firmware boot order unless explicitly promoted.
|
||||
- Extend `validate_boot` to assert the UKI on the ESP carries a valid signature.
|
||||
|
||||
### Target System Files
|
||||
|
||||
@@ -275,7 +285,7 @@ On Windows dual-boot machines:
|
||||
- Never change BitLocker protectors.
|
||||
- Preserve existing firmware default boot order by default.
|
||||
- Warn that adding a boot entry or changing ESP contents can trigger BitLocker recovery.
|
||||
- Recommend suspending BitLocker from Windows before install and resuming it after both OSes boot.
|
||||
- Follow the shipped dual-boot policy: tell users to turn BitLocker off in Windows and let the drive finish decrypting before installing (the configurator already enforces this; suspending alone proved insufficient — see #105).
|
||||
|
||||
If the user chooses to make Omarchy first in boot order, capture the old `BootOrder` and provide rollback guidance.
|
||||
|
||||
@@ -326,7 +336,7 @@ Minimum hardware tests:
|
||||
|
||||
1. Microsoft Secure Boot enabled laptop boots official Secure Boot ISO.
|
||||
2. Windows dual-boot install preserves Windows boot.
|
||||
3. BitLocker-suspended install avoids recovery prompt after resuming BitLocker.
|
||||
3. BitLocker-decrypted install boots both OSes cleanly afterward.
|
||||
4. BitLocker-active install warning is visible before any disk mutation.
|
||||
5. Installed Omarchy boots only after MOK enrollment.
|
||||
6. Secure Boot remains enabled after install.
|
||||
@@ -338,11 +348,13 @@ Minimum hardware tests:
|
||||
|
||||
### Phase 1: Research And Decisions
|
||||
|
||||
- Kick off the EV certificate purchase and `shim-review` submission prep immediately — this is the calendar-bound item that gates Phase 4, and nothing else depends on it being done first.
|
||||
- Confirm shim submission requirements and timeline.
|
||||
- Confirm selected second-stage boot manager.
|
||||
- Confirm UKI generation mechanism on Arch.
|
||||
- Confirm selected second-stage boot manager (systemd-boot unless Limine's signature enforcement is proven).
|
||||
- ~~Confirm UKI generation mechanism on Arch~~ — resolved: mkinitcpio already builds the installed UKI today.
|
||||
- Confirm package availability for signing and MOK workflows.
|
||||
- Decide local MOK key storage and update-hook policy.
|
||||
- Decide the DKMS/out-of-tree module signing story (see Open Questions — this is a v1 blocker, not a nice-to-have).
|
||||
|
||||
### Phase 2: Dev Secure Boot In QEMU
|
||||
|
||||
@@ -387,9 +399,9 @@ Minimum hardware tests:
|
||||
|
||||
## Open Questions
|
||||
|
||||
- Whether v1 should use systemd-boot, GRUB, or a verified Limine configuration as the second stage.
|
||||
- Whether Limine can enforce signature verification on the UKIs and config it loads; if not proven, Secure Boot installs use systemd-boot as the second stage while non-Secure-Boot installs keep Limine.
|
||||
- Whether the local MOK private key should be encrypted with a user-supplied passphrase or stored root-only on encrypted root.
|
||||
- How to support signed out-of-tree kernel modules, especially proprietary GPU drivers or DKMS packages.
|
||||
- How snapshot booting should work when each bootable kernel must be a signed UKI.
|
||||
- How to support signed out-of-tree kernel modules, especially proprietary GPU drivers or DKMS packages. **This must be answered for v1:** once Secure Boot is enforcing, unsigned modules will not load, and NVIDIA laptops are exactly the consumer hardware this plan targets. The module signing hook must sign with the machine-local MOK alongside the UKI.
|
||||
- How snapshot booting (factory reset restores from Btrfs snapshots) should work when each bootable kernel must be a signed UKI.
|
||||
- Whether official builds should always be Secure Boot-capable or ship a separate Secure Boot ISO flavor.
|
||||
- What user-facing recovery path should exist if MOK enrollment is skipped or fails.
|
||||
@@ -1,158 +0,0 @@
|
||||
# Dual-Boot Installation Support for Omarchy ISO
|
||||
|
||||
## Context
|
||||
|
||||
Currently, the Omarchy installer wipes the entire selected disk (`"wipe": true`) and creates two partitions: a 2GB FAT32 ESP and a LUKS-encrypted Btrfs root. This means users must dedicate an entire disk to Omarchy. Adding dual-boot support lets users install alongside an existing OS (typically Windows) while keeping the Omarchy partition encrypted.
|
||||
|
||||
## Core Approach: `pre_mounted_config`
|
||||
|
||||
**Do our own partitioning, then hand off to archinstall for package installation only.**
|
||||
|
||||
archinstall's `manual_partitioning` mode has a long history of bugs with existing partitions and LUKS (archinstall issues #998, #2072, #2444). Instead, we:
|
||||
|
||||
1. Detect existing partitions and free space ourselves (with `sgdisk`/`parted`)
|
||||
2. Create the LUKS partition and Btrfs subvolumes ourselves (with `cryptsetup`/`mkfs.btrfs`)
|
||||
3. Mount everything at `/mnt/archinstall`
|
||||
4. Tell archinstall to use `"config_type": "pre_mounted_config"` — it installs packages into our pre-mounted tree and does zero disk operations
|
||||
5. Handle encryption config (crypttab, mkinitcpio hooks, bootloader cmdline) in post-install
|
||||
|
||||
The existing full-disk path stays completely unchanged. Dual-boot is a parallel code path.
|
||||
|
||||
## Implementation Guardrails
|
||||
|
||||
- **Run target changes in chroot** — all target-system commands (`mkinitcpio -P`, `limine-scan`, bootloader config updates) must run via `arch-chroot "$INSTALL_ROOT" ...`
|
||||
- **Edit target files under `$INSTALL_ROOT` only** — write `mkinitcpio` hook config, `limine.conf`, `crypttab`, and related files in `$INSTALL_ROOT/etc` and `$INSTALL_ROOT/boot` (never in the live environment root)
|
||||
- **Settle kernel partition state** — after creating the new partition, run `partprobe "$DISK"` and `udevadm settle` before `cryptsetup` to avoid device-node races
|
||||
- **Deterministic fstab** — always generate `/etc/fstab` for dual-boot with overwrite semantics (e.g., `genfstab -U "$INSTALL_ROOT" > "$INSTALL_ROOT/etc/fstab"`) to avoid duplicate entries on retries
|
||||
- **Hook compatibility** — when updating mkinitcpio hooks, add `encrypt` for busybox initramfs or `sd-encrypt` for systemd initramfs; never assume one universally
|
||||
- **Safe rollback on failure** — on any dual-boot setup failure: unmount mounts, close LUKS mapping, and surface recovery guidance; optionally delete the just-created partition only if it was created in this run
|
||||
|
||||
## Scope Constraints
|
||||
|
||||
- **UEFI/GPT only** — dual-boot on MBR/BIOS is too fragile; those users get full-disk only
|
||||
- **No auto-shrinking** — users must free up space from their existing OS first (e.g., Windows Disk Management). Too risky to shrink partitions automatically
|
||||
- **Minimum 20GB free space** required for Omarchy
|
||||
|
||||
## User Flow
|
||||
|
||||
```
|
||||
Select disk → Detect layout →
|
||||
|
||||
If disk has existing OS + ESP + ≥20GB free space:
|
||||
"How would you like to install?"
|
||||
→ "Install alongside Windows (use 85GB free space)"
|
||||
→ "Erase entire disk"
|
||||
|
||||
If disk is empty or no free space:
|
||||
Existing "Confirm overwriting" flow (unchanged)
|
||||
```
|
||||
|
||||
## File Changes
|
||||
|
||||
### 1. `configs/airootfs/root/configurator`
|
||||
|
||||
**Add after disk selection (line 233), before config generation:**
|
||||
|
||||
- `detect_disk_layout()` — examines selected disk for:
|
||||
- GPT partition table (required for dual-boot)
|
||||
- Existing ESP partition (via `lsblk` PARTTYPE matching EFI GUID)
|
||||
- Free unallocated space (via `sgdisk -F`/`-E` or `parted print free`)
|
||||
- OS detection for installer UX warnings/prompts (not boot correctness): mount ESP read-only, check common vendor paths like `EFI/Microsoft`, `EFI/systemd`, `EFI/ubuntu`, `EFI/fedora`, `EFI/GRUB`
|
||||
|
||||
- `install_mode_form()` — shows gum choose with dual-boot vs erase options when conditions are met. Sets `DUAL_BOOT=true/false`.
|
||||
|
||||
**Generate different JSON when `DUAL_BOOT=true`:**
|
||||
|
||||
```json
|
||||
{
|
||||
"disk_config": {
|
||||
"config_type": "pre_mounted_config",
|
||||
"mountpoint": "/mnt/archinstall"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
No `device_modifications`, no `disk_encryption`, no `btrfs_options` — we handle all of that ourselves. Everything else (hostname, kernels, packages, etc.) stays the same.
|
||||
|
||||
**Write `install_mode.sh`** alongside the other config files:
|
||||
|
||||
```bash
|
||||
DUAL_BOOT=true
|
||||
DISK=/dev/nvme0n1
|
||||
ESP_PARTITION=/dev/nvme0n1p1
|
||||
```
|
||||
|
||||
### 2. `configs/airootfs/root/.automated_script.sh`
|
||||
|
||||
**Source `install_mode.sh`** in `run_configurator()` if it exists.
|
||||
|
||||
**Add `setup_dual_boot_partitions()`** — runs before archinstall when `DUAL_BOOT=true`:
|
||||
|
||||
1. Select the largest contiguous free region and run `sgdisk` to create new partition there (type 8309 = Linux LUKS)
|
||||
2. `partprobe "$DISK"` + `udevadm settle` so new partition node is present
|
||||
3. `cryptsetup luksFormat` + `luksOpen` with user's password
|
||||
4. `mkfs.btrfs` on `/dev/mapper/omarchy_root`
|
||||
5. Create Btrfs subvolumes: `@`, `@home`, `@log`, `@pkg`
|
||||
6. Mount subvolumes at `/mnt/archinstall` with `compress=zstd`
|
||||
7. Mount existing ESP (untouched) at `/mnt/archinstall/boot`
|
||||
8. Generate target `/etc/fstab` from mounted filesystems before post-install steps
|
||||
|
||||
**Add `configure_dual_boot_post_install()`** — runs after archinstall:
|
||||
|
||||
1. Write `/etc/crypttab` entry using LUKS UUID/PARTUUID (stable identifier), e.g. `omarchy_root UUID=<luks-uuid> none luks,discard`
|
||||
2. Update mkinitcpio hooks before `filesystems`: `encrypt` (busybox) or `sd-encrypt` (systemd)
|
||||
3. Regenerate initramfs with `arch-chroot "$INSTALL_ROOT" mkinitcpio -P`
|
||||
4. Configure Limine kernel cmdline to match initramfs mode:
|
||||
- busybox `encrypt`: `cryptdevice=UUID=<uuid>:omarchy_root root=/dev/mapper/omarchy_root`
|
||||
- systemd `sd-encrypt`: `rd.luks.name=<uuid>=omarchy_root root=/dev/mapper/omarchy_root` (or equivalent `rd.luks.uuid=` form)
|
||||
5. Run `arch-chroot "$INSTALL_ROOT" limine-scan` to detect other OS boot entries (Windows, etc.)
|
||||
6. Preserve current firmware default boot order unless user explicitly chooses to make Limine first (capture and restore `BootOrder` if `efibootmgr` side effects reorder entries)
|
||||
|
||||
**Use `$INSTALL_ROOT` variable** — defaults to `/mnt` for full-disk, `/mnt/archinstall` for dual-boot. Post-install steps (offline mirror bind-mount, sudoers, omarchy copy) reference this instead of hardcoded `/mnt`.
|
||||
|
||||
### 3. `builder/build-iso.sh` + `builder/archinstall.packages`
|
||||
|
||||
Add `parted` to packages available in the live ISO (needed for free space detection).
|
||||
|
||||
## Bootloader Coexistence
|
||||
|
||||
Limine installs to `ESP/EFI/arch-limine/` and registers via `efibootmgr`. This sits alongside:
|
||||
- Windows Boot Manager at `ESP/EFI/Microsoft/Boot/bootmgfw.efi`
|
||||
- Any other bootloader in its own ESP subdirectory
|
||||
|
||||
`limine-scan` auto-detects other UEFI boot entries and adds them to `limine.conf`. Users can choose OS at boot.
|
||||
|
||||
**Boot order policy**: creating a new EFI entry must not silently change the current default boot target. Keep existing firmware boot order by default and only promote Limine when user opts in.
|
||||
|
||||
Implementation note: when registering Limine with `efibootmgr`, do not pass reorder flags by default; if firmware still changes order, explicitly restore prior `BootOrder` unless the user opted to promote Limine.
|
||||
|
||||
**ESP size note**: Windows typically creates a 100-260MB ESP. This is enough for Limine + kernel + initramfs, but Snapper boot snapshots (which copy kernels to ESP) will be limited or disabled.
|
||||
|
||||
**ESP free-space threshold**:
|
||||
- If ESP has `<100MB` free at install time: show a strong warning (do not block install)
|
||||
- If ESP has `<64MB` free: hide dual-boot option and require full-disk install (or user frees space first)
|
||||
|
||||
**BitLocker warning**: If Windows is detected, show a warning about having the BitLocker recovery key ready, since modifying ESP/UEFI entries can trigger recovery.
|
||||
|
||||
## Edge Cases
|
||||
|
||||
| Scenario | Behavior |
|
||||
|----------|----------|
|
||||
| Disk is empty | Full-disk install only (current behavior) |
|
||||
| Existing OS but no free space | Full-disk install only, with note to free space first |
|
||||
| Free space < 20GB | Dual-boot option not shown |
|
||||
| MBR/BIOS disk | Dual-boot option not shown |
|
||||
| ESP < 100MB free after mount | Warn user; continue allowed |
|
||||
| ESP < 64MB free after mount | Dual-boot option not shown |
|
||||
| Multiple free regions | Use largest contiguous region |
|
||||
| Partitioning/setup failure mid-run | Cleanup mounts/LUKS and abort safely |
|
||||
|
||||
## Verification
|
||||
|
||||
1. **Regression**: Full-disk install in VM with empty disk — must work identically to today
|
||||
2. **Dual-boot with Windows**: VM with Windows installed + 40GB free space — detect Windows, install alongside, both OSes boot
|
||||
3. **Dual-boot with Linux**: VM with another Linux + free space — similar test
|
||||
4. **No free space**: VM with fully partitioned disk — dual-boot option should not appear
|
||||
5. **Encryption**: After dual-boot install, verify LUKS unlock prompt at boot and encrypted root
|
||||
6. **Initramfs mode**: Validate both busybox and systemd hook paths boot correctly (`encrypt` vs `sd-encrypt`)
|
||||
7. **Boot order**: Verify existing default UEFI entry remains unchanged unless user opted to promote Limine
|
||||
@@ -1,224 +0,0 @@
|
||||
# OEM Install + First-Boot Setup Plan
|
||||
|
||||
## Goal
|
||||
|
||||
Create a second ISO flavor for OEM preloading that is installed to internal storage at factory time, then boots into customer setup on first power-on (no external media required), and ends in a fully encrypted Omarchy install.
|
||||
|
||||
## Product Requirements
|
||||
|
||||
- Factory can preload one image to internal disk.
|
||||
- Customer first boot launches setup flow automatically (already works: `.automated_script.sh` runs configurator on tty1).
|
||||
- Customer chooses credentials/settings.
|
||||
- Final installed OS uses full-disk encryption (LUKS) with customer password (already works: configurator collects password and passes it to archinstall as `encryption_password`).
|
||||
- Existing consumer ISO behavior remains unchanged.
|
||||
|
||||
---
|
||||
|
||||
## Chosen Architecture
|
||||
|
||||
### Bootstrapping model
|
||||
- OEM devices ship with an OEM bootstrap ISO image written to internal disk.
|
||||
- On first boot, `copytoram=y` kernel arg loads the live environment into RAM, freeing the internal disk.
|
||||
- Bootstrap environment launches existing configurator + installer.
|
||||
- Installer performs a fresh install to internal disk with LUKS encryption enabled.
|
||||
- Bootstrap environment is overwritten during install.
|
||||
|
||||
### Recovery model: zero-recovery
|
||||
- No permanent recovery partition.
|
||||
- Simplest and strongest security story.
|
||||
- Recovery requires external reinstall media.
|
||||
|
||||
---
|
||||
|
||||
## Non-Goals
|
||||
|
||||
- No on-device recovery workflow.
|
||||
- No changes to normal installer UX outside explicit OEM mode checks and warnings.
|
||||
- No factory credential provisioning.
|
||||
|
||||
---
|
||||
|
||||
## Repo Implementation Plan
|
||||
|
||||
## 1) Add OEM build mode
|
||||
|
||||
### Files
|
||||
- `bin/omarchy-iso-make`
|
||||
- `builder/build-iso.sh`
|
||||
|
||||
### Changes
|
||||
- Add CLI flag `--oem` to `bin/omarchy-iso-make`.
|
||||
- Pass `OMARCHY_MODE=oem` into Docker build env (default `normal`).
|
||||
- In `builder/build-iso.sh`, write mode marker `/root/omarchy_mode` containing `oem` or `normal` (same pattern as `omarchy_mirror`).
|
||||
- Keep OEM on current boot stack (`uefi.grub` + `bios.syslinux`); do not add or depend on systemd-boot paths.
|
||||
- When `OMARCHY_MODE=oem`, inject `copytoram=y` into all shipped OEM boot entry points before `mkarchiso` runs:
|
||||
- `grub/grub.cfg`: append to `linux` cmdline entries.
|
||||
- `grub/loopback.cfg`: append to `linux` cmdline entries.
|
||||
- `syslinux/archiso_sys-linux.cfg`: append to `APPEND` lines.
|
||||
- When `OMARCHY_MODE=oem`, remove accessibility/speakup boot entries:
|
||||
- `grub/grub.cfg`: remove `archlinux-accessibility` menuentry.
|
||||
- `grub/loopback.cfg`: remove `archlinux-accessibility` menuentry.
|
||||
- `syslinux/archiso_sys-linux.cfg`: remove `arch64speech` label block.
|
||||
- When `OMARCHY_MODE=oem`, override `iso_application` in `profiledef.sh` to `"Omarchy OEM Installer"`.
|
||||
- Rename output ISO with `-oem` suffix (in addition to existing `-$OMARCHY_ISO_REF` suffix).
|
||||
|
||||
### Hardening
|
||||
- Add post-injection build assertion that fails build if any expected boot config does not contain `copytoram=y`.
|
||||
- Add post-injection build assertion that fails build if any OEM boot config still contains accessibility/speakup entries.
|
||||
- Make injection idempotent (do not duplicate `copytoram=y` if already present).
|
||||
|
||||
### Acceptance criteria
|
||||
- `./bin/omarchy-iso-make --oem` builds successfully.
|
||||
- OEM ISO boot entries contain `copytoram=y` in all supported boot paths.
|
||||
- OEM ISO does not expose accessibility/speakup boot entries.
|
||||
- Normal build output and behavior remain unchanged.
|
||||
|
||||
### Suggested verification commands
|
||||
- `bsdtar -xOf out/<iso>.iso boot/grub/grub.cfg | rg copytoram=y`
|
||||
- `bsdtar -xOf out/<iso>.iso boot/grub/loopback.cfg | rg copytoram=y`
|
||||
- `bsdtar -xOf out/<iso>.iso boot/syslinux/archiso_sys-linux.cfg | rg copytoram=y`
|
||||
- `bsdtar -xOf out/<iso>.iso boot/grub/grub.cfg | rg 'accessibility|speakup'` (should return no matches)
|
||||
- `bsdtar -xOf out/<iso>.iso boot/syslinux/archiso_sys-linux.cfg | rg 'speech|accessibility'` (should return no matches)
|
||||
|
||||
---
|
||||
|
||||
## 2) Add OEM safety guardrails
|
||||
|
||||
### Why
|
||||
OEM image boots from internal disk and later wipes that same disk. Live environment must be fully in RAM before install begins.
|
||||
|
||||
### File
|
||||
- `configs/airootfs/root/.automated_script.sh`
|
||||
|
||||
### Changes
|
||||
- Before `run_configurator`, if `/root/omarchy_mode` is `oem`:
|
||||
- Verify `/proc/cmdline` contains `copytoram=y`; abort with clear actionable error if missing.
|
||||
- Verify factory hardware minimum using `MemTotal`:
|
||||
- Require `MemTotal >= 8 GiB`.
|
||||
- Abort with clear error if below minimum.
|
||||
- Verify runtime memory safety using `MemAvailable`:
|
||||
- Minimum threshold: `1.5 x ISO size + 1 GiB`.
|
||||
- Abort with clear error if below threshold.
|
||||
- Verify runtime state indicates live root is in RAM (for example, expected archiso runtime mounts present and boot media not actively mounted as install target path).
|
||||
|
||||
### Acceptance criteria
|
||||
- OEM mode aborts safely if `copytoram=y` missing from cmdline.
|
||||
- OEM mode aborts safely if `MemTotal < 8 GiB`.
|
||||
- OEM mode aborts safely if `MemAvailable` below threshold.
|
||||
- OEM mode aborts safely if runtime state does not confirm RAM-backed live environment.
|
||||
|
||||
### Error message requirements
|
||||
- State exactly what failed.
|
||||
- State why install is blocked.
|
||||
- Provide next step (reboot using proper OEM media or use external recovery media).
|
||||
|
||||
---
|
||||
|
||||
## 3) OEM disk warning
|
||||
|
||||
### Why
|
||||
With `copytoram=y`, archiso copies squashfs to RAM and releases boot device. Existing configurator call `findmnt -no SOURCE /run/archiso/bootmnt` may return empty, so exclusion filter is skipped and all physical disks are shown, including former boot disk. No disk selection logic change is required.
|
||||
|
||||
OEM mode still needs an unmistakable warning before destructive install proceeds.
|
||||
|
||||
### File
|
||||
- `configs/airootfs/root/configurator`
|
||||
|
||||
### Changes
|
||||
- Read mode from `/root/omarchy_mode`.
|
||||
- If mode is `oem`, add OEM-specific warning text before existing destructive confirmation.
|
||||
- Upgrade confirmation in OEM mode to explicit typed confirmation (for example: `YES, WIPE DISK`) while preserving existing normal-mode flow.
|
||||
|
||||
### Acceptance criteria
|
||||
- Normal ISO behavior is unchanged.
|
||||
- OEM ISO shows OEM-specific warning before disk wipe confirmation.
|
||||
- OEM typed confirmation is required before destructive action.
|
||||
- In VM with `copytoram=y`, former boot disk appears in disk list without exclusion-logic changes.
|
||||
|
||||
---
|
||||
|
||||
## 4) Documentation
|
||||
|
||||
### File
|
||||
- `README.md`
|
||||
|
||||
### Changes
|
||||
- Document `--oem` build flag and resulting artifact naming.
|
||||
- Document factory workflow: writing OEM ISO to internal disk and expected first-boot UX.
|
||||
- Document failure and recovery behavior:
|
||||
- Missing `copytoram=y`, `MemTotal < 8 GiB`, or low `MemAvailable` causes safe abort.
|
||||
- Interrupted/failed install requires external reinstall media.
|
||||
- Add short operator checklist for manufacturing line validation.
|
||||
|
||||
---
|
||||
|
||||
## 5) Validation
|
||||
|
||||
### VM test matrix
|
||||
1. Build OEM ISO.
|
||||
2. Write OEM ISO to virtual disk (not external media emulation).
|
||||
3. Boot from virtual disk and verify:
|
||||
- `/proc/cmdline` contains `copytoram=y`.
|
||||
- Guardrail checks pass in healthy case.
|
||||
- OEM boot menu does not include accessibility/speech entries.
|
||||
4. Complete setup flow on first boot.
|
||||
5. Install to same disk.
|
||||
6. Reboot into installed OS.
|
||||
7. Verify encryption:
|
||||
- `lsblk` shows crypt mapping.
|
||||
- `cryptsetup status` reports active LUKS device.
|
||||
- Boot requires unlock passphrase.
|
||||
8. Validate OEM warning + typed confirmation appears and gates destructive action.
|
||||
|
||||
### Boot path coverage
|
||||
- UEFI + GRUB path.
|
||||
- BIOS/syslinux path (if still shipped).
|
||||
|
||||
### Hardware test matrix
|
||||
- UEFI test on at least two hardware families (Intel + AMD).
|
||||
- Confirm no external media required.
|
||||
- Confirm first boot starts setup automatically.
|
||||
|
||||
### Negative tests
|
||||
- OEM boot without `copytoram=y` -> safe abort with clear error.
|
||||
- `MemTotal < 8 GiB` -> safe abort with clear error.
|
||||
- Low `MemAvailable` -> safe abort with clear error.
|
||||
- Runtime state not RAM-backed -> safe abort with clear error.
|
||||
- Power interruption before installer starts -> deterministic reboot behavior.
|
||||
- Power interruption during install -> recovery requires external media (documented).
|
||||
|
||||
---
|
||||
|
||||
## 6) Security hardening checklist
|
||||
|
||||
- No factory credentials exist; customer sets all passwords at first boot.
|
||||
- Clear shell history and transient setup artifacts at end of install.
|
||||
- Verify no secrets in logs shipped to customer.
|
||||
- Regenerate host identity on first installed boot as needed:
|
||||
- `machine-id`
|
||||
- SSH host keys (if installed/enabled)
|
||||
- Keep package signature verification and keyring handling intact.
|
||||
|
||||
---
|
||||
|
||||
## Rollout Plan
|
||||
|
||||
1. Implement OEM build flag, mode marker, boot config injection, and build assertions.
|
||||
2. Implement copytoram, memory, and runtime-state guardrails in `.automated_script.sh`.
|
||||
3. Add OEM warning text and typed destructive confirmation in configurator.
|
||||
4. Add docs and operator checklist.
|
||||
5. Run VM matrix, including negative tests.
|
||||
6. Run hardware matrix.
|
||||
7. Cut first OEM preproduction release for manufacturing pilot.
|
||||
|
||||
---
|
||||
|
||||
## Definition of Done
|
||||
|
||||
- `--oem` build exists and is documented.
|
||||
- Device preloaded with OEM image boots directly to setup.
|
||||
- Setup installs to internal disk without external media.
|
||||
- Final installed system is LUKS-encrypted with customer-owned passphrase.
|
||||
- OEM safety guardrails fail closed with actionable errors.
|
||||
- Existing non-OEM ISO behavior remains unchanged.
|
||||
- VM and hardware QA matrix pass.
|
||||
@@ -1,643 +0,0 @@
|
||||
# Protected Partition Install Plan: Dual-Boot + Restore
|
||||
|
||||
## Goal
|
||||
|
||||
Implement one shared non-destructive install path that supports both:
|
||||
|
||||
- Dual-boot installs alongside an existing OS.
|
||||
- OEM/restore installs from a permanent internal restore partition set.
|
||||
|
||||
Beyond install: every standalone Omarchy machine — whether OEM-provisioned or installed from the consumer ISO onto an empty disk — exposes a "factory reset" command that durably stages the next boot into the on-disk restore partition set. The installed-OS command leaves the machine as though it had just been prepared to boot from restore; the restore environment owns the destructive wipe/reinstall flow. Dual-boot installs do not get factory reset (no room for a restore partition set).
|
||||
|
||||
The current full-disk install path remains unchanged until the protected-partition path is proven. The protected path does its own partitioning, encryption, filesystems, mounts, and boot configuration, then hands a prepared mount tree to archinstall with `pre_mounted_config`.
|
||||
|
||||
## Core Architecture
|
||||
|
||||
Use a single installer engine with multiple partition policies.
|
||||
|
||||
```text
|
||||
full_disk existing archinstall default_layout + wipe:true path
|
||||
dual_boot protect existing OS partitions, reuse existing ESP, add Omarchy LUKS root
|
||||
restore_install protect restore partition set, create/recreate installed ESP + Omarchy LUKS root
|
||||
```
|
||||
|
||||
The key rule: protected modes must never pass the whole disk to archinstall with `wipe: true`.
|
||||
|
||||
## Why This Combines Both Features
|
||||
|
||||
Dual-boot and restore installs are the same technical problem:
|
||||
|
||||
1. Detect disk layout.
|
||||
2. Identify protected partitions.
|
||||
3. Create or format only explicitly writable Omarchy partitions.
|
||||
4. Set up encrypted root manually.
|
||||
5. Mount a complete install tree manually.
|
||||
6. Run archinstall only as a package/base-system installer.
|
||||
7. Configure encryption, fstab, initramfs, and bootloader after archinstall.
|
||||
|
||||
Only the partition policy differs.
|
||||
|
||||
## Scope Constraints
|
||||
|
||||
- UEFI/GPT only for `dual_boot` and `restore_install` v1.
|
||||
- Existing BIOS/syslinux ISO behavior stays available for normal full-disk installs.
|
||||
- No automatic shrinking of existing partitions.
|
||||
- Dual-boot requires pre-existing free space.
|
||||
- Restore install requires a detected Omarchy restore partition set.
|
||||
- Installed Omarchy root is encrypted with LUKS.
|
||||
- Restore partitions are not encrypted unless a later product requirement demands it.
|
||||
- Restore payload partitions are normally left unmounted in the installed OS and mounted read-only by the restore environment. A separate restore state partition is the only restore-owned partition mounted read-write for reset triggers and recovery logs.
|
||||
- Swap matches the current full-disk install: zram for memory pressure, plus a Btrfs swapfile in a dedicated `NODATACOW` `/swap` subvolume sized to RAM for hibernation. The subvolume, swapfile, `resume` mkinitcpio hook, and `resume=<dev> resume_offset=<offset>` Limine cmdline drop-in are created post-install by Omarchy's existing `omarchy-hibernation-setup`. Protected modes must not break this: the `encrypt`/`sd-encrypt` hook must precede `resume` in mkinitcpio so the swapfile is reachable after LUKS unlock, and Limine must honor `/etc/limine-entry-tool.d/*.conf` drop-ins so the post-install hook can append resume parameters. No swap partition.
|
||||
|
||||
## Partition Policies
|
||||
|
||||
### Full Disk
|
||||
|
||||
Current behavior:
|
||||
|
||||
```text
|
||||
p1 installed ESP FAT32 2G
|
||||
p2 installed root LUKS rest of disk
|
||||
```
|
||||
|
||||
Implementation stays on archinstall `default_layout` with `wipe: true` for now.
|
||||
|
||||
Phase 7 replaces this with a layout that mirrors `restore_install`:
|
||||
|
||||
```text
|
||||
p1 restore ESP FAT32 protected after install
|
||||
p2 restore payload ext4 protected after install, read-only payload
|
||||
p3 restore state ext4 protected after install, writable trigger/log state
|
||||
p4 installed ESP FAT32 writable
|
||||
p5 installed root LUKS writable
|
||||
```
|
||||
|
||||
Rationale: factory reset requires an on-disk restore partition set. Making this the default for standalone installs gives every consumer machine the same self-recovery capability OEM-provisioned machines get. The legacy two-partition layout becomes opt-in (e.g. `--no-restore`) for users who explicitly want the disk space back.
|
||||
|
||||
### Dual Boot
|
||||
|
||||
Example target disk before install:
|
||||
|
||||
```text
|
||||
p1 existing ESP FAT32 protected, reused as /efi
|
||||
p2 Windows MSR MSR protected
|
||||
p3 Windows NTFS protected
|
||||
free space writable region
|
||||
```
|
||||
|
||||
After install:
|
||||
|
||||
```text
|
||||
p1 existing ESP FAT32 protected, mounted as /efi during install
|
||||
p2 Windows MSR MSR protected
|
||||
p3 Windows NTFS protected
|
||||
p4 Omarchy root LUKS new encrypted Btrfs root
|
||||
```
|
||||
|
||||
Policy:
|
||||
|
||||
- Protect all existing partitions.
|
||||
- Reuse the existing ESP only for Omarchy boot files under `EFI/Omarchy`. Do not write top-level `vmlinuz-*`, `initramfs-*`, or vendor-looking paths on a shared ESP.
|
||||
- Mount the shared ESP at `/efi`, keep `/boot` on the encrypted root, and install an Omarchy-owned kernel/initramfs sync hook that copies boot artifacts into `/efi/EFI/Omarchy` after kernel or initramfs updates.
|
||||
- Refuse to install if the existing ESP is below 200 MB total or has less than 150 MB free. Warn below 300 MB total or below 200 MB free. These thresholds size for one Omarchy kernel + initramfs + Limine alongside a typical vendor loader; revisit if the Omarchy initramfs grows materially. Free space must be measured from the mounted ESP, not inferred from partition size.
|
||||
- Create one new LUKS partition in the largest single contiguous free region of at least 40 GB. Refuse otherwise. Do not stitch across multiple non-contiguous regions.
|
||||
- Preserve current firmware boot order unless the user explicitly opts to make Omarchy first.
|
||||
- Abort with a clear error if any Windows partition is detected as BitLocker/FVE, including suspended BitLocker. Do not proceed past detection. Adding a new partition to a disk with a BitLocker-protected volume changes the firmware/boot environment enough that Windows can demand the recovery key on next boot — and many users do not have it. The error message must instruct the user to turn off BitLocker from inside Windows and wait for decryption to complete, then reboot into the Omarchy installer and retry. Do not offer an "I have my recovery key, continue anyway" override in v1; users who really want it can fully disable BitLocker themselves.
|
||||
- Warn if non-BitLocker Windows is detected, since boot order changes can still surprise users.
|
||||
|
||||
### Restore Install
|
||||
|
||||
Recommended factory disk image layout:
|
||||
|
||||
```text
|
||||
p1 restore ESP FAT32 protected, boots restore environment
|
||||
p2 restore payload ext4 protected, contains live installer/offline payload
|
||||
p3 restore state ext4 protected from formatting, writable reset trigger/log state
|
||||
p4 installed ESP FAT32 writable, created/recreated by installer
|
||||
p5 installed root LUKS writable, created/recreated by installer
|
||||
```
|
||||
|
||||
Policy:
|
||||
|
||||
- Protect restore ESP, restore payload, and restore state partitions from delete/format operations. Only the restore state partition is mounted read-write, and only for trigger files and logs.
|
||||
- On first boot, create installed ESP and installed root in remaining disk space.
|
||||
- On reinstall, format the installed Omarchy partitions in place by default. Only delete and recreate them when their geometry no longer matches policy (e.g. the disk was resized). Format-in-place preserves PARTUUIDs, keeps NVRAM entries valid, and avoids touching the partition table.
|
||||
- Set installed Omarchy first in boot order after successful install.
|
||||
- Keep restore boot available as firmware fallback and as a boot menu entry.
|
||||
- Require `copytoram=y` before mutating the internal disk from restore mode.
|
||||
|
||||
Use separate restore and installed ESPs for v1. A shared ESP saves space but makes restore easier to break during normal bootloader maintenance or reinstall.
|
||||
|
||||
## Restore Image Provisioning
|
||||
|
||||
Create a factory artifact separate from the normal consumer ISO:
|
||||
|
||||
```text
|
||||
omarchy-restore.img.zst
|
||||
```
|
||||
|
||||
Factory provisioning writes this image to the internal disk once:
|
||||
|
||||
```bash
|
||||
zstd -dc omarchy-restore.img.zst | dd of=/dev/nvme0n1 bs=16M status=progress conv=fsync
|
||||
```
|
||||
|
||||
The restore image should contain:
|
||||
|
||||
- A restore ESP with `EFI/BOOT/BOOTX64.EFI` fallback boot path.
|
||||
- A restore payload partition labeled `OMARCHY_RESTORE`.
|
||||
- A small restore state partition labeled `OMARCHY_STATE` for reset triggers and recovery logs.
|
||||
- The archiso live environment payload, offline package mirror, configurator, and installer scripts.
|
||||
- A boot entry that passes `omarchy.mode=restore copytoram=y`.
|
||||
- Boot configuration that locates the restore payload by stable label/UUID, not by transient disk name.
|
||||
- A signed manifest covering the archiso payload and offline mirror. The verification public key must be shipped outside the mutable restore payload, such as in the restore boot environment and installed reset tool package.
|
||||
|
||||
The factory flasher must verify the integrity of `omarchy-restore.img.zst` before writing. The on-disk restore environment must verify its signed payload manifest at boot before mutating the internal disk. A plain checksum stored on the same writable disk is not sufficient. Without a signed manifest, a tampered or corrupted restore image silently destroys the user's data the next time they invoke "factory reset."
|
||||
|
||||
On first restore boot:
|
||||
|
||||
1. Bind the candidate restore disk to the actual boot source (`/run/archiso/bootmnt`, kernel command line, or equivalent). Do not select an arbitrary disk just because it has matching labels; cloned restore images can have duplicate labels and UUIDs.
|
||||
2. Move the backup GPT header to the real end of disk with `sgdisk -e` if the factory image was written to a larger disk. This relocates the header only — existing partitions are not grown. The newly-available space at the end of the disk is what installed ESP and installed root consume.
|
||||
3. On first boot only, randomize the GPT disk GUID, partition GUIDs/PARTUUIDs, and filesystem UUIDs for restore-owned partitions before generating any NVRAM entries, fstab entries, or installer state. Labels may remain stable; UUIDs must not stay cloned across machines.
|
||||
4. Detect and protect restore partitions by the newly-randomized PARTUUIDs.
|
||||
5. Create installed ESP and installed root in remaining space.
|
||||
6. Continue through the shared protected install path.
|
||||
|
||||
## Factory Reset
|
||||
|
||||
Goal: an installed Omarchy machine that has a restore partition set (any standalone install — `restore_install` today, `full_disk` after Phase 7) exposes a user-facing factory reset command that prepares the device to boot from internal restore without external media. After the next restore boot, the restore environment returns the device to a fresh-install state.
|
||||
|
||||
### User Flow
|
||||
|
||||
1. User runs `omarchy-factory-reset` from a terminal with sudo. (A GUI entry under Settings is deferred to a follow-up.)
|
||||
2. The command prints which partitions will be destroyed (installed ESP, installed root) and which will be preserved (restore ESP, restore payload, restore state), by stable identifier, and asks the user to type a confirmation phrase. The typed-phrase gate is intentional friction; no `--yes` shortcut in v1.
|
||||
3. On confirmation, the command writes a trigger file to the restore state partition, verifies or recreates the restore boot entry, and sets `BootNext` via `efibootmgr` to that restore entry.
|
||||
4. The command exits only after the trigger file is fsynced, the restore state partition is unmounted, and `BootNext` is confirmed. At that point the installed-OS side is complete: the machine has been left as though it had just been prepared to boot from the restore partition.
|
||||
5. The user reboots when ready. A later GUI may offer a "reboot now" action, but rebooting is a convenience after the staged state is durable, not part of the safety-critical mutation.
|
||||
6. The restore environment detects the trigger on boot, verifies the signed restore payload manifest, writes a reset-in-progress marker to restore state, and temporarily sets persistent `BootOrder` to restore first before mutating installed partitions.
|
||||
7. The restore environment runs the existing `restore_install` reinstall path — format installed ESP, LUKS-format installed root, run the standard install flow — non-interactively, then deletes the trigger and reset-in-progress marker.
|
||||
8. On install completion, the restore environment restores persistent `BootOrder` to installed Omarchy first, restore second, sets `BootNext` to the installed Omarchy entry, and reboots.
|
||||
9. The user lands in a fresh installed Omarchy. Normal persistent `BootOrder` (Omarchy first, restore second) has been restored.
|
||||
|
||||
User data on installed ESP and installed root is destroyed. Restore ESP, restore payload, and restore state are protected from destructive operations throughout. The restore payload is the source of truth for the rebuild; restore state contains only trigger and recovery state.
|
||||
|
||||
### Trigger Mechanism
|
||||
|
||||
Use a flag file on the restore state partition rather than NVRAM variables or the restore payload. NVRAM is fragile across firmware updates, and the restore payload should stay immutable/read-only so signed manifest verification remains meaningful.
|
||||
|
||||
- Path: `<restore-state-mount>/.omarchy-factory-reset`
|
||||
- Contents: timestamp, hostname at trigger time, optional reason. Plain text, one `key=value` per line.
|
||||
- The installed-OS command mounts the restore state partition by `OMARCHY_STATE` label, writes the flag, fsync, and unmounts. It may mount the restore payload read-only only long enough to verify the signed manifest before triggering.
|
||||
- The restore environment checks for the flag at boot. If present, it runs the reset flow non-interactively and deletes the flag on success. If absent, restore boot behaves normally (manual install/repair menu).
|
||||
- The flag must be deleted before reboot. Otherwise the machine resets itself in a loop.
|
||||
|
||||
### Boot Order
|
||||
|
||||
`efibootmgr --bootnext <restore-entry>` is one-shot — it takes effect on the next boot only, then NVRAM reverts to the existing `BootOrder`. This is what we want before the destructive phase: if the reset is interrupted before restore boot, the next normal boot still tries the installed Omarchy first.
|
||||
|
||||
After the restore environment accepts the trigger and before it wipes installed partitions, it must temporarily set persistent `BootOrder` to restore first, installed Omarchy second. This prevents a power loss during reinstall from leaving firmware stuck on a half-written installed ESP. On successful reinstall, the restore environment deletes the reset-in-progress marker, restores persistent `BootOrder` to installed Omarchy first and restore second, then sets `BootNext` to the installed Omarchy entry to land the user in their fresh OS.
|
||||
|
||||
If the installed OS cannot write and confirm `BootNext`, the staging command must remove any trigger it wrote and abort; a manual reinstall can still proceed through the firmware boot menu, but `omarchy-factory-reset` has not successfully prepared the machine. If the restore environment cannot set temporary restore-first `BootOrder` for an unattended reset, abort before destructive operations; manual reinstall can still proceed with an explicit warning.
|
||||
|
||||
### Safety
|
||||
|
||||
The factory reset command is a staging tool, not the destructive installer. It must:
|
||||
|
||||
- Require root and refuse to run otherwise.
|
||||
- Refuse to run if no complete restore partition set is detected (restore ESP, restore payload, restore state), e.g. on a dual-boot machine or a `--no-restore` full-disk install.
|
||||
- Refuse to run if the signed restore payload manifest check fails — a corrupt restore is not recoverable from inside the running OS, and triggering a reset would brick the machine.
|
||||
- Verify the restore boot entry exists in NVRAM before triggering; if not, repopulate it from `EFI/BOOT/BOOTX64.EFI` fallback or abort with a message.
|
||||
- Confirm `BootNext` points to the restore boot entry before exiting, so the system is actually prepared to boot restore.
|
||||
- Print a final pre-confirmation list of partitions that will be destroyed, by stable identifier, so the user sees exactly what they are committing to.
|
||||
|
||||
The restore environment, when running due to the trigger flag, must still apply every guard from the Safety Model. The trigger is permission to run the reinstall flow, not permission to skip safety checks.
|
||||
|
||||
### File Changes for Factory Reset
|
||||
|
||||
- Ship `omarchy-factory-reset` on the installed system. Source location depends on Omarchy's package boundary — either as part of the Omarchy package on the offline mirror, or copied from the live ISO into the installed system during install. Pick one consistent approach during implementation.
|
||||
- Restore state must be mountable read-write from the installed OS by an admin via `OMARCHY_STATE`. Restore payload should only be mounted read-only for manifest verification via `OMARCHY_RESTORE`.
|
||||
|
||||
## Safety Model
|
||||
|
||||
Protected installs must use stable identifiers, not only `/dev/nvme0n1pX` names.
|
||||
|
||||
Track:
|
||||
|
||||
```text
|
||||
protected partition PARTUUIDs
|
||||
restore state PARTUUID
|
||||
writable partition PARTUUIDs
|
||||
selected disk ID
|
||||
install mode
|
||||
install root
|
||||
```
|
||||
|
||||
Every destructive operation must call a guard first:
|
||||
|
||||
```text
|
||||
assert_writable_partition <partition>
|
||||
assert_not_protected <partition>
|
||||
```
|
||||
|
||||
Guarded operations include:
|
||||
|
||||
- `sgdisk --delete`
|
||||
- `sgdisk --new`
|
||||
- `wipefs`
|
||||
- `mkfs.fat`
|
||||
- `mkfs.btrfs`
|
||||
- `cryptsetup luksFormat`
|
||||
- partition table rewrites
|
||||
|
||||
In restore mode, also assert:
|
||||
|
||||
- `/proc/cmdline` contains `copytoram=y`.
|
||||
- The restore payload is not mounted read-write from the target disk at mutation time.
|
||||
- Restore ESP, restore payload, and restore state partitions are detected and marked protected from delete/format operations.
|
||||
- The installed target partitions do not overlap protected partition ranges.
|
||||
|
||||
### Power Loss Recovery
|
||||
|
||||
A torn install must be recoverable on next boot rather than leaving the disk in a state that needs manual intervention.
|
||||
|
||||
- After partition table changes but before LUKS format: the new partition exists but holds no recognizable filesystem or LUKS header. On the next install boot, treat any writable partition without a valid header as discardable and re-run the format step.
|
||||
- After LUKS format but before archinstall completes: the LUKS header exists but no working OS is installed. On the next boot from restore or ISO, offer to wipe and retry rather than attempting to resume.
|
||||
- During archinstall: same as above. Resuming partway through a torn pacstrap is more brittle than restarting it.
|
||||
|
||||
In dual-boot mode, "wipe and retry" applies only to the writable Omarchy partition. Protected partitions must be re-verified by PARTUUID before any retry runs — power loss does not unlock protected ranges.
|
||||
|
||||
## Installer State Contract
|
||||
|
||||
The configurator writes `install_mode.sh` for `.automated_script.sh` to source.
|
||||
|
||||
Example dual-boot state:
|
||||
|
||||
```bash
|
||||
INSTALL_MODE=dual_boot
|
||||
INSTALL_ROOT=/mnt/archinstall
|
||||
DISK=/dev/nvme0n1
|
||||
BOOT_PARTITION=/dev/nvme0n1p1
|
||||
ROOT_PARTITION=/dev/nvme0n1p4
|
||||
PROTECTED_PARTUUIDS="1111-2222 3333-4444 5555-6666"
|
||||
WRITABLE_PARTUUIDS="7777-8888"
|
||||
PROMOTE_OMARCHY_BOOT=false
|
||||
```
|
||||
|
||||
Example restore state:
|
||||
|
||||
```bash
|
||||
INSTALL_MODE=restore_install
|
||||
INSTALL_ROOT=/mnt/archinstall
|
||||
DISK=/dev/nvme0n1
|
||||
RESTORE_ESP_PARTITION=/dev/nvme0n1p1
|
||||
RESTORE_PAYLOAD_PARTITION=/dev/nvme0n1p2
|
||||
RESTORE_STATE_PARTITION=/dev/nvme0n1p3
|
||||
INSTALLED_ESP_PARTITION=/dev/nvme0n1p4
|
||||
ROOT_PARTITION=/dev/nvme0n1p5
|
||||
PROTECTED_PARTUUIDS="1111-2222 3333-4444 5555-6666"
|
||||
WRITABLE_PARTUUIDS="7777-8888 9999-aaaa"
|
||||
PROMOTE_OMARCHY_BOOT=true
|
||||
```
|
||||
|
||||
Keep this file simple shell, generated only by our configurator, and quote values safely.
|
||||
|
||||
Restore mode uses `INSTALLED_ESP_PARTITION` (distinct from `RESTORE_ESP_PARTITION`) because two ESPs are present. It also tracks `RESTORE_STATE_PARTITION` separately because that partition is writable state but protected from delete/format operations. Dual-boot mode keeps `BOOT_PARTITION` since only one ESP exists and is unambiguous.
|
||||
|
||||
## Archinstall Config
|
||||
|
||||
Protected modes generate this disk config and explicitly disable archinstall bootloader writes:
|
||||
|
||||
```json
|
||||
{
|
||||
"bootloader": null,
|
||||
"disk_config": {
|
||||
"config_type": "pre_mounted_config",
|
||||
"mountpoint": "/mnt/archinstall"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Do not include `device_modifications`, `disk_encryption`, or `btrfs_options` in protected modes. The installer handles those before and after archinstall. If archinstall does not accept `"bootloader": null`, Phase 2a must identify the supported equivalent; protected mode must not proceed while archinstall can write boot files or NVRAM entries independently.
|
||||
|
||||
Full-disk mode keeps the existing generated `default_layout` config.
|
||||
|
||||
**Verify before Phase 2b.** Under `pre_mounted_config`, archinstall still tends to run `genfstab`, write a bootloader, and may write `/etc/crypttab`. The plan currently assumes archinstall acts only as a base-system installer in protected mode; this needs to be confirmed on a throwaway VM. Once confirmed, decide for each step (fstab, crypttab, bootloader, initramfs, kernel cmdline) whether the manual steps below run *instead of* archinstall's behavior, *after* archinstall has had its turn, or with archinstall's step disabled in config. The bootloader outcome is a hard gate: protected mode must have a confirmed way to prevent archinstall from writing Limine files or NVRAM entries. Do not start writing the manual pre/post steps until this is resolved — the unknown sits underneath every downstream step.
|
||||
|
||||
## File Changes
|
||||
|
||||
### `configs/airootfs/root/configurator`
|
||||
|
||||
Add shared detection and policy selection:
|
||||
|
||||
- `detect_disk_layout` finds GPT state, partitions, partition ranges, filesystem labels, ESPs, ESP free space, and free regions.
|
||||
- `detect_existing_os` mounts ESP read-only and checks known vendor paths like `EFI/Microsoft`, `EFI/ubuntu`, `EFI/fedora`, `EFI/GRUB`, and `EFI/systemd`.
|
||||
- `detect_bitlocker` checks every Windows/basic-data candidate partition on the selected disk for BitLocker. Use `blkid -o value -s TYPE`; BitLocker volumes report `BitLocker` rather than `ntfs`. As a backup, read 8 bytes at offset 3 of the partition — BitLocker volumes contain `-FVE-FS-` instead of `NTFS `. If any partition reports BitLocker, the dual-boot path aborts before any disk mutation with the message described in the dual-boot policy.
|
||||
- `detect_restore_layout` finds `OMARCHY_RESTORE` and `OMARCHY_STATE` partitions and validates the restore ESP/payload/state set.
|
||||
- `find_free_regions` finds unallocated GPT space using `sgdisk` or `parted`. Selection rule: pick the largest single contiguous region of at least 40 GB. Do not concatenate non-contiguous regions.
|
||||
- `install_mode_form` chooses between full disk, dual boot, and restore install based on context.
|
||||
|
||||
User flow:
|
||||
|
||||
```text
|
||||
Normal ISO boot:
|
||||
select disk
|
||||
detect layout
|
||||
if existing OS/install is detected:
|
||||
show detected installs and disk layout summary
|
||||
always offer "Exclusive install (erase disk)" using the existing full-disk `wipe: true` path
|
||||
if existing ESP + enough free space + guardrails pass:
|
||||
also offer "Install alongside"
|
||||
else:
|
||||
show why "Install alongside" is unavailable (for example: no ESP, no suitable free space, BitLocker/FVE, ESP too small)
|
||||
else:
|
||||
keep current erase-disk flow
|
||||
|
||||
Restore boot:
|
||||
detect restore disk automatically
|
||||
show first-install or reinstall warning
|
||||
protect restore ESP/payload/state partitions
|
||||
create/recreate installed partitions only
|
||||
```
|
||||
|
||||
Generated files:
|
||||
|
||||
- `user_credentials.json`
|
||||
- `user_configuration.json`
|
||||
- `user_full_name.txt`
|
||||
- `user_email_address.txt`
|
||||
- `install_mode.sh`
|
||||
|
||||
### `configs/airootfs/root/.automated_script.sh`
|
||||
|
||||
Add shared protected install functions:
|
||||
|
||||
- Source `install_mode.sh` after configurator runs.
|
||||
- Set `INSTALL_ROOT=/mnt/archinstall` for all modes, including full-disk. A single mount root avoids subtle bugs in code touched by both paths and removes one branch from every post-install step.
|
||||
- Before changing the mount root, grep the live ISO and post-install scripts for hardcoded `/mnt` references and produce an explicit list of call sites. Update each one consciously rather than via a global rename.
|
||||
- Add `setup_protected_partitions` before archinstall.
|
||||
- Add `configure_protected_post_install` after archinstall.
|
||||
- Add cleanup trap for mounts, LUKS mappings, and temporary directories.
|
||||
|
||||
Protected pre-install steps:
|
||||
|
||||
1. Verify mode-specific guardrails.
|
||||
2. Create writable partitions if needed.
|
||||
3. Run `partprobe "$DISK"` and `udevadm settle`.
|
||||
4. Format installed ESP when policy requires it.
|
||||
5. `cryptsetup luksFormat` the root partition.
|
||||
6. `cryptsetup open` root as `omarchy_root`.
|
||||
7. `mkfs.btrfs /dev/mapper/omarchy_root`.
|
||||
8. Create Btrfs subvolumes `@`, `@home`, `@log`, and `@pkg`.
|
||||
9. Mount subvolumes at `$INSTALL_ROOT` with `compress=zstd`.
|
||||
10. Mount ESP at `$INSTALL_ROOT/efi`; keep `$INSTALL_ROOT/boot` as a normal directory on encrypted root.
|
||||
11. Generate deterministic fstab with overwrite semantics.
|
||||
|
||||
Protected post-install steps:
|
||||
|
||||
1. Configure root unlock for the initramfs hook actually in use. Root unlock is driven by initramfs + kernel cmdline, not by `/etc/crypttab`:
|
||||
- `encrypt` hook: kernel cmdline `cryptdevice=UUID=<luks-uuid>:omarchy_root root=/dev/mapper/omarchy_root`. No crypttab entry needed for root.
|
||||
- `sd-encrypt` hook: write `/etc/crypttab.initramfs` (not `/etc/crypttab`) with the LUKS UUID, and pass `rd.luks.name=<luks-uuid>=omarchy_root root=/dev/mapper/omarchy_root` on the kernel cmdline.
|
||||
2. Update mkinitcpio hooks for the initramfs mode actually present.
|
||||
3. Regenerate initramfs in chroot with `mkinitcpio -P`.
|
||||
4. Install an Omarchy-owned kernel/initramfs sync hook that copies boot artifacts from `/boot` to `/efi/EFI/Omarchy` after kernel or initramfs updates.
|
||||
5. Run the initial boot artifact sync before writing Limine config.
|
||||
6. Configure Limine kernel cmdline for encrypted root per the hook chosen above, pointing at namespaced artifacts under `EFI/Omarchy`.
|
||||
7. Install or update Limine on the selected installed ESP.
|
||||
8. Run `limine-scan` in chroot when appropriate.
|
||||
9. Apply mode-specific boot order policy.
|
||||
10. Leave swapfile creation, `resume` hook, and `resume=` cmdline injection to Omarchy's existing `omarchy-hibernation-setup` post-install hook. Verify `/etc/limine-entry-tool.d/` drop-ins are honored by the Limine config layout written here so that hook works unchanged.
|
||||
|
||||
### `builder/archinstall.packages`
|
||||
|
||||
Ensure the live environment has the tools needed for protected installs:
|
||||
|
||||
- `parted`
|
||||
- `gptfdisk`
|
||||
- `btrfs-progs`
|
||||
- `cryptsetup`
|
||||
- `dosfstools`
|
||||
- `efibootmgr`
|
||||
- `mtools`
|
||||
|
||||
`efibootmgr` already exists in this file, but keep it explicit in the protected-install dependency checklist.
|
||||
|
||||
### `builder/build-iso.sh`
|
||||
|
||||
Add build-time mode support:
|
||||
|
||||
- Persist `/root/omarchy_mode` as `normal`, `dual_boot_capable`, or `restore`.
|
||||
- For restore builds, inject `copytoram=y omarchy.mode=restore` into restore boot entries.
|
||||
- For restore builds, assert boot entries contain `copytoram=y`.
|
||||
- For normal ISO builds, keep existing behavior except adding dual-boot capability.
|
||||
|
||||
### `bin/omarchy-iso-make`
|
||||
|
||||
Add optional build flags:
|
||||
|
||||
```text
|
||||
--restore-image build omarchy-restore.img.zst factory artifact
|
||||
```
|
||||
|
||||
Keep the existing ISO output path unchanged unless a restore image is explicitly requested.
|
||||
|
||||
## Bootloader Policy
|
||||
|
||||
### Default Boot Target
|
||||
|
||||
For any standalone install (full-disk or restore_install, with or without a restore partition set), installed Omarchy is the default boot target. The persistent `BootOrder` after every successful install or factory reset is:
|
||||
|
||||
1. Installed Omarchy
|
||||
2. Restore (when a restore partition set exists)
|
||||
3. Firmware fallback
|
||||
|
||||
The user should never have to pick Omarchy from a boot menu under normal operation. Restore is reachable but never default. Boot-menu entries inside Limine for restore/reinstall are convenience; they do not replace this NVRAM ordering.
|
||||
|
||||
`BootNext` is used only for one-shot transitions (factory reset trigger, post-reset return to installed Omarchy) and must not be used to make Omarchy "stickily" default — that's the job of `BootOrder`. The only temporary exception is an in-progress factory reset: after the restore environment accepts the trigger and before it mutates installed partitions, restore becomes the persistent first boot target until reinstall succeeds.
|
||||
|
||||
For dual-boot, the previous OS's firmware order is preserved unless the user explicitly opts to make Omarchy first. Dual-boot is the only mode where Omarchy may not be the firmware default.
|
||||
|
||||
### Dual Boot
|
||||
|
||||
- Install Omarchy boot files under `EFI/Omarchy` on the shared ESP.
|
||||
- Do not overwrite existing vendor directories.
|
||||
- Preserve firmware default boot order unless user opts in.
|
||||
- Run `limine-scan` so Windows/Linux entries are discoverable from Omarchy's menu. Verify on a real Windows + Linux dual-boot before depending on this — Limine's auto-detection is less battle-tested than GRUB's. If it does not pick them up cleanly, fall back to the firmware boot menu and document the limitation rather than hand-writing entries.
|
||||
- BitLocker is handled at detection time by aborting the install (see Dual Boot policy). The bootloader path therefore only ever sees Windows volumes with BitLocker fully off/decrypted.
|
||||
|
||||
### Restore Install
|
||||
|
||||
- Installed Omarchy gets its own ESP and boot entry.
|
||||
- Restore ESP keeps `EFI/BOOT/BOOTX64.EFI` fallback path.
|
||||
- After successful install, write `BootOrder` as installed Omarchy first, restore second. Do not reorder on every boot — only after install or factory reset.
|
||||
- Add a restore/reinstall entry to the installed Limine menu if it can be done cleanly.
|
||||
- If NVRAM writes fail, rely on fallback boot paths and show a warning. The user can still recover via firmware boot menu.
|
||||
|
||||
## Rollout Plan
|
||||
|
||||
### Phase 1: Refactor Without Behavior Change
|
||||
|
||||
- Introduce `INSTALL_MODE=full_disk`.
|
||||
- Introduce `$INSTALL_ROOT` and update post-install paths.
|
||||
- Keep existing full-disk JSON and archinstall behavior.
|
||||
- Add tests or dry-run checks for config generation.
|
||||
|
||||
### Phase 2a: Archinstall pre_mounted_config Spike
|
||||
|
||||
Single-purpose spike on a throwaway VM. No production code changes.
|
||||
|
||||
- Drive archinstall with a hand-crafted mount tree and `pre_mounted_config`.
|
||||
- Record exactly what archinstall does: fstab generation, crypttab writes, bootloader install, initramfs regeneration, kernel cmdline writes.
|
||||
- Prove the protected-mode config disables archinstall bootloader and NVRAM writes, or document the supported replacement setting. This is a release blocker for Phase 2b.
|
||||
- Decide whether the manual fstab/Limine/initramfs steps in this plan run before, after, or instead of archinstall's own steps.
|
||||
- Update this plan with the answers before Phase 2b begins. The downstream design depends on this; do not skip.
|
||||
|
||||
### Phase 2b: Shared Protected Install Engine
|
||||
|
||||
- Add `pre_mounted_config` generation.
|
||||
- Add manual LUKS, Btrfs, subvolume, mount, fstab, and cleanup logic.
|
||||
- Add encrypted boot post-install configuration.
|
||||
- Add namespaced ESP boot artifact sync under `EFI/Omarchy`.
|
||||
- Keep it behind internal mode switches until validated.
|
||||
|
||||
### Phase 3: Dual-Boot UI and Policy
|
||||
|
||||
- Add disk layout detection.
|
||||
- When another install is detected, show an install-mode choice instead of assuming dual boot: "Install alongside" when eligible, and "Exclusive install (erase disk)" using the existing full-disk `wipe: true` path.
|
||||
- If another install is detected but dual boot is not eligible, explain why and still offer the exclusive install path.
|
||||
- Add Windows/BitLocker warnings.
|
||||
- Validate alongside Windows and Linux.
|
||||
|
||||
### Phase 4: Restore Install Policy
|
||||
|
||||
- Add restore layout detection.
|
||||
- Add restore partition set protection.
|
||||
- Add first-install and reinstall flows.
|
||||
- Validate that restore ESP, payload, and state survive installation and later reinstall.
|
||||
|
||||
### Phase 5: Restore Factory Image
|
||||
|
||||
- Build `omarchy-restore.img.zst`.
|
||||
- Add factory flashing instructions or a dedicated factory flasher ISO/PXE workflow.
|
||||
- Validate first boot from internal disk with no external media.
|
||||
- Sign `omarchy-restore.img.zst` and the restore payload manifest. Verify in the factory flasher and at restore boot before any disk mutation.
|
||||
- Add first-boot UUID randomization for cloned restore images before generating installed boot entries or state.
|
||||
- Decide on Secure Boot before this phase ships. Shipping with SB disabled is a non-starter for some buyers, and BitLocker (when present on a dual-boot machine restored later) reseals against firmware state. Either implement a signed shim/Limine path, or commit to "SB off" with a documented rationale and a way for the user to flip it on later if they have keys.
|
||||
|
||||
### Phase 6: Factory Reset
|
||||
|
||||
- Implement `omarchy-factory-reset` as the installed-OS staging command: write and fsync the trigger flag, verify/recreate the restore boot entry, set and confirm `BootNext`, then leave the machine ready to boot restore.
|
||||
- Wire the restore environment to detect the trigger flag and run the reinstall flow non-interactively.
|
||||
- Set `BootNext` for one-shot transitions and temporary restore-first persistent `BootOrder` during the destructive reset window.
|
||||
- Validate on `restore_install` machines first (the flow already has a restore partition set).
|
||||
|
||||
### Phase 7: Restore Partition for Standalone Installs
|
||||
|
||||
- Extend the standalone full-disk install path to create restore ESP + restore payload + restore state + installed ESP + installed root, mirroring the `restore_install` layout.
|
||||
- Populate restore payload at install time from the live ISO offline mirror.
|
||||
- Add `--no-restore` opt-out for users who explicitly want the legacy two-partition layout.
|
||||
- After this phase, every consumer install gets factory reset by default.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- Full-disk install behavior remains unchanged through Phase 6. Phase 7 changes the default layout to include a restore partition set; legacy layout remains available via `--no-restore`.
|
||||
- Dual-boot install preserves existing OS partitions.
|
||||
- Dual-boot install creates encrypted Omarchy root in free space.
|
||||
- When another install is detected, the installer offers the current exclusive full-disk wipe path and only offers dual boot when guardrails pass.
|
||||
- Dual-boot install writes Omarchy boot artifacts only under `EFI/Omarchy` on a shared ESP and leaves existing vendor paths untouched.
|
||||
- Dual-boot install aborts cleanly when BitLocker/FVE is detected, including suspended BitLocker, before any disk mutation, with an actionable message.
|
||||
- Restore install preserves restore ESP, restore payload, and restore state partitions.
|
||||
- Restore install creates or recreates only installed Omarchy partitions.
|
||||
- Protected modes never generate archinstall config with `wipe: true`.
|
||||
- Protected modes prevent archinstall from independently writing boot files or NVRAM entries.
|
||||
- Protected modes abort before destructive operations if a target partition is protected.
|
||||
- Restore payload integrity is verified with a signed manifest before any restore-triggered disk mutation.
|
||||
- Installed Omarchy boots and requires LUKS unlock.
|
||||
- Installed Omarchy is the default firmware boot target for any standalone install (full-disk or restore_install).
|
||||
- Restore boot remains available after first install but is never the default.
|
||||
- Reinstall from restore works without external media.
|
||||
- `omarchy-factory-reset` from the installed OS leaves the machine staged exactly like a freshly prepared restore-boot device: trigger flag durable on restore state, restore boot entry present, and `BootNext` pointing at restore. No installed partitions are destroyed before the next restore boot.
|
||||
- A subsequent restore boot from that staged state wipes installed partitions, reinstalls a fresh Omarchy, and lands the user back in the installed OS without external media. Restore ESP, payload, and state partitions survive intact.
|
||||
- Factory reset refuses to run when no complete restore partition set is present (e.g. dual-boot, `--no-restore` install).
|
||||
|
||||
## Validation Matrix
|
||||
|
||||
### Regression
|
||||
|
||||
1. Full-disk UEFI install on empty disk.
|
||||
2. Current normal ISO boot menu and default install behavior.
|
||||
3. Existing offline package installation flow.
|
||||
|
||||
### Dual Boot
|
||||
|
||||
1. Windows + free space + existing ESP (BitLocker off).
|
||||
2. Windows + BitLocker enabled — installer must abort before any disk mutation with a clear "turn off BitLocker and wait for decryption" message.
|
||||
3. Windows + BitLocker suspended — installer must still abort, because v1 treats any BitLocker/FVE signature as unsafe.
|
||||
4. Linux distro + free space + existing ESP.
|
||||
5. GPT disk with no free space.
|
||||
6. ESP below total-size warning threshold.
|
||||
7. ESP below total-size minimum threshold.
|
||||
8. ESP large enough by total size but below free-space minimum.
|
||||
9. Multiple free regions; choose largest suitable region.
|
||||
10. Firmware boot order preservation.
|
||||
|
||||
### Restore
|
||||
|
||||
1. Factory image written to larger virtual disk.
|
||||
2. First boot from internal restore ESP.
|
||||
3. First install randomizes cloned disk/partition/filesystem UUIDs before creating installed boot entries.
|
||||
4. First install creates installed ESP/root and preserves restore ESP, payload, and state.
|
||||
5. Installed OS boots with encrypted root.
|
||||
6. Installed Omarchy is the firmware default; restore is reachable but not default.
|
||||
7. Restore boot still works after installed OS exists.
|
||||
8. Reinstall formats only the installed Omarchy partitions in place; PARTUUIDs unchanged.
|
||||
9. Restore mode without `copytoram=y` aborts before disk mutation.
|
||||
10. Missing restore payload or restore state aborts before disk mutation.
|
||||
11. NVRAM boot entry write failure still leaves fallback boot path usable.
|
||||
|
||||
### Factory Reset
|
||||
|
||||
1. `omarchy-factory-reset` from installed OS leaves the system staged for restore boot: trigger flag durable on restore state, restore boot entry present, and `BootNext` confirmed.
|
||||
2. No installed partitions are destroyed before the staged system actually boots into restore.
|
||||
3. Booting into restore from the staged state reinstalls and returns to a fresh installed Omarchy as the default-booted OS.
|
||||
4. Trigger flag is deleted before the post-reset reboot. Machine does not loop.
|
||||
5. Reset interrupted between trigger and restore boot: next normal boot still goes to installed Omarchy (because `BootNext` is one-shot).
|
||||
6. Reset interrupted during reinstall (power loss): persistent temporary restore-first `BootOrder` boots restore again and re-runs the flow from the trigger flag/reset-in-progress state.
|
||||
7. Reset refused when no complete restore partition set is detected.
|
||||
8. Reset refused when signed restore payload verification fails.
|
||||
9. Reset refused when running without root.
|
||||
10. Reset refused when restore boot entry is missing from NVRAM and cannot be repopulated from fallback.
|
||||
|
||||
### Negative Safety Tests
|
||||
|
||||
1. Attempt to format protected restore ESP.
|
||||
2. Attempt to format protected restore payload.
|
||||
3. Attempt to format protected restore state.
|
||||
4. Attempt to format existing Windows partition in dual-boot mode.
|
||||
5. Partition overlap with protected range.
|
||||
6. Power loss before partition creation.
|
||||
7. Power loss after partition creation but before archinstall.
|
||||
8. Power loss during archinstall.
|
||||
|
||||
## Open Questions
|
||||
|
||||
- Restore payload size: full offline mirror versus smaller network-capable restore image. Affects whether the consumer ISO's restore-partition default in Phase 7 is feasible at typical disk sizes.
|
||||
- Restore update strategy after devices ship.
|
||||
- Whether restore should also expose diagnostics / log upload alongside factory reset.
|
||||
- Whether factory reset should preserve `/home` user data optionally, or always wipe. v1 always wipes (simpler, matches user expectation of "factory reset"); a "keep my files" variant could land later.
|
||||
|
||||
Resolved:
|
||||
|
||||
- User-facing reset staging command: yes, `omarchy-factory-reset` (Phase 6).
|
||||
- Secure Boot: promoted to Phase 5 decision gate.
|
||||
- Btrfs subvolume layout: protected modes use the current full-disk layout, `@`, `@home`, `@log`, and `@pkg`. The `/swap` subvolume for hibernation is created post-install by `omarchy-hibernation-setup` and is not predeclared at install time.
|
||||
|
||||
## Definition of Done
|
||||
|
||||
- One shared protected-partition implementation supports both dual-boot and restore install policies.
|
||||
- Full-disk installs remain stable through Phase 6 and gain a default restore partition set in Phase 7.
|
||||
- Dual-boot users can install alongside existing OSes without data loss.
|
||||
- OEM devices can boot internal restore on first power-on, install Omarchy, and retain restore for future reinstall.
|
||||
- All destructive operations are guarded by protected partition checks.
|
||||
- Installed Omarchy is the firmware default boot target on every standalone install.
|
||||
- `omarchy-factory-reset` stages any standalone install to boot internal restore without external media; the restore-triggered reinstall returns the user to a fresh installed Omarchy.
|
||||
- VM and hardware validation matrices pass.
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Fast, VM-free tests only. The integration scenarios that boot the ISO in
|
||||
# QEMU live in test/integration.d/ and run via ./test/integration.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
|
||||
for test in "$ROOT"/test/unit/*-test.sh; do
|
||||
printf '==> %s\n' "${test#$ROOT/}"
|
||||
bash "$test"
|
||||
done
|
||||
|
||||
printf '==> test/unit/test_*.py\n'
|
||||
python3 -m unittest discover -t "$ROOT" -s "$ROOT/test/unit"
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Integration runner: boots an ISO's installed system in QEMU and runs the
|
||||
# scenarios in test/integration.d/ against it. The unattended cidata install
|
||||
# happens once per ISO and is saved as a reusable base image; every scenario
|
||||
# then boots a throwaway overlay of that base.
|
||||
#
|
||||
# Usage: test/integration [release/omarchy.iso] [scenario ...] [options]
|
||||
#
|
||||
# scenario Basename of a test/integration.d/<scenario>-test.sh file;
|
||||
# all scenarios run when none are named
|
||||
# --reuse-base Skip the install if a saved base image exists
|
||||
# --port PORT Host port forwarded to guest SSH (default 2322)
|
||||
# --memory MB VM memory (default 8192)
|
||||
# --timeout SECS Install timeout (default 2400)
|
||||
# --no-preview Do not open the collected screenshots in imv
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
|
||||
ISO=""
|
||||
REUSE_BASE=false
|
||||
SCENARIOS=()
|
||||
|
||||
export OMARCHY_INTEGRATION_SSH_PORT=2322
|
||||
export OMARCHY_INTEGRATION_MEMORY=8192
|
||||
export OMARCHY_INTEGRATION_INSTALL_TIMEOUT=2400
|
||||
export OMARCHY_INTEGRATION_NO_PREVIEW=false
|
||||
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--reuse-base) REUSE_BASE=true ;;
|
||||
--no-preview) OMARCHY_INTEGRATION_NO_PREVIEW=true ;;
|
||||
--port) OMARCHY_INTEGRATION_SSH_PORT="$2"; shift ;;
|
||||
--memory) OMARCHY_INTEGRATION_MEMORY="$2"; shift ;;
|
||||
--timeout) OMARCHY_INTEGRATION_INSTALL_TIMEOUT="$2"; shift ;;
|
||||
-*) echo "Unknown option: $1" >&2; exit 1 ;;
|
||||
*)
|
||||
if [[ $1 == *.iso ]]; then
|
||||
ISO="$1"
|
||||
else
|
||||
SCENARIOS+=("$ROOT/test/integration.d/$1-test.sh")
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $ISO && -t 0 ]]; then
|
||||
ISO=$(ls -t "$ROOT"/release/*.iso 2>/dev/null | gum choose --header "Select ISO to test")
|
||||
fi
|
||||
|
||||
if [[ ! -f ${ISO:-} ]]; then
|
||||
echo "No ISO to test. Pass one explicitly or put it in release/." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if (( ${#SCENARIOS[@]} == 0 )); then
|
||||
SCENARIOS=("$ROOT"/test/integration.d/*-test.sh)
|
||||
else
|
||||
for scenario in "${SCENARIOS[@]}"; do
|
||||
if [[ $(basename "$scenario") == "base-test.sh" || ! -f $scenario ]]; then
|
||||
echo "No such scenario: $scenario" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
omarchy-pkg-add qemu-full edk2-ovmf socat imagemagick tesseract tesseract-data-eng mtools
|
||||
|
||||
export OMARCHY_INTEGRATION_ISO
|
||||
OMARCHY_INTEGRATION_ISO=$(realpath "$ISO")
|
||||
|
||||
# The install phase runs in this process; scenarios run in their own so each
|
||||
# gets its own VM lifecycle, cleanup trap, and run directory.
|
||||
SCENARIO=install
|
||||
source "$ROOT/test/integration.d/base-test.sh"
|
||||
|
||||
if $REUSE_BASE && base_image_ready; then
|
||||
log "Reusing existing base image: $BASE_DISK"
|
||||
else
|
||||
install_phase
|
||||
fi
|
||||
|
||||
status=0
|
||||
for scenario in "${SCENARIOS[@]}"; do
|
||||
[[ $(basename "$scenario") == "base-test.sh" ]] && continue
|
||||
printf '\033[1;35m==> %s\033[0m\n' "${scenario#$ROOT/}"
|
||||
# env -u: a SCENARIO exported by the caller (or leaked from this process)
|
||||
# must not override the name each scenario derives from its own $0.
|
||||
env -u SCENARIO bash "$scenario" || status=1
|
||||
done
|
||||
|
||||
exit $status
|
||||
@@ -0,0 +1,597 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Shared harness for the integration scenarios in test/integration.d/: QEMU
|
||||
# lifecycle, QMP screendump + OCR console driving, virtual keystrokes, guest
|
||||
# SSH, cidata autoinstall, and the reusable base-image contract. Source this
|
||||
# from a scenario; ./test/integration exports the configuration and ensures
|
||||
# the base image exists before any scenario runs.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
|
||||
ISO="$OMARCHY_INTEGRATION_ISO"
|
||||
SSH_PORT="${OMARCHY_INTEGRATION_SSH_PORT:-2322}"
|
||||
MEMORY="${OMARCHY_INTEGRATION_MEMORY:-8192}"
|
||||
INSTALL_TIMEOUT="${OMARCHY_INTEGRATION_INSTALL_TIMEOUT:-2400}"
|
||||
# cache=none keeps the host page cache out of the guest's disk writes, so
|
||||
# install times measure the installer rather than the host (CI sets it).
|
||||
DISK_CACHE="${OMARCHY_INTEGRATION_DISK_CACHE:-}"
|
||||
NO_PREVIEW="${OMARCHY_INTEGRATION_NO_PREVIEW:-false}"
|
||||
BOOT_TIMEOUT=600
|
||||
|
||||
GUEST_USER="omarchy"
|
||||
GUEST_PASSWORD="omarchy"
|
||||
GUEST_HOSTNAME="omarchy-test"
|
||||
|
||||
SCENARIO="${SCENARIO:-$(basename "${0%-test.sh}")}"
|
||||
|
||||
OVMF_CODE="/usr/share/edk2/x64/OVMF_CODE.4m.fd"
|
||||
OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
|
||||
|
||||
BASE_DIR="$ROOT/test-runs/$(basename "$ISO" .iso)-integration"
|
||||
RUN_DIR="$BASE_DIR/runs/$(date +%Y%m%d-%H%M%S)-$SCENARIO"
|
||||
BASE_DISK="$BASE_DIR/base.qcow2"
|
||||
BASE_OVMF="$BASE_DIR/OVMF_VARS.4m.fd"
|
||||
ACTIVE_OVMF="$BASE_OVMF"
|
||||
SSH_KEY="$BASE_DIR/id_ed25519"
|
||||
CIDATA_IMG="$BASE_DIR/cidata.img"
|
||||
HTTP_PORT=$((SSH_PORT + 1))
|
||||
HTTP_PID=""
|
||||
|
||||
mkdir -p "$BASE_DIR" "$RUN_DIR"
|
||||
|
||||
QMP_SOCK=$(mktemp -u "${TMPDIR:-/tmp}/omarchy-integration-qmp.XXXXXX.sock")
|
||||
PIDFILE="$RUN_DIR/qemu.pid"
|
||||
|
||||
FAILURES=0
|
||||
|
||||
log() {
|
||||
printf '\033[1;35m==> %s\033[0m\n' "$1"
|
||||
}
|
||||
|
||||
check() {
|
||||
local description="$1"
|
||||
shift
|
||||
|
||||
if "$@" >/dev/null 2>&1; then
|
||||
printf 'ok - %s\n' "$description"
|
||||
else
|
||||
printf 'not ok - %s\n' "$description"
|
||||
((FAILURES += 1))
|
||||
fi
|
||||
}
|
||||
|
||||
finish() {
|
||||
if ((FAILURES == 0)); then
|
||||
log "$SCENARIO passed. Artifacts: $RUN_DIR"
|
||||
else
|
||||
log "$SCENARIO FAILED: $FAILURES assertion(s). Artifacts: $RUN_DIR"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
base_image_ready() {
|
||||
[[ -f $BASE_DISK && -f $BASE_OVMF && -f $SSH_KEY ]]
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- vm control
|
||||
|
||||
vm_running() {
|
||||
[[ -f $PIDFILE ]] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null
|
||||
}
|
||||
|
||||
qmp() {
|
||||
printf '{"execute":"qmp_capabilities"}\n{"execute":%s}\n' "$1" |
|
||||
timeout 5 socat -t 2 - "UNIX-CONNECT:$QMP_SOCK" 2>/dev/null || true
|
||||
}
|
||||
|
||||
screendump() {
|
||||
qmp "\"screendump\", \"arguments\": {\"filename\": \"$1\"}" >/dev/null
|
||||
}
|
||||
|
||||
capture_console() {
|
||||
local name="$1" shot="$RUN_DIR/.capture.ppm"
|
||||
|
||||
sleep 1
|
||||
screendump "$shot"
|
||||
[[ -s $shot ]] || return 0
|
||||
magick "$shot" "$RUN_DIR/$name.png" 2>/dev/null || true
|
||||
rm -f "$shot"
|
||||
}
|
||||
|
||||
stop_vm() {
|
||||
vm_running || return 0
|
||||
|
||||
if ! ssh_guest "echo $GUEST_PASSWORD | sudo -S systemctl poweroff" >/dev/null 2>&1; then
|
||||
qmp '"system_powerdown"' >/dev/null
|
||||
fi
|
||||
|
||||
local waited=0
|
||||
while vm_running && ((waited < 15)); do
|
||||
sleep 1
|
||||
((waited += 1))
|
||||
done
|
||||
|
||||
if vm_running; then
|
||||
qmp '"quit"' >/dev/null
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if vm_running; then
|
||||
kill "$(cat "$PIDFILE")" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
}
|
||||
|
||||
open_screenshots() {
|
||||
local entry
|
||||
local -a screenshots=()
|
||||
|
||||
while IFS= read -r -d '' entry; do
|
||||
screenshots+=("${entry#* }")
|
||||
done < <(
|
||||
find "$RUN_DIR" -type f \( -name "success-*.png" -o -name "failure-*.png" \) -printf '%T@ %p\0' |
|
||||
sort -zn
|
||||
)
|
||||
|
||||
(( ${#screenshots[@]} > 0 )) || return 0
|
||||
|
||||
log "Visual review: ${#screenshots[@]} screenshots in $RUN_DIR"
|
||||
[[ $NO_PREVIEW == "true" ]] && return 0
|
||||
|
||||
if command -v imv >/dev/null && [[ -n ${WAYLAND_DISPLAY:-}${DISPLAY:-} ]]; then
|
||||
setsid -f imv "${screenshots[@]}" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
local status=$?
|
||||
|
||||
[[ -n $HTTP_PID ]] && kill "$HTTP_PID" 2>/dev/null || true
|
||||
vm_running && log "Stopping test VM"
|
||||
stop_vm
|
||||
rm -f "$RUN_DIR/.screen.ppm" "$RUN_DIR/.screen.png"
|
||||
open_screenshots
|
||||
rmdir "$RUN_DIR" 2>/dev/null || true
|
||||
|
||||
return $status
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
start_vm() {
|
||||
local disk="$1" serial="$2"
|
||||
shift 2
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-cpu host -enable-kvm -machine q35,accel=kvm \
|
||||
-smp "$(nproc)" \
|
||||
-m "$MEMORY" \
|
||||
-drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \
|
||||
-drive if=pflash,format=raw,file="$ACTIVE_OVMF" \
|
||||
-drive file="$disk",format=qcow2,if=none,id=drive0${DISK_CACHE:+,cache=$DISK_CACHE} \
|
||||
-device virtio-blk-pci,drive=drive0,bootindex=1 \
|
||||
-device virtio-vga \
|
||||
-display none \
|
||||
-usb -device usb-tablet \
|
||||
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:$SSH_PORT-:22 \
|
||||
-device virtio-net-pci,netdev=net0 \
|
||||
-qmp "unix:$QMP_SOCK,server,nowait" \
|
||||
-serial "file:$serial" \
|
||||
-pidfile "$PIDFILE" \
|
||||
-daemonize \
|
||||
"$@"
|
||||
}
|
||||
|
||||
# Boot a throwaway overlay of the installed base. The disk gets a per-run
|
||||
# overlay; the firmware vars need the same isolation or NVRAM state would
|
||||
# leak between runs.
|
||||
start_vm_from_base() {
|
||||
qemu-img create -f qcow2 -b "$BASE_DISK" -F qcow2 "$RUN_DIR/run.qcow2" >/dev/null
|
||||
cp "$BASE_OVMF" "$RUN_DIR/OVMF_VARS.4m.fd"
|
||||
ACTIVE_OVMF="$RUN_DIR/OVMF_VARS.4m.fd"
|
||||
start_vm "$RUN_DIR/run.qcow2" "$RUN_DIR/serial.log"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------ console driver
|
||||
|
||||
ocr_screen() {
|
||||
local shot="$RUN_DIR/.screen.ppm" prepped="$RUN_DIR/.screen.png"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
wait_for_screen() {
|
||||
local text="$1" timeout="$2" waited=0 slug
|
||||
|
||||
until ocr_screen | grep -qi "$text"; do
|
||||
if ! vm_running; then
|
||||
echo "VM exited while waiting for screen: $text" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ((waited >= timeout)); then
|
||||
slug=${text,,}
|
||||
slug=${slug// /-}
|
||||
slug=${slug//[^a-z0-9-]/}
|
||||
capture_console "failure-waiting-for-$slug"
|
||||
echo "Timed out after ${timeout}s waiting for screen: $text" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
sleep 3
|
||||
((waited += 3))
|
||||
done
|
||||
|
||||
sleep 1
|
||||
}
|
||||
|
||||
press() {
|
||||
local part json=""
|
||||
local -a parts
|
||||
|
||||
IFS='-' read -ra parts <<<"$1"
|
||||
for part in "${parts[@]}"; do
|
||||
json+="{\"type\":\"qcode\",\"data\":\"$part\"},"
|
||||
done
|
||||
|
||||
qmp "\"send-key\", \"arguments\": {\"keys\": [${json%,}]}" >/dev/null
|
||||
}
|
||||
|
||||
type_text() {
|
||||
local text="$1" ch i
|
||||
|
||||
for ((i = 0; i < ${#text}; i++)); do
|
||||
ch=${text:i:1}
|
||||
case "$ch" in
|
||||
[a-z0-9]) press "$ch" ;;
|
||||
[A-Z]) press "shift-${ch,,}" ;;
|
||||
" ") press spc ;;
|
||||
.) press dot ;;
|
||||
,) press comma ;;
|
||||
-) press minus ;;
|
||||
_) press shift-minus ;;
|
||||
/) press slash ;;
|
||||
:) press shift-semicolon ;;
|
||||
"&") press shift-7 ;;
|
||||
"=") press equal ;;
|
||||
"?") press shift-slash ;;
|
||||
"!") press shift-1 ;;
|
||||
"~") press shift-grave_accent ;;
|
||||
@) press shift-2 ;;
|
||||
*) echo "type_text: unsupported character: $ch" >&2; return 1 ;;
|
||||
esac
|
||||
sleep 0.05
|
||||
done
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------- guest
|
||||
|
||||
ssh_guest() {
|
||||
ssh -i "$SSH_KEY" -p "$SSH_PORT" \
|
||||
-o BatchMode=yes \
|
||||
-o IdentitiesOnly=yes \
|
||||
-o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=/dev/null \
|
||||
-o ConnectTimeout=5 \
|
||||
-o LogLevel=ERROR \
|
||||
"$GUEST_USER@127.0.0.1" "$@"
|
||||
}
|
||||
|
||||
ssh_sudo() {
|
||||
ssh_guest "echo $GUEST_PASSWORD | sudo -S -p '' bash -c $(printf %q "$1")"
|
||||
}
|
||||
|
||||
# The deadline is wall-clock: under QEMU user networking every attempt can
|
||||
# spend its whole ConnectTimeout waiting for a banner, so counting only the
|
||||
# sleeps let a "300 s" wait run for ten minutes or more, silently.
|
||||
wait_for_ssh() {
|
||||
local timeout="$1" failure_name="${2:-failure-ssh-timeout}"
|
||||
local started=$SECONDS next_note=30 progress_name
|
||||
|
||||
while ! ssh_guest true 2>/dev/null; do
|
||||
if ! vm_running; then
|
||||
echo "VM exited while waiting for SSH" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ((SECONDS - started >= timeout)); then
|
||||
capture_console "$failure_name"
|
||||
echo "Timed out after ${timeout}s waiting for SSH" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ((SECONDS - started >= next_note)); then
|
||||
printf -v progress_name 'waiting-ssh-%04ds' "$((SECONDS - started))"
|
||||
capture_console "$progress_name"
|
||||
echo " ... waiting for SSH ($((SECONDS - started))s)"
|
||||
((next_note += 30))
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
done
|
||||
}
|
||||
|
||||
# Authorize SSH the way a person would when the guest has no key yet (or a
|
||||
# reset just scrubbed it): console login on a spare TTY, then a bootstrap
|
||||
# script fetched from a throwaway host HTTP server.
|
||||
bootstrap_ssh() {
|
||||
log "Authorizing SSH access via console login"
|
||||
|
||||
mkdir -p "$BASE_DIR/www"
|
||||
cat >"$BASE_DIR/www/bootstrap" <<EOF
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
echo "$(cat "$SSH_KEY.pub")" >>~/.ssh/authorized_keys
|
||||
chmod 600 ~/.ssh/authorized_keys
|
||||
echo "$GUEST_PASSWORD" | sudo -S ufw allow from 10.0.2.2 to any port 22 proto tcp
|
||||
echo "$GUEST_PASSWORD" | sudo -S systemctl enable --now sshd.service
|
||||
EOF
|
||||
|
||||
(cd "$BASE_DIR/www" && exec python3 -m http.server "$HTTP_PORT" --bind 127.0.0.1 >/dev/null 2>&1) &
|
||||
HTTP_PID=$!
|
||||
|
||||
local waited=0
|
||||
while true; do
|
||||
press ctrl-alt-f3
|
||||
sleep 4
|
||||
ocr_screen | grep -qi "login:" && break
|
||||
((waited += 8))
|
||||
|
||||
if ((waited >= 300)); then
|
||||
capture_console "failure-console-timeout"
|
||||
echo "Timed out waiting for a console login prompt" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 4
|
||||
done
|
||||
|
||||
type_text "$GUEST_USER"
|
||||
press ret
|
||||
wait_for_screen "Password" 60
|
||||
type_text "$GUEST_PASSWORD"
|
||||
press ret
|
||||
sleep 3
|
||||
|
||||
type_text "curl -fsS http://10.0.2.2:$HTTP_PORT/bootstrap -o /tmp/bs && bash /tmp/bs"
|
||||
press ret
|
||||
|
||||
wait_for_ssh 360 "failure-bootstrap-ssh-timeout"
|
||||
capture_console "success-bootstrap-ssh"
|
||||
|
||||
kill "$HTTP_PID" 2>/dev/null || true
|
||||
HTTP_PID=""
|
||||
press ctrl-alt-f1
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------- cidata autoinstall
|
||||
|
||||
# The configurator's own output files, synthesized for the 40G virtio disk the
|
||||
# VM boots from. Sizing mirrors the configurator: 1MiB gap, 2GiB ESP, the rest
|
||||
# btrfs minus the GPT backup reserve.
|
||||
build_cidata() {
|
||||
local dir="$BASE_DIR/cidata" hash
|
||||
local disk_bytes=$((40 * 1024 * 1024 * 1024))
|
||||
local mib=$((1024 * 1024)) gib=$((1024 * 1024 * 1024))
|
||||
local boot_start=$mib boot_size=$((2 * gib))
|
||||
local main_start=$((boot_size + boot_start))
|
||||
local main_size=$((disk_bytes - main_start - mib))
|
||||
|
||||
rm -rf "$dir"
|
||||
mkdir -p "$dir"
|
||||
|
||||
hash=$(openssl passwd -6 "$GUEST_PASSWORD")
|
||||
|
||||
cat >"$dir/user_credentials.json" <<EOF
|
||||
{
|
||||
"root_enc_password": $(jq -Rn --arg v "$hash" '$v'),
|
||||
"users": [
|
||||
{
|
||||
"enc_password": $(jq -Rn --arg v "$hash" '$v'),
|
||||
"groups": [],
|
||||
"sudo": true,
|
||||
"username": "$GUEST_USER"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
cat >"$dir/user_configuration.json" <<EOF
|
||||
{
|
||||
"app_config": null,
|
||||
"archinstall-language": "English",
|
||||
"auth_config": {},
|
||||
"audio_config": { "audio": "pipewire" },
|
||||
"bootloader_config": { "bootloader": "Limine", "uki": false, "removable": false },
|
||||
"custom_commands": [],
|
||||
"omarchy_install": {
|
||||
"mode": "full_disk",
|
||||
"defer_provisioning": false,
|
||||
"target_mount": "/mnt",
|
||||
"boot": {
|
||||
"esp_mount": "/boot",
|
||||
"esp_path": "/EFI/limine",
|
||||
"efi_binary": "limine_x64.efi",
|
||||
"enable_fallback": true
|
||||
},
|
||||
"storage": { "kernel": "linux-omarchy" }
|
||||
},
|
||||
"disk_config": {
|
||||
"config_type": "default_layout",
|
||||
"device_modifications": [
|
||||
{
|
||||
"device": "/dev/vda",
|
||||
"partitions": [
|
||||
{
|
||||
"btrfs": [],
|
||||
"dev_path": null,
|
||||
"flags": [ "boot", "esp" ],
|
||||
"fs_type": "fat32",
|
||||
"mount_options": [],
|
||||
"mountpoint": "/boot",
|
||||
"obj_id": "ea21d3f2-82bb-49cc-ab5d-6f81ae94e18d",
|
||||
"size": { "sector_size": { "unit": "B", "value": 512 }, "unit": "B", "value": $boot_size },
|
||||
"start": { "sector_size": { "unit": "B", "value": 512 }, "unit": "B", "value": $boot_start },
|
||||
"status": "create",
|
||||
"type": "primary"
|
||||
},
|
||||
{
|
||||
"btrfs": [
|
||||
{ "mountpoint": "/", "name": "@" },
|
||||
{ "mountpoint": "/home", "name": "@home" },
|
||||
{ "mountpoint": "/var/log", "name": "@log" },
|
||||
{ "mountpoint": "/var/cache/pacman/pkg", "name": "@pkg" }
|
||||
],
|
||||
"dev_path": null,
|
||||
"flags": [],
|
||||
"fs_type": "btrfs",
|
||||
"mount_options": [ "compress=zstd" ],
|
||||
"mountpoint": null,
|
||||
"obj_id": "8c2c2b92-1070-455d-b76a-56263bab24aa",
|
||||
"size": { "sector_size": { "unit": "B", "value": 512 }, "unit": "B", "value": $main_size },
|
||||
"start": { "sector_size": { "unit": "B", "value": 512 }, "unit": "B", "value": $main_start },
|
||||
"status": "create",
|
||||
"type": "primary"
|
||||
}
|
||||
],
|
||||
"wipe": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostname": "$GUEST_HOSTNAME",
|
||||
"kernels": [ "linux-omarchy" ],
|
||||
"network_config": { "type": "iso" },
|
||||
"ntp": true,
|
||||
"parallel_downloads": 8,
|
||||
"script": null,
|
||||
"services": [],
|
||||
"swap": true,
|
||||
"timezone": "UTC",
|
||||
"locale_config": { "kb_layout": "us", "sys_enc": "UTF-8", "sys_lang": "en_US.UTF-8" },
|
||||
"mirror_config": {
|
||||
"custom_repositories": [],
|
||||
"custom_servers": [
|
||||
{"url": "https://mirror.omarchy.org/\$repo/os/\$arch"},
|
||||
{"url": "https://mirror.rackspace.com/archlinux/\$repo/os/\$arch"},
|
||||
{"url": "https://geo.mirror.pkgbuild.com/\$repo/os/\$arch"}
|
||||
],
|
||||
"mirror_regions": {},
|
||||
"optional_repositories": []
|
||||
},
|
||||
"packages": [
|
||||
"base-devel",
|
||||
"git",
|
||||
"omarchy-keyring",
|
||||
"$SETTINGS_PACKAGE",
|
||||
"$RUNTIME_PACKAGE"
|
||||
],
|
||||
"profile_config": { "gfx_driver": null, "greeter": null, "profile": {} },
|
||||
"version": "3.0.9"
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "Omarchy Test" >"$dir/user_full_name.txt"
|
||||
echo "test@omarchy.org" >"$dir/user_email_address.txt"
|
||||
echo "false" >"$dir/user_encrypt_installation.txt"
|
||||
cp "$SSH_KEY.pub" "$dir/authorized_keys"
|
||||
|
||||
rm -f "$CIDATA_IMG"
|
||||
truncate -s 4M "$CIDATA_IMG"
|
||||
mkfs.vfat -n CIDATA "$CIDATA_IMG" >/dev/null
|
||||
mcopy -i "$CIDATA_IMG" "$dir"/* ::/
|
||||
}
|
||||
|
||||
# The dev/local ISO installs the -dev packages; a stable ISO the plain ones.
|
||||
detect_packages() {
|
||||
RUNTIME_PACKAGE=omarchy-dev
|
||||
SETTINGS_PACKAGE=omarchy-settings-dev
|
||||
if [[ $(basename "$ISO") != *dev* && $(basename "$ISO") != *local* && $(basename "$ISO") != *pr* ]]; then
|
||||
RUNTIME_PACKAGE=omarchy
|
||||
SETTINGS_PACKAGE=omarchy-settings
|
||||
fi
|
||||
}
|
||||
|
||||
install_phase() {
|
||||
log "Installing $(basename "$ISO") unattended via cidata (headless)"
|
||||
|
||||
[[ -f $SSH_KEY ]] || ssh-keygen -t ed25519 -N "" -q -C "omarchy-integration" -f "$SSH_KEY"
|
||||
detect_packages
|
||||
build_cidata
|
||||
|
||||
# Build under a staging name: the finished base is promoted only after a
|
||||
# clean shutdown, so a failed install can never pass for a reusable base.
|
||||
rm -f "$BASE_DISK" "$BASE_DISK.building"
|
||||
qemu-img create -f qcow2 "$BASE_DISK.building" 40G >/dev/null
|
||||
cp "$OVMF_VARS_TEMPLATE" "$BASE_OVMF"
|
||||
ACTIVE_OVMF="$BASE_OVMF"
|
||||
|
||||
start_vm "$BASE_DISK.building" "$RUN_DIR/install-serial.log" \
|
||||
-drive "file=$ISO,media=cdrom,if=none,format=raw,id=cdrom0" \
|
||||
-device ide-cd,drive=cdrom0,bootindex=2 \
|
||||
-drive "file=$CIDATA_IMG,format=raw,if=none,id=cidata" \
|
||||
-device usb-storage,drive=cidata
|
||||
|
||||
log "Waiting for the unattended install to finish (timeout ${INSTALL_TIMEOUT}s)"
|
||||
local waited=0 text progress_name
|
||||
while true; do
|
||||
# An unattended install reboots on its own; SSH answering means the
|
||||
# installed system is up (cidata's authorized_keys enables sshd).
|
||||
if ssh_guest true 2>/dev/null; then
|
||||
log "Install finished and rebooted into the installed system."
|
||||
capture_console "success-install-first-boot"
|
||||
break
|
||||
fi
|
||||
|
||||
text=$(ocr_screen)
|
||||
|
||||
if grep -qi "Reboot Now" <<<"$text"; then
|
||||
log "Install finished. Confirming the reboot prompt."
|
||||
capture_console "success-install-reboot"
|
||||
press ret
|
||||
fi
|
||||
|
||||
if grep -qi "installation stopped" <<<"$text"; then
|
||||
capture_console "failure-install-stopped"
|
||||
echo "Install failed — screenshot saved to $RUN_DIR" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! vm_running; then
|
||||
echo "VM exited during install" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ((waited >= INSTALL_TIMEOUT)); then
|
||||
capture_console "failure-install-timeout"
|
||||
echo "Timed out after ${INSTALL_TIMEOUT}s waiting for install" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# A line every 30 s so a slow runner never looks hung; a screenshot of
|
||||
# the installer's dashboard every 2 min, which is enough to see progress.
|
||||
if ((waited % 120 == 0)); then
|
||||
printf -v progress_name 'success-install-progress-%04ds' "$waited"
|
||||
capture_console "$progress_name"
|
||||
fi
|
||||
((waited % 30 == 0)) && echo " ... installing (${waited}s)"
|
||||
|
||||
sleep 10
|
||||
((waited += 10))
|
||||
done
|
||||
|
||||
# Keep the installer's own clock, its log and the first boot's numbers next
|
||||
# to the base image while the system is reachable, so CI can report them
|
||||
# without attaching the disk.
|
||||
ssh_sudo "cat /var/log/omarchy-install-timing.json" >"$BASE_DIR/omarchy-install-timing.json" 2>/dev/null || true
|
||||
ssh_sudo "cat /var/log/omarchy-install.log" >"$BASE_DIR/omarchy-install.log" 2>/dev/null || true
|
||||
# SSH can answer before startup finishes, and systemd-analyze refuses until
|
||||
# it has; wait (bounded) so the first-boot numbers are final.
|
||||
ssh_guest "timeout 120 systemctl is-system-running --wait >/dev/null; systemd-analyze" \
|
||||
>"$BASE_DIR/first-boot-systemd-analyze.txt" 2>/dev/null || true
|
||||
|
||||
log "Installed system is up. Saving base image."
|
||||
stop_vm
|
||||
mv "$BASE_DISK.building" "$BASE_DISK"
|
||||
}
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Everyday boot: boots the installed system a second time and records how
|
||||
# long it takes to answer SSH and what systemd-analyze reports, then asserts
|
||||
# that systemd finished starting with no failed units. CI reports these next
|
||||
# to the install time, so a change that slows booting shows up in its PR.
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
base_image_ready || { echo "No base image; run this through ./test/integration" >&2; exit 1; }
|
||||
|
||||
log "Booting the installed system"
|
||||
boot_started=$(date +%s%N)
|
||||
start_vm_from_base
|
||||
if ! wait_for_ssh 300 failure-boot-ssh-timeout; then
|
||||
# The console screenshot is saved; the serial log shows what the firmware,
|
||||
# loader and kernel printed, which a screenshot of a hung boot often lacks.
|
||||
echo "--- last lines of the serial console ---" >&2
|
||||
tail -n 40 "$RUN_DIR/serial.log" >&2 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
boot_ms=$((($(date +%s%N) - boot_started) / 1000000))
|
||||
# Coarse: wait_for_ssh polls every 2 s. systemd-analyze below has the exact
|
||||
# firmware, loader, kernel and userspace split.
|
||||
log "SSH answered within ${boot_ms} ms of power-on"
|
||||
|
||||
# --wait returns once startup has finished, so systemd-analyze has final
|
||||
# numbers and a unit that fails late in boot is still counted. It exits
|
||||
# non-zero for "degraded"; keep the answer so the diagnostics below are still
|
||||
# collected and the assertion reports it.
|
||||
state=$(ssh_guest "timeout 120 systemctl is-system-running --wait" 2>/dev/null | tr -d '\r' || true)
|
||||
ssh_guest "systemd-analyze" >"$RUN_DIR/systemd-analyze.txt" 2>/dev/null || true
|
||||
ssh_guest "systemd-analyze blame --no-pager | head -n 20" >"$RUN_DIR/systemd-analyze-blame.txt" 2>/dev/null || true
|
||||
# A query that fails must not read as "no failed units".
|
||||
ssh_guest "systemctl --failed --no-legend --plain" >"$RUN_DIR/failed-units.txt" 2>/dev/null ||
|
||||
echo "could not query failed units over SSH" >"$RUN_DIR/failed-units.txt"
|
||||
printf '{"boot_to_ssh_ms": %d, "system_state": "%s"}\n' "$boot_ms" "$state" >"$RUN_DIR/boot-timing.json"
|
||||
|
||||
check "systemd reports the system running (got: ${state:-nothing})" test "$state" = running
|
||||
check "no failed units" test ! -s "$RUN_DIR/failed-units.txt"
|
||||
capture_console "success-boot"
|
||||
|
||||
stop_vm
|
||||
finish
|
||||
Executable
+287
@@ -0,0 +1,287 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Factory reset on a shared ESP: proves omarchy-system-factory-reset hands a
|
||||
# machine on without destroying a dual-boot setup (basecamp/omarchy#6847).
|
||||
# Dresses the installed ESP up as a dual-boot machine (Windows + a foreign
|
||||
# Linux, exactly what the reset must not destroy), runs a real factory reset,
|
||||
# and walks the first-boot setup that follows.
|
||||
#
|
||||
# Staging asserts the Windows and foreign Linux entries and their ESP payload
|
||||
# survive, the old Omarchy identity (entry + directory) is gone, and a fresh
|
||||
# Omarchy entry exists. First boot asserts provisioning completes, the machine
|
||||
# identity changed, and the foreign entries are still intact afterwards.
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
FOREIGN_ID="fedcfedcfedcfedcfedcfedcfedcfedc"
|
||||
|
||||
base_image_ready || { echo "No base image; run this through ./test/integration" >&2; exit 1; }
|
||||
|
||||
# --------------------------------------------------------------- esp fixture
|
||||
|
||||
# Dress the ESP up as a shared dual-boot ESP: a Windows entry, and a second
|
||||
# Linux installation cloned from the real Omarchy entry so its shape is
|
||||
# exactly what limine-entry-tool writes, under a foreign machine-id with its
|
||||
# own boot directory and byte-identical UKIs (so the cloned entry hashes
|
||||
# stay valid).
|
||||
fixture_shared_esp() {
|
||||
OLD_ID=$(ssh_guest "cat /etc/machine-id" | tr -d '\r\n')
|
||||
[[ $OLD_ID =~ ^[0-9a-f]{32}$ ]] || { echo "unexpected machine-id: $OLD_ID" >&2; return 1; }
|
||||
|
||||
ssh_sudo "cp /boot/limine.conf /boot/limine.conf.pretest" >/dev/null
|
||||
ssh_sudo "
|
||||
set -euo pipefail
|
||||
awk '/^\//{block=1} block' /boot/limine.conf |
|
||||
sed -e 's/$OLD_ID/$FOREIGN_ID/g' \
|
||||
-e 's|/EFI/Linux/omarchy_|/EFI/Linux/foreign_|g' \
|
||||
-e 's|^/\(+\{0,1\}\)\([^/+]\)|/\1Foreign \2|' >/tmp/foreign-entries
|
||||
grep -q 'machine-id=$FOREIGN_ID' /tmp/foreign-entries
|
||||
for uki in /boot/EFI/Linux/omarchy_*.efi; do
|
||||
cp \"\$uki\" \"\${uki/omarchy_/foreign_}\"
|
||||
done
|
||||
cat >>/boot/limine.conf <<'CONF'
|
||||
|
||||
/Windows
|
||||
protocol: efi
|
||||
path: boot():/EFI/Microsoft/Boot/bootmgfw.efi
|
||||
CONF
|
||||
cat /tmp/foreign-entries >>/boot/limine.conf
|
||||
mkdir -p /boot/$FOREIGN_ID /boot/EFI/Microsoft/Boot
|
||||
echo foreign-payload >/boot/$FOREIGN_ID/marker
|
||||
echo windows-payload >/boot/EFI/Microsoft/Boot/bootmgfw.efi
|
||||
" >/dev/null
|
||||
|
||||
ssh_sudo "cat /boot/limine.conf" >"$RUN_DIR/limine.conf.fixtured"
|
||||
log "ESP fixtured as a shared dual-boot ESP (old machine-id $OLD_ID)"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------- reset driver
|
||||
|
||||
# Drive the interactive reset through a pty on the guest: `script` supplies
|
||||
# the terminal gum needs, a fifo feeds it answers on our schedule, and the
|
||||
# typescript lands in /tmp/reset.out for the polling below.
|
||||
start_reset() {
|
||||
# script hands the pty over at 0x0 when its own stdin is not a terminal,
|
||||
# which crashes gum's text input; give it a real size first. setsid keeps
|
||||
# both processes alive after this ssh session hangs up.
|
||||
ssh_guest "
|
||||
rm -f /tmp/reset.in /tmp/reset.out
|
||||
mkfifo /tmp/reset.in
|
||||
setsid bash -c 'exec 3<>/tmp/reset.in && sleep 3600' >/dev/null 2>&1 &
|
||||
setsid script -qefc 'stty rows 35 cols 130; sudo -S -p \"\" omarchy-system-factory-reset' /tmp/reset.out \
|
||||
</tmp/reset.in >/dev/null 2>&1 &
|
||||
"
|
||||
sleep 2
|
||||
ssh_guest "printf '%s\n' '$GUEST_PASSWORD' >/tmp/reset.in"
|
||||
}
|
||||
|
||||
reset_output() {
|
||||
ssh_guest "sed 's/\x1b\[[0-9;?]*[A-Za-z]//g; s/\x1b\][^\x07]*\x07//g' /tmp/reset.out 2>/dev/null" || true
|
||||
}
|
||||
|
||||
wait_for_reset_output() {
|
||||
local text="$1" timeout="$2" waited=0
|
||||
|
||||
until reset_output | grep -qi "$text"; do
|
||||
if reset_output | grep -qE "^Error:|COMMAND_EXIT_CODE"; then
|
||||
reset_output >"$RUN_DIR/reset.out"
|
||||
echo "The factory reset failed before reaching: $text" >&2
|
||||
reset_output | grep -E "^Error:" >&2 || true
|
||||
return 1
|
||||
fi
|
||||
if ((waited >= timeout)); then
|
||||
reset_output >"$RUN_DIR/reset.out"
|
||||
echo "Timed out after ${timeout}s waiting for reset output: $text" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 3
|
||||
((waited += 3))
|
||||
done
|
||||
}
|
||||
|
||||
reset_phase() {
|
||||
log "Booting reset VM from base image overlay"
|
||||
|
||||
start_vm_from_base
|
||||
wait_for_ssh "$BOOT_TIMEOUT"
|
||||
|
||||
fixture_shared_esp
|
||||
|
||||
log "Running omarchy-system-factory-reset"
|
||||
start_reset
|
||||
wait_for_reset_output "Type 'reset' to continue" 60
|
||||
capture_console "success-reset-confirm"
|
||||
ssh_guest "printf 'reset\r' >/tmp/reset.in"
|
||||
|
||||
# Staging clones @factory, rebuilds the UKI in a chroot, and reworks the
|
||||
# ESP; only then does the reboot prompt appear.
|
||||
wait_for_reset_output "Reboot to complete the reset" 900
|
||||
reset_output >"$RUN_DIR/reset.out"
|
||||
log "Reset staged. Asserting on the shared ESP before rebooting."
|
||||
|
||||
check "windows entry survives staging" \
|
||||
ssh_sudo "grep -q '^/Windows' /boot/limine.conf"
|
||||
check "windows boot payload survives staging" \
|
||||
ssh_sudo "grep -q windows-payload /boot/EFI/Microsoft/Boot/bootmgfw.efi"
|
||||
check "foreign linux entry survives staging" \
|
||||
ssh_sudo "grep -q 'machine-id=$FOREIGN_ID' /boot/limine.conf"
|
||||
check "foreign boot directory survives staging" \
|
||||
ssh_sudo "grep -q foreign-payload /boot/$FOREIGN_ID/marker"
|
||||
check "foreign UKI survives staging" \
|
||||
ssh_sudo "test -f /boot/EFI/Linux/foreign_linux.efi"
|
||||
check "old omarchy entry is removed by staging" \
|
||||
ssh_sudo "! grep -q 'machine-id=$OLD_ID' /boot/limine.conf"
|
||||
check "old omarchy boot directory is removed by staging" \
|
||||
ssh_sudo "! test -e /boot/$OLD_ID"
|
||||
check "a fresh omarchy entry exists after staging" \
|
||||
ssh_sudo "grep -o 'machine-id=[0-9a-f]\{32\}' /boot/limine.conf | grep -qv 'machine-id=$FOREIGN_ID'"
|
||||
|
||||
ssh_sudo "cat /boot/limine.conf" >"$RUN_DIR/limine.conf.staged" || true
|
||||
ssh_sudo "cat /var/log/omarchy-system-factory-reset.log" >"$RUN_DIR/factory-reset.log" || true
|
||||
capture_console "success-reset-staged"
|
||||
|
||||
if ((FAILURES > 0)); then
|
||||
log "Staging assertions failed; keeping the VM off the reboot path."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Decline the prompt's reboot; reboot deliberately so the ssh session
|
||||
# closing cannot race the answer.
|
||||
ssh_guest "printf 'n' >/tmp/reset.in"
|
||||
sleep 2
|
||||
log "Rebooting into the factory first boot"
|
||||
ssh_sudo "systemctl reboot" || true
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------- first boot
|
||||
|
||||
# Answer whichever setup screens the factory first boot presents. The form's
|
||||
# exact steps depend on what the reset deferred, so dispatch on the screen
|
||||
# actually showing instead of scripting a fixed sequence.
|
||||
drive_first_boot() {
|
||||
log "Driving the factory first-boot setup"
|
||||
|
||||
# The reset must leave a bootable default: the machine has to reach the
|
||||
# first-boot greeter on its own. A numeric default_entry pointing at a
|
||||
# moved entry parks Limine at the menu instead — catch that explicitly,
|
||||
# then boot the Omarchy entry by hand so the rest of the flow still runs.
|
||||
if wait_for_screen "Linux by DHH" 120 2>/dev/null; then
|
||||
printf 'ok - %s\n' "the machine boots into first-boot setup unattended"
|
||||
else
|
||||
if ocr_screen | grep -qi "Omarchy Bootloader"; then
|
||||
printf 'not ok - %s\n' "the machine boots into first-boot setup unattended (parked at the Limine menu)"
|
||||
((FAILURES += 1))
|
||||
capture_console "failure-firstboot-parked-at-menu"
|
||||
log "Selecting the Omarchy entry manually to continue the run"
|
||||
press down; sleep 1; press down; sleep 1; press down; sleep 1
|
||||
press ret
|
||||
wait_for_screen "Linux by DHH" 600
|
||||
else
|
||||
echo "Neither the greeter nor the Limine menu appeared" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
capture_console "success-firstboot-00-greeter"
|
||||
press ret
|
||||
|
||||
local waited=0 text step
|
||||
local -A answered=()
|
||||
while true; do
|
||||
text=$(ocr_screen)
|
||||
step=""
|
||||
|
||||
if grep -qi "look right" <<<"$text"; then
|
||||
capture_console "success-firstboot-03-review"
|
||||
press ret
|
||||
break
|
||||
elif grep -qi "keyboard layout" <<<"$text"; then
|
||||
step="keyboard"; [[ -v answered[$step] ]] || { capture_console "success-firstboot-01-keyboard"; press ret; }
|
||||
elif grep -qi "Username" <<<"$text"; then
|
||||
step="username"; [[ -v answered[$step] ]] || { type_text "$GUEST_USER"; press ret; }
|
||||
elif grep -qi "Conf *irm" <<<"$text"; then
|
||||
step="confirm"; [[ -v answered[$step] ]] || { type_text "$GUEST_PASSWORD"; press ret; }
|
||||
elif grep -qi "Password" <<<"$text"; then
|
||||
step="password"; [[ -v answered[$step] ]] || { type_text "$GUEST_PASSWORD"; press ret; }
|
||||
elif grep -qi "Full name" <<<"$text"; then
|
||||
step="fullname"; [[ -v answered[$step] ]] || { type_text "Omarchy Test"; press ret; }
|
||||
elif grep -qi "Email address" <<<"$text"; then
|
||||
step="email"; [[ -v answered[$step] ]] || { type_text "test@omarchy.org"; capture_console "success-firstboot-02-form"; press ret; }
|
||||
elif grep -qi "Hostname" <<<"$text"; then
|
||||
step="hostname"; [[ -v answered[$step] ]] || { type_text "$GUEST_HOSTNAME"; press ret; }
|
||||
elif grep -qi "Timezone" <<<"$text"; then
|
||||
step="timezone"; [[ -v answered[$step] ]] || press ret
|
||||
fi
|
||||
[[ -n $step ]] && answered[$step]=1
|
||||
|
||||
if ! vm_running; then
|
||||
echo "VM exited during first-boot setup" >&2
|
||||
return 1
|
||||
fi
|
||||
if ((waited >= 600)); then
|
||||
capture_console "failure-firstboot-form-timeout"
|
||||
echo "Timed out driving the first-boot form" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 3
|
||||
((waited += 3))
|
||||
done
|
||||
|
||||
capture_console "success-firstboot-04-finalizing"
|
||||
}
|
||||
|
||||
first_boot_phase() {
|
||||
drive_first_boot
|
||||
|
||||
# Finalization can still be running when the console appears; the pending
|
||||
# flag clearing is the definitive end of provisioning. The reset scrubbed
|
||||
# users, host keys, and sshd state, so SSH has to be re-authorized first.
|
||||
bootstrap_ssh
|
||||
|
||||
log "Waiting for provisioning to finish"
|
||||
local waited=0 rc
|
||||
while true; do
|
||||
rc=0
|
||||
ssh_guest "test -f /var/lib/omarchy/provisioning/pending" 2>/dev/null || rc=$?
|
||||
(( rc == 0 || rc == 255 )) || break
|
||||
if ((waited >= 900)); then
|
||||
capture_console "failure-provisioning-timeout"
|
||||
echo "Timed out waiting for first-boot provisioning to complete" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 10
|
||||
((waited += 10))
|
||||
done
|
||||
|
||||
local new_id
|
||||
new_id=$(ssh_guest "cat /etc/machine-id" | tr -d '\r\n')
|
||||
|
||||
check "provisioning completed on first boot" \
|
||||
ssh_guest "! test -f /var/lib/omarchy/provisioning/pending"
|
||||
# A well-formed identity, and not one we already know: an empty or echoed
|
||||
# ID would make the boot-entry grep below match the wrong entry.
|
||||
check "the reset minted a fresh machine identity" \
|
||||
bash -c "[[ '$new_id' =~ ^[0-9a-f]{32}\$ && '$new_id' != '$OLD_ID' && '$new_id' != '$FOREIGN_ID' ]]"
|
||||
check "windows entry survives the first boot" \
|
||||
ssh_sudo "grep -q '^/Windows' /boot/limine.conf"
|
||||
check "windows boot payload survives the first boot" \
|
||||
ssh_sudo "grep -q windows-payload /boot/EFI/Microsoft/Boot/bootmgfw.efi"
|
||||
check "foreign linux entry survives the first boot" \
|
||||
ssh_sudo "grep -q 'machine-id=$FOREIGN_ID' /boot/limine.conf"
|
||||
check "foreign boot directory survives the first boot" \
|
||||
ssh_sudo "grep -q foreign-payload /boot/$FOREIGN_ID/marker"
|
||||
check "foreign UKI survives the first boot" \
|
||||
ssh_sudo "test -f /boot/EFI/Linux/foreign_linux.efi"
|
||||
check "old omarchy identity never returns" \
|
||||
ssh_sudo "! grep -q 'machine-id=$OLD_ID' /boot/limine.conf"
|
||||
check "the new identity owns a boot entry" \
|
||||
ssh_sudo "grep -q 'machine-id=$new_id' /boot/limine.conf"
|
||||
|
||||
ssh_sudo "cat /boot/limine.conf" >"$RUN_DIR/limine.conf.final" || true
|
||||
capture_console "success-final"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------- main
|
||||
|
||||
reset_phase
|
||||
first_boot_phase
|
||||
finish
|
||||
Whitespace-only changes.
@@ -0,0 +1,224 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Unit tests for omarchy-cidata-load. The script takes a path prefix, so every
|
||||
# case runs against a throwaway sandbox with mount/umount/udevadm stubbed out:
|
||||
# "mounting" copies the fake drive's contents into the mountpoint, and every
|
||||
# stub logs its invocation so the cases can assert what was (not) called.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
CIDATA_LOAD="$ROOT/configs/airootfs/usr/local/bin/omarchy-cidata-load"
|
||||
|
||||
pass() {
|
||||
printf 'ok - %s\n' "$1"
|
||||
}
|
||||
|
||||
fail() {
|
||||
local description="$1"
|
||||
local detail="${2:-}"
|
||||
|
||||
[[ -n $detail ]] && printf '%s\n' "$detail" >&2
|
||||
printf 'not ok - %s\n' "$description" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'chmod -R u+w "$work"; rm -rf "$work"' EXIT
|
||||
|
||||
stub_dir="$work/stubs"
|
||||
mkdir -p "$stub_dir"
|
||||
|
||||
cat >"$stub_dir/udevadm" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'udevadm %s\n' "$*" >>"$TEST_LOG"
|
||||
STUB
|
||||
|
||||
cat >"$stub_dir/mount" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'mount %s\n' "$*" >>"$TEST_LOG"
|
||||
[[ ${MOUNT_FAIL:-} == 1 ]] && exit 32
|
||||
device=$3 mountpoint=$4
|
||||
cp -a "$(readlink -f "$device")"/. "$mountpoint"/
|
||||
STUB
|
||||
|
||||
cat >"$stub_dir/umount" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'umount %s\n' "$*" >>"$TEST_LOG"
|
||||
STUB
|
||||
|
||||
chmod +x "$stub_dir"/*
|
||||
|
||||
new_sandbox() {
|
||||
sandbox=$(mktemp -d "$work/sandbox.XXXXXX")
|
||||
mkdir -p "$sandbox/dev/disk/by-label" "$sandbox/root" "$sandbox/media"
|
||||
export TEST_LOG="$sandbox/calls.log"
|
||||
: >"$TEST_LOG"
|
||||
}
|
||||
|
||||
attach_drive() {
|
||||
ln -s "$sandbox/media" "$sandbox/dev/disk/by-label/$1"
|
||||
}
|
||||
|
||||
run_load() {
|
||||
PATH="$stub_dir:$PATH" "$CIDATA_LOAD" "$sandbox"
|
||||
}
|
||||
|
||||
write_required_pair() {
|
||||
echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json"
|
||||
echo '{"users": []}' >"$sandbox/media/user_credentials.json"
|
||||
}
|
||||
|
||||
# No cidata drive attached: fall back to the wizard without mounting anything.
|
||||
new_sandbox
|
||||
! run_load || fail "no drive exits non-zero"
|
||||
! grep -q '^mount ' "$TEST_LOG" || fail "no drive mounts nothing"
|
||||
pass "no drive falls back to the wizard"
|
||||
|
||||
# The probe must wait for udev to finish enumerating before concluding there
|
||||
# is no drive.
|
||||
grep -q '^udevadm settle$' "$TEST_LOG" || fail "probe settles udev first"
|
||||
pass "probe settles udev first"
|
||||
|
||||
# A drive with the full file set: everything lands in /root and the drive is
|
||||
# unmounted afterwards.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
echo "Jeff" >"$sandbox/media/user_full_name.txt"
|
||||
echo "jeff@example.com" >"$sandbox/media/user_email_address.txt"
|
||||
echo "false" >"$sandbox/media/user_encrypt_installation.txt"
|
||||
echo 'ssh-ed25519 AAAA jeff@host' >"$sandbox/media/authorized_keys"
|
||||
echo 'tskey-auth-kFAKEKEY' >"$sandbox/media/tailscale_authkey"
|
||||
run_load || fail "full file set loads"
|
||||
for file in user_configuration.json user_credentials.json user_full_name.txt user_email_address.txt user_encrypt_installation.txt authorized_keys tailscale_authkey; do
|
||||
[[ -f $sandbox/root/$file ]] || fail "full file set copies $file"
|
||||
done
|
||||
grep -q '^umount ' "$TEST_LOG" || fail "full file set unmounts the drive"
|
||||
pass "full file set loads, copies everything, and unmounts"
|
||||
|
||||
# The uppercase label variant some tools produce works too.
|
||||
new_sandbox
|
||||
attach_drive CIDATA
|
||||
write_required_pair
|
||||
run_load || fail "uppercase CIDATA label loads"
|
||||
pass "uppercase CIDATA label loads"
|
||||
|
||||
# The required pair alone is a valid autoinstall drive; the optional files
|
||||
# stay optional.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
run_load || fail "required pair alone loads"
|
||||
[[ ! -e $sandbox/root/authorized_keys ]] || fail "required pair alone copies no optional files"
|
||||
pass "required pair alone loads without optional files"
|
||||
|
||||
# Optional files are copied individually when present.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
echo 'ssh-ed25519 AAAA jeff@host' >"$sandbox/media/authorized_keys"
|
||||
run_load || fail "required pair plus authorized_keys loads"
|
||||
[[ -f $sandbox/root/authorized_keys ]] || fail "authorized_keys is copied when present"
|
||||
[[ ! -e $sandbox/root/user_full_name.txt ]] || fail "absent optional files are not copied"
|
||||
[[ ! -e $sandbox/root/tailscale_authkey ]] || fail "absent tailscale_authkey is not copied"
|
||||
pass "present optional files are copied, absent ones skipped"
|
||||
|
||||
# A defer-provisioning marker replaces user_credentials.json: deferred-provisioning installs
|
||||
# creation to first boot, so imaging rigs ship no credentials at all.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json"
|
||||
: >"$sandbox/media/defer-provisioning"
|
||||
run_load || fail "config plus defer-provisioning marker loads"
|
||||
[[ -f $sandbox/root/defer-provisioning ]] || fail "defer-provisioning marker is copied"
|
||||
[[ ! -e $sandbox/root/user_credentials.json ]] || fail "defer-provisioning drive copies no credentials"
|
||||
pass "defer-provisioning marker stands in for credentials"
|
||||
|
||||
# The defer-provisioning marker and credentials can coexist (rig supplies its own LUKS
|
||||
# passphrase in the credentials file); both are copied.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
: >"$sandbox/media/defer-provisioning"
|
||||
run_load || fail "defer-provisioning marker plus credentials loads"
|
||||
[[ -f $sandbox/root/defer-provisioning && -f $sandbox/root/user_credentials.json ]] || fail "both defer-provisioning marker and credentials are copied"
|
||||
pass "defer-provisioning marker plus credentials copies both"
|
||||
|
||||
# An defer-provisioning marker without the configuration is still not an autoinstall drive.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
: >"$sandbox/media/defer-provisioning"
|
||||
! run_load || fail "defer-provisioning marker alone is not an autoinstall drive"
|
||||
[[ ! -e $sandbox/root/defer-provisioning ]] || fail "defer-provisioning marker alone copies nothing"
|
||||
pass "defer-provisioning marker alone falls back to the wizard"
|
||||
|
||||
# Stale deferred-provisioning inputs from a previous load in the same session are cleared before
|
||||
# the current drive is copied: a normal drive must not inherit an old defer-provisioning
|
||||
# marker or credentials.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
: >"$sandbox/root/defer-provisioning" # leftover from a prior deferred-provisioning load
|
||||
echo 'old-keys' >"$sandbox/root/authorized_keys"
|
||||
run_load || fail "normal drive after a stale defer-provisioning load loads"
|
||||
[[ ! -e $sandbox/root/defer-provisioning ]] || fail "stale defer-provisioning marker is cleared"
|
||||
[[ ! -e $sandbox/root/authorized_keys ]] || fail "stale optional inputs are cleared"
|
||||
pass "stale deferred-provisioning inputs are cleared before loading a normal drive"
|
||||
|
||||
# A drive that isn't an autoinstall drive at all still clears stale inputs so
|
||||
# the wizard that follows doesn't inherit them.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json" # half a pair
|
||||
: >"$sandbox/root/defer-provisioning"
|
||||
! run_load || fail "half-pair drive still falls back"
|
||||
[[ ! -e $sandbox/root/defer-provisioning ]] || fail "stale defer-provisioning marker cleared even on fallback"
|
||||
pass "stale inputs are cleared even when falling back to the wizard"
|
||||
|
||||
# Half the required pair is not an autoinstall drive: unmount and fall back.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json"
|
||||
! run_load || fail "half the required pair exits non-zero"
|
||||
[[ ! -e $sandbox/root/user_configuration.json ]] || fail "half the required pair copies nothing"
|
||||
grep -q '^umount ' "$TEST_LOG" || fail "half the required pair still unmounts"
|
||||
pass "half the required pair falls back and unmounts"
|
||||
|
||||
# An empty drive labeled cidata is not an autoinstall drive either.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
! run_load || fail "empty drive exits non-zero"
|
||||
grep -q '^umount ' "$TEST_LOG" || fail "empty drive still unmounts"
|
||||
pass "empty drive falls back and unmounts"
|
||||
|
||||
# A drive that will not mount falls back rather than failing the boot.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
! MOUNT_FAIL=1 run_load || fail "mount failure exits non-zero"
|
||||
! grep -q '^umount ' "$TEST_LOG" || fail "mount failure has nothing to unmount"
|
||||
pass "mount failure falls back to the wizard"
|
||||
|
||||
# A copy failure must not report a loaded drive: the install would start with
|
||||
# missing inputs. Fall back and let the wizard produce them instead.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
chmod 555 "$sandbox/root"
|
||||
! run_load 2>/dev/null || fail "copy failure exits non-zero"
|
||||
grep -q '^umount ' "$TEST_LOG" || fail "copy failure still unmounts"
|
||||
pass "copy failure falls back and unmounts"
|
||||
|
||||
# A partial copy must clean up after itself: the wizard removes only what it
|
||||
# writes, so anything the loader left behind would leak into the interactive
|
||||
# install that follows.
|
||||
new_sandbox
|
||||
attach_drive cidata
|
||||
write_required_pair
|
||||
echo 'ssh-ed25519 AAAA jeff@host' >"$sandbox/media/authorized_keys"
|
||||
mkdir "$sandbox/root/user_credentials.json"
|
||||
! run_load 2>/dev/null || fail "partial copy exits non-zero"
|
||||
[[ ! -e $sandbox/root/user_configuration.json ]] || fail "partial copy removes what it copied"
|
||||
[[ ! -e $sandbox/root/authorized_keys ]] || fail "partial copy leaves no authorized_keys behind"
|
||||
pass "partial copy cleans up what it copied"
|
||||
Executable
+452
@@ -0,0 +1,452 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Unit tests for omarchy-install-diagnose-media and the failure screen that
|
||||
# renders it. Every case builds a throwaway offline mirror -- a package file
|
||||
# and a real repo-add-shaped offline.db naming its sha256 -- so the three
|
||||
# verdicts are told apart by the same evidence the live ISO has.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
DIAGNOSE="$ROOT/configs/airootfs/usr/local/bin/omarchy-install-diagnose-media"
|
||||
DASHBOARD="$ROOT/configs/airootfs/usr/local/bin/omarchy-install-dashboard"
|
||||
PACKAGE="npth-1.8-1-x86_64.pkg.tar.zst"
|
||||
TARGET_CACHE="/mnt/var/cache/pacman/pkg"
|
||||
|
||||
pass() {
|
||||
printf 'ok - %s\n' "$1"
|
||||
}
|
||||
|
||||
fail() {
|
||||
local description="$1"
|
||||
local detail="${2:-}"
|
||||
|
||||
[[ -n $detail ]] && printf '%s\n' "$detail" >&2
|
||||
printf 'not ok - %s\n' "$description" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
mirror="$work/mirror"
|
||||
mkdir -p "$mirror"
|
||||
|
||||
# repo-add writes one desc record per package, %FILENAME% before %SHA256SUM%.
|
||||
# Building a real gzipped tar of that shape keeps the parser honest.
|
||||
write_mirror_db() {
|
||||
local checksum="$1" filename="${2:-$PACKAGE}" staging="$work/db"
|
||||
|
||||
rm -rf "$staging"
|
||||
mkdir -p "$staging/npth-1.8-1"
|
||||
{
|
||||
printf '%%FILENAME%%\n%s\n\n' "$filename"
|
||||
printf '%%NAME%%\nnpth\n\n'
|
||||
printf '%%VERSION%%\n1.8-1\n\n'
|
||||
printf '%%SHA256SUM%%\n%s\n\n' "$checksum"
|
||||
} >"$staging/npth-1.8-1/desc"
|
||||
|
||||
# A second package proves the lookup matches on name rather than on order.
|
||||
mkdir -p "$staging/zlib-1.3-1"
|
||||
{
|
||||
printf '%%FILENAME%%\nzlib-1.3-1-x86_64.pkg.tar.zst\n\n'
|
||||
printf '%%NAME%%\nzlib\n\n'
|
||||
printf '%%SHA256SUM%%\n%s\n\n' "$(printf 'f%.0s' {1..64})"
|
||||
} >"$staging/zlib-1.3-1/desc"
|
||||
|
||||
tar -czf "$mirror/offline.db" -C "$staging" npth-1.8-1 zlib-1.3-1
|
||||
}
|
||||
|
||||
write_log() {
|
||||
local log="$1" path="${2:-$TARGET_CACHE/$PACKAGE}"
|
||||
|
||||
{
|
||||
echo "[dashboard] checking package integrity..."
|
||||
echo "[dashboard] :: File $path is corrupted (invalid or corrupted package)."
|
||||
echo "[dashboard] error: failed to commit transaction (invalid or corrupted package)"
|
||||
echo "[dashboard] ==> ERROR: Failed to install packages to new root"
|
||||
} >"$log"
|
||||
}
|
||||
|
||||
diagnose() {
|
||||
OMARCHY_OFFLINE_MIRROR="$mirror" OMARCHY_TARGET_PACKAGE_CACHE="$TARGET_CACHE" \
|
||||
"$DIAGNOSE" "$@"
|
||||
}
|
||||
|
||||
log="$work/install.log"
|
||||
write_log "$log"
|
||||
|
||||
# The medium was written wrong: the package on the ISO no longer hashes to what
|
||||
# the build recorded for it.
|
||||
printf 'a package, but damaged\n' >"$mirror/$PACKAGE"
|
||||
write_mirror_db "$(printf '0%.0s' {1..64})"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$log")
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
(( status == 0 )) || fail "a checksum mismatch is diagnosed" "exit status $status"
|
||||
[[ $(head -n 1 <<<"$output") == "The install medium is damaged" ]] ||
|
||||
fail "a checksum mismatch is diagnosed" "$output"
|
||||
grep -qF "$PACKAGE" <<<"$output" ||
|
||||
fail "the diagnosis names the package" "$output"
|
||||
grep -qF "no longer matches the checksum" <<<"$output" ||
|
||||
fail "the diagnosis says the checksum disagrees" "$output"
|
||||
grep -qF "sha256sum" <<<"$output" ||
|
||||
fail "the diagnosis says how to verify a fresh download" "$output"
|
||||
pass "a checksum mismatch says the medium is damaged and names the package"
|
||||
|
||||
# The medium reads clean now, so the bytes were misread rather than written
|
||||
# wrong. Re-downloading fixes nothing, and the advice has to say so.
|
||||
write_mirror_db "$(sha256sum "$mirror/$PACKAGE" | cut -d " " -f 1)"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$log")
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
(( status == 0 )) || fail "an intact package is still diagnosed" "exit status $status"
|
||||
[[ $(head -n 1 <<<"$output") == "The install medium was misread" ]] ||
|
||||
fail "an intact package is diagnosed as a misread" "$output"
|
||||
grep -qF "another USB port" <<<"$output" ||
|
||||
fail "a misread points at the hardware" "$output"
|
||||
if grep -qF "Re-download" <<<"$output"; then
|
||||
fail "a misread does not send anyone to re-download" "$output"
|
||||
fi
|
||||
pass "an intact package on the medium is diagnosed as a misread, not a bad download"
|
||||
|
||||
# The usual case. pacstrap runs with --noconfirm, which answers yes to pacman's
|
||||
# "delete it?" and unlinks the package through the bind mount, so by the time
|
||||
# anything here looks there is nothing left to weigh. The verdict must name the
|
||||
# medium without claiming a comparison it never made, and must offer both
|
||||
# remedies: a bad write and a bad read leave identical evidence.
|
||||
rm "$mirror/$PACKAGE"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$log")
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
(( status == 0 )) || fail "a deleted package is still diagnosed" "exit status $status"
|
||||
[[ $(head -n 1 <<<"$output") == "The install medium is damaged or misread" ]] ||
|
||||
fail "a deleted package is diagnosed without over-claiming" "$output"
|
||||
grep -qF "read straight off this ISO" <<<"$output" ||
|
||||
fail "a deleted package still names the medium" "$output"
|
||||
grep -qF "sha256sum" <<<"$output" ||
|
||||
fail "a deleted package offers the download remedy" "$output"
|
||||
grep -qF "memory is at fault" <<<"$output" ||
|
||||
fail "a deleted package offers the hardware remedy too" "$output"
|
||||
if grep -qF "no longer matches the checksum" <<<"$output"; then
|
||||
fail "a deleted package claims no comparison" "$output"
|
||||
fi
|
||||
pass "a deleted package names the medium without claiming which way it failed"
|
||||
|
||||
# A record with no %SHA256SUM% must not borrow the next record's, which would
|
||||
# compare a real file against another package's checksum.
|
||||
printf 'a package, but damaged\n' >"$mirror/$PACKAGE"
|
||||
staging="$work/db"
|
||||
rm -rf "$staging"
|
||||
mkdir -p "$staging/npth-1.8-1" "$staging/zlib-1.3-1"
|
||||
printf '%%FILENAME%%\n%s\n\n%%NAME%%\nnpth\n\n' "$PACKAGE" >"$staging/npth-1.8-1/desc"
|
||||
{
|
||||
printf '%%FILENAME%%\nzlib-1.3-1-x86_64.pkg.tar.zst\n\n'
|
||||
printf '%%SHA256SUM%%\n%s\n\n' "$(sha256sum "$mirror/$PACKAGE" | cut -d " " -f 1)"
|
||||
} >"$staging/zlib-1.3-1/desc"
|
||||
tar -czf "$mirror/offline.db" -C "$staging" npth-1.8-1 zlib-1.3-1
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$log")
|
||||
set -e
|
||||
|
||||
[[ $(head -n 1 <<<"$output") == "The install medium is damaged or misread" ]] ||
|
||||
fail "a record without a checksum borrows nobody else's" "$output"
|
||||
pass "a record without a checksum borrows nobody else's"
|
||||
|
||||
# A package version may legally hold a backslash. It must not reach a terminal
|
||||
# as an escape sequence, and awk must look it up literally rather than as one.
|
||||
escaped='demo-1\033[2J-1-x86_64.pkg.tar.zst'
|
||||
write_log "$work/escaped.log" "$TARGET_CACHE/$escaped"
|
||||
printf 'a package, but damaged\n' >"$mirror/$escaped"
|
||||
write_mirror_db "$(printf '0%.0s' {1..64})" "$escaped"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$work/escaped.log")
|
||||
set -e
|
||||
|
||||
# The dashboard renders these lines through printf %b, which turns a surviving
|
||||
# backslash into whatever escape it spells. None may reach it.
|
||||
if grep -qF '\' <<<"$output"; then
|
||||
fail "a backslash in a package name never reaches the renderer" "$(cat -v <<<"$output")"
|
||||
fi
|
||||
grep -qF "demo-1033" <<<"$output" ||
|
||||
fail "the sanitized name still identifies the package" "$output"
|
||||
# The database record is found despite the backslash, so the verdict is the
|
||||
# mismatch rather than the one that means no comparison could be made.
|
||||
[[ $(head -n 1 <<<"$output") == "The install medium is damaged" ]] ||
|
||||
fail "a backslash in a package name is looked up literally" "$output"
|
||||
pass "a backslash in a package name is looked up literally and never rendered as an escape"
|
||||
rm "$mirror/$escaped"
|
||||
|
||||
# The live ISO has bsdtar through pacman's libarchive, but the tar fallback is
|
||||
# the one that runs if that ever stops being true.
|
||||
printf 'a package, but damaged\n' >"$mirror/$PACKAGE"
|
||||
write_mirror_db "$(sha256sum "$mirror/$PACKAGE" | cut -d " " -f 1)"
|
||||
no_bsdtar="$work/no-bsdtar"
|
||||
mkdir -p "$no_bsdtar"
|
||||
for tool in sed awk tar gzip sha256sum cat grep head tail cut printf; do
|
||||
command -v "$tool" >/dev/null && ln -sf "$(command -v "$tool")" "$no_bsdtar/$tool"
|
||||
done
|
||||
|
||||
set +e
|
||||
output=$(PATH="$no_bsdtar" diagnose "$log")
|
||||
set -e
|
||||
|
||||
[[ $(head -n 1 <<<"$output") == "The install medium was misread" ]] ||
|
||||
fail "the tar fallback reads the database when bsdtar is absent" "$output"
|
||||
pass "the tar fallback reads the database when bsdtar is absent"
|
||||
|
||||
printf 'a package, but damaged\n' >"$mirror/$PACKAGE"
|
||||
write_mirror_db "$(printf '0%.0s' {1..64})"
|
||||
|
||||
# A corrupt package that was never read off this ISO is somebody else's
|
||||
# problem. Guessing here sends people to buy a USB stick they did not need.
|
||||
write_log "$work/elsewhere.log" "/var/tmp/build/$PACKAGE"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$work/elsewhere.log")
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
(( status == 1 )) || fail "corruption outside the target cache is not diagnosed" "exit $status: $output"
|
||||
[[ -z $output ]] || fail "corruption outside the target cache prints nothing" "$output"
|
||||
pass "corruption outside the target cache is not blamed on the medium"
|
||||
|
||||
# An ordinary failure has no media diagnosis, and the caller asks
|
||||
# unconditionally, so silence has to be the answer.
|
||||
printf 'error: something else went wrong entirely\n' >"$work/other.log"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$work/other.log")
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
(( status == 1 )) || fail "an unrelated failure is not diagnosed" "exit $status: $output"
|
||||
[[ -z $output ]] || fail "an unrelated failure prints nothing" "$output"
|
||||
pass "an unrelated failure produces no diagnosis"
|
||||
|
||||
set +e
|
||||
output=$(diagnose "$work/does-not-exist.log")
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
(( status == 1 )) || fail "a missing log is not diagnosed" "exit $status: $output"
|
||||
pass "a missing log produces no diagnosis"
|
||||
|
||||
# End to end: the dashboard runs a failing installer and the diagnosis has to
|
||||
# reach both the screen and the support log, above the tail it explains.
|
||||
#
|
||||
# The screen goes through a real pty rather than a file. The dashboard's exit
|
||||
# handler reopens its TTY with a truncating redirect, which does nothing to a
|
||||
# character device and empties a regular file, so a file would capture nothing.
|
||||
stubs="$work/stubs"
|
||||
mkdir -p "$stubs"
|
||||
{
|
||||
echo '#!/bin/bash'
|
||||
echo "OMARCHY_OFFLINE_MIRROR='$mirror' OMARCHY_TARGET_PACKAGE_CACHE='$TARGET_CACHE' exec '$DIAGNOSE' \"\$@\""
|
||||
} >"$stubs/omarchy-install-diagnose-media"
|
||||
chmod +x "$stubs/omarchy-install-diagnose-media"
|
||||
|
||||
state_file="$work/state.json"
|
||||
screen="$work/screen"
|
||||
|
||||
# A ten-line logo, the height of the real one. Without it the dashboard falls
|
||||
# back to a single centred word and the screen can never be tall enough to
|
||||
# overflow, which is exactly the case worth testing.
|
||||
omarchy_share="$work/share"
|
||||
mkdir -p "$omarchy_share"
|
||||
# 81 columns wide, like the real logo: the dashboard takes its content width
|
||||
# from the logo, and a narrow one would truncate every line under test.
|
||||
{
|
||||
printf 'LOGO TOP ROW%*s\n' 69 ''
|
||||
for n in 2 3 4 5 6 7 8 9; do printf 'logo row %s%*s\n' "$n" 71 ''; done
|
||||
printf 'logo bottom row%*s\n' 66 ''
|
||||
} >"$omarchy_share/logo.txt"
|
||||
|
||||
run_dashboard() {
|
||||
local install_log="$1"
|
||||
|
||||
# A real failure carries the failed phase as well as the current one, and
|
||||
# that second summary line is another row the screen has to find space for.
|
||||
cat >"$state_file" <<'STATE'
|
||||
{"current_phase": "Installing Arch + Omarchy",
|
||||
"phases": [{"name": "Installing Arch + Omarchy", "status": "failed",
|
||||
"error": "Pacstrap failed. See /var/log/archinstall.log"}]}
|
||||
STATE
|
||||
: >"$screen"
|
||||
script -qefc "stty rows 40 cols 120; PATH='$stubs:$PATH' OMARCHY_PATH='$omarchy_share' OMARCHY_UI_INTERACTIVE=no OMARCHY_UI_FAILURE_ACTION=exit OMARCHY_FAILURE_TAIL_LOG='$install_log' '$DASHBOARD' '$install_log' '$state_file' -- bash -c 'exit 1'" \
|
||||
"$screen" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
visible_screen() {
|
||||
# Carriage returns as well as escapes: the pty ends every line with one, and
|
||||
# a row that looks blank still carries it.
|
||||
sed -E $'s/\x1b\\[[0-9;?]*[A-Za-z]//g; s/\r//g' "$screen"
|
||||
}
|
||||
|
||||
dashboard_log="$work/dashboard.log"
|
||||
write_log "$dashboard_log"
|
||||
|
||||
# A real install log is longer than the tail can show, so the tail actually
|
||||
# spends its whole budget. A short one hides an over-tall screen.
|
||||
{
|
||||
for n in $(seq 1 20); do printf '[dashboard] installing package %s\n' "$n"; done
|
||||
cat "$dashboard_log"
|
||||
} >"$dashboard_log.padded"
|
||||
mv "$dashboard_log.padded" "$dashboard_log"
|
||||
|
||||
# State the case rather than inheriting whichever verdict the previous one left
|
||||
# behind: this is the shape a real install fails in, with pacman having deleted
|
||||
# the package it rejected.
|
||||
rm -f "$mirror/$PACKAGE"
|
||||
write_mirror_db "$(printf '0%.0s' {1..64})"
|
||||
|
||||
set +e
|
||||
run_dashboard "$dashboard_log"
|
||||
dashboard_status=$?
|
||||
set -e
|
||||
|
||||
(( dashboard_status == 1 )) ||
|
||||
fail "the dashboard still exits with the installer's status" "exit $dashboard_status"
|
||||
visible_screen | grep -qF "The install medium is damaged" ||
|
||||
fail "the failure screen shows the diagnosis" "$(visible_screen | tail -n 25)"
|
||||
visible_screen | grep -qF "$PACKAGE" ||
|
||||
fail "the failure screen names the package" "$(visible_screen | tail -n 25)"
|
||||
grep -qF "[dashboard] The install medium is damaged" "$dashboard_log" ||
|
||||
fail "the diagnosis is written to the support log" "$(tail -n 20 "$dashboard_log")"
|
||||
|
||||
# Once on the screen. The log tail rendered underneath reads the same file the
|
||||
# diagnosis is recorded in, and the same finding printed twice reads as two.
|
||||
headline_count=$(visible_screen | grep -cF "The install medium is damaged or misread" || true)
|
||||
(( headline_count == 1 )) ||
|
||||
fail "the diagnosis appears once on the screen" "found $headline_count times"
|
||||
|
||||
# The renderer used to drop blank lines, so the break has to be checked where
|
||||
# it matters: on the screen, not only in the text the helper produced.
|
||||
package_row=$(visible_screen | grep -nF "$PACKAGE" | grep -v "dashboard" | head -n 1 | cut -d: -f1)
|
||||
[[ -n $package_row ]] ||
|
||||
fail "the screen names the package on its own row" "$(visible_screen | tail -n 25)"
|
||||
next_row=$(visible_screen | sed -n "$((package_row + 1))p")
|
||||
[[ -z ${next_row// /} ]] ||
|
||||
fail "the screen breaks after the package" "next row was: $next_row"
|
||||
pass "the dashboard renders the diagnosis once, with the break, and logs it"
|
||||
|
||||
# The diagnosis costs rows the log tail's budget knew nothing about, so a
|
||||
# screen carrying one scrolled its own logo off the top of the console. The
|
||||
# tail gives those rows back now, which is visible as a shorter tail: count the
|
||||
# filler lines it reaches, with a diagnosis and without one.
|
||||
#
|
||||
# Asserting the logo is still on screen would be the direct test, and it cannot
|
||||
# be written here: this reads the output stream, which keeps every row ever
|
||||
# emitted whether or not it stayed visible. Only a terminal emulator could tell
|
||||
# the difference, so the mechanism is what gets checked.
|
||||
tail_filler_rows() {
|
||||
visible_screen | grep -c "installing package" || true
|
||||
}
|
||||
|
||||
with_diagnosis=$(tail_filler_rows)
|
||||
|
||||
# The same log line for line, differing only in the one path that decides
|
||||
# whether there is a diagnosis at all. Two differently shaped logs would show
|
||||
# different amounts of filler for reasons that have nothing to do with the
|
||||
# budget, and the comparison would prove nothing.
|
||||
elsewhere_log="$work/elsewhere-padded.log"
|
||||
write_log "$elsewhere_log" "/var/tmp/build/$PACKAGE"
|
||||
{
|
||||
for n in $(seq 1 20); do printf '[dashboard] installing package %s\n' "$n"; done
|
||||
cat "$elsewhere_log"
|
||||
} >"$elsewhere_log.padded"
|
||||
mv "$elsewhere_log.padded" "$elsewhere_log"
|
||||
|
||||
set +e
|
||||
run_dashboard "$elsewhere_log"
|
||||
set -e
|
||||
without_diagnosis=$(tail_filler_rows)
|
||||
|
||||
(( with_diagnosis < without_diagnosis )) ||
|
||||
fail "the tail gives up rows to the diagnosis" \
|
||||
"with: $with_diagnosis, without: $without_diagnosis"
|
||||
pass "the log tail gives up rows to the diagnosis so the screen still fits"
|
||||
|
||||
# The screen is only as wide as the logo and the dashboard truncates to it with
|
||||
# an ellipsis. Every sentence has to survive that, whatever the package is
|
||||
# called, or the advice arrives with its second half cut off.
|
||||
long_package="linux-firmware-nvidia-tegra-20250917.0e800e46-1-any.pkg.tar.zst"
|
||||
long_log="$work/long.log"
|
||||
write_log "$long_log" "$TARGET_CACHE/$long_package"
|
||||
|
||||
check_widths() {
|
||||
local label="$1" line
|
||||
while IFS= read -r line; do
|
||||
(( ${#line} <= 81 )) ||
|
||||
fail "no diagnosis line outruns the screen ($label)" "${#line} chars: $line"
|
||||
done < <(diagnose "$long_log")
|
||||
}
|
||||
|
||||
# The package line and the remedy that follows it are two different thoughts,
|
||||
# so a blank line separates them in every verdict.
|
||||
check_break() {
|
||||
local label="$1" package="$2" out
|
||||
out=$(diagnose "$long_log")
|
||||
local -a lines
|
||||
mapfile -t lines <<<"$out"
|
||||
|
||||
local i
|
||||
for i in "${!lines[@]}"; do
|
||||
[[ ${lines[i]} == "$package" ]] || continue
|
||||
[[ -z ${lines[i + 1]-x} ]] ||
|
||||
fail "a break follows the package ($label)" "$out"
|
||||
[[ -n ${lines[i + 2]-} ]] ||
|
||||
fail "the remedy follows the break ($label)" "$out"
|
||||
return 0
|
||||
done
|
||||
fail "the package is on a line of its own ($label)" "$out"
|
||||
}
|
||||
|
||||
# All three verdicts, since each writes its own sentences.
|
||||
rm -f "$mirror/$long_package"
|
||||
check_widths "deleted"
|
||||
check_break "deleted" "$long_package"
|
||||
printf 'these are not the bytes that were built\n' >"$mirror/$long_package"
|
||||
write_mirror_db "$(printf '0%.0s' {1..64})" "$long_package"
|
||||
check_widths "damaged"
|
||||
check_break "damaged" "$long_package"
|
||||
write_mirror_db "$(sha256sum "$mirror/$long_package" | cut -d " " -f 1)" "$long_package"
|
||||
check_widths "misread"
|
||||
check_break "misread" "$long_package"
|
||||
rm -f "$mirror/$long_package"
|
||||
pass "no diagnosis line outruns the screen, even with a long package name"
|
||||
pass "a break separates the package from the remedy in every verdict"
|
||||
|
||||
# A failure with no media explanation must leave the screen as it was, rather
|
||||
# than gaining a banner or an empty gap where the diagnosis would go.
|
||||
printf 'error: something else went wrong entirely\n' >"$work/plain.log"
|
||||
|
||||
set +e
|
||||
run_dashboard "$work/plain.log"
|
||||
set -e
|
||||
|
||||
if visible_screen | grep -qF "install medium"; then
|
||||
fail "an unrelated failure gets no media banner" "$(visible_screen | tail -n 25)"
|
||||
fi
|
||||
visible_screen | grep -qF "Omarchy installation stopped" ||
|
||||
fail "an unrelated failure still renders the normal failure screen" "$(visible_screen | tail -n 25)"
|
||||
pass "an unrelated failure renders the failure screen unchanged"
|
||||
|
||||
# The failure menu redraws the screen after uploading or viewing the log, and a
|
||||
# redraw that drops the diagnosis loses it exactly when someone went looking.
|
||||
# Those paths need gum and a person at the keyboard, so they are checked here.
|
||||
missing_redraw=$(grep -n 'render_failure "' "$DASHBOARD" | grep -v 'failure_media_diagnosis' || true)
|
||||
[[ -z $missing_redraw ]] ||
|
||||
fail "every failure-screen redraw carries the diagnosis" "$missing_redraw"
|
||||
pass "every failure-screen redraw carries the diagnosis"
|
||||
Executable
+175
@@ -0,0 +1,175 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Unit tests for the checksum sidecar omarchy-iso-release writes and
|
||||
# omarchy-iso-upload ships. Both scripts derive everything from their own
|
||||
# location and their argument, so each case runs against a throwaway sandbox
|
||||
# with the real script copied in and rclone/sign/upload stubbed out.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
|
||||
pass() {
|
||||
printf 'ok - %s\n' "$1"
|
||||
}
|
||||
|
||||
fail() {
|
||||
local description="$1"
|
||||
local detail="${2:-}"
|
||||
|
||||
[[ -n $detail ]] && printf '%s\n' "$detail" >&2
|
||||
printf 'not ok - %s\n' "$description" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
# omarchy-iso-release resolves its release directory from the script's own
|
||||
# path, so relocating the script is what points it at the sandbox.
|
||||
sandbox="$work/repo"
|
||||
mkdir -p "$sandbox/bin" "$sandbox/release" "$work/stubs"
|
||||
cp "$ROOT/bin/omarchy-iso-release" "$sandbox/bin/"
|
||||
printf 'not really an iso\n' >"$sandbox/release/omarchy-2099.01.01-x86_64-quattro.iso"
|
||||
|
||||
cat >"$work/stubs/omarchy-iso-sign" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'signature\n' >"$1.sig"
|
||||
STUB
|
||||
|
||||
cat >"$work/stubs/omarchy-iso-upload" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'upload %s\n' "$*" >>"$TEST_LOG"
|
||||
STUB
|
||||
|
||||
# Log one argument per field rather than "$*": the point of several cases below
|
||||
# is that a path survives as a single argument, which "$*" cannot show.
|
||||
cat >"$work/stubs/rclone" <<'STUB'
|
||||
#!/bin/bash
|
||||
printf 'rclone'
|
||||
printf '|%s' "$@"
|
||||
printf '\n'
|
||||
[[ -n ${RCLONE_FAIL_ON:-} && $* == *"$RCLONE_FAIL_ON"* ]] && exit 1
|
||||
exit 0
|
||||
STUB
|
||||
|
||||
chmod +x "$work/stubs"/*
|
||||
|
||||
export TEST_LOG="$work/log"
|
||||
: >"$TEST_LOG"
|
||||
|
||||
run_upload() {
|
||||
PATH="$work/stubs:$PATH" "$ROOT/bin/omarchy-iso-upload" "$@" >"$work/rclone-log" 2>"$work/upload-err"
|
||||
}
|
||||
|
||||
PATH="$work/stubs:$PATH" "$sandbox/bin/omarchy-iso-release" --no-make 9.9.9 >/dev/null
|
||||
|
||||
release_iso="$sandbox/release/omarchy-9.9.9.iso"
|
||||
checksum_file="$release_iso.sha256"
|
||||
|
||||
[[ -f $checksum_file ]] ||
|
||||
fail "release writes a checksum beside the ISO" "missing: $checksum_file"
|
||||
pass "release writes a checksum beside the ISO"
|
||||
|
||||
# The name in the file has to be the ISO alone. A build path in there verifies
|
||||
# only on the release machine, which is the one machine that never needs it.
|
||||
expected="$(sha256sum "$release_iso" | cut -d " " -f 1) omarchy-9.9.9.iso"
|
||||
actual="$(cat "$checksum_file")"
|
||||
[[ $actual == "$expected" ]] ||
|
||||
fail "the checksum names the ISO alone" "expected: $expected"$'\n'"actual: $actual"
|
||||
pass "the checksum names the ISO alone"
|
||||
|
||||
(cd "$sandbox/release" && sha256sum -c --status omarchy-9.9.9.iso.sha256) ||
|
||||
fail "sha256sum -c verifies the ISO from its own directory"
|
||||
pass "sha256sum -c verifies the ISO from its own directory"
|
||||
|
||||
# The whole point of the sidecar is catching bytes that changed after release,
|
||||
# so prove it fails on bytes that changed after release.
|
||||
printf 'corrupted\n' >>"$release_iso"
|
||||
if (cd "$sandbox/release" && sha256sum -c --status omarchy-9.9.9.iso.sha256 2>/dev/null); then
|
||||
fail "sha256sum -c rejects a corrupted ISO"
|
||||
fi
|
||||
pass "sha256sum -c rejects a corrupted ISO"
|
||||
|
||||
# An unreadable ISO must stop the release rather than publish an empty digest
|
||||
# beside a stale sidecar from the previous one.
|
||||
stale="$sandbox/release/omarchy-8.8.8.iso.sha256"
|
||||
printf 'deadbeef omarchy-8.8.8.iso\n' >"$stale"
|
||||
rm "$sandbox/release/omarchy-2099.01.01-x86_64-quattro.iso"
|
||||
printf 'not really an iso\n' >"$sandbox/release/omarchy-2099.01.02-x86_64-quattro.iso"
|
||||
cp "$sandbox/release/omarchy-2099.01.02-x86_64-quattro.iso" "$sandbox/release/omarchy-8.8.8.iso"
|
||||
chmod 000 "$sandbox/release/omarchy-8.8.8.iso"
|
||||
|
||||
set +e
|
||||
PATH="$work/stubs:$PATH" "$sandbox/bin/omarchy-iso-release" --no-make 8.8.8 >/dev/null 2>&1
|
||||
release_status=$?
|
||||
set -e
|
||||
chmod 644 "$sandbox/release/omarchy-8.8.8.iso"
|
||||
|
||||
(( release_status != 0 )) ||
|
||||
fail "release stops when the ISO cannot be checksummed" "exit status was 0"
|
||||
[[ "$(cat "$stale")" == "deadbeef omarchy-8.8.8.iso" ]] ||
|
||||
fail "a failed checksum leaves no half-written sidecar" "$(cat "$stale")"
|
||||
pass "release stops when the ISO cannot be checksummed"
|
||||
|
||||
# Uploading: both sidecars go up with the ISO, and a missing one is skipped
|
||||
# rather than handed to rclone as a path that does not exist.
|
||||
export HOME="$work/home"
|
||||
mkdir -p "$HOME/.config/rclone"
|
||||
: >"$HOME/.config/rclone/rclone.conf"
|
||||
|
||||
# A space in the path is the case that tells a quoted argument from an unquoted
|
||||
# one, so every upload case runs from a directory that has one.
|
||||
mkdir -p "$work/release builds"
|
||||
upload_iso="$work/release builds/omarchy-9.9.9.iso"
|
||||
printf 'not really an iso\n' >"$upload_iso"
|
||||
printf 'signature\n' >"$upload_iso.sig"
|
||||
printf 'checksum\n' >"$upload_iso.sha256"
|
||||
|
||||
run_upload "$upload_iso"
|
||||
|
||||
for suffix in "" ".sig" ".sha256"; do
|
||||
grep -qxF "rclone|copy|$upload_iso$suffix|Omarchy:omarchy/|-P" "$work/rclone-log" ||
|
||||
fail "upload ships the ISO, its signature and its checksum, path spaces intact" \
|
||||
"$(cat "$work/rclone-log")"
|
||||
done
|
||||
pass "upload ships the ISO, its signature and its checksum, path spaces intact"
|
||||
|
||||
rm "$upload_iso.sig"
|
||||
run_upload "$upload_iso"
|
||||
|
||||
if grep -qF ".sig" "$work/rclone-log"; then
|
||||
fail "upload skips a sidecar that is not there" "$(cat "$work/rclone-log")"
|
||||
fi
|
||||
grep -qF "$upload_iso.sha256" "$work/rclone-log" ||
|
||||
fail "upload still ships the checksum without a signature" "$(cat "$work/rclone-log")"
|
||||
pass "upload skips a sidecar that is not there"
|
||||
|
||||
# A failed copy has to fail the upload even when a later copy succeeds, or a
|
||||
# release reports success having published an ISO nobody can download.
|
||||
printf 'signature\n' >"$upload_iso.sig"
|
||||
set +e
|
||||
RCLONE_FAIL_ON=".sig" run_upload "$upload_iso"
|
||||
upload_status=$?
|
||||
set -e
|
||||
(( upload_status != 0 )) ||
|
||||
fail "a failed sidecar copy fails the upload" "$(cat "$work/rclone-log")"
|
||||
grep -qF "$upload_iso.sha256" "$work/rclone-log" ||
|
||||
fail "a failed sidecar copy still attempts the rest" "$(cat "$work/rclone-log")"
|
||||
pass "a failed sidecar copy fails the upload without skipping the rest"
|
||||
|
||||
set +e
|
||||
RCLONE_FAIL_ON="omarchy-9.9.9.iso" run_upload "$upload_iso"
|
||||
upload_status=$?
|
||||
set -e
|
||||
(( upload_status != 0 )) ||
|
||||
fail "a failed ISO copy fails the upload" "$(cat "$work/rclone-log")"
|
||||
pass "a failed ISO copy fails the upload"
|
||||
|
||||
# Publishing an ISO nobody can verify is the thing this change exists to stop,
|
||||
# so the uploader says so out loud rather than exiting quietly.
|
||||
rm "$upload_iso.sha256"
|
||||
run_upload "$upload_iso"
|
||||
grep -qF "nobody can verify" "$work/upload-err" ||
|
||||
fail "upload warns when there is no checksum to publish" "$(cat "$work/upload-err")"
|
||||
pass "upload warns when there is no checksum to publish"
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
mkdir -p "$work/install/provisioning"
|
||||
cat > "$work/install/provisioning/setup-form.sh" <<'FORM'
|
||||
OMARCHY_KEYBOARD_LAYOUTS=$'Chinese (Simplified, Pinyin)|us|pinyin
|
||||
English (US)|us
|
||||
Japanese|jp106|mozc'
|
||||
FORM
|
||||
export OMARCHY_PATH="$work"
|
||||
eval "$(sed -n '/^select_keyboard() {$/,/^}$/p' "$ROOT/bin/omarchy-iso-test")"
|
||||
press() { pressed+=("$1"); }
|
||||
sleep() { :; }
|
||||
|
||||
pressed=()
|
||||
select_keyboard "Japanese"
|
||||
[[ ${pressed[*]} == "down" ]]
|
||||
pressed=()
|
||||
select_keyboard "Chinese (Simplified, Pinyin)"
|
||||
[[ ${pressed[*]} == "up" ]]
|
||||
pressed=()
|
||||
select_keyboard "English (US)"
|
||||
(( ${#pressed[@]} == 0 ))
|
||||
if (set -e; select_keyboard "Missing") 2>"$work/error"; then
|
||||
echo "Unknown keyboard unexpectedly succeeded" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -q 'Keyboard choice is absent' "$work/error"
|
||||
echo "ok - VM keyboard choices are relative to the default and reject absent rows"
|
||||
@@ -0,0 +1,131 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# create_partition() must report the number parted actually assigned, never a
|
||||
# predicted one. The regression this pins: the configurator used to compute
|
||||
# "highest existing partition + 1", while parted fills the lowest free GPT
|
||||
# slot. Any disk whose numbering has a hole — what deleting a partition to
|
||||
# free space leaves behind — then had every later command (cryptsetup, mkfs,
|
||||
# mount) pointed at device nodes that did not exist, surfacing much later as
|
||||
# "protected mode: /mnt is not a mountpoint".
|
||||
#
|
||||
# parted operates on image files directly, so this needs no root, no loop
|
||||
# devices, and no real disk.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
LIB="$ROOT/configs/airootfs/usr/share/omarchy-iso/disk-partitioning.sh"
|
||||
|
||||
if ! command -v parted >/dev/null 2>&1; then
|
||||
echo "SKIP: parted is not installed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# shellcheck source=../configs/airootfs/usr/share/omarchy-iso/disk-partitioning.sh
|
||||
source "$LIB"
|
||||
|
||||
WORK=$(mktemp -d)
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
IMG="$WORK/disk.img"
|
||||
MIB=$((1024 * 1024))
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
local label="$1" expected="$2" actual="$3"
|
||||
if [[ $expected == "$actual" ]]; then
|
||||
printf ' ok %s\n' "$label"
|
||||
else
|
||||
printf ' FAIL %s: expected %s, got %s\n' "$label" "$expected" "$actual"
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
# parted reports a partition's size inclusive of both endpoints, so it lands
|
||||
# one sector above (end - start). Same slack create_partition allows.
|
||||
check_size() {
|
||||
local label="$1" want="$2" actual="${3:-0}" delta
|
||||
delta=$((actual - want))
|
||||
(( delta < 0 )) && delta=$((-delta))
|
||||
if (( delta <= MIB )); then
|
||||
printf ' ok %s\n' "$label"
|
||||
else
|
||||
printf ' FAIL %s: expected ~%s, got %s\n' "$label" "$want" "$actual"
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
# parted's end position is inclusive, so partitions laid back to back overlap
|
||||
# by a sector and are refused. Leave a MiB between them.
|
||||
mkpart_mib() {
|
||||
parted --script "$IMG" mkpart "$1" "$2" "$(($3 * MIB))B" "$(($4 * MIB))B"
|
||||
}
|
||||
|
||||
# A disk with holes: four partitions, then delete the middle two. Slots 2 and
|
||||
# 3 are free while the highest number in use is 4 — the shape of the reported
|
||||
# failure, where the user deleted a partition to make room.
|
||||
build_holey_disk() {
|
||||
rm -f "$IMG"
|
||||
truncate -s 4G "$IMG"
|
||||
parted --script "$IMG" mklabel gpt
|
||||
mkpart_mib one ext4 1 200
|
||||
mkpart_mib two ext4 201 400
|
||||
mkpart_mib three ext4 401 600
|
||||
mkpart_mib four ext4 601 800
|
||||
parted --script "$IMG" rm 2
|
||||
parted --script "$IMG" rm 3
|
||||
created_parts=()
|
||||
}
|
||||
|
||||
echo "==> numbering on a disk with holes"
|
||||
build_holey_disk
|
||||
check "existing numbers" "1 4" "$(partition_numbers "$IMG" | sort | tr '\n' ' ' | sed 's/ $//')"
|
||||
|
||||
create_partition "$IMG" "$((1000 * MIB))" "$((1200 * MIB))" fat32 OMARCHY_EFI
|
||||
check "create_partition succeeded (esp)" "0" "$?"
|
||||
esp_num="$created_partition_number"
|
||||
check "esp took the lowest free slot" "2" "$esp_num"
|
||||
|
||||
# Starts a MiB past the ESP, the way run_partition_decide aligns ROOT_START_B
|
||||
# up from EFI_END_B + 1.
|
||||
create_partition "$IMG" "$((1201 * MIB))" "$((2000 * MIB))" btrfs OMARCHY_ROOT
|
||||
check "create_partition succeeded (root)" "0" "$?"
|
||||
root_num="$created_partition_number"
|
||||
check "root took the next free slot" "3" "$root_num"
|
||||
|
||||
# The old prediction. If either of these ever matches again, the regression is
|
||||
# back: the highest number in use was 4, so the guess would have been 5 and 6.
|
||||
check "esp is not the predicted number" "not-5" "$([[ $esp_num == 5 ]] && echo 5 || echo not-5)"
|
||||
check "root is not the predicted number" "not-6" "$([[ $root_num == 6 ]] && echo 6 || echo not-6)"
|
||||
|
||||
check "both creations tracked for rollback" "2 3" "${created_parts[*]}"
|
||||
check_size "esp size" "$((200 * MIB))" "$(partition_size_bytes "$IMG" "$esp_num")"
|
||||
check_size "root size" "$((799 * MIB))" "$(partition_size_bytes "$IMG" "$root_num")"
|
||||
|
||||
echo "==> rollback reclaims only what this run created"
|
||||
rollback_created_parts "$IMG"
|
||||
check "created partitions removed" "1 4" "$(partition_numbers "$IMG" | sort | tr '\n' ' ' | sed 's/ $//')"
|
||||
check "rollback list cleared" "0" "${#created_parts[@]}"
|
||||
|
||||
echo "==> numbering on a disk without holes"
|
||||
rm -f "$IMG"
|
||||
truncate -s 4G "$IMG"
|
||||
parted --script "$IMG" mklabel gpt
|
||||
mkpart_mib one ext4 1 200
|
||||
mkpart_mib two ext4 201 400
|
||||
created_parts=()
|
||||
|
||||
create_partition "$IMG" "$((1000 * MIB))" "$((1200 * MIB))" fat32 OMARCHY_EFI
|
||||
check "appends when there is no hole" "3" "$created_partition_number"
|
||||
|
||||
echo "==> a refused creation stays out of the rollback list"
|
||||
created_parts=()
|
||||
create_partition "$IMG" "$((100 * MIB))" "$((300 * MIB))" ext4 OVERLAP
|
||||
check "overlapping creation failed" "1" "$?"
|
||||
check "nothing tracked" "0" "${#created_parts[@]}"
|
||||
|
||||
if (( failures > 0 )); then
|
||||
printf '\n%d check(s) failed\n' "$failures"
|
||||
exit 1
|
||||
fi
|
||||
printf '\nall checks passed\n'
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Exercise the compatibility boundary without importing host archinstall."""
|
||||
import ast
|
||||
from pathlib import Path
|
||||
import types
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
source = ROOT / "configs/airootfs/usr/share/omarchy-iso/orchestrator/archinstall_adapter.py"
|
||||
tree = ast.parse(source.read_text())
|
||||
namespace = {}
|
||||
functions = [node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name in {"_method_accepts", "sanity_check"}]
|
||||
exec(compile(ast.Module(body=functions, type_ignores=[]), str(source), "exec"), namespace)
|
||||
|
||||
|
||||
class SanityCheckTest(unittest.TestCase):
|
||||
def test_legacy_archinstall_stays_offline(self):
|
||||
calls = []
|
||||
def check(offline=False, skip_ntp=False, skip_wkd=False):
|
||||
calls.append((offline, skip_ntp, skip_wkd))
|
||||
namespace["sanity_check"](types.SimpleNamespace(sanity_check=check))
|
||||
self.assertEqual(calls, [(True, True, True)])
|
||||
|
||||
def test_archinstall_45_does_not_receive_removed_argument(self):
|
||||
calls = []
|
||||
class Installer:
|
||||
def sanity_check(self, skip_ntp=False, skip_wkd=False):
|
||||
calls.append((skip_ntp, skip_wkd))
|
||||
namespace["sanity_check"](Installer())
|
||||
self.assertEqual(calls, [(True, True)])
|
||||
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""Undecodable bytes in command output, and where tolerating them stops.
|
||||
|
||||
The orchestrator reads firmware and filesystem metadata out of commands whose
|
||||
output is not required to be UTF-8: noise in a boot entry must not stop an
|
||||
install, while a mangled identifier must stop one. These tests run stand-in
|
||||
commands emitting the bytes two HP firmwares actually put in a legacy BBS entry,
|
||||
so they exercise the decode itself rather than a mocked result.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(ROOT / "configs/airootfs/usr/share/omarchy-iso"))
|
||||
|
||||
# phases_impl imports the archinstall adapter at module scope, which pulls in
|
||||
# the archinstall library that only exists on the live ISO.
|
||||
sys.modules.setdefault(
|
||||
"orchestrator.archinstall_adapter",
|
||||
types.ModuleType("orchestrator.archinstall_adapter"),
|
||||
)
|
||||
|
||||
from orchestrator import phases_impl # noqa: E402
|
||||
from orchestrator.command import capture, capture_identifier # noqa: E402
|
||||
|
||||
# Boot0000 is the entry that aborted the install: raw bytes inside a BBS device
|
||||
# path, in a legacy entry nothing in the installer reads. 0x80 and 0xe0 are the
|
||||
# bytes two different HP firmwares emitted.
|
||||
EFIBOOTMGR_OUTPUT = (
|
||||
b"BootCurrent: 0003\n"
|
||||
b"Timeout: 0 seconds\n"
|
||||
b"BootOrder: 2001,0003,0000\n"
|
||||
b"Boot0000* Notebook Hard Drive\tBBS(HD,\x80\x7f\xff\x04\xe0\x7f,)\n"
|
||||
b"Boot0003* Omarchy\tHD(1,GPT,0d9c9d4f)/File(\\EFI\\limine\\BOOTX64.EFI)\n"
|
||||
b"Boot2001* USB Drive (UEFI)\tRC\n"
|
||||
)
|
||||
|
||||
|
||||
class CommandCaptureTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.bin_dir = None
|
||||
|
||||
def fake_bin(self) -> Path:
|
||||
"""A directory at the front of PATH, made once per test."""
|
||||
if self.bin_dir is None:
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
self.bin_dir = Path(tmp.name)
|
||||
path = os.environ["PATH"]
|
||||
self.addCleanup(os.environ.__setitem__, "PATH", path)
|
||||
os.environ["PATH"] = f"{self.bin_dir}:{path}"
|
||||
return self.bin_dir
|
||||
|
||||
def fake_script(self, name: str, body: str) -> None:
|
||||
script = self.fake_bin() / name
|
||||
script.write_text(f"#!/bin/sh\n{body}\n")
|
||||
script.chmod(0o755)
|
||||
|
||||
def fake_command(self, name: str, output: bytes) -> None:
|
||||
"""A command printing exactly these bytes, undecodable ones included."""
|
||||
payload = self.fake_bin() / f"{name}.out"
|
||||
payload.write_bytes(output)
|
||||
self.fake_script(name, f'cat "{payload}"')
|
||||
|
||||
def fake_findmnt(self, source: bytes) -> None:
|
||||
"""A findmnt answering per column, so the phase gets as far as SOURCE."""
|
||||
payload = self.fake_bin() / "findmnt.source"
|
||||
payload.write_bytes(source)
|
||||
self.fake_script(
|
||||
"findmnt",
|
||||
'case "$2" in\n'
|
||||
" FSTYPE) echo btrfs ;;\n"
|
||||
" OPTIONS) echo rw,subvol=/@ ;;\n"
|
||||
f' SOURCE) cat "{payload}" ;;\n'
|
||||
"esac",
|
||||
)
|
||||
|
||||
def test_undecodable_bytes_are_replaced_rather_than_raised(self):
|
||||
self.fake_command("omarchy-not-utf8", b"before\x80after\n")
|
||||
self.assertEqual(capture(["omarchy-not-utf8"]).stdout, "before�after\n")
|
||||
|
||||
def test_efibootmgr_entries_parse_around_a_legacy_bbs_entry(self):
|
||||
self.fake_command("efibootmgr", EFIBOOTMGR_OUTPUT)
|
||||
|
||||
state = phases_impl._read_efibootmgr()
|
||||
|
||||
self.assertEqual(state["order"], ["2001", "0003", "0000"])
|
||||
self.assertEqual(phases_impl._find_label_entries(state["entries"], "Omarchy"), ["0003"])
|
||||
self.assertTrue(state["entries"]["0000"].startswith("Notebook Hard Drive"))
|
||||
|
||||
def test_a_mangled_identifier_stops_the_install_rather_than_reaching_fstab(self):
|
||||
# _validate_pre_mounted_filesystems reads the UUID back from this same
|
||||
# command, so a replaced byte would agree with itself all the way to a
|
||||
# machine that cannot find its root.
|
||||
self.fake_command("blkid", b"1a2b3c4d-\x80-dead-beef\n")
|
||||
|
||||
with self.assertRaises(RuntimeError) as raised:
|
||||
phases_impl._blkid_uuid("/dev/sda2")
|
||||
|
||||
self.assertIn("the UUID of /dev/sda2 is not valid text", str(raised.exception))
|
||||
|
||||
def test_a_mangled_btrfs_device_is_never_handed_to_mount(self):
|
||||
# create_factory_snapshot mounts this device and deletes subvolumes
|
||||
# under it; a replaced byte must stop the phase before that, not turn
|
||||
# into an opaque mount failure.
|
||||
self.fake_findmnt(source=b"/dev/sda\xe02[/@]")
|
||||
ctx = types.SimpleNamespace(target=Path("/mnt"), state_dir=Path("/run/omarchy"))
|
||||
|
||||
with mock.patch.object(phases_impl, "info"), self.assertRaises(RuntimeError) as raised:
|
||||
phases_impl.create_factory_snapshot(ctx)
|
||||
|
||||
self.assertIn("is not valid text", str(raised.exception))
|
||||
|
||||
def test_a_clean_identifier_is_returned_unchanged(self):
|
||||
self.fake_command("blkid", b"1a2b3c4d-0e5f-dead-beef\n")
|
||||
self.assertEqual(
|
||||
capture_identifier(["blkid"], "the UUID"), "1a2b3c4d-0e5f-dead-beef"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,153 @@
|
||||
"""Unit tests for the orchestrator's configure_ssh_access phase.
|
||||
|
||||
The phase touches the target only through the filesystem and arch-chroot, so
|
||||
the tests run it against a temp directory with subprocess.run recorded and the
|
||||
ufw side effect (writing user.rules) simulated by the fake.
|
||||
"""
|
||||
|
||||
import stat
|
||||
import sys
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from subprocess import CompletedProcess
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "configs/airootfs/usr/share/omarchy-iso"))
|
||||
|
||||
# phases_impl imports the archinstall adapter at module scope, which pulls in
|
||||
# the archinstall library that only exists on the live ISO. configure_ssh_access
|
||||
# never touches it, so stub the adapter out before the import.
|
||||
sys.modules["orchestrator.archinstall_adapter"] = types.ModuleType("orchestrator.archinstall_adapter")
|
||||
|
||||
from orchestrator import phases_impl # noqa: E402
|
||||
|
||||
UFW_RULE = "-A ufw-user-input -p tcp --dport 22 -j ACCEPT\n"
|
||||
|
||||
|
||||
class ConfigureSshAccessTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.target = Path(self.tmp.name)
|
||||
self.calls = []
|
||||
|
||||
info_patch = mock.patch.object(phases_impl, "info")
|
||||
info_patch.start()
|
||||
self.addCleanup(info_patch.stop)
|
||||
|
||||
run_patch = mock.patch.object(phases_impl.subprocess, "run", side_effect=self.fake_run)
|
||||
run_patch.start()
|
||||
self.addCleanup(run_patch.stop)
|
||||
|
||||
self.ufw_writes_rule = True
|
||||
|
||||
def fake_run(self, cmd, **kwargs):
|
||||
self.calls.append(cmd)
|
||||
if cmd[2] == "ufw":
|
||||
if self.ufw_writes_rule:
|
||||
rules = self.target / "etc" / "ufw" / "user.rules"
|
||||
rules.parent.mkdir(parents=True, exist_ok=True)
|
||||
rules.write_text(UFW_RULE)
|
||||
# ufw cannot reach netfilter inside a chroot and exits non-zero
|
||||
# even when it recorded the rule; the phase must not trust this.
|
||||
return CompletedProcess(cmd, 1)
|
||||
return CompletedProcess(cmd, 0)
|
||||
|
||||
def ctx(self, authorized_keys=None):
|
||||
authorized_keys_path = None
|
||||
if authorized_keys is not None:
|
||||
authorized_keys_path = self.target / "authorized_keys"
|
||||
authorized_keys_path.write_text(authorized_keys)
|
||||
return types.SimpleNamespace(target=self.target, username="jeff", authorized_keys_path=authorized_keys_path, defer_provisioning=False)
|
||||
|
||||
def configure(self, **kwargs):
|
||||
phases_impl.configure_ssh_access(self.ctx(**kwargs))
|
||||
|
||||
def authorized_keys(self):
|
||||
return self.target / "home" / "jeff" / ".ssh" / "authorized_keys"
|
||||
|
||||
def chrooted(self, program):
|
||||
return [cmd for cmd in self.calls if cmd[:2] == ["arch-chroot", str(self.target)] and cmd[2] == program]
|
||||
|
||||
def test_no_authorized_keys_is_a_no_op(self):
|
||||
self.configure()
|
||||
self.assertEqual(self.calls, [])
|
||||
self.assertFalse((self.target / "home" / "jeff" / ".ssh").exists())
|
||||
|
||||
def test_installs_keys_one_per_line(self):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\nssh-rsa BBBB jeff@work\n")
|
||||
self.assertEqual(self.authorized_keys().read_text(), "ssh-ed25519 AAAA jeff@host\nssh-rsa BBBB jeff@work\n")
|
||||
|
||||
def test_drops_blank_lines_and_comments(self):
|
||||
self.configure(authorized_keys="# work laptop\n\n ssh-ed25519 AAAA jeff@host \n")
|
||||
self.assertEqual(self.authorized_keys().read_text(), "ssh-ed25519 AAAA jeff@host\n")
|
||||
|
||||
def test_keys_with_options_pass_through(self):
|
||||
key = 'command="/usr/bin/true",no-pty ssh-ed25519 AAAA jeff@host'
|
||||
self.configure(authorized_keys=f"{key}\n")
|
||||
self.assertEqual(self.authorized_keys().read_text(), f"{key}\n")
|
||||
|
||||
def test_ssh_dir_is_private(self):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\n")
|
||||
mode = stat.S_IMODE((self.target / "home" / "jeff" / ".ssh").stat().st_mode)
|
||||
self.assertEqual(mode, 0o700)
|
||||
|
||||
def test_authorized_keys_is_private(self):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\n")
|
||||
self.assertEqual(stat.S_IMODE(self.authorized_keys().stat().st_mode), 0o600)
|
||||
|
||||
def test_chowns_ssh_dir_to_the_user(self):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\n")
|
||||
self.assertEqual(self.chrooted("chown"), [
|
||||
["arch-chroot", str(self.target), "chown", "-R", "jeff:jeff", "/home/jeff/.ssh"],
|
||||
])
|
||||
|
||||
def test_enables_sshd(self):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\n")
|
||||
self.assertEqual(self.chrooted("systemctl"), [
|
||||
["arch-chroot", str(self.target), "systemctl", "enable", "sshd.service"],
|
||||
])
|
||||
|
||||
def test_allows_ssh_through_ufw_despite_chroot_exit_status(self):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\n")
|
||||
self.assertEqual(self.chrooted("ufw"), [
|
||||
["arch-chroot", str(self.target), "ufw", "allow", "ssh"],
|
||||
])
|
||||
|
||||
def test_fails_when_ufw_does_not_record_the_rule(self):
|
||||
self.ufw_writes_rule = False
|
||||
with self.assertRaisesRegex(RuntimeError, "allow rule for port 22"):
|
||||
self.configure(authorized_keys="ssh-ed25519 AAAA jeff@host\n")
|
||||
|
||||
def test_empty_file_fails_the_phase(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "contains no SSH keys"):
|
||||
self.configure(authorized_keys="")
|
||||
|
||||
def test_blank_only_file_fails_the_phase(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "contains no SSH keys"):
|
||||
self.configure(authorized_keys="\n \n")
|
||||
|
||||
def test_comment_only_file_fails_the_phase(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "contains no SSH keys"):
|
||||
self.configure(authorized_keys="# no keys here\n")
|
||||
|
||||
|
||||
class OptionalPathTest(unittest.TestCase):
|
||||
def test_unset_and_missing_paths_are_none(self):
|
||||
from orchestrator.context import _optional_path
|
||||
|
||||
self.assertIsNone(_optional_path(None))
|
||||
self.assertIsNone(_optional_path(""))
|
||||
self.assertIsNone(_optional_path("/does/not/exist/authorized_keys"))
|
||||
|
||||
def test_existing_path_is_returned(self):
|
||||
from orchestrator.context import _optional_path
|
||||
|
||||
with tempfile.NamedTemporaryFile() as f:
|
||||
self.assertEqual(_optional_path(f.name), Path(f.name))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,164 @@
|
||||
"""Unit tests for the orchestrator's configure_tailscale phase.
|
||||
|
||||
Same harness as the SSH access tests: the phase touches the target only
|
||||
through the filesystem and arch-chroot, so it runs against a temp directory
|
||||
with subprocess.run recorded and the ufw side effect (writing user.rules)
|
||||
simulated by the fake.
|
||||
"""
|
||||
|
||||
import stat
|
||||
import sys
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from subprocess import CompletedProcess
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "configs/airootfs/usr/share/omarchy-iso"))
|
||||
|
||||
# phases_impl imports the archinstall adapter at module scope, which pulls in
|
||||
# the archinstall library that only exists on the live ISO. configure_tailscale
|
||||
# never touches it, so stub the adapter out before the import.
|
||||
sys.modules["orchestrator.archinstall_adapter"] = types.ModuleType("orchestrator.archinstall_adapter")
|
||||
|
||||
from orchestrator import phases_impl # noqa: E402
|
||||
|
||||
UFW_RULE = "-A ufw-user-input -i tailscale0 -j ACCEPT\n"
|
||||
|
||||
|
||||
class ConfigureTailscaleTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.target = Path(self.tmp.name)
|
||||
self.calls = []
|
||||
|
||||
info_patch = mock.patch.object(phases_impl, "info")
|
||||
info_patch.start()
|
||||
self.addCleanup(info_patch.stop)
|
||||
|
||||
run_patch = mock.patch.object(phases_impl.subprocess, "run", side_effect=self.fake_run)
|
||||
run_patch.start()
|
||||
self.addCleanup(run_patch.stop)
|
||||
|
||||
self.ufw_writes_rule = True
|
||||
|
||||
def fake_run(self, cmd, **kwargs):
|
||||
self.calls.append(cmd)
|
||||
if cmd[2] == "ufw":
|
||||
if self.ufw_writes_rule:
|
||||
rules = self.target / "etc" / "ufw" / "user.rules"
|
||||
rules.parent.mkdir(parents=True, exist_ok=True)
|
||||
rules.write_text(UFW_RULE)
|
||||
# ufw cannot reach netfilter inside a chroot and exits non-zero
|
||||
# even when it recorded the rule; the phase must not trust this.
|
||||
return CompletedProcess(cmd, 1)
|
||||
return CompletedProcess(cmd, 0)
|
||||
|
||||
def ctx(self, authkey=None, tailscale_installed=True):
|
||||
authkey_path = None
|
||||
if authkey is not None:
|
||||
authkey_path = self.target / "tailscale_authkey"
|
||||
authkey_path.write_text(authkey)
|
||||
if tailscale_installed:
|
||||
binary = self.target / "usr" / "bin" / "tailscale"
|
||||
binary.parent.mkdir(parents=True, exist_ok=True)
|
||||
binary.touch()
|
||||
return types.SimpleNamespace(target=self.target, tailscale_authkey_path=authkey_path)
|
||||
|
||||
def configure(self, **kwargs):
|
||||
phases_impl.configure_tailscale(self.ctx(**kwargs))
|
||||
|
||||
def staged_key(self):
|
||||
return self.target / "etc" / "tailscale" / "authkey"
|
||||
|
||||
def unit(self):
|
||||
return self.target / "etc" / "systemd" / "system" / "omarchy-tailscale-join.service"
|
||||
|
||||
def chrooted(self, program):
|
||||
return [cmd for cmd in self.calls if cmd[:2] == ["arch-chroot", str(self.target)] and cmd[2] == program]
|
||||
|
||||
def test_no_authkey_is_a_no_op(self):
|
||||
self.configure()
|
||||
self.assertEqual(self.calls, [])
|
||||
self.assertFalse((self.target / "etc" / "tailscale").exists())
|
||||
|
||||
def test_stages_the_key(self):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
self.assertEqual(self.staged_key().read_text(), "tskey-auth-kFAKEKEY\n")
|
||||
|
||||
def test_drops_blank_lines_and_comments(self):
|
||||
self.configure(authkey="# reusable, tagged\n\n tskey-auth-kFAKEKEY \n")
|
||||
self.assertEqual(self.staged_key().read_text(), "tskey-auth-kFAKEKEY\n")
|
||||
|
||||
def test_key_dir_and_file_are_root_private(self):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
self.assertEqual(stat.S_IMODE((self.target / "etc" / "tailscale").stat().st_mode), 0o700)
|
||||
self.assertEqual(stat.S_IMODE(self.staged_key().stat().st_mode), 0o600)
|
||||
|
||||
def test_installs_the_join_unit(self):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
text = self.unit().read_text()
|
||||
self.assertIn("ConditionPathExists=/etc/tailscale/authkey", text)
|
||||
# The key must not outlive a successful join, the unit must not run
|
||||
# again after one, and cleanup must be sequenced after the join
|
||||
# succeeds -- inside the script, not in ExecStartPost.
|
||||
self.assertIn(
|
||||
"ExecStart=/usr/bin/sh -c 'until tailscale up --auth-key file:/etc/tailscale/authkey;"
|
||||
" do sleep 15; done; rm -f /etc/tailscale/authkey;"
|
||||
" systemctl disable omarchy-tailscale-join.service'",
|
||||
text,
|
||||
)
|
||||
|
||||
def test_join_unit_does_not_hold_up_boot(self):
|
||||
# A Type=oneshot wanted by multi-user.target holds the whole boot
|
||||
# (SDDM included) hostage until the join finishes or times out --
|
||||
# target units implicitly gain After= for their Wants=.
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
text = self.unit().read_text()
|
||||
self.assertIn("Type=simple", text)
|
||||
self.assertNotIn("Type=oneshot", text)
|
||||
self.assertNotIn("TimeoutStartSec", text)
|
||||
|
||||
def test_unit_avoids_systemd_variable_expansion(self):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
self.assertNotIn("$", self.unit().read_text())
|
||||
|
||||
def test_enables_tailscaled_and_the_join(self):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
self.assertEqual(self.chrooted("systemctl"), [
|
||||
["arch-chroot", str(self.target), "systemctl", "enable",
|
||||
"tailscaled.service", "omarchy-tailscale-join.service"],
|
||||
])
|
||||
|
||||
def test_allows_tailnet_traffic_through_ufw_despite_chroot_exit_status(self):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
self.assertEqual(self.chrooted("ufw"), [
|
||||
["arch-chroot", str(self.target), "ufw", "allow", "in", "on", "tailscale0"],
|
||||
])
|
||||
|
||||
def test_fails_when_ufw_does_not_record_the_rule(self):
|
||||
self.ufw_writes_rule = False
|
||||
with self.assertRaisesRegex(RuntimeError, "allow rule for tailscale0"):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n")
|
||||
|
||||
def test_fails_when_tailscale_is_not_on_the_target(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "not installed on the target"):
|
||||
self.configure(authkey="tskey-auth-kFAKEKEY\n", tailscale_installed=False)
|
||||
|
||||
def test_empty_file_fails_the_phase(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "contains no auth key"):
|
||||
self.configure(authkey="")
|
||||
|
||||
def test_comment_only_file_fails_the_phase(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "contains no auth key"):
|
||||
self.configure(authkey="# no key here\n")
|
||||
|
||||
def test_multiple_keys_fail_the_phase(self):
|
||||
with self.assertRaisesRegex(RuntimeError, "expected exactly one"):
|
||||
self.configure(authkey="tskey-auth-kONE\ntskey-auth-kTWO\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,196 @@
|
||||
"""Fresh installs use the Omarchy kernel, except for T2 Macs."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
from contextlib import ExitStack
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(ROOT / "configs/airootfs/usr/share/omarchy-iso"))
|
||||
sys.modules.setdefault(
|
||||
"orchestrator.archinstall_adapter",
|
||||
types.ModuleType("orchestrator.archinstall_adapter"),
|
||||
)
|
||||
from orchestrator import context, phases_impl # noqa: E402
|
||||
|
||||
|
||||
class KernelSelectionTest(unittest.TestCase):
|
||||
def test_hardware_detection(self):
|
||||
# Run the configurator's actual probe without starting its disk wizard.
|
||||
configurator = (ROOT / "configs/airootfs/root/configurator").read_text()
|
||||
probe = re.search(r"^detect_kernel\(\) \{\n.*?^\}", configurator, re.M | re.S)
|
||||
self.assertIsNotNone(probe)
|
||||
cases = [
|
||||
("00:02.0 VGA compatible controller [0300]: Intel [8086:b080]", "linux-omarchy"),
|
||||
("00:01.0 Ethernet controller [0200]: Apple [106b:2001]", "linux-omarchy"),
|
||||
("04:00.0 Mass storage controller [0180]: Apple [106b:1801]", "linux-t2"),
|
||||
("04:00.0 Mass storage controller [0180]: Apple [106b:1802]", "linux-t2"),
|
||||
("", "linux-omarchy"),
|
||||
]
|
||||
for devices, expected in cases:
|
||||
with self.subTest(devices=devices):
|
||||
result = subprocess.run(
|
||||
["bash", "-c", 'lspci() { printf "%s\\n" "$TEST_PCI"; }\n'
|
||||
+ probe.group() + "\ndetect_kernel"],
|
||||
env={**os.environ, "TEST_PCI": devices},
|
||||
check=True, capture_output=True, text=True,
|
||||
)
|
||||
self.assertEqual(result.stdout.strip(), expected)
|
||||
|
||||
def test_unattended_kernel_default_uses_pci_hardware(self):
|
||||
for vendor, device, expected in [
|
||||
("0x8086", "0xb080", "linux-omarchy"),
|
||||
("0x106b", "0x2001", "linux-omarchy"),
|
||||
("0x106b", "0x1801", "linux-t2"),
|
||||
("0x106b", "0x1802", "linux-t2"),
|
||||
]:
|
||||
with self.subTest(device=device), tempfile.TemporaryDirectory() as tmp:
|
||||
pci = Path(tmp)
|
||||
slot = pci / "0000:00:00.0"
|
||||
slot.mkdir()
|
||||
(slot / "vendor").write_text(vendor + "\n")
|
||||
(slot / "device").write_text(device + "\n")
|
||||
self.assertEqual(context._default_kernel(pci), expected)
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
self.assertEqual(context._default_kernel(Path(tmp)), "linux-omarchy")
|
||||
|
||||
def test_context_passes_effective_kernels_to_archinstall(self):
|
||||
for config, default, expected in [
|
||||
({}, "linux-omarchy", ["linux-omarchy"]),
|
||||
({"kernels": []}, "linux-omarchy", ["linux-omarchy"]),
|
||||
({"kernels": None}, "linux-t2", ["linux-t2"]),
|
||||
({}, "linux-t2", ["linux-t2"]),
|
||||
({"kernels": ["linux-lts"]}, "linux-omarchy", ["linux-lts"]),
|
||||
({"kernels": ["linux-omarchy", "linux-lts"]}, "linux-t2", ["linux-omarchy", "linux-lts"]),
|
||||
({"omarchy_install": {"storage": {"kernel": "linux-t2"}}}, "linux-omarchy", ["linux-t2"]),
|
||||
]:
|
||||
with self.subTest(config=config, default=default), tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
config_path = root / "config.json"
|
||||
creds_path = root / "creds.json"
|
||||
config_path.write_text(json.dumps(config))
|
||||
creds_path.write_text(json.dumps({"users": [{"username": "test"}]}))
|
||||
with mock.patch.dict(os.environ, {
|
||||
"OMARCHY_INSTALL_CONFIG": str(config_path),
|
||||
"OMARCHY_INSTALL_CREDS": str(creds_path),
|
||||
"OMARCHY_INSTALL_STATE_DIR": str(root / "state"),
|
||||
}, clear=True), mock.patch.object(context, "_default_kernel", return_value=default):
|
||||
ctx = context.InstallContext.from_env()
|
||||
self.assertEqual(ctx.user_configuration["kernels"], expected)
|
||||
self.assertEqual(json.loads(ctx.arch_config_path.read_text())["kernels"], expected)
|
||||
|
||||
def test_headers_install_before_dkms_packages(self):
|
||||
for kernels in (["linux-omarchy"], ["linux-t2"], ["linux-omarchy", "linux-lts"]):
|
||||
for fail_headers in (False, True):
|
||||
with self.subTest(kernels=kernels, fail_headers=fail_headers), ExitStack() as stack:
|
||||
events = []
|
||||
installer = mock.MagicMock()
|
||||
installer.minimal_installation.side_effect = lambda **kwargs: events.append("base")
|
||||
|
||||
def install_packages(packages):
|
||||
events.append(packages)
|
||||
if fail_headers:
|
||||
raise RuntimeError("header install failed")
|
||||
|
||||
installer.add_additional_packages.side_effect = install_packages
|
||||
config = types.SimpleNamespace(
|
||||
kernels=kernels, locale_config=None, mirror_config=None,
|
||||
swap=None, auth_config=None, app_config=None, timezone=None,
|
||||
ntp=False, hostname="test", pacman_config="/etc/pacman.conf",
|
||||
)
|
||||
ctx = types.SimpleNamespace(
|
||||
state={"arch_config_handler": types.SimpleNamespace(config=config), "mirror_handler": None},
|
||||
target=Path("/unused"), tailscale_authkey_path=None, omarchy_install={},
|
||||
)
|
||||
for name in ("_mount_offline_package_cache", "_mask_mkinitcpio_pacman_hooks",
|
||||
"_configure_limine_boot", "_write_pre_mounted_fstab"):
|
||||
stack.enter_context(mock.patch.object(phases_impl, name))
|
||||
unmask = stack.enter_context(mock.patch.object(phases_impl, "_unmask_mkinitcpio_pacman_hooks"))
|
||||
unmount = stack.enter_context(mock.patch.object(phases_impl, "_unmount_offline_package_cache"))
|
||||
stack.enter_context(mock.patch.object(phases_impl, "configure_keyboard", return_value=True))
|
||||
stack.enter_context(mock.patch.object(phases_impl, "_install_early_packages", side_effect=lambda inst: events.append("early")))
|
||||
stack.enter_context(mock.patch.object(phases_impl, "_runtime_package_list", return_value=["omarchy"]))
|
||||
stack.enter_context(mock.patch.object(phases_impl.arch, "is_pre_mount", return_value=True, create=True))
|
||||
stack.enter_context(mock.patch.object(phases_impl.arch, "root_user", return_value=None, create=True))
|
||||
stack.enter_context(mock.patch.object(phases_impl.arch, "sanity_check", create=True))
|
||||
opened = stack.enter_context(mock.patch.object(phases_impl.arch, "open_installer", create=True))
|
||||
opened.return_value.__enter__.return_value = installer
|
||||
if fail_headers:
|
||||
with self.assertRaisesRegex(RuntimeError, "header install failed"):
|
||||
phases_impl.arch_install_system(ctx)
|
||||
else:
|
||||
phases_impl.arch_install_system(ctx)
|
||||
expected = ["base", [f"{kernel}-headers" for kernel in kernels]]
|
||||
if not fail_headers:
|
||||
expected += ["early", ["omarchy"]]
|
||||
self.assertEqual(events, expected)
|
||||
unmask.assert_called_once_with(ctx)
|
||||
unmount.assert_called_once_with(ctx)
|
||||
|
||||
def test_validation_rejects_missing_or_mismatched_headers(self):
|
||||
for kernel in ("linux-omarchy", "linux-t2"):
|
||||
with self.subTest(kernel=kernel), tempfile.TemporaryDirectory() as tmp:
|
||||
target = Path(tmp)
|
||||
ctx = types.SimpleNamespace(target=target)
|
||||
with self.assertRaisesRegex(RuntimeError, "no installed kernel"):
|
||||
phases_impl._validate_kernel_headers(ctx)
|
||||
modules = target / "usr/lib/modules/7.2-test"
|
||||
modules.mkdir(parents=True)
|
||||
(modules / "pkgbase").write_text(kernel + "\n")
|
||||
with self.assertRaisesRegex(RuntimeError, "no kernel headers"):
|
||||
phases_impl._validate_kernel_headers(ctx)
|
||||
header_release = modules / "build/include/config/kernel.release"
|
||||
header_release.parent.mkdir(parents=True)
|
||||
header_release.write_text("7.2-stock\n")
|
||||
with self.assertRaisesRegex(RuntimeError, "headers do not match"):
|
||||
phases_impl._validate_kernel_headers(ctx)
|
||||
header_release.write_text("7.2-test\n")
|
||||
phases_impl._validate_kernel_headers(ctx)
|
||||
|
||||
def test_boot_validation_uses_default_or_explicit_kernel(self):
|
||||
for storage, configuration, expected in [
|
||||
({}, {}, "linux-omarchy"),
|
||||
({}, {"kernels": ["linux-t2"]}, "linux-t2"),
|
||||
({"kernel": "linux-t2"}, {"kernels": ["linux-omarchy"]}, "linux-t2"),
|
||||
({}, {"kernels": ["linux-lts"]}, "linux-lts"),
|
||||
]:
|
||||
with self.subTest(kernel=expected, storage=storage), tempfile.TemporaryDirectory() as tmp:
|
||||
target = Path(tmp)
|
||||
files = {
|
||||
f"usr/lib/modules/7.2-test/pkgbase": expected + "\n",
|
||||
"usr/lib/modules/7.2-test/build/include/config/kernel.release": "7.2-test\n",
|
||||
"boot/limine.conf": "/Omarchy\n",
|
||||
"etc/kernel/cmdline": "root=UUID=test\n",
|
||||
"etc/default/limine": "CUSTOM_UKI_NAME=omarchy\n",
|
||||
"boot/EFI/limine/limine_x64.efi": "bootloader",
|
||||
f"boot/EFI/Linux/omarchy_{expected}.efi": "UKI",
|
||||
}
|
||||
for name, content in files.items():
|
||||
path = target / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(content)
|
||||
ctx = types.SimpleNamespace(
|
||||
target=target, omarchy_install={"storage": storage},
|
||||
user_configuration=configuration, encrypt=False,
|
||||
is_protected=False, defer_provisioning=False,
|
||||
)
|
||||
with mock.patch.object(phases_impl, "_assert_boot_hooks_restored"), \
|
||||
mock.patch.object(phases_impl.arch, "has_uefi", return_value=True, create=True), \
|
||||
mock.patch.object(phases_impl, "_read_efibootmgr", return_value={
|
||||
"entries": {"0001": "Limine\tHD(1,GPT,test)"},
|
||||
}):
|
||||
phases_impl.validate_boot(ctx)
|
||||
(target / f"boot/EFI/Linux/omarchy_{expected}.efi").unlink()
|
||||
with self.assertRaisesRegex(RuntimeError, "missing or empty"):
|
||||
phases_impl.validate_boot(ctx)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(ROOT / "configs/airootfs/usr/share/omarchy-iso"))
|
||||
|
||||
from orchestrator import keyboard as KEYBOARD # noqa: E402
|
||||
|
||||
# The layout list lives in the Omarchy runtime now, shared verbatim with the
|
||||
# first-boot owner setup; build-iso.sh vendors it onto the ISO. Read it from
|
||||
# wherever this checkout can see a runtime, and skip the coverage test rather
|
||||
# than fail when none is around (a bare CI checkout of just this repo).
|
||||
SETUP_FORM_CANDIDATES = (
|
||||
Path(os.environ.get("OMARCHY_PATH", "/nonexistent")) / "install/provisioning/setup-form.sh",
|
||||
Path("/omarchy-source/install/provisioning/setup-form.sh"),
|
||||
ROOT.parent / "omarchy/install/provisioning/setup-form.sh",
|
||||
Path("/usr/share/omarchy/install/provisioning/setup-form.sh"),
|
||||
)
|
||||
|
||||
|
||||
def supported_keymaps():
|
||||
for candidate in SETUP_FORM_CANDIDATES:
|
||||
if not candidate.is_file():
|
||||
continue
|
||||
block = re.search(
|
||||
r"OMARCHY_KEYBOARD_LAYOUTS=\$'(.*?)'\n", candidate.read_text(), re.DOTALL
|
||||
)
|
||||
assert block, f"no layout list in {candidate}"
|
||||
return [line.split("|")[1] for line in block.group(1).splitlines()]
|
||||
return None
|
||||
|
||||
|
||||
SUPPORTED_KEYMAPS = supported_keymaps()
|
||||
|
||||
|
||||
class KeyboardConfigurationTest(unittest.TestCase):
|
||||
def target(self, directory: str) -> Path:
|
||||
target = Path(directory)
|
||||
(target / "etc").mkdir()
|
||||
(target / "etc/vconsole.conf").write_text(
|
||||
"KEYMAP=us\nFONT=default8x16\n"
|
||||
)
|
||||
return target
|
||||
|
||||
def test_writes_keymap_and_xkb_settings_and_preserves_font(self):
|
||||
# XKBLAYOUT is load-bearing: omarchy's detect-keyboard-layout.sh copies
|
||||
# it into Hyprland's kb_layout on the installed system.
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
self.assertTrue(KEYBOARD.configure_keyboard(target, "us"))
|
||||
lines = (target / "etc/vconsole.conf").read_text().splitlines()
|
||||
self.assertIn("KEYMAP=us", lines)
|
||||
self.assertIn("XKBLAYOUT=us", lines)
|
||||
self.assertEqual(lines.count("FONT=default8x16"), 1)
|
||||
|
||||
def test_all_configurator_keymaps_are_known_to_localectl(self):
|
||||
if SUPPORTED_KEYMAPS is None:
|
||||
self.skipTest("no Omarchy runtime checkout to read the layout list from")
|
||||
for keymap in SUPPORTED_KEYMAPS:
|
||||
with self.subTest(keymap=keymap), tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
self.assertTrue(KEYBOARD.configure_keyboard(target, keymap))
|
||||
lines = (target / "etc/vconsole.conf").read_text().splitlines()
|
||||
self.assertIn(f"KEYMAP={keymap}", lines)
|
||||
self.assertEqual(lines.count("FONT=default8x16"), 1)
|
||||
|
||||
def test_unknown_and_empty_keymaps_match_archinstall_behavior(self):
|
||||
for keymap, expected in (("definitely-not-a-keymap", False), ("", True)):
|
||||
with self.subTest(keymap=keymap), tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
self.assertEqual(KEYBOARD.configure_keyboard(target, keymap), expected)
|
||||
self.assertEqual(
|
||||
(target / "etc/vconsole.conf").read_text(),
|
||||
"KEYMAP=us\nFONT=default8x16\n",
|
||||
)
|
||||
|
||||
def test_input_choice_survives_while_console_keymap_stays_real(self):
|
||||
for method, keymap, layout in (("mozc", "jp106", ""), ("mozc", "us", ""), ("hangul", "us", "kr"), ("pinyin", "us", ""), ("chewing", "us", "")):
|
||||
with self.subTest(method=method), tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
self.assertTrue(KEYBOARD.configure_keyboard(target, keymap, method, layout))
|
||||
self.assertIn(f"KEYMAP={keymap}", (target / "etc/vconsole.conf").read_text())
|
||||
if keymap == "jp106":
|
||||
self.assertIn("XKBLAYOUT=jp", (target / "etc/vconsole.conf").read_text())
|
||||
self.assertEqual((target / "etc/omarchy/input-method").read_text(), f"INPUT_METHOD={method}\nXKB_LAYOUT={layout}\n")
|
||||
|
||||
def test_input_choice_with_no_console_map_defaults_to_us(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
self.assertTrue(KEYBOARD.configure_keyboard(target, "", "pinyin"))
|
||||
self.assertIn("INPUT_METHOD=pinyin", (target / "etc/omarchy/input-method").read_text())
|
||||
|
||||
def test_unknown_keyboard_does_not_silently_drop_an_input_choice(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
with self.assertRaises(ValueError):
|
||||
KEYBOARD.configure_keyboard(target, "unknown", "pinyin")
|
||||
|
||||
def test_invalid_input_preferences_are_rejected_without_writes(self):
|
||||
for method, layout in (("unknown", ""), ("hangul", "kr\nKEYMAP=ru")):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
target = self.target(directory)
|
||||
with self.assertRaises(ValueError):
|
||||
KEYBOARD.configure_keyboard(target, "us", method, layout)
|
||||
self.assertFalse((target / "etc/omarchy/input-method").exists())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
PRUNER = ROOT / "builder/prune-offline-mirror.sh"
|
||||
|
||||
|
||||
class OfflineMirrorPruningTest(unittest.TestCase):
|
||||
def run_pruner(self, mirror: Path, required: list[str]):
|
||||
return subprocess.run(
|
||||
["bash", str(PRUNER), str(mirror)],
|
||||
input="".join(f"{filename}\n" for filename in required),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
def add_file(self, mirror: Path, filename: str):
|
||||
(mirror / filename).write_bytes(b"package")
|
||||
|
||||
def test_keeps_only_exactly_selected_package_archives(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
mirror = Path(directory)
|
||||
keep = "keep-2.0-1-x86_64.pkg.tar.zst"
|
||||
other = "other-1.0-1-any.pkg.tar.zst"
|
||||
stale_version = "keep-1.0-1-x86_64.pkg.tar.zst"
|
||||
removed_package = "removed-1.0-1-x86_64.pkg.tar.zst"
|
||||
orphan_signature = "interrupted-1.0-1-x86_64.pkg.tar.zst.sig"
|
||||
|
||||
for filename in (keep, other, stale_version, removed_package):
|
||||
self.add_file(mirror, filename)
|
||||
for filename in (keep, stale_version, removed_package):
|
||||
self.add_file(mirror, f"{filename}.sig")
|
||||
self.add_file(mirror, orphan_signature)
|
||||
self.add_file(mirror, "offline.db.tar.gz")
|
||||
|
||||
result = self.run_pruner(mirror, [keep, other])
|
||||
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(
|
||||
{path.name for path in mirror.iterdir()},
|
||||
{keep, f"{keep}.sig", other, "offline.db.tar.gz"},
|
||||
)
|
||||
self.assertIn(stale_version, result.stdout)
|
||||
self.assertIn(removed_package, result.stdout)
|
||||
|
||||
def test_missing_selection_aborts_before_deleting_anything(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
mirror = Path(directory)
|
||||
cached = "cached-1.0-1-x86_64.pkg.tar.zst"
|
||||
self.add_file(mirror, cached)
|
||||
|
||||
result = self.run_pruner(
|
||||
mirror, ["missing-1.0-1-x86_64.pkg.tar.zst"]
|
||||
)
|
||||
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertTrue((mirror / cached).exists())
|
||||
self.assertIn("selected packages are missing", result.stderr)
|
||||
|
||||
def test_empty_selection_aborts_before_deleting_anything(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
mirror = Path(directory)
|
||||
cached = "cached-1.0-1-x86_64.pkg.tar.zst"
|
||||
self.add_file(mirror, cached)
|
||||
|
||||
result = self.run_pruner(mirror, [])
|
||||
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertTrue((mirror / cached).exists())
|
||||
self.assertIn("empty package selection", result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,440 @@
|
||||
"""Unit tests for deferred-provisioning install support in the orchestrator.
|
||||
|
||||
Covers the InstallContext deferred-provisioning plumbing (marker file, credential-less input,
|
||||
throwaway LUKS passphrase injection) and the stage_provisioning_state /
|
||||
create_factory_snapshot / configure_login phases against a temp target with
|
||||
subprocess mocked out.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from subprocess import CompletedProcess
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "configs/airootfs/usr/share/omarchy-iso"))
|
||||
|
||||
sys.modules.setdefault(
|
||||
"orchestrator.archinstall_adapter", types.ModuleType("orchestrator.archinstall_adapter")
|
||||
)
|
||||
|
||||
from orchestrator import phases_impl # noqa: E402
|
||||
from orchestrator.context import InstallContext # noqa: E402
|
||||
|
||||
|
||||
class ContextDeferProvisioningTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.dir = Path(self.tmp.name)
|
||||
self.state_dir = self.dir / "state"
|
||||
|
||||
self.env = {
|
||||
"OMARCHY_INSTALL_CONFIG": str(self.dir / "user_configuration.json"),
|
||||
"OMARCHY_INSTALL_CREDS": str(self.dir / "user_credentials.json"),
|
||||
"OMARCHY_INSTALL_STATE_DIR": str(self.state_dir),
|
||||
}
|
||||
|
||||
def write_config(self, config):
|
||||
(self.dir / "user_configuration.json").write_text(json.dumps(config))
|
||||
|
||||
def write_creds(self, creds):
|
||||
(self.dir / "user_credentials.json").write_text(json.dumps(creds))
|
||||
|
||||
def from_env(self, **extra_env):
|
||||
env = {**self.env, **extra_env}
|
||||
with mock.patch.dict(os.environ, env, clear=False):
|
||||
for key in ("OMARCHY_INSTALL_DEFER_PROVISIONING_FILE",):
|
||||
if key not in env:
|
||||
os.environ.pop(key, None)
|
||||
return InstallContext.from_env()
|
||||
|
||||
def base_config(self, defer_provisioning=None, disk_encryption=None):
|
||||
config = {
|
||||
"disk_config": {"config_type": "default_layout"},
|
||||
"omarchy_install": {"mode": "full_disk", "target_mount": "/mnt"},
|
||||
}
|
||||
if defer_provisioning is not None:
|
||||
config["omarchy_install"]["defer_provisioning"] = defer_provisioning
|
||||
if disk_encryption is not None:
|
||||
config["disk_config"]["disk_encryption"] = disk_encryption
|
||||
return config
|
||||
|
||||
def test_defer_provisioning_flag_from_config(self):
|
||||
self.write_config(self.base_config(defer_provisioning=True))
|
||||
ctx = self.from_env()
|
||||
self.assertTrue(ctx.defer_provisioning)
|
||||
self.assertEqual(ctx.user_credentials, {"users": []})
|
||||
self.assertEqual(ctx.username, "")
|
||||
|
||||
def test_marker_file_arms_deferred_provisioning_without_credentials(self):
|
||||
self.write_config(self.base_config())
|
||||
marker = self.dir / "defer_provisioning"
|
||||
marker.touch()
|
||||
ctx = self.from_env(OMARCHY_INSTALL_DEFER_PROVISIONING_FILE=str(marker))
|
||||
self.assertTrue(ctx.defer_provisioning)
|
||||
self.assertTrue(ctx.omarchy_install["defer_provisioning"])
|
||||
|
||||
def test_absent_marker_file_is_not_deferred_provisioning(self):
|
||||
self.write_config(self.base_config())
|
||||
self.write_creds({"users": [{"username": "jeff"}]})
|
||||
ctx = self.from_env(OMARCHY_INSTALL_DEFER_PROVISIONING_FILE=str(self.dir / "missing-defer_provisioning"))
|
||||
self.assertFalse(ctx.defer_provisioning)
|
||||
self.assertEqual(ctx.username, "jeff")
|
||||
|
||||
def test_missing_credentials_without_defer_provisioning_raises(self):
|
||||
self.write_config(self.base_config())
|
||||
with self.assertRaisesRegex(RuntimeError, "credentials file missing"):
|
||||
self.from_env()
|
||||
|
||||
def test_deferred_provisioning_generates_throwaway_luks_passphrase(self):
|
||||
self.write_config(self.base_config(defer_provisioning=True, disk_encryption={
|
||||
"encryption_type": "luks", "partitions": ["x"],
|
||||
}))
|
||||
ctx = self.from_env()
|
||||
|
||||
password = ctx.user_configuration["disk_config"]["disk_encryption"]["encryption_password"]
|
||||
self.assertTrue(password)
|
||||
self.assertEqual(ctx.user_credentials["encryption_password"], password)
|
||||
|
||||
# archinstall reads both files from disk; the injected passphrase must
|
||||
# be present in each.
|
||||
arch_config = json.loads(ctx.arch_config_path.read_text())
|
||||
self.assertEqual(
|
||||
arch_config["disk_config"]["disk_encryption"]["encryption_password"], password
|
||||
)
|
||||
synthesized = json.loads(ctx.creds_path.read_text())
|
||||
self.assertEqual(synthesized["encryption_password"], password)
|
||||
|
||||
def test_deferred_provisioning_reuses_rig_supplied_passphrase(self):
|
||||
self.write_config(self.base_config(defer_provisioning=True, disk_encryption={
|
||||
"encryption_type": "luks", "partitions": ["x"],
|
||||
}))
|
||||
self.write_creds({"users": [], "encryption_password": "rig-secret"})
|
||||
ctx = self.from_env()
|
||||
self.assertEqual(
|
||||
ctx.user_configuration["disk_config"]["disk_encryption"]["encryption_password"],
|
||||
"rig-secret",
|
||||
)
|
||||
|
||||
def test_deferred_provisioning_discards_account_material(self):
|
||||
# A rig credentials file must not smuggle in users or a root password.
|
||||
self.write_config(self.base_config(defer_provisioning=True))
|
||||
self.write_creds({
|
||||
"users": [{"username": "backdoor", "enc_password": "x", "sudo": True}],
|
||||
"root_enc_password": "x",
|
||||
"encryption_password": "rig-secret",
|
||||
})
|
||||
ctx = self.from_env()
|
||||
self.assertEqual(ctx.user_credentials["users"], [])
|
||||
self.assertNotIn("root_enc_password", ctx.user_credentials)
|
||||
self.assertEqual(ctx.user_credentials["encryption_password"], "rig-secret")
|
||||
synthesized = json.loads(ctx.creds_path.read_text())
|
||||
self.assertEqual(synthesized["users"], [])
|
||||
self.assertNotIn("root_enc_password", synthesized)
|
||||
|
||||
def test_defer_provisioning_strips_account_fields(self):
|
||||
config = self.base_config(defer_provisioning=True)
|
||||
config["!users"] = [{"username": "rig"}]
|
||||
config["!root-password"] = "hunter2"
|
||||
config["root_enc_password"] = "x"
|
||||
config["auth_config"] = {"users": [{"username": "rig"}], "root_enc_password": "x"}
|
||||
self.write_config(config)
|
||||
ctx = self.from_env()
|
||||
|
||||
arch_config = json.loads(ctx.arch_config_path.read_text())
|
||||
for key in ("!users", "!root-password", "root_enc_password", "users"):
|
||||
self.assertNotIn(key, arch_config)
|
||||
self.assertEqual(arch_config["auth_config"], {})
|
||||
|
||||
def test_deferred_provisioning_unencrypted_touches_nothing(self):
|
||||
self.write_config(self.base_config(defer_provisioning=True))
|
||||
ctx = self.from_env()
|
||||
self.assertNotIn("encryption_password", ctx.user_credentials)
|
||||
|
||||
|
||||
def make_ctx(target, **overrides):
|
||||
defaults = dict(
|
||||
target=target,
|
||||
defer_provisioning=True,
|
||||
encrypt=False,
|
||||
username="",
|
||||
omarchy_install={"mode": "full_disk", "defer_provisioning": True, "storage": {}},
|
||||
user_configuration={"disk_config": {}},
|
||||
user_credentials={"users": []},
|
||||
state_dir=target / "state",
|
||||
authorized_keys_path=None,
|
||||
)
|
||||
defaults.update(overrides)
|
||||
return types.SimpleNamespace(**defaults)
|
||||
|
||||
|
||||
class StageProvisioningStateTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.target = Path(self.tmp.name) / "mnt"
|
||||
self.target.mkdir()
|
||||
|
||||
info_patch = mock.patch.object(phases_impl, "info")
|
||||
info_patch.start()
|
||||
self.addCleanup(info_patch.stop)
|
||||
|
||||
# A fake bundled Node tarball on the "live ISO".
|
||||
self.packages = Path(self.tmp.name) / "opt-packages"
|
||||
self.packages.mkdir()
|
||||
(self.packages / "node-v24.0.0-linux-x64.tar.gz").write_bytes(b"node")
|
||||
node_patch = mock.patch.object(phases_impl, "NODE_PACKAGES_DIR", self.packages)
|
||||
node_patch.start()
|
||||
self.addCleanup(node_patch.stop)
|
||||
|
||||
def install_runtime_provisioning_support(self):
|
||||
service = self.target / "usr/share/omarchy/install/provisioning/omarchy-provision-owner.service"
|
||||
service.parent.mkdir(parents=True, exist_ok=True)
|
||||
service.write_text("[Unit]\n")
|
||||
setup_bin = self.target / "usr/bin/omarchy-provision-owner"
|
||||
setup_bin.parent.mkdir(parents=True, exist_ok=True)
|
||||
setup_bin.write_text("#!/bin/bash\n")
|
||||
|
||||
def provisioning_dir(self):
|
||||
return self.target / "var/lib/omarchy/provisioning"
|
||||
|
||||
def test_normal_install_stages_only_the_node_tarball(self):
|
||||
ctx = make_ctx(self.target, defer_provisioning=False)
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
self.assertTrue((self.provisioning_dir() / "packages/node-v24.0.0-linux-x64.tar.gz").exists())
|
||||
self.assertFalse((self.provisioning_dir() / "pending").exists())
|
||||
self.assertFalse((self.target / "etc/systemd/system/omarchy-provision-owner.service").exists())
|
||||
|
||||
def test_deferred_provisioning_against_runtime_without_support_fails_clearly(self):
|
||||
ctx = make_ctx(self.target)
|
||||
with self.assertRaisesRegex(RuntimeError, "does not ship"):
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
def test_deferred_provisioning_without_node_tarball_fails(self):
|
||||
for tarball in self.packages.glob("*.tar.gz"):
|
||||
tarball.unlink()
|
||||
self.install_runtime_provisioning_support()
|
||||
ctx = make_ctx(self.target)
|
||||
with self.assertRaisesRegex(RuntimeError, "Node tarball"):
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
def test_missing_node_tarball_fails_normal_installs_too(self):
|
||||
# The stash is what makes a later factory reset work offline.
|
||||
for tarball in self.packages.glob("*.tar.gz"):
|
||||
tarball.unlink()
|
||||
ctx = make_ctx(self.target, defer_provisioning=False)
|
||||
with self.assertRaisesRegex(RuntimeError, "Node tarball"):
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
def test_deferred_provisioning_arms_first_boot_setup(self):
|
||||
self.install_runtime_provisioning_support()
|
||||
ctx = make_ctx(self.target)
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
self.assertTrue((self.provisioning_dir() / "pending").exists())
|
||||
self.assertTrue((self.target / "etc/systemd/system/omarchy-provision-owner.service").exists())
|
||||
link = self.target / "etc/systemd/system/multi-user.target.wants/omarchy-provision-owner.service"
|
||||
self.assertTrue(link.is_symlink())
|
||||
self.assertEqual(
|
||||
os.readlink(link), "/etc/systemd/system/omarchy-provision-owner.service"
|
||||
)
|
||||
# Unencrypted: no LUKS staging.
|
||||
self.assertFalse((self.provisioning_dir() / "luks-key").exists())
|
||||
|
||||
def test_deferred_provisioning_encrypted_stages_luks_auto_unlock(self):
|
||||
self.install_runtime_provisioning_support()
|
||||
ctx = make_ctx(
|
||||
self.target,
|
||||
user_configuration={"disk_config": {"disk_encryption": {
|
||||
"encryption_type": "luks",
|
||||
"encryption_password": "throwaway-secret",
|
||||
}}},
|
||||
)
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
# Byte-for-byte the slot passphrase — no trailing newline.
|
||||
self.assertEqual((self.provisioning_dir() / "luks-key").read_text(), "throwaway-secret")
|
||||
keyfile = self.target / "etc/omarchy/provisioning.key"
|
||||
self.assertEqual(keyfile.read_text(), "throwaway-secret")
|
||||
self.assertEqual(keyfile.stat().st_mode & 0o777, 0o600)
|
||||
|
||||
cmdline = (self.target / "etc/limine-entry-tool.d/99-omarchy-provisioning-unlock.conf").read_text()
|
||||
self.assertIn("cryptkey=rootfs:/etc/omarchy/provisioning.key", cmdline)
|
||||
files = (self.target / "etc/mkinitcpio.conf.d/99-omarchy-provisioning-key.conf").read_text()
|
||||
self.assertIn("FILES+=(/etc/omarchy/provisioning.key)", files)
|
||||
|
||||
def test_deferred_provisioning_pre_encrypted_without_passphrase_fails(self):
|
||||
self.install_runtime_provisioning_support()
|
||||
ctx = make_ctx(
|
||||
self.target,
|
||||
omarchy_install={"mode": "protected", "defer_provisioning": True, "storage": {"luks_uuid": "abc"}},
|
||||
)
|
||||
with self.assertRaisesRegex(RuntimeError, "passphrase"):
|
||||
phases_impl.stage_provisioning_state(ctx)
|
||||
|
||||
|
||||
class ConfigureLoginDeferProvisioningTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.target = Path(self.tmp.name)
|
||||
self.calls = []
|
||||
|
||||
run_patch = mock.patch.object(
|
||||
phases_impl.subprocess, "run",
|
||||
side_effect=lambda cmd, **kw: (self.calls.append(cmd), CompletedProcess(cmd, 0))[1],
|
||||
)
|
||||
run_patch.start()
|
||||
self.addCleanup(run_patch.stop)
|
||||
|
||||
def test_deferred_provisioning_login_leaves_user_state_to_first_boot(self):
|
||||
ctx = make_ctx(self.target, encrypt=True)
|
||||
phases_impl.configure_login(ctx)
|
||||
|
||||
self.assertTrue((self.target / "etc/sddm.conf.d/99-omarchy-login.conf").exists())
|
||||
self.assertFalse((self.target / "etc/sddm.conf.d/autologin.conf").exists())
|
||||
self.assertFalse((self.target / "var/lib/sddm/state.conf").exists())
|
||||
self.assertTrue(any("sddm.service" in cmd for cmd in self.calls))
|
||||
|
||||
def test_normal_encrypted_login_still_autologs_in(self):
|
||||
ctx = make_ctx(self.target, defer_provisioning=False, encrypt=True, username="jeff")
|
||||
phases_impl.configure_login(ctx)
|
||||
|
||||
autologin = (self.target / "etc/sddm.conf.d/autologin.conf").read_text()
|
||||
self.assertIn("User=jeff", autologin)
|
||||
state = (self.target / "var/lib/sddm/state.conf").read_text()
|
||||
self.assertIn("User=jeff", state)
|
||||
|
||||
|
||||
class ConfigureSshAccessDeferProvisioningTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.target = Path(self.tmp.name) / "mnt"
|
||||
self.target.mkdir()
|
||||
|
||||
info_patch = mock.patch.object(phases_impl, "info")
|
||||
info_patch.start()
|
||||
self.addCleanup(info_patch.stop)
|
||||
|
||||
def fake_run(cmd, **kwargs):
|
||||
self.calls.append(cmd)
|
||||
if "ufw" in cmd:
|
||||
rules = self.target / "etc/ufw/user.rules"
|
||||
rules.parent.mkdir(parents=True, exist_ok=True)
|
||||
rules.write_text("-A ufw-user-input -p tcp --dport 22 -j ACCEPT\n")
|
||||
return CompletedProcess(cmd, 0)
|
||||
|
||||
self.calls = []
|
||||
run_patch = mock.patch.object(phases_impl.subprocess, "run", side_effect=fake_run)
|
||||
run_patch.start()
|
||||
self.addCleanup(run_patch.stop)
|
||||
|
||||
def test_deferred_provisioning_stages_keys_for_first_boot(self):
|
||||
keys = Path(self.tmp.name) / "authorized_keys"
|
||||
keys.write_text("ssh-ed25519 AAAA rig@host\n")
|
||||
ctx = make_ctx(self.target, authorized_keys_path=keys)
|
||||
|
||||
phases_impl.configure_ssh_access(ctx)
|
||||
|
||||
staged = self.target / "var/lib/omarchy/provisioning/authorized_keys"
|
||||
self.assertEqual(staged.read_text(), "ssh-ed25519 AAAA rig@host\n")
|
||||
self.assertEqual(staged.stat().st_mode & 0o777, 0o600)
|
||||
# No user yet — nothing under /home, no chown.
|
||||
self.assertFalse((self.target / "home").exists())
|
||||
self.assertFalse(any("chown" in cmd for cmd in self.calls))
|
||||
# The door is still opened for first boot.
|
||||
self.assertTrue(any("sshd.service" in cmd for cmd in self.calls))
|
||||
|
||||
|
||||
class CreateFactorySnapshotTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.target = Path(self.tmp.name) / "mnt"
|
||||
self.target.mkdir()
|
||||
self.state_dir = Path(self.tmp.name) / "state"
|
||||
self.state_dir.mkdir()
|
||||
|
||||
info_patch = mock.patch.object(phases_impl, "info")
|
||||
info_patch.start()
|
||||
self.addCleanup(info_patch.stop)
|
||||
|
||||
self.findmnt = {
|
||||
"FSTYPE": "btrfs",
|
||||
"OPTIONS": "rw,noatime,compress=zstd:3,subvol=/@",
|
||||
"SOURCE": "/dev/mapper/omarchy_root[/@]",
|
||||
}
|
||||
self.calls = []
|
||||
|
||||
def fake_run(cmd, **kwargs):
|
||||
self.calls.append(cmd)
|
||||
if cmd[0] == "findmnt":
|
||||
return CompletedProcess(cmd, 0, stdout=self.findmnt[cmd[2]] + "\n", stderr="")
|
||||
if cmd[0] == "mount":
|
||||
# Simulate the top level containing @.
|
||||
(Path(cmd[-1]) / "@").mkdir(parents=True, exist_ok=True)
|
||||
return CompletedProcess(cmd, 0, stdout="", stderr="")
|
||||
|
||||
run_patch = mock.patch.object(phases_impl.subprocess, "run", side_effect=fake_run)
|
||||
run_patch.start()
|
||||
self.addCleanup(run_patch.stop)
|
||||
|
||||
def ctx(self):
|
||||
return make_ctx(self.target, defer_provisioning=False, state_dir=self.state_dir)
|
||||
|
||||
def test_snapshots_root_as_factory(self):
|
||||
phases_impl.create_factory_snapshot(self.ctx())
|
||||
|
||||
top = str(self.state_dir / "factory-top")
|
||||
self.assertIn(["mount", "-o", "subvolid=5", "/dev/mapper/omarchy_root", top], self.calls)
|
||||
self.assertIn(
|
||||
["btrfs", "subvolume", "snapshot", f"{top}/@", f"{top}/@factory"],
|
||||
self.calls,
|
||||
)
|
||||
self.assertIn(
|
||||
["btrfs", "property", "set", "-ts", f"{top}/@factory", "ro", "true"],
|
||||
self.calls,
|
||||
)
|
||||
self.assertIn(["umount", top], self.calls)
|
||||
|
||||
def test_factory_snapshot_scrubs_provisioning_credentials(self):
|
||||
# Simulate the snapshot carrying deployment credentials; the scrub
|
||||
# must drop them before the snapshot goes read-only.
|
||||
top = self.state_dir / "factory-top"
|
||||
factory = top / "@factory"
|
||||
secrets = [
|
||||
factory / "var/lib/omarchy/provisioning/authorized_keys",
|
||||
factory / "etc/tailscale/authkey",
|
||||
factory / "etc/omarchy/provisioning.key",
|
||||
]
|
||||
keep = factory / "var/lib/omarchy/provisioning/groups"
|
||||
for path in [*secrets, keep]:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("secret")
|
||||
|
||||
phases_impl.create_factory_snapshot(self.ctx())
|
||||
|
||||
for path in secrets:
|
||||
self.assertFalse(path.exists(), path)
|
||||
self.assertTrue(keep.exists())
|
||||
|
||||
def test_non_btrfs_target_skips(self):
|
||||
self.findmnt["FSTYPE"] = "ext4"
|
||||
phases_impl.create_factory_snapshot(self.ctx())
|
||||
self.assertFalse(any(cmd[0] == "mount" for cmd in self.calls))
|
||||
|
||||
def test_non_subvol_root_skips(self):
|
||||
self.findmnt["OPTIONS"] = "rw,noatime"
|
||||
phases_impl.create_factory_snapshot(self.ctx())
|
||||
self.assertFalse(any(cmd[0] == "mount" for cmd in self.calls))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user