From e7cd952970406bd04f55f84f74604ee469621797 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 10 Apr 2020 21:11:15 +0200 Subject: [PATCH] Fix missing version detection for darwin and freebsd --- lib/GHCup/Platform.hs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/GHCup/Platform.hs b/lib/GHCup/Platform.hs index e43d184..1e8bbb2 100644 --- a/lib/GHCup/Platform.hs +++ b/lib/GHCup/Platform.hs @@ -79,16 +79,24 @@ getPlatform = do "linux" -> do (distro, ver) <- liftE getLinuxDistro pure $ PlatformResult { _platform = Linux distro, _distroVersion = ver } - -- TODO: these are not verified - "darwin" -> - pure $ PlatformResult { _platform = Darwin, _distroVersion = Nothing } + "darwin" -> do + ver <- + (either (const Nothing) Just . versioning . E.decodeUtf8) + <$> getDarwinVersion + pure $ PlatformResult { _platform = Darwin, _distroVersion = ver } "freebsd" -> do - ver <- getFreeBSDVersion + ver <- + (either (const Nothing) Just . versioning . E.decodeUtf8) + <$> getFreeBSDVersion pure $ PlatformResult { _platform = FreeBSD, _distroVersion = ver } what -> throwE $ NoCompatiblePlatform what lift $ $(logDebug) [i|Identified Platform as: #{pfr}|] pure pfr - where getFreeBSDVersion = pure Nothing + where + getFreeBSDVersion = + liftIO $ fmap _stdOut $ executeOut [rel|freebsd-version|] [] Nothing + getDarwinVersion = + liftIO $ fmap _stdOut $ executeOut [rel|sw_vers|] ["-productVersion"] Nothing getLinuxDistro :: (MonadCatch m, MonadIO m)