Add call to hostnamectl in detectOsImpl (#10048)

This commit is contained in:
Taylor Hoff
2018-12-20 02:45:43 -05:00
committed by Andreas Rumpf
parent ca18dc2505
commit 68ec42cec7

View File

@@ -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