How omarchy update Works in Omarchy: A Deep Dive into the System Update Orchestrator
The omarchy update command is a Bash orchestration script that executes a 14-step pipeline to safely upgrade both Omarchy and the underlying Arch Linux system, utilizing file-based locking, automatic conflict resolution, and modular helper binaries to ensure reliable, unattended-capable system maintenance.
The omarchy update command serves as the central maintenance interface for the Omarchy desktop environment. Implemented in the omacom/omarchy repository as a modular Bash architecture, this command coordinates complex system-wide updates while ensuring data safety through snapshots, preventing concurrent executions via file locking, and handling package manager conflicts automatically.
The Core Architecture of omarchy update
The main orchestrator resides in bin/omarchy-update, which coordinates a series of specialized helper scripts located in the bin/ directory. This modular design isolates distinct concerns—such as locking, logging, and package management—into separate executables, making the system easier to maintain and test. The command is also integrated into the Omarchy menu system via default/omarchy/omarchy-menu.jsonc, which launches the update in a floating terminal using omarchy-launch-floating-terminal-with-presentation omarchy-update.
Step-by-Step Execution Flow
The update process follows a strict sequence designed to maximize safety and recoverability.
1. Concurrency Control via File Locking
Before performing any operations, the script invokes omarchy-update-lock to acquire a file-based lock using flock -n (non-blocking). This guarantees that only one update process runs at a time, preventing race conditions with package manager operations. If the lock is already held, the helper re-executes the command within the lock context.
2. Logging and Restart-Safe Execution
The first invocation re-executes under the script command to capture a complete log at /tmp/omarchy-update.log. The script checks for the OMARCHY_UPDATE_LOGGED environment variable (lines 10-13 of bin/omarchy-update) to skip recursive logging on subsequent runs. This ensures a full audit trail even if the process later execs another binary.
3. Pre-Update Validation
The pipeline verifies system readiness through two checks:
- Disk space:
omarchy-update-requires-free-spaceaborts early if insufficient free space exists. - Interactive confirmation: Unless the
-yflag is passed,omarchy-update-confirmprompts the user viagum. The-yflag setsOMARCHY_UPDATE_UNATTENDED=1, enabling fully automated operation.
4. System Preparation
Before modifying system packages, the script prepares the environment:
- Cache pruning:
omarchy-update-pkg-prunerunspaccache -rk2to retain only the two most recent versions of each package, freeing disk space. - Snapshot creation:
omarchy-snapshot creategenerates a system snapshot if Snapper is available; if missing, the update proceeds without error. - Suspend prevention:
omarchy-update-stay-awake startactivates a systemd inhibitor to block suspend or hibernate during the update process.
5. Core Package Updates
The actual upgrade happens in several phases:
- Development tools:
omarchy-update-devupdates internal development utilities. - Pacman keyring:
omarchy-update-keyringrefreshes the package manager's keyring. - System packages:
omarchy-update-system-pkgsexecutespacman -Syu --noconfirmwith an overwrite rule for/usr/share/omarchy/*. - Conflict resolution: If pacman reports file conflicts,
omarchy-update-system-pkgs-when-conflictedautomatically removes the offending files and retries, eliminating manual intervention.
6. Post-Update Processing
After system packages upgrade, the script applies configuration changes and cleans up:
- Migrations:
omarchy-migrateapplies pending database or configuration migrations. - Hooks:
omarchy-hook post-updateexecutes user-defined post-update scripts. - AUR packages:
omarchy-update-aur-pkgsupdates packages from the Arch User Repository. - Mise tools:
omarchy-update-miseupdates tools managed by the mise version manager. - Orphan cleanup:
omarchy-update-orphan-pkgsdetects and optionally removes packages with no remaining dependents.
7. Finalization and Reboot
The final phase handles reporting and system restart:
- Log analysis:
omarchy-update-analyze-logsparses/tmp/omarchy-update.logfor errors. - Status reporting:
omarchy-update-statusprints a concise summary of the update outcome. - Reboot prompt:
omarchy-update-restartreleases the stay-awake inhibitor and offers a system reboot or user session restart.
Key Design Patterns and Safety Mechanisms
Several architectural decisions ensure omarchy update remains robust across diverse system states:
- File-based locking: The
flock -nimplementation inomarchy-update-lockguarantees atomic lock acquisition, preventing corruption from overlapping package operations. - Idempotent logging: The outer
scriptwrapper ensures log capture persists acrossexeccalls, providing complete forensic data even if the main script is replaced mid-execution. - Pacman conflict resolution: The
omarchy-update-system-pkgs-when-conflictedhelper detects when pacman cannot overwrite Omarchy-owned files and automatically clears the obstruction before retrying. - Modular architecture: Each distinct task (pruning, snapshots, stay-awake) lives in its own binary, simplifying unit testing and debugging.
Usage Examples
# Standard interactive update with confirmation prompt
omarchy update
# Fully unattended update for automation or scripts
omarchy update -y
# Force snapshot creation even if Snapper is missing
OMARCHY_SNAPSHOT_FORCE=1 omarchy update
# Run a custom command within the update lock context
omarchy-update-lock run my-custom-script.sh
Summary
- The
omarchy updatecommand inomacom/omarchyorchestrates a 14-step Bash pipeline for system maintenance. - File-based locking via
omarchy-update-lockprevents concurrent update attempts usingflock -n. - Restart-safe logging captures all output to
/tmp/omarchy-update.logusing thescriptcommand. - The
-yflag enables unattended mode by settingOMARCHY_UPDATE_UNATTENDED=1and bypassing thegumconfirmation UI. - Automatic conflict resolution in
omarchy-update-system-pkgs-when-conflictedhandles pacman file ownership issues without manual intervention. - The process includes safety checks for disk space, optional Snapper snapshots, and a systemd stay-awake inhibitor to prevent suspend during critical operations.
Frequently Asked Questions
What happens if I run omarchy update while another update is in progress?
The omarchy-update-lock helper prevents concurrent executions by using flock -n (non-blocking) on a file descriptor. If the lock is already held, the command re-executes through the lock helper, ensuring only one update process runs at a time and preventing race conditions with package manager operations.
How does omarchy update handle pacman file conflicts?
When pacman -Syu encounters files in /usr/share/omarchy/* that it cannot overwrite, the omarchy-update-system-pkgs-when-conflicted helper automatically removes the offending files and retries the operation. This avoids manual intervention during system updates while preserving Omarchy's custom configurations.
Can omarchy update run unattended in scripts?
Yes. Passing the -y flag sets OMARCHY_UPDATE_UNATTENDED=1, which bypasses the interactive gum confirmation prompt in omarchy-update-confirm. This enables fully automated updates suitable for provisioning scripts or scheduled maintenance windows.
Where are omarchy update logs stored?
The outermost script execution captures all output to /tmp/omarchy-update.log using the script command. Subsequent invocations check for the OMARCHY_UPDATE_LOGGED environment variable to avoid recursive logging. After completion, omarchy-update-analyze-logs parses this file for errors and omarchy-update-status displays the final results.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →