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

feat: Improve file_release support #329

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

exincore
Copy link
Contributor

@exincore exincore commented Jan 1, 2023

Description

Support more operating systems for linux/file_release.rs that linux/lsb_release.rs can already detect.
Allow linux/file_release.rs to detect more information about an operating system.

Motivation

linux/file_release.rs does not yet match the functionality of linux/lsb_release.rs. Some systems which are claimed to be supported on the README are not detected where lsb_release is not present.

Todo

  • Test Arch
  • Support Debian
  • Test Debian
  • Support EndeavorOS
  • Test EndeavorOS
  • Support Garuda
  • Test Garuda
  • Support Gentoo
  • Test Gentoo
  • Support Manjaro
  • Test Manjaro
  • Test openSUSE
  • Support Pop
  • Test Pop
  • Support Raspbian
  • Test Raspbian
  • Support Solus
  • Test Solus
  • Test SUSE (sled and sles_sap)
  • Improve testing clarity and naming
  • Add rolling release detection
  • Add edition detection where possible
  • Add codename detection where possible
  • Add gathering of data from every release file instead of only the first match in order to obtain information that may be scattered between release files

@exincore exincore force-pushed the feature/more-linux-distributions-file-release branch from 65b38e5 to 65d018d Compare January 1, 2023 18:21
Support more operating systems for file_release that lsb_release can already detect
…g unit tests

* test: reorder `file_release::tests::retrieve` `expected_pairs`

* test: accidentally discover and fix errors in tests of `centos-release` and `redhat-release`

* test: stop test `release_info_debug` from debug printing

* test: discard unknown version tests of `centos-release`, `fedora-release`, `mariner-release`, and `redhat-release`
* test: detect edition
* test: add codename detection
@exincore exincore force-pushed the feature/more-linux-distributions-file-release branch from 544c957 to 82c5617 Compare January 2, 2023 01:04
@exincore
Copy link
Contributor Author

exincore commented Jan 2, 2023

I am finding some issues when categorizing some distributions.

There is only one Type::SUSE, but multiple variations, SUSE Linux Enterprise Server and SUSE Linux Enterprise Desktop, for example, exist which are not recorded as actual editions/variations within the os-release, but instead as different IDs (sles vs sled). To make matters worse, sles-sap has an ID=sles and the only difference is in CPE_NAME.

A similar issue appears between openSUSE Leap and openSUSE Tumbleweed, where the distinction is recorded as different IDs (opensuse-leapvsopensuse-tumbleweed`).

It is unclear to me whether they should be categorized into editions anyway, or if new Types are needed to differentiate, or if the current structure needs to be more deeply revamped in order to handle these more complex relationships between distributions, platforms (families?), etc.

Related #313 #312 #280

@stanislav-tkach
Copy link
Owner

Sorry for the delay with response and thank you very much for the pull request!

I'm also not sure in what direction to go with editions and families, so suggestions are welcome. Ideally I want to both preserve maximum information in a convenient way and not to over-complicate it. Originally I only wanted to have a string in any consistent format just to print it in logs and potentially show on a dashboard, but I understand that other people have different use cases.

By the way, there already was a discussion about families, but people voiced the same concerns: sometimes it isn't obvious how to properly categorize a specific distribution.

Additionally I think that versioning (the Version struct) is too complicated. Now I would prefer to have a simple version string with all the details because it only introduces unnecessary complexity without benefits. I don't want to bump version to 4.0 just for that, though.

),
];

for (root, expected) in expected_pairs {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also usually prefer to write tests like this, but now it stops at the first failure. Not a big issue, though.

@martintc
Copy link
Contributor

martintc commented Jan 7, 2023

My idea with families was more to deal with complications that can arise out of doing certain things on Linux platforms. As an example, comtrya is a config management tool. We have some logic that may change depending on the OS. using OS_Info for Windows and MacOS is a breeze to match on. Linux though is a pain because often what we want to do, the distro doesn't matter since what we are doing is quiet often universal to distributions. So the families was feature was a way to introduce where if I could rely on it is linux and the distro doesn't matter, the same action will work whether it is Debian or Fedora or Arch without need to create a bunch of arms to match against each distro to do the same thing.

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

Successfully merging this pull request may close these issues.

None yet

3 participants