update installCabalBindist
to take a "Maybe FilePath" argument for isolated installs
This commit is contained in:
parent
62d03b776b
commit
1f760af880
16
lib/GHCup.hs
16
lib/GHCup.hs
@ -397,6 +397,7 @@ installCabalBindist :: ( MonadMask m
|
|||||||
)
|
)
|
||||||
=> DownloadInfo
|
=> DownloadInfo
|
||||||
-> Version
|
-> Version
|
||||||
|
-> Maybe FilePath -- ^ isolated install filepath, if user provides any.
|
||||||
-> Excepts
|
-> Excepts
|
||||||
'[ AlreadyInstalled
|
'[ AlreadyInstalled
|
||||||
, CopyError
|
, CopyError
|
||||||
@ -412,12 +413,16 @@ installCabalBindist :: ( MonadMask m
|
|||||||
]
|
]
|
||||||
m
|
m
|
||||||
()
|
()
|
||||||
installCabalBindist dlinfo ver = do
|
installCabalBindist dlinfo ver isoFilepath = do
|
||||||
lift $ $(logDebug) [i|Requested to install cabal version #{ver}|]
|
lift $ $(logDebug) [i|Requested to install cabal version #{ver}|]
|
||||||
|
|
||||||
PlatformRequest {..} <- lift getPlatformReq
|
PlatformRequest {..} <- lift getPlatformReq
|
||||||
Dirs {..} <- lift getDirs
|
Dirs {..} <- lift getDirs
|
||||||
|
|
||||||
|
let isIsolatedInstall = isJust isoFilepath
|
||||||
|
|
||||||
|
-- check if cabal already installed in regular (non-isolated) installs
|
||||||
|
when (not isIsolatedInstall) $
|
||||||
whenM
|
whenM
|
||||||
(lift (cabalInstalled ver) >>= \a -> liftIO $
|
(lift (cabalInstalled ver) >>= \a -> liftIO $
|
||||||
handleIO (\_ -> pure False)
|
handleIO (\_ -> pure False)
|
||||||
@ -438,9 +443,18 @@ installCabalBindist dlinfo ver = do
|
|||||||
-- the subdir of the archive where we do the work
|
-- the subdir of the archive where we do the work
|
||||||
workdir <- maybe (pure tmpUnpack) (liftE . intoSubdir tmpUnpack) (view dlSubdir dlinfo)
|
workdir <- maybe (pure tmpUnpack) (liftE . intoSubdir tmpUnpack) (view dlSubdir dlinfo)
|
||||||
|
|
||||||
|
let isoDir = fromJust isoFilepath
|
||||||
|
|
||||||
|
if isIsolatedInstall
|
||||||
|
then do
|
||||||
|
lift $ $(logInfo) [i|isolated installing Cabal to #{isoDir}|]
|
||||||
|
liftE $ installCabal' workdir isoDir ver
|
||||||
|
else do
|
||||||
liftE $ installCabal' workdir binDir ver
|
liftE $ installCabal' workdir binDir ver
|
||||||
|
|
||||||
-- create symlink if this is the latest version
|
-- create symlink if this is the latest version
|
||||||
|
-- not applicable for isolated installs
|
||||||
|
whenM (pure $ not isIsolatedInstall) $ do
|
||||||
cVers <- lift $ fmap rights getInstalledCabals
|
cVers <- lift $ fmap rights getInstalledCabals
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user