OpenMediaVault-Plugin-Developers / openmediavault-apttool

openmediavault plugin for apt tools
6 stars 2 forks source link

Suggestion: Perform a check before removing package #4

Open BillyNate opened 5 months ago

BillyNate commented 5 months ago

If someone (not me ๐Ÿ™„) adds a package to the package list that's a (already installed) dependency of the openmediavault package (let's say libxml2), and removes this package later on, the --yes --auto-remove will promptly remove openmediavault (and all related packages) as well.
Maybe a check before a package gets removed, preventing any dependencies of openmediavault to be removed, would be a nice addition ๐Ÿ˜…

ryecoaaron commented 5 months ago

That would be tough. OMV not including plugins have all of these dependencies but the plugin would have to prevent the dependencies of those dependencies from being removed. I am open to suggestions though.

BillyNate commented 5 months ago

I was thinking about checking the output of apt-cache rdepends --installed --recurse pkgname for openmediavault.
If present, the removal of the package could be blocked and the output could show a message.

ryecoaaron commented 5 months ago

Good ideal. I see what I can come up with.

BillyNate commented 5 months ago

Thank you for your effort. If there's anything I can help you out with, please let me know.
I have no experience with the inner workings of OVM plugins though ๐Ÿ˜ช

ryecoaaron commented 5 months ago

7.1 is in the repo. Let me know what you think.

BillyNate commented 5 months ago

Wow, you work quick!
7.1 has been installed, and is looking good! The OMV dependency column also gives a nice quick overview.
Previously I installed git through the Apt Tool. I noticed it gets recognized as a dependency now.
The output of apt-cache rdepends --recurse git is a pretty long list of packages, including various openmediavault packages. When the --installed parameter is added, the list of returned packages is empty.
Since I can safely apt remove git without autoremoving any openmediavault packages I would say git should not be recognized as a dependency of OMV. How do you feel about adding the --installed parameter to the isOmvDependency() function?

ryecoaaron commented 5 months ago

I tried many different combinations and got false positives no matter what I used. I got more false positives with the โ€”installed flag set.

BillyNate commented 5 months ago

Thank you for looking into it!

ryecoaaron commented 5 months ago

7.1.1 is in the repo now. It uses apt-get purge --simulate to check to see if the system would remove the package. I think this will be the most accurate method.

BillyNate commented 5 months ago

Nice job!