tracer
tracer copied to clipboard
Automatically recognize available package managers
Currently, we have a hardcoded dictionary in System.package_manager
saying what package managers should be used on what distributions. I think this is no longer a good enough solution.
Maybe we could go through all package managers that Tracer can work with and see if they are available on the system. Each implementation of IPackageManager
could provide is_available
method running whatever check is necessary to decide whether such package manager is available on the system. If no package manager is found, we will raise an exception.
We should also do something like this for if System.distribution() in ["rhel", "fedora", "centos", "centos-7", "mageia", "suse", "ol"]:
conditions.
Maybe we could go through all package managers that Tracer can work with and see if they are available on the system.
That's not necessarily the best idea. I've had problems with other tools that do that, because apt
is installed on my Fedora system. It's not the system package manager, but it's there and available. Too many tools see that, and jump right to the conclusion that it's a Debian-derived install when in reality nothing could be further from the truth. A certain package manager merely being available says... well, exactly nothing, honestly.
A better test might be to find some way to query what backend PackageKit is using on the host, which should be representative of the system package manager.
Thank you for the insight @ferdnyc, I didn't think of that.
@FrostyX Yeah, I don't think I would have either, if I hadn't been bitten by it enough times. 🫤
I think this is no longer a good enough solution.
Maybe you could expand a bit on the problems of the current approach? It's probably obvious to you but just from the outside I think hard-coding a package manager for a specific distro is not too bad. In the end to me this is about system-level integration which often requires putting down specific values.
Or to put it differently: heuristics for auto-detection will have their own flaws.