Only use major version for Darwin

This commit is contained in:
Julian Ospald 2020-04-11 22:15:09 +02:00
parent 5ac8f5b651
commit b11b74d2b4
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

View File

@ -81,7 +81,11 @@ getPlatform = do
pure $ PlatformResult { _platform = Linux distro, _distroVersion = ver } pure $ PlatformResult { _platform = Linux distro, _distroVersion = ver }
"darwin" -> do "darwin" -> do
ver <- ver <-
(either (const Nothing) Just . versioning . E.decodeUtf8) ( either (const Nothing) Just
. versioning
. getMajorVersion
. E.decodeUtf8
)
<$> getDarwinVersion <$> getDarwinVersion
pure $ PlatformResult { _platform = Darwin, _distroVersion = ver } pure $ PlatformResult { _platform = Darwin, _distroVersion = ver }
"freebsd" -> do "freebsd" -> do
@ -93,10 +97,12 @@ getPlatform = do
lift $ $(logDebug) [i|Identified Platform as: #{pfr}|] lift $ $(logDebug) [i|Identified Platform as: #{pfr}|]
pure pfr pure pfr
where where
getMajorVersion = T.intercalate "." . take 2 . T.split (== '.')
getFreeBSDVersion = getFreeBSDVersion =
liftIO $ fmap _stdOut $ executeOut [rel|freebsd-version|] [] Nothing liftIO $ fmap _stdOut $ executeOut [rel|freebsd-version|] [] Nothing
getDarwinVersion = getDarwinVersion = liftIO $ fmap _stdOut $ executeOut [rel|sw_vers|]
liftIO $ fmap _stdOut $ executeOut [rel|sw_vers|] ["-productVersion"] Nothing ["-productVersion"]
Nothing
getLinuxDistro :: (MonadCatch m, MonadIO m) getLinuxDistro :: (MonadCatch m, MonadIO m)