mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 11:54:11 +00:00
Add call to hostnamectl in detectOsImpl (#10048)
This commit is contained in:
committed by
Andreas Rumpf
parent
ca18dc2505
commit
68ec42cec7
@@ -133,8 +133,8 @@ const
|
||||
LacksDevPackages* = {Distribution.Gentoo, Distribution.Slackware,
|
||||
Distribution.ArchLinux}
|
||||
|
||||
var unameRes, releaseRes: string ## we cache the result of the 'uname -a'
|
||||
## execution for faster platform detections.
|
||||
var unameRes, releaseRes, hostnamectlRes: string ## we cache the result of the 'uname -a'
|
||||
## execution for faster platform detections.
|
||||
|
||||
template unameRelease(cmd, cache): untyped =
|
||||
if cache.len == 0:
|
||||
@@ -143,6 +143,7 @@ template unameRelease(cmd, cache): untyped =
|
||||
|
||||
template uname(): untyped = unameRelease("uname -a", unameRes)
|
||||
template release(): untyped = unameRelease("lsb_release -a", releaseRes)
|
||||
template hostnamectl(): untyped = unameRelease("hostnamectl", hostnamectlRes)
|
||||
|
||||
proc detectOsImpl(d: Distribution): bool =
|
||||
case d
|
||||
@@ -172,7 +173,7 @@ proc detectOsImpl(d: Distribution): bool =
|
||||
result = defined(haiku)
|
||||
else:
|
||||
let dd = toLowerAscii($d)
|
||||
result = dd in toLowerAscii(uname()) or dd in toLowerAscii(release())
|
||||
result = dd in toLowerAscii(uname()) or dd in toLowerAscii(release()) or dd in toLowerAscii(hostnamectl())
|
||||
|
||||
template detectOs*(d: untyped): bool =
|
||||
## Distro/OS detection. For convenience the
|
||||
|
||||
Reference in New Issue
Block a user