-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing for package managers is getting to be a big mess #439
Comments
declare -A pkg_system
pkg_system["label"] = "rpm"
pkg_system["probe"] = "command -v rpm"
pkg_system["label"] = "deb"
pkg_system["probe"] = "command -v deb"
pkg_system["label"] = "arch"
pkg_system["probe"] = "command -v pacman" Then we'd see which of these labels applies and have another list of package names that are distro dependent or something like that? I'm open to other approaches. Probing /etc/os-release is a good suggestion tbh - at least for freedesktop compliant linuxes. |
I also think maybe we should have a |
It occurs to me if we probe attempt_probe_os_release() {
# DO SOME MAGIC HERE
::
}
os_release_id = $(attempt_probe_os_release)
case $os_release_id in
"debian") ...
_KERL_PROBE_COMMAND=$( dpkg ... )
_KERL_BUILD_PREREQS="foo bar baz"
;;
"redhat")
...
;;
*)
echo "This linux flavor ${os_release_id} is unrecognized. Build prerequisites will not be checked. Support this Linux variant by submitting a PR to https://github.com/kerl/kerl"
_KERL_CHECK_BUILD_PACKAGES=false
esac |
My favorite bit 😄 |
in addition to if its helpful, here's a table mapping
In the rows where more than one distro ID is listed, the other columns apply exactly to those IDs. Where ID_LIKE is missing, it is not included in that distro's os-release. "ol" is the somewhat cryptic ID for Oracle Linux, which is (afaict) similar to RHEL. |
Thanks for the table @skwerlman that's super helpful |
Something else that's come up a bunch is that package names using dnf/rpm are not consistent across distros - I know SuSE has some different library names from Fedora or Amazon Linux. So I guess we'll have to account for that somehow too. |
@jadeallenx, if that's Ok with you, I could edit (and keep editing) the initial description to include a simple algo. for the code update when someone eventually gets to this. Otherwise reading through all these comments can contain contradictory suggestions/options (they're good for history, otherwise, but maybe not be "best" place to design the algo.). Thoughts? |
Yeah that's good with me. I have been "thinking aloud" here and it is not all very simple or coherent |
What do we do when there's more than one package manager? Test them one by one? e.g. |
I would say we expect the "default" method (so probably
Yeah this is exactly why I didn't want to get into this business in the first place 😂 I think we start with the package managers we currently support and make it easy for people to extend with a PR if they are so inclined. |
I see. Maybe that's more feasible, to start with what we have. I was already listing package managers per "most popular Linux distro" and then I'd drill down. Do you know of any other issue that might be tied to this, too? So you don't want an addition, right? You want a kinda code refactor (?) |
Ideally I'd like to see a generic set of functions that scan for packages and make it somewhat obvious for people who want to support new distros what needs to be added (and where) |
Yeah, something like redhat
rpm
make
_rpm_is_installed "make" (?) |
What distros should we aim for, to start? Something like
|
I think it'd be something like probe_method = id_distro
for pkg in $(get_distro_pkgs)
_is_installed probe_method pkg But I don't know if that's feasible. Open to other ideas, too. But to me that seems super clean. |
I'm missing something. You need to identify:
right? Or would you do without the package manager? And simply shove that into the probe? |
e.g.
We could go over the entries in the array and split distro from package. |
Maybe rpm would be repeated a few times, but you get more flexibility. You might wanna just verify some file exists or something... |
POSIX-sh has no associative arrays 😢 Kerl is POSIX. Edit: as an added bonus, if we moved to Bash we'd get locally scoped variables 😄 |
As an example, the closest I have to this working is
The way I have it is generic, but potentially more repetitive, in writing the probes. If we wanna consider the probes not only linked to a package manager (as I suggested before) verbose is better. |
Proposed strategy: an associative array (i.e., a map in erlang terms, or a dict in python terms) of a command string with a label - execute the command and if it returns "true" then add the label to an output array. When we get the output array back we can see how many elements are in it and then call the appropriate testing functions (if any) for installed packages,
The text was updated successfully, but these errors were encountered: