aboutsummaryrefslogtreecommitdiff
path: root/todo.org
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-25 00:23:47 -0400
committerCraig Jennings <c@cjennings.net>2026-06-25 00:23:47 -0400
commit2da6a6f9e56b6e785a8c51266c5c75e6c8dca29c (patch)
tree9fab3f7138a3c4d21211ddc57ca3b4ae8e9a8c1a /todo.org
parent5dbc1d74a96e044b3b88ac20735ba5d94db1bd24 (diff)
downloadarchsetup-2da6a6f9e56b6e785a8c51266c5c75e6c8dca29c.tar.gz
archsetup-2da6a6f9e56b6e785a8c51266c5c75e6c8dca29c.zip
feat(archsetup): back up system files before in-place edits
Add a backup_system_file helper that snapshots a pre-existing file to <path>.archsetup.bak before archsetup edits it in place, so a botched edit to fstab, mkinitcpio.conf, or sudoers is recoverable. It is idempotent: it never overwrites an existing backup, so the pristine original survives repeated edits within a run and across re-runs. It uses cp -p to preserve mode and ownership. Only the in-place sed and append edits to pre-existing files route through it (locale.gen, makepkg.conf, pacman.conf, sudoers, wireless-regdom, geoclue.conf, pacman-contrib, fstab, mkinitcpio.conf, vconsole.conf). The brand-new drop-in files archsetup fully owns are skipped: there is no prior state to save, and recovery is just deleting them. Covered by tests/backup-system-file/ (Normal, Boundary, Error cases, including mode preservation and the no-overwrite guarantee).
Diffstat (limited to 'todo.org')
-rw-r--r--todo.org5
1 files changed, 4 insertions, 1 deletions
diff --git a/todo.org b/todo.org
index 158ed03..eefaf3a 100644
--- a/todo.org
+++ b/todo.org
@@ -521,7 +521,8 @@ Some operations log to ~$logfile~, others don't - standardize logging
All package installs should log, all system modifications should log, all errors should log with context
Makes debugging failed installations easier
-** TODO [#B] Add backup before system file modifications :solo:
+** DONE [#B] Add backup before system file modifications :solo:
+CLOSED: [2026-06-25 Thu]
:PROPERTIES:
:LAST_REVIEWED: 2026-06-24
:END:
@@ -529,6 +530,8 @@ Safety net for /etc/X11/xorg.conf.d and other system file edits
Files like ~/etc/sudoers~, ~/etc/pacman.conf~, ~/etc/default/grub~ modified without backup
If modifications fail or are incorrect, difficult to recover - should backup files to ~.backup~ before modifying
+Done 2026-06-25: added a =backup_system_file <path>= helper next to =safe_rm_rf= — it snapshots a pre-existing file to =<path>.archsetup.bak= before an in-place edit, idempotent (never clobbers an existing backup, so the pristine original survives repeated edits and re-runs), =cp -p= to preserve mode/ownership, no-op when the file is absent. Took the narrow scope (Craig's call): route only the in-place =sed -i= / append edits to *pre-existing* files through it — locale.gen, makepkg.conf, pacman.conf, sudoers, conf.d/wireless-regdom, geoclue.conf, conf.d/pacman-contrib, fstab, mkinitcpio.conf, vconsole.conf — and skip the brand-new drop-in files archsetup fully owns (nothing to back up; recovery is just deleting them). Tests: =tests/backup-system-file/= (7 Normal/Boundary/Error, incl. mode-preserved, existing-backup-not-overwritten, missing-target no-op, cp-failure). =make test-unit= green across all 5 suites; =bash -n= clean; only shellcheck note is the known SC2329 false positive (indirect STEPS dispatch). Integration verification is the next VM run.
+
** TODO [#B] Implement Testinfra test suite for archsetup
:PROPERTIES:
:LAST_REVIEWED: 2026-06-24