Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds timestamped backups for Pacman and Limine refreshes to preserve configuration history.
Changes:
- Validates Pacman channels before backup creation.
- Timestamps Pacman and Limine backups.
- Adds backup retention and invalid-channel tests.
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 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
bin/omarchy-refresh-pacman |
Validates channels and creates paired timestamped backups. |
bin/omarchy-refresh-limine |
Adds timestamped Limine backups. |
test/shell.d/refresh-backup-test.sh |
Tests backup retention and channel rejection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| SH | ||
| chmod +x "$stub_bin/sudo" | ||
|
|
||
| for tool in limine-update limine-snapper-sync omarchy-update omarchy-pkg-add; do |
There was a problem hiding this comment.
Both right, and the first one is the more serious of the two. Fixed in d47a4d3.
omarchy-refresh-pacman:28 calls omarchy-hook pre-refresh-pacman, and omarchy-hook runs $HOME/.config/omarchy/hooks/<name> through bash. The test stubbed neither that nor HOME. It happened not to bite here only because omarchy-hook is not on PATH in my environment and the script has no set -e, so the missing command was shrugged off. On a machine with Omarchy installed it would have run the real hook with no isolation at all.
omarchy-hook is now stubbed alongside the other external commands, and HOME points at an empty directory inside the temp tree for every run, so a hook is unreachable by either route. The stubs also log what they were called with, and there is an assertion that the omarchy-hook pre-refresh-pacman call was answered by the stub. That way the isolation is proven rather than assumed, and if the script later calls something else instead, this test fails and gets looked at again.
| count=$(backups_in "$root_fs/etc" 'pacman.conf*bak') | ||
| (( count == 2 )) || | ||
| fail "two pacman refreshes keep both backups" "got: $count" | ||
|
|
||
| grep -rqx 'first pacman conf' "$root_fs/etc"/pacman.conf*bak || | ||
| fail "the first pacman refresh's backup survives the second" |
There was a problem hiding this comment.
Correct, and it undercut the paired-backup claim in the description. Fixed in d47a4d3.
The mirrorlist now gets the same two checks as pacman.conf: two backups after two runs, and the first run's content still readable in one of them. On top of that, the pairing is checked directly. The stamp is read off each pacman.conf.<stamp>.bak and a mirrorlist.<stamp>.bak is required to exist for it, so either file drifting to its own clock or to a fixed name fails.
Verified it catches what you described: reverting only the mirrorlist line to /etc/pacman.d/mirrorlist.bak and leaving pacman.conf timestamped now fails with "two pacman refreshes keep both mirrorlist backups, got: 1". Against the original scripts the first case still fails at "got: 1".
One aside while I was in here. My earlier check of this test against the old scripts was worthless, because I used git stash on files that were already committed on the branch, so nothing was actually reverted. Redone with git checkout upstream/quattro -- on the two scripts, which is where the failures quoted above come from.
Both scripts wrote a fixed .bak name, so a second run overwrote the backup from the first and the pre-refresh configuration could not be recovered. refresh-limine moves rather than copies, so there was nothing else left. refresh-pacman also took its backups before checking the channel argument, so an unknown channel spent them on its way to exiting. Name both <file>.bak.<epoch>, the same form omarchy-refresh-config uses, and check the channel first. The test reroots /etc and /boot through a sudo stub, stubs omarchy-hook so a developer's own pre-refresh-pacman hook never runs, and checks both pacman backups carry the same stamp.
d47a4d3 to
441f391
Compare
|
Switched the backup name to |
quattro rewrote omarchy-refresh-pacman behind its sudo boundary and already checks the channel before the backups, so the conflict resolves to quattro's script with only the backup names timestamped. The same rewrite rebuilds PATH around the no-update sudo wrapper, so the test's sudo stub no longer answered the pacman refresh: on a machine with passwordless sudo it would have reached the real /etc and a real pacman -Syyuu. The pacman half now runs on test/shell.d/fixtures/sudo-boundary-test.sh, whose stand-ins replace the fixed privileged paths, with cp rerooted into the test's tree and omarchy-update-pacman a logged no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Reviewed and verified on a disposable Omarchy worker. The fix holds on The bug is real. On the worker, two refreshes on What I pushed, and why. The branch conflicted with The same rewrite rebuilds Tests, on the worker:
Second opinion: Codex Medium reviewed the merged head read-only and found nothing to change. It agreed that the change is proportionate, the merge resolution is sound under the hardened startup, and the test cannot reach the host or pass on the unfixed scripts. It also noted that epoch-second stamps can still collide if two refreshes land in the same second, the same limit Nothing is left for you to do. This waits on the maintainer. One overlap to note: #13362 also edits these backup lines in |
…refresh quattro taught omarchy-refresh-pacman to pick its templates by platform and to refuse a channel the platform has no templates for, both before the backups are taken. The conflict resolves to quattro's script with only the two backup names timestamped, so a refused channel still writes no backup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
quattro's pacman-templates-test pins the exact backup commands, so it still expected the fixed .bak names this branch replaces. It now takes the stamp from the run's own log and requires the mirrorlist backup to carry the same one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This branch conflicted with What moved on Test update. Tests, on the worker:
Second opinion: Codex Medium reviewed this head read-only. It found no problem with the merge or the test update, and agreed that the change is proportionate and that neither test can pass vacuously. Its independence from my review is not guaranteed. Its one finding is that two refreshes started in the same second would still get the same name. That is the same limit Classification is unsettled. I classified this as a bug fix. Codex Medium, asked separately, classified it as an enhancement. Reasonable readings differ on whether an overwritten backup is a defect or the old design. The two models disagree, so I removed the |
|
| # Timestamped, the way omarchy-refresh-config names its backups. A fixed .bak | ||
| # name means a second run overwrites the backup from the first, so the config | ||
| # the machine booted with before any refresh cannot be recovered. | ||
| sudo mv /boot/limine.conf "/boot/limine.conf.bak.$(date +%s)" |
There was a problem hiding this comment.
Both refresh scripts still overwrite an earlier backup if two runs reach the backup step within the same second, such as a quick retry after a failed refresh. date +%s gives both runs the same filename, and mv or cp -f replaces the first backup. For omarchy-refresh-limine, this can erase the original configuration entirely.
Use names that cannot collide, while keeping one shared suffix for the pacman pair. Add a repeated-run test with a fixed clock; the current tests use sleep 1 and miss this case.
omarchy-refresh-limineandomarchy-refresh-pacmanboth keep a backup of what they replace, at a name that does not change between runs:Run either one twice and the second run overwrites the first run's backup. What is lost is the state the machine was in before any refresh, which is the state someone reaching for a backup usually wants.
omarchy-refresh-limineis the worse of the two, because it moves the config rather than copying it, so once the backup is overwritten the original is gone outright.The sibling scripts already timestamp.
omarchy-refresh-configwrites<file>.bak.$(date +%s)andomarchy-restart-audiodoes the same, so recoverable history is the house pattern and these two are the ones that drifted from it.omarchy-refresh-pacmanhas a second problem in the same lines. The backups are taken at the top of the file, before the channel argument is checked:So
omarchy refresh pacman stabeloverwrites both backups and then exits without changing anything else. A typo costs you the backups from the previous real run.What changed: both scripts name their backups
<file>.bak.<epoch>, the same formomarchy-refresh-configuses, andomarchy-refresh-pacmanchecks the channel before it writes anything. The two pacman backups share one timestamp so a pair from the same run stays recognisable as a pair.Tests: new
test/shell.d/refresh-backup-test.shstubssudoso the/etcand/bootpaths are rerooted into a directory the test owns, which keeps the real ones out of reach.omarchy-hookis stubbed too andHOMEpoints inside the temp tree, becauserefresh-pacmancallsomarchy-hook pre-refresh-pacmanand that runs a script from~/.config/omarchy/hooksthrough bash. Four cases: two pacman refreshes leave twopacman.confand twomirrorlistbackups with the first run's content still readable and each pair sharing one timestamp, an unknown channel is refused without writing a backup, the hook call is answered by the stub rather than a real hook, and two limine refreshes leave two backups. All 4 pass. Against the original scripts the first case fails reporting no timestamped backup where two were expected, which is the overwrite.