Adds isolate install functionality to 'Cabal' tool installs
This commit is contained in:
parent
9a511669a8
commit
476513b0a7
@ -1679,19 +1679,27 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
|
|
||||||
|
|
||||||
let installCabal InstallOptions{..} =
|
let installCabal InstallOptions{..} =
|
||||||
(case instBindist of
|
(case isolateDir of
|
||||||
Nothing -> runInstTool instPlatform $ do
|
Just isoDir ->
|
||||||
(v, vi) <- liftE $ fromVersion instVer Cabal
|
runInstTool instPlatform $ do
|
||||||
liftE $ installCabalBin (_tvVersion v)
|
(v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
pure vi
|
let cabalVersion = (_tvVersion v)
|
||||||
Just uri -> do
|
liftE $ installCabalBinIsolated isoDir cabalVersion
|
||||||
s' <- appState
|
pure vi
|
||||||
runInstTool' s'{ settings = settings { noVerify = True}} instPlatform $ do
|
Nothing ->
|
||||||
(v, vi) <- liftE $ fromVersion instVer Cabal
|
case instBindist of
|
||||||
liftE $ installCabalBindist
|
Nothing -> runInstTool instPlatform $ do
|
||||||
(DownloadInfo uri Nothing "")
|
(v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
(_tvVersion v)
|
liftE $ installCabalBin (_tvVersion v)
|
||||||
pure vi
|
pure vi
|
||||||
|
Just uri -> do
|
||||||
|
s' <- appState
|
||||||
|
runInstTool' s'{ settings = settings { noVerify = True}} instPlatform $ do
|
||||||
|
(v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
|
liftE $ installCabalBindist
|
||||||
|
(DownloadInfo uri Nothing "")
|
||||||
|
(_tvVersion v)
|
||||||
|
pure vi
|
||||||
)
|
)
|
||||||
>>= \case
|
>>= \case
|
||||||
VRight vi -> do
|
VRight vi -> do
|
||||||
|
51
lib/GHCup.hs
51
lib/GHCup.hs
@ -487,6 +487,57 @@ installCabal' path inst ver = do
|
|||||||
destPath
|
destPath
|
||||||
lift $ chmod_755 destPath
|
lift $ chmod_755 destPath
|
||||||
|
|
||||||
|
-- | Installs GHC to a specified location, doesn't make any symlinks.
|
||||||
|
installCabalBinIsolated :: ( MonadMask m
|
||||||
|
, MonadCatch m
|
||||||
|
, MonadReader env m
|
||||||
|
, HasPlatformReq env
|
||||||
|
, HasGHCupInfo env
|
||||||
|
, HasDirs env
|
||||||
|
, HasSettings env
|
||||||
|
, MonadLogger m
|
||||||
|
, MonadResource m
|
||||||
|
, MonadIO m
|
||||||
|
, MonadUnliftIO m
|
||||||
|
, MonadFail m
|
||||||
|
)
|
||||||
|
=> FilePath
|
||||||
|
-> Version
|
||||||
|
-> Excepts
|
||||||
|
'[ AlreadyInstalled
|
||||||
|
, CopyError
|
||||||
|
, DigestError
|
||||||
|
, DownloadFailed
|
||||||
|
, NoDownload
|
||||||
|
, NotInstalled
|
||||||
|
, UnknownArchive
|
||||||
|
, TarDirDoesNotExist
|
||||||
|
#if !defined(TAR)
|
||||||
|
, ArchiveResult
|
||||||
|
#endif
|
||||||
|
]
|
||||||
|
m
|
||||||
|
()
|
||||||
|
installCabalBinIsolated isoDir ver = do
|
||||||
|
dlinfo <- liftE $ getDownloadInfo Cabal ver
|
||||||
|
lift $ $(logDebug) [i|Requested to install cabal version #{ver}|]
|
||||||
|
|
||||||
|
-- download (or use cached version)
|
||||||
|
dl <- liftE $ downloadCached dlinfo Nothing
|
||||||
|
|
||||||
|
PlatformRequest {_rPlatform} <- lift getPlatformReq
|
||||||
|
|
||||||
|
-- unpack
|
||||||
|
tmpUnpack <- lift withGHCupTmpDir
|
||||||
|
liftE $ unpackToDir tmpUnpack dl
|
||||||
|
void $ lift $ darwinNotarization _rPlatform tmpUnpack
|
||||||
|
|
||||||
|
-- the subdir of the archive where we do the work
|
||||||
|
workdir <- maybe (pure tmpUnpack) (liftE . intoSubdir tmpUnpack) (view dlSubdir dlinfo)
|
||||||
|
|
||||||
|
lift $ $(logInfo) [i|isolated installing Cabal to #{isoDir}|]
|
||||||
|
liftE $ installCabal' workdir isoDir ver
|
||||||
|
|
||||||
|
|
||||||
-- | Installs cabal into @~\/.ghcup\/bin/cabal-\<ver\>@ and
|
-- | Installs cabal into @~\/.ghcup\/bin/cabal-\<ver\>@ and
|
||||||
-- creates a default @cabal -> cabal-x.y.z.q@ symlink for
|
-- creates a default @cabal -> cabal-x.y.z.q@ symlink for
|
||||||
|
Loading…
Reference in New Issue
Block a user