update `installStackBindist` to take a "Maybe FilePath" argument for isolated installs

This commit is contained in:
Arjun Kathuria 2021-07-25 22:23:58 +05:30
parent 960d5ce79f
commit 6b89646c1e
1 changed files with 19 additions and 7 deletions

View File

@ -707,6 +707,7 @@ installStackBindist :: ( MonadMask m
)
=> DownloadInfo
-> Version
-> Maybe FilePath
-> Excepts
'[ AlreadyInstalled
, CopyError
@ -722,13 +723,16 @@ installStackBindist :: ( MonadMask m
]
m
()
installStackBindist dlinfo ver = do
installStackBindist dlinfo ver isoFilepath = do
lift $ $(logDebug) [i|Requested to install stack version #{ver}|]
PlatformRequest {..} <- lift getPlatformReq
Dirs {..} <- lift getDirs
whenM (lift (stackInstalled ver))
let isIsolatedInstall = isJust isoFilepath
when (not isIsolatedInstall) $
whenM (lift (stackInstalled ver))
(throwE $ AlreadyInstalled Stack ver)
-- download (or use cached version)
@ -742,12 +746,20 @@ installStackBindist dlinfo ver = do
-- the subdir of the archive where we do the work
workdir <- maybe (pure tmpUnpack) (liftE . intoSubdir tmpUnpack) (view dlSubdir dlinfo)
liftE $ installStack' workdir binDir ver
let isoDir = fromJust isoFilepath
-- create symlink if this is the latest version
sVers <- lift $ fmap rights getInstalledStacks
let lInstStack = headMay . reverse . sort $ sVers
when (maybe True (ver >=) lInstStack) $ liftE $ setStack ver
if isIsolatedInstall
then do
lift $ $(logInfo) [i|isolated installing Stack to #{isoDir}|]
liftE $ installStack' workdir isoDir ver
else do
liftE $ installStack' workdir binDir ver
-- create symlink if this is the latest version and a regular install
whenM (pure $ not isIsolatedInstall) $ do
sVers <- lift $ fmap rights getInstalledStacks
let lInstStack = headMay . reverse . sort $ sVers
when (maybe True (ver >=) lInstStack) $ liftE $ setStack ver
-- | Install an unpacked stack distribution.