move some code around for better consistency
This commit is contained in:
parent
6011242eae
commit
8fc128e89b
@ -1783,17 +1783,20 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
(case instBindist of
|
(case instBindist of
|
||||||
Nothing -> runInstTool instPlatform $ do
|
Nothing -> runInstTool instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer Cabal
|
(v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
liftE $ installCabalBin (_tvVersion v) isolateDir forceInstall
|
liftE $ installCabalBin
|
||||||
|
(_tvVersion v)
|
||||||
|
isolateDir
|
||||||
|
forceInstall
|
||||||
pure vi
|
pure vi
|
||||||
Just uri -> do
|
Just uri -> do
|
||||||
s' <- appState
|
s' <- appState
|
||||||
runInstTool' s'{ settings = settings { noVerify = True}} instPlatform $ do
|
runInstTool' s'{ settings = settings { noVerify = True}} instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer Cabal
|
(v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
liftE $ installCabalBindist
|
liftE $ installCabalBindist
|
||||||
(DownloadInfo uri Nothing "")
|
(DownloadInfo uri Nothing "")
|
||||||
(_tvVersion v)
|
(_tvVersion v)
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
pure vi
|
pure vi
|
||||||
)
|
)
|
||||||
>>= \case
|
>>= \case
|
||||||
|
55
lib/GHCup.hs
55
lib/GHCup.hs
@ -441,17 +441,17 @@ installCabalBindist dlinfo ver isoFilepath forceInstall = do
|
|||||||
regularCabalInstalled <- lift $ checkIfToolInstalled Cabal ver
|
regularCabalInstalled <- lift $ checkIfToolInstalled Cabal ver
|
||||||
|
|
||||||
if
|
if
|
||||||
|
| not forceInstall
|
||||||
|
, regularCabalInstalled
|
||||||
|
, Nothing <- isoFilepath -> do
|
||||||
|
throwE $ AlreadyInstalled Cabal ver
|
||||||
|
|
||||||
| forceInstall
|
| forceInstall
|
||||||
, regularCabalInstalled
|
, regularCabalInstalled
|
||||||
, Nothing <- isoFilepath -> do
|
, Nothing <- isoFilepath -> do
|
||||||
lift $ logInfo $ "Removing the currently installed version first!"
|
lift $ logInfo $ "Removing the currently installed version first!"
|
||||||
liftE $ rmCabalVer ver
|
liftE $ rmCabalVer ver
|
||||||
|
|
||||||
| not forceInstall
|
|
||||||
, regularCabalInstalled
|
|
||||||
, Nothing <- isoFilepath -> do
|
|
||||||
throwE $ AlreadyInstalled Cabal ver
|
|
||||||
|
|
||||||
| otherwise -> pure ()
|
| otherwise -> pure ()
|
||||||
|
|
||||||
|
|
||||||
@ -479,22 +479,6 @@ installCabalBindist dlinfo ver isoFilepath forceInstall = do
|
|||||||
let lInstCabal = headMay . reverse . sort $ cVers
|
let lInstCabal = headMay . reverse . sort $ cVers
|
||||||
when (maybe True (ver >=) lInstCabal) $ liftE $ setCabal ver
|
when (maybe True (ver >=) lInstCabal) $ liftE $ setCabal ver
|
||||||
|
|
||||||
checkIfToolInstalled :: ( MonadIO m
|
|
||||||
, MonadReader env m
|
|
||||||
, HasDirs env
|
|
||||||
, MonadCatch m) =>
|
|
||||||
Tool ->
|
|
||||||
Version ->
|
|
||||||
m Bool
|
|
||||||
|
|
||||||
checkIfToolInstalled tool ver =
|
|
||||||
case tool of
|
|
||||||
Cabal -> cabalInstalled ver
|
|
||||||
HLS -> hlsInstalled ver
|
|
||||||
Stack -> stackInstalled ver
|
|
||||||
GHC -> ghcInstalled $ mkTVer ver
|
|
||||||
_ -> pure False
|
|
||||||
|
|
||||||
-- | Install an unpacked cabal distribution.Symbol
|
-- | Install an unpacked cabal distribution.Symbol
|
||||||
installCabalUnpacked :: (MonadCatch m, HasLog env, MonadIO m, MonadReader env m)
|
installCabalUnpacked :: (MonadCatch m, HasLog env, MonadIO m, MonadReader env m)
|
||||||
=> FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides)
|
=> FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides)
|
||||||
@ -598,17 +582,17 @@ installHLSBindist dlinfo ver isoFilepath forceInstall = do
|
|||||||
regularHLSInstalled <- lift $ checkIfToolInstalled HLS ver
|
regularHLSInstalled <- lift $ checkIfToolInstalled HLS ver
|
||||||
|
|
||||||
if
|
if
|
||||||
| forceInstall
|
|
||||||
, regularHLSInstalled
|
|
||||||
, Nothing <- isoFilepath -> do -- regular forced install
|
|
||||||
lift $ logInfo "Removing the currently installed version of HLS before force installing!"
|
|
||||||
liftE $ rmHLSVer ver
|
|
||||||
|
|
||||||
| not forceInstall
|
| not forceInstall
|
||||||
, regularHLSInstalled
|
, regularHLSInstalled
|
||||||
, Nothing <- isoFilepath -> do -- regular install
|
, Nothing <- isoFilepath -> do -- regular install
|
||||||
throwE $ AlreadyInstalled HLS ver
|
throwE $ AlreadyInstalled HLS ver
|
||||||
|
|
||||||
|
| forceInstall
|
||||||
|
, regularHLSInstalled
|
||||||
|
, Nothing <- isoFilepath -> do -- regular forced install
|
||||||
|
lift $ logInfo "Removing the currently installed version of HLS before force installing!"
|
||||||
|
liftE $ rmHLSVer ver
|
||||||
|
|
||||||
| otherwise -> pure ()
|
| otherwise -> pure ()
|
||||||
|
|
||||||
-- download (or use cached version)
|
-- download (or use cached version)
|
||||||
@ -2421,6 +2405,21 @@ whereIsTool tool ver@GHCTargetVersion {..} = do
|
|||||||
currentRunningExecPath <- liftIO getExecutablePath
|
currentRunningExecPath <- liftIO getExecutablePath
|
||||||
liftIO $ canonicalizePath currentRunningExecPath
|
liftIO $ canonicalizePath currentRunningExecPath
|
||||||
|
|
||||||
|
checkIfToolInstalled :: ( MonadIO m
|
||||||
|
, MonadReader env m
|
||||||
|
, HasDirs env
|
||||||
|
, MonadCatch m) =>
|
||||||
|
Tool ->
|
||||||
|
Version ->
|
||||||
|
m Bool
|
||||||
|
|
||||||
|
checkIfToolInstalled tool ver =
|
||||||
|
case tool of
|
||||||
|
Cabal -> cabalInstalled ver
|
||||||
|
HLS -> hlsInstalled ver
|
||||||
|
Stack -> stackInstalled ver
|
||||||
|
GHC -> ghcInstalled $ mkTVer ver
|
||||||
|
_ -> pure False
|
||||||
|
|
||||||
throwIfFileAlreadyExists :: ( MonadIO m ) =>
|
throwIfFileAlreadyExists :: ( MonadIO m ) =>
|
||||||
FilePath ->
|
FilePath ->
|
||||||
|
Loading…
Reference in New Issue
Block a user