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

View File

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