factor out checkIfCabalInstalled
to checkIfToolInstalled
This commit is contained in:
parent
107fed6e60
commit
0f98ec6b78
32
lib/GHCup.hs
32
lib/GHCup.hs
@ -422,9 +422,6 @@ installCabalBindist dlinfo ver isoFilepath forceInstall = do
|
|||||||
PlatformRequest {..} <- lift getPlatformReq
|
PlatformRequest {..} <- lift getPlatformReq
|
||||||
Dirs {..} <- lift getDirs
|
Dirs {..} <- lift getDirs
|
||||||
|
|
||||||
-- check if we already have a regular cabal already installed
|
|
||||||
regularCabalInstalled <- checkIfCabalInstalled ver binDir exeExt
|
|
||||||
|
|
||||||
-- check if we already have a regular cabal already installed
|
-- check if we already have a regular cabal already installed
|
||||||
regularCabalInstalled <- lift $ checkIfToolInstalled Cabal ver
|
regularCabalInstalled <- lift $ checkIfToolInstalled Cabal ver
|
||||||
|
|
||||||
@ -467,18 +464,29 @@ 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
|
||||||
|
|
||||||
where
|
checkIfToolInstalled :: ( MonadIO m
|
||||||
|
, MonadLogger m
|
||||||
|
, MonadReader env m
|
||||||
|
, HasDirs env
|
||||||
|
, MonadCatch m) =>
|
||||||
|
Tool ->
|
||||||
|
Version ->
|
||||||
|
m Bool
|
||||||
|
|
||||||
checkIfCabalInstalled ver binDir exeExt = (lift (cabalInstalled ver) >>= \a -> liftIO $
|
checkIfToolInstalled tool ver = do
|
||||||
handleIO (\_ -> pure False)
|
Dirs { binDir } <- getDirs
|
||||||
$ fmap (\x -> a && x)
|
|
||||||
-- ignore when the installation is a legacy cabal (binary, not symlink)
|
|
||||||
$ pathIsLink (binDir </> "cabal" <> exeExt)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
case tool of
|
||||||
|
Cabal -> do
|
||||||
|
v <- cabalInstalled ver
|
||||||
|
liftIO $ handleIO (\_ -> pure False)
|
||||||
|
$ fmap (\x -> v && x)
|
||||||
|
$ pathIsLink (binDir </> "cabal" <> exeExt)
|
||||||
|
|
||||||
-- | Install an unpacked cabal distribution.
|
_ -> pure False
|
||||||
installCabalUnpacked :: (MonadReader env m, HasLog env, MonadCatch m, MonadIO m)
|
|
||||||
|
-- | Install an unpacked cabal distribution.Symbol
|
||||||
|
installCabalUnpacked :: (MonadLogger m, MonadCatch m, MonadIO m)
|
||||||
=> FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides)
|
=> FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides)
|
||||||
-> FilePath -- ^ Path to install to
|
-> FilePath -- ^ Path to install to
|
||||||
-> Maybe Version -- ^ Nothing for isolated install
|
-> Maybe Version -- ^ Nothing for isolated install
|
||||||
|
Loading…
Reference in New Issue
Block a user