Skip to content
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

Adopt a hierarchy for getting distro name/version on Linux #1576

Open
joshuar opened this issue Jan 2, 2024 · 0 comments
Open

Adopt a hierarchy for getting distro name/version on Linux #1576

joshuar opened this issue Jan 2, 2024 · 0 comments

Comments

@joshuar
Copy link

joshuar commented Jan 2, 2024

Is your feature request related to a problem? Please describe.
On Linux, there are many difference files that can provide distribution details. gopsutil should adopt a hierarchy for checking those files, using the information from the first file found.

Describe the solution you'd like
While gopsutil does currently adopt this kind of approach, the order of checks could be improved. My suggestion would be something like:

  • /etc/os-release
  • /etc/lsb-release
  • /etc/*[version|release]

Above, preference the general standards/guideline files first, then the distro-specific files. /etc/os-release appears to be adopted widely, and often contains much more specific information (regarding distribution variants) than the other sources. While /etc/lsb-release usage appears to be waning and discouraged, it is still an important source for this information. The remaining files such as /etc/redhat-release, /etc/SuSE-release, /etc/debian_version, /etc/arch-release, /etc/gentoo-release, /etc/slackware-version, /etc/frugalware-release, /etc/altlinux-release, /etc/mandriva-release, /etc/meego-release, /etc/angstrom-version, /etc/mageia-release may or may not contain variant-specific information.

For example, I would image a lot of variants based on Debian do not edit /etc/debian_version and so relying on this first will report the wrong information (the debian base version, not the variant version). Likewise, if I was going to build my own distribution based on Fedora, I would likely leave /etc/redhat-release untouched and place my distribution information in the /etc/os-release file.

Describe alternatives you've considered
For my own usage, my alternative would be to just write my own code to apply the above order.

Additional context
Preferencing /etc/os-release over /etc/debian_release for example should fix #1469 and #224 and likely avoid similar issues in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants