updates Bindist functions as per https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/127#note_366702
This commit is contained in:
parent
5683493cae
commit
e1bec789b0
74
lib/GHCup.hs
74
lib/GHCup.hs
@ -204,14 +204,13 @@ installGHCBindist :: ( MonadFail m
|
|||||||
()
|
()
|
||||||
installGHCBindist dlinfo ver isoFilepath = do
|
installGHCBindist dlinfo ver isoFilepath = do
|
||||||
let tver = mkTVer ver
|
let tver = mkTVer ver
|
||||||
let isIsolatedInstall = isJust isoFilepath
|
|
||||||
|
|
||||||
|
|
||||||
lift $ $(logDebug) [i|Requested to install GHC with #{ver}|]
|
lift $ $(logDebug) [i|Requested to install GHC with #{ver}|]
|
||||||
|
|
||||||
|
case isoFilepath of
|
||||||
-- we only care for already installed errors in regular (non-isolated) installs
|
-- we only care for already installed errors in regular (non-isolated) installs
|
||||||
when (not isIsolatedInstall) $
|
Nothing -> whenM (lift $ ghcInstalled tver) (throwE $ AlreadyInstalled GHC ver)
|
||||||
whenM (lift $ ghcInstalled tver) (throwE $ AlreadyInstalled GHC ver)
|
_ -> pure ()
|
||||||
|
|
||||||
-- download (or use cached version)
|
-- download (or use cached version)
|
||||||
dl <- liftE $ downloadCached dlinfo Nothing
|
dl <- liftE $ downloadCached dlinfo Nothing
|
||||||
@ -219,21 +218,16 @@ installGHCBindist dlinfo ver isoFilepath = do
|
|||||||
-- prepare paths
|
-- prepare paths
|
||||||
ghcdir <- lift $ ghcupGHCDir tver
|
ghcdir <- lift $ ghcupGHCDir tver
|
||||||
|
|
||||||
let isoDir = if isIsolatedInstall
|
case isoFilepath of
|
||||||
then fromJust isoFilepath
|
Just isoDir -> do -- isolated install
|
||||||
else mempty :: FilePath
|
|
||||||
|
|
||||||
if isIsolatedInstall
|
|
||||||
then do
|
|
||||||
lift $ $(logInfo) [i|isolated installing GHC to #{isoDir}|]
|
lift $ $(logInfo) [i|isolated installing GHC to #{isoDir}|]
|
||||||
liftE $ installPackedGHC dl (view dlSubdir dlinfo) isoDir ver
|
liftE $ installPackedGHC dl (view dlSubdir dlinfo) isoDir ver
|
||||||
else do
|
Nothing -> do -- regular install
|
||||||
toolchainSanityChecks
|
toolchainSanityChecks
|
||||||
liftE $ installPackedGHC dl (view dlSubdir dlinfo) ghcdir ver
|
liftE $ installPackedGHC dl (view dlSubdir dlinfo) ghcdir ver
|
||||||
|
|
||||||
-- make symlinks & stuff when regular install,
|
-- make symlinks & stuff when regular install,
|
||||||
-- don't make any for isolated installs.
|
liftE $ postGHCInstall tver
|
||||||
whenM (pure $ not isIsolatedInstall) (liftE $ postGHCInstall tver)
|
|
||||||
|
|
||||||
where
|
where
|
||||||
toolchainSanityChecks = do
|
toolchainSanityChecks = do
|
||||||
@ -419,10 +413,8 @@ installCabalBindist dlinfo ver isoFilepath = do
|
|||||||
PlatformRequest {..} <- lift getPlatformReq
|
PlatformRequest {..} <- lift getPlatformReq
|
||||||
Dirs {..} <- lift getDirs
|
Dirs {..} <- lift getDirs
|
||||||
|
|
||||||
let isIsolatedInstall = isJust isoFilepath
|
case isoFilepath of
|
||||||
|
Nothing -> -- for regular install check if any previous versions installed
|
||||||
-- 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)
|
||||||
@ -432,6 +424,8 @@ installCabalBindist dlinfo ver isoFilepath = do
|
|||||||
)
|
)
|
||||||
(throwE $ AlreadyInstalled Cabal ver)
|
(throwE $ AlreadyInstalled Cabal ver)
|
||||||
|
|
||||||
|
_ -> pure () -- check isn't required in isolated installs
|
||||||
|
|
||||||
-- download (or use cached version)
|
-- download (or use cached version)
|
||||||
dl <- liftE $ downloadCached dlinfo Nothing
|
dl <- liftE $ downloadCached dlinfo Nothing
|
||||||
|
|
||||||
@ -443,18 +437,15 @@ installCabalBindist dlinfo ver isoFilepath = 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
|
case isoFilepath of
|
||||||
|
Just isoDir -> do -- isolated install
|
||||||
if isIsolatedInstall
|
|
||||||
then do
|
|
||||||
lift $ $(logInfo) [i|isolated installing Cabal to #{isoDir}|]
|
lift $ $(logInfo) [i|isolated installing Cabal to #{isoDir}|]
|
||||||
liftE $ installCabalUnpacked workdir isoDir ver
|
liftE $ installCabalUnpacked workdir isoDir ver
|
||||||
else do
|
|
||||||
|
Nothing -> do -- regular install
|
||||||
liftE $ installCabalUnpacked workdir binDir ver
|
liftE $ installCabalUnpacked workdir binDir ver
|
||||||
|
|
||||||
-- create symlink if this is the latest version
|
-- create symlink if this is the latest version for regular installs
|
||||||
-- 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
|
||||||
@ -552,13 +543,14 @@ installHLSBindist dlinfo ver isoFilepath = do
|
|||||||
PlatformRequest {..} <- lift getPlatformReq
|
PlatformRequest {..} <- lift getPlatformReq
|
||||||
Dirs {..} <- lift getDirs
|
Dirs {..} <- lift getDirs
|
||||||
|
|
||||||
let isIsolatedInstall = isJust isoFilepath
|
case isoFilepath of
|
||||||
|
Nothing ->
|
||||||
-- we only check for already installed in regular (non-isolated) installs
|
-- we only check for already installed in regular (non-isolated) installs
|
||||||
when (not isIsolatedInstall) $
|
|
||||||
whenM (lift (hlsInstalled ver))
|
whenM (lift (hlsInstalled ver))
|
||||||
(throwE $ AlreadyInstalled HLS ver)
|
(throwE $ AlreadyInstalled HLS ver)
|
||||||
|
|
||||||
|
_ -> pure ()
|
||||||
|
|
||||||
-- download (or use cached version)
|
-- download (or use cached version)
|
||||||
dl <- liftE $ downloadCached dlinfo Nothing
|
dl <- liftE $ downloadCached dlinfo Nothing
|
||||||
|
|
||||||
@ -569,21 +561,21 @@ installHLSBindist dlinfo ver isoFilepath = 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
|
case isoFilepath of
|
||||||
then do
|
Just isoDir -> do
|
||||||
lift $ $(logInfo) [i|isolated installing HLS to #{isoDir}|]
|
lift $ $(logInfo) [i|isolated installing HLS to #{isoDir}|]
|
||||||
liftE $ installHLSUnpacked workdir isoDir ver
|
liftE $ installHLSUnpacked workdir isoDir ver
|
||||||
else do
|
|
||||||
|
Nothing -> do
|
||||||
liftE $ installHLSUnpacked workdir binDir ver
|
liftE $ installHLSUnpacked workdir binDir ver
|
||||||
|
|
||||||
-- create symlink if this is the latest version in a regular install
|
-- create symlink if this is the latest version in a regular install
|
||||||
whenM (pure $ not isIsolatedInstall) $ do
|
|
||||||
hlsVers <- lift $ fmap rights getInstalledHLSs
|
hlsVers <- lift $ fmap rights getInstalledHLSs
|
||||||
let lInstHLS = headMay . reverse . sort $ hlsVers
|
let lInstHLS = headMay . reverse . sort $ hlsVers
|
||||||
when (maybe True (ver >=) lInstHLS) $ liftE $ setHLS ver
|
when (maybe True (ver >=) lInstHLS) $ liftE $ setHLS ver
|
||||||
|
|
||||||
|
|
||||||
-- | Install an unpacked hls distribution.
|
-- | Install an unpacked hls distribution.
|
||||||
installHLSUnpacked :: (MonadFail m, MonadLogger m, MonadCatch m, MonadIO m)
|
installHLSUnpacked :: (MonadFail m, MonadLogger m, MonadCatch m, MonadIO m)
|
||||||
=> FilePath -- ^ Path to the unpacked hls bindist (where the executable resides)
|
=> FilePath -- ^ Path to the unpacked hls bindist (where the executable resides)
|
||||||
@ -730,12 +722,13 @@ installStackBindist dlinfo ver isoFilepath = do
|
|||||||
PlatformRequest {..} <- lift getPlatformReq
|
PlatformRequest {..} <- lift getPlatformReq
|
||||||
Dirs {..} <- lift getDirs
|
Dirs {..} <- lift getDirs
|
||||||
|
|
||||||
let isIsolatedInstall = isJust isoFilepath
|
case isoFilepath of
|
||||||
|
Nothing -> -- check previous versions in case of regular installs
|
||||||
when (not isIsolatedInstall) $
|
|
||||||
whenM (lift (stackInstalled ver))
|
whenM (lift (stackInstalled ver))
|
||||||
(throwE $ AlreadyInstalled Stack ver)
|
(throwE $ AlreadyInstalled Stack ver)
|
||||||
|
|
||||||
|
_ -> pure () -- don't do shit for isolates
|
||||||
|
|
||||||
-- download (or use cached version)
|
-- download (or use cached version)
|
||||||
dl <- liftE $ downloadCached dlinfo Nothing
|
dl <- liftE $ downloadCached dlinfo Nothing
|
||||||
|
|
||||||
@ -747,17 +740,14 @@ installStackBindist dlinfo ver isoFilepath = 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
|
case isoFilepath of
|
||||||
|
Just isoDir -> do -- isolated install
|
||||||
if isIsolatedInstall
|
|
||||||
then do
|
|
||||||
lift $ $(logInfo) [i|isolated installing Stack to #{isoDir}|]
|
lift $ $(logInfo) [i|isolated installing Stack to #{isoDir}|]
|
||||||
liftE $ installStackUnpacked workdir isoDir ver
|
liftE $ installStackUnpacked workdir isoDir ver
|
||||||
else do
|
Nothing -> do -- regular install
|
||||||
liftE $ installStackUnpacked workdir binDir ver
|
liftE $ installStackUnpacked workdir binDir ver
|
||||||
|
|
||||||
-- create symlink if this is the latest version and a regular install
|
-- create symlink if this is the latest version and a regular install
|
||||||
whenM (pure $ not isIsolatedInstall) $ do
|
|
||||||
sVers <- lift $ fmap rights getInstalledStacks
|
sVers <- lift $ fmap rights getInstalledStacks
|
||||||
let lInstStack = headMay . reverse . sort $ sVers
|
let lInstStack = headMay . reverse . sort $ sVers
|
||||||
when (maybe True (ver >=) lInstStack) $ liftE $ setStack ver
|
when (maybe True (ver >=) lInstStack) $ liftE $ setStack ver
|
||||||
|
Loading…
Reference in New Issue
Block a user