stanislav-tkach / os_info

Rust library to detect the operating system type
MIT License
175 stars 52 forks source link

FreeBSD support #246

Closed vpushkar closed 3 years ago

vpushkar commented 4 years ago

FreeBSD support

stanislav-tkach commented 4 years ago

Thanks for the suggestion! Unfortunately, right now I have only macOS at hand. Perhaps you would like to submit a pull request?

kraileth commented 3 years ago

@stanislav-tkach Would it help if I provided a way to get the relevant info on FreeBSD? I gave adding support for it myself a try by mostly copying Redox as an example. That way I got FreeBSD detected instead of Unknown, but I'm unable to write a proper os_info/src/freebsd/mod.rs as I am not a programmer (and know no Rust at all). I guess that I'd only have to call out to uname and parse what it returns but that's beyond what I can do.

In case anybody would give it a shot, here's the relevant commands and output from an modern arm server: It's running Release Candidate 1 for the upcoming FreeBSD 13.0, platform is aarch64, kernel version 1300139.

# uname -s
FreeBSD
# uname -r
13.0-RC1
# uname -K
1300139
# uname -p
aarch64

Output on my standard x86_64 workstation: It's running version 12.2, "release" branch, patchlevel 4 on amd64 with kernel version 1202000.

FreeBSD
12.2-RELEASE-p4
1202000
amd64

Here's an x86_64 laptop: It's running the development version (14.0 at this time) which is only available as the "current" branch, with kernel version 1400005.

FreeBSD
14.0-CURRENT
1400005
amd64

On an old Celeron test machine: This one is running version 12, "stable" branch, on i386 with kernel version 1202505.

FreeBSD
12.2-STABLE
1202505
i386

Not sure if the kernel version is relevant for os_info at all (it's more of an internal thing that the package manager uses to figure out if a newer package might not work on a system with a too old kernel). The platform surely is because it determines whether it's 64 or 32 bit.

There's two more platforms than shown here that are 32 bit: armv6 and armv7. Another 64-bit platform is supported, too: powerpc64. However I don't have any such machines at hand right now. FreeBSD supports a couple more platforms but those are irrelevant in this case because Rust has not been bootstrapped on them. Uname returns "powerpc" on powerpc64, if I'm not mistaken and 32-bit arm variants should identify as "arm".

If anybody chooses to implement FreeBSD detection, I can offer to test it on all platforms except for powerpc64 as I lack the hardware.

stanislav-tkach commented 3 years ago

I have published the 3.0.2 version. Thanks @wahjava for the pull request!