Add an optional, confirmed Clean Up action to Spaced Update (#217) - #226
Merged
Merged
Conversation
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.
Deploying spaced-linux with
|
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-planis read-only and printsREMOVE <pkg> <ver>,BLOCKED <pkg> <reason>andAUTOCLEAN_BYTES <n>, based onapt-get -s autoremove.cleanup-applyrecomputes the plan itself and never trusts input from the GUI. Autoremove is refused entirely if the set contains anyCLEANUP_PROTECTED_PATTERNSentry: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 exits3("cache cleaned; removal refused for safety").cleanup-applyruns 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)Tests: 12 tests in
tests/test_update_cleanup.pywith fakeapt-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.shpassed; 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