rpm-software-management / libdnf

Package management library.
GNU Lesser General Public License v2.1
184 stars 139 forks source link

os-release error on macOS #1221

Open ttmgraham opened 3 years ago

ttmgraham commented 3 years ago

I'm currently working on getting libdnf/microdnf working on macOS (I know weird right?), but here libdnf is hardcoded to look for VERSION_ID in the os-release file. Since os-release is not a thing on mac we get the following error.

error: Could not find os-release in etc/, usr/etc, or usr/lib under source root '/'

While we can work around this it has a potential to cause problems with our configuration management setup, because it also looks for that file while compiling system information.

I'm willing to create a PR to try and fix this so libdnf can pull the version on macs, but any advice as to the correct way to implement that would be appreciated.

lukash commented 3 years ago

So the VERSION_ID from os-release is ultimately used as the $releasever substitution variable in repository configs. Would you like to use this established mechanism for anything and set the $releasever to a particular value?

Another question is how would you actually detect you're running on macOS? Or would you just compile for macOS and assume you're always running on it? (the binary probably won't run anywhere else, right?)

The easiest way for you might be to just create the /etc/os-release file with reasonable data. Bring macOS on with the standard :grinning:

FWIW we're now working on version 5 of dnf/libdnf. It's likely not worth it making any significant changes to the way this is handled in the current code base. We might just accept an #ifdef...

Conan-Kudo commented 3 years ago

If we use distroverpkg strategy like DNF itself does, then a custom-made macos-release package could handle it. :)