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,7 +1631,14 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
----------------------- -----------------------
let installGHC InstallOptions{..} = let installGHC InstallOptions{..} =
(case instBindist of (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 Nothing -> runInstTool instPlatform $ do
(v, vi) <- liftE $ fromVersion instVer GHC (v, vi) <- liftE $ fromVersion instVer GHC
liftE $ installGHCBin (_tvVersion v) liftE $ installGHCBin (_tvVersion v)

View File

@ -229,6 +229,49 @@ installGHCBindist dlinfo ver = do
lift $ $(logWarn) "environments). If you encounter problems, unset CC and LD and reinstall." 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 -- | Install a packed GHC distribution. This only deals with unpacking and the GHC
-- build system and nothing else. -- build system and nothing else.
installPackedGHC :: ( MonadMask m installPackedGHC :: ( MonadMask m