diff options
author | Taylor Hoff <primdevs@protonmail.com> | 2018-12-20 02:45:43 -0500 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-12-20 08:45:43 +0100 |
commit | 68ec42cec70496eef072c921f54a91686bb8b43b (patch) | |
tree | a90c44ac28032229f426183876161be86bcc60bd /lib/pure | |
parent | ca18dc2505d3e3429860bef89d7e6a353cf935de (diff) | |
download | Nim-68ec42cec70496eef072c921f54a91686bb8b43b.tar.gz |
Add call to hostnamectl in detectOsImpl (#10048)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/distros.nim | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/pure/distros.nim b/lib/pure/distros.nim index 5847cfadb..4bf1c3da3 100644 --- a/lib/pure/distros.nim +++ b/lib/pure/distros.nim @@ -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 |