-
Notifications
You must be signed in to change notification settings - Fork 6
Add extra fields, default values and documentation from man os-release and other OSs
#1
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
base: master
Are you sure you want to change the base?
Conversation
Also added default values for fields, fall back on `/usr/lib/os-release` if `/etc/os-release` cannot be opened and added more tests.
|
Should optional keys be |
|
I think it'd be better if optional fields are left in the extras hashmap, and accessible through methods. |
Almost all of the fields are optional though. In fact, only 3 aren't. I think all fields in the spec should be present in the struct with additional (unofficial) fields in the hash-map. I considered making optional fields |
Doc correction: mention that version is optional.
Just to be clear, I think having fields as |
| id: "linux".into(), | ||
| pretty_name: "Linux".into(), | ||
|
|
||
| version: String::new(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I know this is an ancient PR, but we were considering adding a new use of this crate in a project and I went to look at it and noticed the last commit was 6 years ago, which...isn't wrong since obviously things are stable, but on the other hand I'd like to just know things I depend on are maintained)
Anyways: I think this can just be ..Default::default() right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't seen any use case that required updating it. There is already a hash map storing extra fields.
The basis of this PR is https://www.freedesktop.org/software/systemd/man/os-release.html
I've added fields specified in that man page which weren't in the OsRelease structure before. These fields appear in other operating systems such as Arch, Fedora and derivatives. These are:
ANSI_COLOR(this is the main thing I found missing!)CPE_NAMEDOCUMENTATION_URLBUILD_IDVARIANTVARIANT_IDLOGODefault values for
name,pretty_nameandidare now also provided as specified by the man page.OsRelease::newfalls back to/usr/lib/os-release.Also added tests with os-release files from multiple distros with added weird formatting.
Thanks!