Add call to hostnamectl in detectOsImpl (#10048)
This commit is contained in:
parent
ca18dc2505
commit
68ec42cec7
1 changed files with 4 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue