adds rudimentary isolate capability to ghcup install ghc command

This commit is contained in:
Arjun Kathuria 2021-07-22 19:32:56 +05:30
parent 521ab0aedb
commit 8666fcd120
2 changed files with 63 additions and 13 deletions

View File

@ -1631,22 +1631,29 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
-----------------------
let installGHC InstallOptions{..} =
(case instBindist of
Nothing -> runInstTool instPlatform $ do
(v, vi) <- liftE $ fromVersion instVer GHC
liftE $ installGHCBin (_tvVersion v)
when instSet $ void $ liftE $ setGHC v SetGHCOnly
pure vi
Just uri -> do
s' <- liftIO appState
runInstTool' s'{ settings = settings {noVerify = True}} instPlatform $ do
(case isolateDir of
Just isoDir -> runInstTool instPlatform $ do
(v, vi) <- liftE $ fromVersion instVer GHC
let ghcVersion = _tvVersion v
liftE $ installGHCBinIsolated isoDir ghcVersion
pure vi
Nothing ->
case instBindist of
Nothing -> runInstTool instPlatform $ do
(v, vi) <- liftE $ fromVersion instVer GHC
liftE $ installGHCBindist
(DownloadInfo uri (Just $ RegexDir "ghc-.*") "")
(_tvVersion v)
liftE $ installGHCBin (_tvVersion v)
when instSet $ void $ liftE $ setGHC v SetGHCOnly
pure vi
)
Just uri -> do
s' <- liftIO appState
runInstTool' s'{ settings = settings {noVerify = True}} instPlatform $ do
(v, vi) <- liftE $ fromVersion instVer GHC
liftE $ installGHCBindist
(DownloadInfo uri (Just $ RegexDir "ghc-.*") "")
(_tvVersion v)
when instSet $ void $ liftE $ setGHC v SetGHCOnly
pure vi
)
>>= \case
VRight vi -> do
runLogger $ $(logInfo) "GHC installation successful"

View File

@ -229,6 +229,49 @@ installGHCBindist dlinfo ver = do
lift $ $(logWarn) "environments). If you encounter problems, unset CC and LD and reinstall."
-- | Installs GHC to a specified location, doesn't make any symlinks.
installGHCBinIsolated :: ( MonadFail m
, MonadMask m
, MonadCatch m
, MonadReader env m
, HasPlatformReq env
, HasGHCupInfo env
, HasDirs env
, HasSettings env
, MonadLogger m
, MonadResource m
, MonadIO m
, MonadUnliftIO m
)
=> FilePath
-> Version -- ^ the version to install
-> Excepts
'[ AlreadyInstalled
, BuildFailed
, DigestError
, DownloadFailed
, NoDownload
, NotInstalled
, UnknownArchive
, TarDirDoesNotExist
#if !defined(TAR)
, ArchiveResult
#endif
]
m
()
installGHCBinIsolated isoDir ver = do
dlinfo <- liftE $ getDownloadInfo GHC ver
lift $ $(logDebug) [i|Requested to install GHC with #{ver}|]
-- download (or use cached version)
dl <- liftE $ downloadCached dlinfo Nothing
liftE $ installPackedGHC dl (view dlSubdir dlinfo) isoDir ver
-- | Install a packed GHC distribution. This only deals with unpacking and the GHC
-- build system and nothing else.
installPackedGHC :: ( MonadMask m