Skip to content

Add an optional, confirmed Clean Up action to Spaced Update (#217) - #226

Merged
crhy merged 4 commits into
mainfrom
feature/217-update-cleanup
Sep 14, 2026
Merged

crhy merged 4 commits into
mainfrom
feature/217-update-cleanup

Conversation

@crhy

@crhy crhy commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Fixes #217.

Updates still never clean up automatically. Clean Up is a separate, explicit action.

Helper (spaced-update-helper, runs as root via pkexec)

  • cleanup-plan is read-only and prints REMOVE <pkg> <ver>, BLOCKED <pkg> <reason> and AUTOCLEAN_BYTES <n>, based on apt-get -s autoremove.
  • cleanup-apply recomputes the plan itself and never trusts input from the GUI. Autoremove is refused entirely if the set contains any CLEANUP_PROTECTED_PATTERNS entry: spaced-* packages, mate-, caja, compiz, marco, lightdm, network-manager, sysvinit, elogind, xserver-xorg-core, flatpak, apt, dpkg, the running kernel's image or headers, or more than 50 packages. In that case it only runs autoclean and exits 3 ("cache cleaned; removal refused for safety").
  • cleanup-apply runs under the same transaction lock and the same APT transaction guard as updates (DPkg::Pre-Install-Pkgs). That second layer validates the real dpkg transaction, covering anything that changes between plan and apply.

GUI (spaced-update.py)

  • A secondary "Clean Up…" button, disabled while busy, shows the plan with Cancel as the default.
  • If anything is blocked, the dialog explains why and offers only "Clean Package Cache"; exit 3 is reported as success along with the blocked packages. "Nothing to clean up." is shown when the plan is empty.

Tests: 12 tests in tests/test_update_cleanup.py with fake apt-get/uname, a stub guard, and exit-code mapping. They are host-independent (proven with the real guard path hidden). check.sh asserts the modes, protected patterns, the kernel check, the guard condition, and that update paths contain no autoremove. check.sh passed; 104 tests OK.

Implemented by Muse Spark 1.3 (opencode). Review findings from Claude, implemented by Muse Spark: apply the APT transaction guard to cleanup, make the tests independent of the host guard, and report a cache-only cleanup as success instead of failure.

🤖 Generated with Claude Code

https://claude.ai/code/session_0157UgH4vsxpmbozsNLjJ42m

rhy added 3 commits September 14, 2026 14:10
Spaced Update gains a secondary Clean Up button that plans
autoremove/autoclean through two new privileged helper modes and only
proceeds on explicit confirmation. cleanup-plan reports REMOVE/BLOCKED/
AUTOCLEAN_BYTES lines; cleanup-apply re-plans internally, refuses
autoremove entirely when protected desktop/init/running-kernel packages
or an unusually large set is present (autoclean only, non-zero exit),
and otherwise runs autoclean plus autoremove under the update lock.
Update paths never clean up automatically. Adds helper unit tests with
fake apt-get/uname, check.sh assertions, and a CHANGELOG entry.

Fixes #217
Install the APT transaction guard (DPkg::Pre-Install-Pkgs) for
cleanup-apply exactly like 'all' and 'apt-install', so the guard
validates the real dpkg transaction under APT's lock and refuses
removal of critical packages even if the set changes between the
cleanup plan and 'apt-get autoremove'.

Make the guard path overridable only in test mode via
SPACED_UPDATE_TEST_GUARD (pkexec strips test variables in
production), relaxing only the root-ownership check for the
user-owned stub while keeping the no-group/other-write check.
Point the cleanup tests at a stub guard and assert apply passes it
through; add a check.sh assertion on the guard condition.
A blocked cleanup-apply cleans the package cache successfully but
exited 1, so the GUI reported a failure and the status line wrongly
promised package removal. The helper now exits the blocked branch
with the distinct documented code 3 (cache cleaned, removal refused
for safety); real failures keep their existing codes.

The GUI sends APPLY for 'Clean Package Cache' and shows 'Cleaning
the package cache' while it runs, maps exit 3 to a 'Package cache
cleaned' INFO result listing the blocked packages, and keeps the
'Cleanup complete' dialog for exit 0. check_status() is untouched.
Tests assert the new code and the exit-code/blocked-list mapping.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 14, 2026

Copy link
Copy Markdown

Deploying spaced-linux with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8795281
Status: ✅  Deploy successful!
Preview URL: https://d1a60a7e.spaced-linux.pages.dev
Branch Preview URL: https://feature-217-update-cleanup.spaced-linux.pages.dev

View logs

@crhy
crhy merged commit 3bd4f9f into main Sep 14, 2026
2 checks passed
@crhy
crhy deleted the feature/217-update-cleanup branch September 14, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should spaced update do autoremove and autoclean?

1 participant