From b11b74d2b48834fa9a69cde9c2b5f503b1be07a8 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 11 Apr 2020 22:15:09 +0200 Subject: [PATCH] Only use major version for Darwin --- lib/GHCup/Platform.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/GHCup/Platform.hs b/lib/GHCup/Platform.hs index 1e8bbb2..33514f0 100644 --- a/lib/GHCup/Platform.hs +++ b/lib/GHCup/Platform.hs @@ -81,7 +81,11 @@ getPlatform = do pure $ PlatformResult { _platform = Linux distro, _distroVersion = ver } "darwin" -> do ver <- - (either (const Nothing) Just . versioning . E.decodeUtf8) + ( either (const Nothing) Just + . versioning + . getMajorVersion + . E.decodeUtf8 + ) <$> getDarwinVersion pure $ PlatformResult { _platform = Darwin, _distroVersion = ver } "freebsd" -> do @@ -93,10 +97,12 @@ getPlatform = do lift $ $(logDebug) [i|Identified Platform as: #{pfr}|] pure pfr where + getMajorVersion = T.intercalate "." . take 2 . T.split (== '.') getFreeBSDVersion = liftIO $ fmap _stdOut $ executeOut [rel|freebsd-version|] [] Nothing - getDarwinVersion = - liftIO $ fmap _stdOut $ executeOut [rel|sw_vers|] ["-productVersion"] Nothing + getDarwinVersion = liftIO $ fmap _stdOut $ executeOut [rel|sw_vers|] + ["-productVersion"] + Nothing getLinuxDistro :: (MonadCatch m, MonadIO m)