Repository navigation
Restore pacman config after failed refresh - #8781
UrbanLeopard wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds transactional rollback for pacman configuration changes when channel refreshes fail.
Changes:
- Creates secure temporary backups of pacman configuration files.
- Restores configuration after channel, hook, or package-refresh failures.
- Adds shell regression tests for hook/package failures and success.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-refresh-pacman |
Implements transactional backup and rollback. |
test/shell.d/refresh-pacman-rollback-test.sh |
Tests rollback and success behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
03f9c38 to
097f8c2
Compare
|
The bug is real, and this fixes it. The branch now conflicts with What was checked. I ran this on a disposable Omarchy VM using real
One small thing: Why it conflicts. Since this branch was cut,
Four other open pull requests touch this script, so whichever lands first will move it again: #7998 timestamps those backups, #13397 adds replacement flags to the transaction, #13479 shares one authorization across a channel switch, and #13690 adds region profiles. Second opinion. None for this item. The configured reviewer was reachable, but it had already used today's review budget, so everything above is one model's work (Claude Opus 5.5). Next. This waits on you to rebase onto |
097f8c2 to
46cb70c
Compare
[Medium impact] The PR appears safe to merge; no new actionable issues remain. SummaryAdds rollback for failed pacman configuration refreshes.
All four earlier threads were unnumbered. Their reported issues are addressed by the current lock, cleanup traps, and recovery advice. No new actionable issues were found. Bash syntax and diff whitespace checks passed; runtime suites were not rerun during this review.
|
|
Thanks for the rebase. The rollback now works on top of the sudo boundary, and the reproduction passes at this head. One gap is left: the sync databases are not restored along with the configuration. What was checked. I'm Claude Opus 5.5, reviewing for omabot. On a disposable Omarchy VM (x86_64) I ran
Cleanup is still handled by the EXIT trap, the credential is revoked before the restore copies, and the original exit status is kept. The gap. The proportionate fix is to refresh the databases after both files are restored, for example Second opinion. Codex Medium reviewed this head. It found the database gap above, which I had not looked at, and the VM run confirms it. It also asked whether a transaction that fails during commit, after some packages are already installed, is made worse by restoring the old channel. I don't think it needs a change. Pacman's conflict and disk-space checks run before any package is touched, so commit-time failures are rare. Rerunning Related. #7998 renames these backups to timestamped names. Whichever lands second has to make Next. This waits on you for the database refresh. Once that is pushed, it will be tested again on a worker. |
46cb70c to
433db5e
Compare
|
Re-reviewed at 433db5e. The lock and the signal handling work, and the rollback still fixes the bug. The sync-database gap from my last comment is still open. This push landed a minute after that comment, so it could not have covered it. What was checked. I'm Claude Opus 5.5, reviewing for omabot. I used a disposable Omarchy VM (x86_64) with real
I read the new EXIT trap against Still open: the sync databases. After the failed sync above, the configuration was back on stable but A limit worth stating in the description. The rollback revokes the sudo timestamp and then asks for authorization again. If the refresh was ended by HUP because its terminal closed, there is nothing to answer that prompt. The restore copies then fail and the script prints "Failed to restore the previous pacman configuration." That is no worse than Second opinion. Codex Medium reviewed this head. It also found the database gap and the HUP limit. On the databases, it preferred the message to running a refresh from inside cleanup. It found no defect in the Related. #7998 renames these backups, and #9878 adds a step after the channel copies in the same script. Whichever lands second has to be adjusted. Next. This waits on you to handle the sync databases. Once that is pushed, it will be tested again on a worker. |
433db5e to
8bea833
Compare
8bea833 to
b46a017
Compare
|
Re-reviewed at b46a017. The rollback still fixes the bug, and the database warning closes the gap from my last comment. One line of the newest guidance points users at the wrong command, though. What was checked. I'm Claude Opus 5.5, reviewing for omabot. I used a disposable Omarchy VM (x86_64) with real
The retry line.
A fix that keeps the point of the warning: keep line 58, and make line 59 say to resolve the error and retry the command that started the refresh, before installing more packages, without naming one. A test for the advice is also weak. The stub writes the "updated package" marker whatever the transaction is, so the new case checks the wording and not that following it recovers anything. That is fine for wording. It just should not be read as more. Second opinion. Codex Medium reviewed this head. It raised the same retry-line problem, and added the Next. This waits on you to fix the retry line. Once that is pushed, it will be tested again on a worker. |
b46a017 to
4fdd3f9
Compare
|
Re-reviewed at 4fdd3f9. The retry line is fixed, and the rollback still works. Nothing else is open on this pull request. What was checked. I'm Claude Opus 5.5, reviewing for omabot. I used a disposable Omarchy VM (x86_64) with real
Second opinion. Codex Medium reviewed this head. It checked the new wording against Next. Nothing is waiting on you. This waits on the maintainer, and on the unrelated |
quattro now resolves the platform's pacman templates and default channel before touching /etc (omacom#14431). That validation exits before anything changes, so it runs first, and the lock, backups and rollback trap follow it unchanged; the channel copies read from $templates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This had started to conflict with The conflict. #14431 made What was checked. I'm Claude Opus 5.5, reviewing for omabot. I used a disposable Omarchy VM (x86_64) with real
Second opinion. Codex Medium reviewed the merge. It found nothing wrong. It checked that the platform check still exits before any change. It checked that the rollback restores fixed paths in Next. This waits on the maintainer, and on the shell suite failures that are also on |
omacom#15903 added an --ignore for omarchy-dev and omarchy-settings-dev to the stable and rc transaction, on the same line the rollback closes the refresh lock on. Both stay: the ignore list is passed first and the lock fd is closed after it. The rollback test's success case refreshes to stable, so it now expects the ignore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This had started to conflict with The conflict. #15903 made the final transaction pass What was checked. I'm Claude Opus 5.5, reviewing for omabot. I used a disposable Omarchy VM (x86_64) with real
Second opinion. Codex Medium reviewed the merge and found nothing wrong. It checked that the rollback still covers everything from the backups to the end of the transaction. It checked that the ignore pair reaches stable and rc and not edge, and that closing the lock fd works alongside an empty array under Next. This waits on the maintainer, and on the shell suite failures that are also on |
When a channel refresh fails or is interrupted after replacing pacman's configuration,
omarchy-refresh-pacmanleaves the machine pointing at the unsuccessful channel. Restore both/etc/pacman.confand/etc/pacman.d/mirrorlistfrom the existing.bakfiles on failure, preserving the original exit status.The refresh acquires a nonblocking, system-wide
flockon the existing root-owned/etc/pacman.ddirectory before making either backup. The lock stays held through the transaction, rollback, and final sudo revocation. A second refresh exits before copying anything, even from a different runtime directory. Hook and transaction children do not inherit the lock descriptor, so background hook processes cannot retain it after the refresh exits.Rollback is armed only after both backups succeed and disarmed only after the transaction succeeds. EXIT cleanup attempts to restore both files for ordinary failures and HUP/INT/TERM, then calls
omarchy_security_exit_with_revoked_sudoto retain upstream's credential cleanup. Bash waits for the foreground child before handling a signal, preventing restoration from racing that child. Cleanup ignores further HUP/INT/TERM while attempting both restorations. As with any shell cleanup, SIGKILL and power loss cannot be handled.Restoring configuration does not restore downloaded sync databases. After both restore copies succeed, the command warns that the databases may still belong to the failed channel and tells the user to run
sudo pacman -Syybefore installing packages. If package changes began before the failure, database refresh alone cannot complete or undo them. The message also tells the user to resolve the error and retry the command that started the refresh before installing more packages. This retains the caller's remaining steps, including channel package selection, linking, migrations, or package reinstalls. Cleanup does not start another network/package operation.Restoration requires sudo authorization after the timestamp is revoked. If HUP means the terminal has closed and sudo cannot prompt, the copies can fail. The script reports that failure and preserves the original status; the signal tests with authorized sudo establish the cleanup path, not guaranteed recovery after terminal loss. A separate HUP regression denies both restore authorizations and checks this limitation explicitly.
Rebased onto
quattroatf45461a3. The privileged Bash entry checks, cold hook boundary,omarchy-update-pacmantransaction, and four-copy success path remain intact. The real hook runner continues to report and swallow user-hook failures; tests distinguish that behavior from failure of the runner itself.Validation in an isolated checkout in the disposable ARM64 Omarchy VM:
sudo -k. Channel sudo-boundary tests: 19/19 with default HUP/INT dispositions restored by the VM runner. The earlier HUP failure was caused by inherited signal handling in the background test launcher.omarchy-refresh-pacmanmakes the initiating-command wording regression fail. Earlier independent mutation checks fail as expected: removing the partial-upgrade advice or database warning fails the corresponding guidance assertion; disabling the lock allows the second refresh through; bypassing rollback for TERM leaves pacman.conf changed. The earlier unmodified-upstream mutation also fails the partial-copy regression.git diff --checkpass. Runtime suites require Linux (/procand fixed/usr/binpaths), so they run in the VM../test/all: 8 of 292 shell test files failed and 16 files reported skipped checks; the CLI suite also failed. All eight failing files and the CLI suite were rerun on untouchedf45461a3and failed there too:config,kernel-headers-migration,launch-browser,omarchy-kernel-migration,passwordless-grant-lifecycle,snapper,unowned-system-paths, andvideo-background. The CLI failure remainsvscode generated theme references current theme file. These include the missing companionomarchy-pkgscheckout and VM/environment limitations; the aggregate suite is not claimed green.channel-sudo-boundarypasses on both patched and untouched checkouts with normal signal dispositions.