The purpose would be to have the equivalent of Ubuntu's "apt-get autoremove" functionality.
When you install package P, it might draw in dependancies D1, D2, ... Dn automatically.
When you later uninstall P, the dependancies D1, D2, ..., Dn might remain on your system.
If you keep installing and uninstalling packages, after a while your system remains cluttered with things you don't need.
The idea would be to mark all dependancies that were installed but not explicitely requested as "installed automatically". Then a command like "zypper autoremove" could remove them at once if they are not needed anymore.
Approaches seen online
After scouring forms for solutions these are some alias's used to replicate the functionality
zypper packages --unneeded | awk -F'|' 'NR==0 || NR==1 || NR==2 || NR==3 || NR==4 {next} {print $3}' | grep -v Name | sudo xargs zypper remove --clean-deps
This one is a script and has bashisms
bash mapfile -t unneeded < <(zypper --quiet pa --unneeded | awk '$1 == "i" { print $5, "-", $7 }') (( ${#unneeded@]} )) && sudo zypper --quiet rm --clean-deps --details "${unneeded@]}"
sudo zypper rm $(zypper pa --unneeded | awk '/i / {print $3}' FS='|' | uniq | tr -d ' ')
Based on testing zypper packages --orphaned
provides packages that are not in any repo, even if a user has explicitly installed them, so --orphaned
may not be the way to go, instead focusing on --unneeded
Looking for hackers with the skills:
This project is part of:
Hack Week 15 Hack Week 24
Activity
Comments
-
almost 8 years ago by dmacvicar | Reply
There is
zypper packages --unneeded
which I am not sure if it takes into account/var/lib/zypp/AutoInstalled
.In any case a worth project is to:
- Fix the man page
- Expose the functionality somehow present
zypper packages --unneeded
(only lists) andzypper rm -U foo
(not usable without a package argument) into an usable command.
-
almost 8 years ago by e_bischoff | Reply
Thanks Duncan. I did not know about the --unneeded flags.
After searching a bit, I found it was described by
https://features.opensuse.org/300758
I don't think that
"packages which are not required by other packages and are not in wanted selections"
match the list of "automatically installed" packages that I described, but it seems to address pretty much the same use case:
A typical use case: user installs an application which pulls in some dependencies to test it, uninstalls the application shortly after or way later but the dependencies stay unused installed on the system.
In any case, turning this list of packages into a command currently requires quite a bit of sed/awk:
https://forums.opensuse.org/showthread.php/422841-Remove-unused-packages-with-zypper-or-yast/page2
so a "usable command" as you say it would make sense.
-
almost 8 years ago by e_bischoff | Reply
My first tests show that once you remove packages listed with zypper packages --unneeded, new unneeded packages appear. This shows that the --unneeded feature does not explore the tree in depth, or said otherwise, it does not mark as unneeded the packages that would become unneeded if the "immediately" unneeded were removed.
I also remarked that packages you installed explicitely but are not in "wanted selections" are marked as "unneeded". That one is bad.
In short, this "unneeded" feature does not really work the same way as the "installed automatically" feature on Debian / Ubuntu.
-
almost 8 years ago by mlandres | Reply
IMO prerequisite for any automatic cleanup is the ability to inspect and manipulate a packages 'autoinstalled' property. This is the base on which the resolver decides which packages can be cleaned and which are requested by the user. If you can not change this property, you can not influence the resolvers decision.
-
over 5 years ago by e_bischoff | Reply
Right.
At the end I had not the time to work on this in Hackweek 17.
-
17 days ago by e_bischoff | Reply
Congrats! I can't wait until it is integrated into the official zypper!
Similar Projects
Ansible for add-on management by lmanfredi
Description
Machines can contains various combinations of add-ons and are often modified during the time.
The list of repos can change so I would like to create an automation able to reset the status to a given state, based on metadata available for these machines
Goals
Create an Ansible automation able to take care of add-on (repo list) configuration using metadata as reference
Resources
- Machines
- Repositories
- Developing modules
- Basic VM Guest management
- Module
zypper_repository_list
- ansible-collections community.general
Results
Created WIP project Ansible-add-on-openSUSE