factor out installCabal' from installCabalBindist
, to be shared with installCabalBinIsolated
function
This commit is contained in:
parent
8666fcd120
commit
a16a25a3cd
32
lib/GHCup.hs
32
lib/GHCup.hs
@ -470,22 +470,22 @@ installCabalBindist dlinfo ver = 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
|
-- | Install an unpacked cabal distribution.
|
||||||
-- | Install an unpacked cabal distribution.
|
installCabal' :: (MonadLogger m, MonadCatch m, MonadIO m)
|
||||||
installCabal' :: (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
|
-> Version
|
||||||
-> Excepts '[CopyError] m ()
|
-> Excepts '[CopyError] m ()
|
||||||
installCabal' path inst = do
|
installCabal' path inst ver = do
|
||||||
lift $ $(logInfo) "Installing cabal"
|
lift $ $(logInfo) "Installing cabal"
|
||||||
let cabalFile = "cabal"
|
let cabalFile = "cabal"
|
||||||
liftIO $ createDirRecursive' inst
|
liftIO $ createDirRecursive' inst
|
||||||
let destFileName = cabalFile <> "-" <> T.unpack (prettyVer ver) <> exeExt
|
let destFileName = cabalFile <> "-" <> T.unpack (prettyVer ver) <> exeExt
|
||||||
let destPath = inst </> destFileName
|
let destPath = inst </> destFileName
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||||
(path </> cabalFile <> exeExt)
|
(path </> cabalFile <> exeExt)
|
||||||
destPath
|
destPath
|
||||||
lift $ chmod_755 destPath
|
lift $ chmod_755 destPath
|
||||||
|
|
||||||
|
|
||||||
-- | Installs cabal into @~\/.ghcup\/bin/cabal-\<ver\>@ and
|
-- | Installs cabal into @~\/.ghcup\/bin/cabal-\<ver\>@ and
|
||||||
|
Loading…
Reference in New Issue
Block a user