Detects the host operating system and, on Linux, parses /etc/os-release.
On macOS, queries sw_vers. Returns a structured platform object used by
the rest of the package. When os_release is supplied and exists, the file
is parsed even on macOS or Windows; this makes fixture-driven testing
practical.
See also
Other platform:
detect_package_manager(),
resolve_platform()
Examples
platform <- detect_platform()
platform$distro
#> [1] "ubuntu"
# Reproducible reads from a fixture file:
fixture <- system.file(
"extdata", "os-release-fedora-40",
package = "sysreqr",
mustWork = FALSE
)
if (nzchar(fixture)) detect_platform(os_release = fixture)
#> $os
#> [1] "linux"
#>
#> $distro
#> [1] "fedora"
#>
#> $version
#> [1] "40"
#>
#> $codename
#> [1] NA
#>
#> $package_manager
#> [1] "dnf"
#>
#> $ppm_binary_url
#> [1] NA
#>
#> $supported
#> [1] TRUE
#>
#> $label
#> [1] "Fedora Linux 40 (Workstation Edition) fedora"
#>
#> attr(,"class")
#> [1] "sysreqr_platform"
