parent
ce3d1f4309
commit
326bf510c9
@ -910,7 +910,7 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
settings@Settings{dirs = Dirs{..}, ..} <- toSettings opt
|
settings@Settings{dirs = Dirs{..}, ..} <- toSettings opt
|
||||||
|
|
||||||
-- create ~/.ghcup dir
|
-- create ~/.ghcup dir
|
||||||
createDirRecursive newDirPerms baseDir
|
createDirRecursive' baseDir
|
||||||
|
|
||||||
-- logger interpreter
|
-- logger interpreter
|
||||||
logfile <- flip runReaderT settings $ initGHCupFileLogging [rel|ghcup.log|]
|
logfile <- flip runReaderT settings $ initGHCupFileLogging [rel|ghcup.log|]
|
||||||
|
@ -273,7 +273,7 @@ installCabalBindist dlinfo ver (PlatformRequest {..}) = do
|
|||||||
installCabal' path inst = do
|
installCabal' path inst = do
|
||||||
lift $ $(logInfo) "Installing cabal"
|
lift $ $(logInfo) "Installing cabal"
|
||||||
let cabalFile = [rel|cabal|]
|
let cabalFile = [rel|cabal|]
|
||||||
liftIO $ createDirRecursive newDirPerms inst
|
liftIO $ createDirRecursive' inst
|
||||||
destFileName <- lift $ parseRel (toFilePath cabalFile <> "-" <> verToBS ver)
|
destFileName <- lift $ parseRel (toFilePath cabalFile <> "-" <> verToBS ver)
|
||||||
let destPath = inst </> destFileName
|
let destPath = inst </> destFileName
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||||
@ -352,7 +352,7 @@ setGHC ver sghc = do
|
|||||||
|
|
||||||
-- symlink destination
|
-- symlink destination
|
||||||
Settings { dirs = Dirs {..} } <- lift ask
|
Settings { dirs = Dirs {..} } <- lift ask
|
||||||
liftIO $ hideError AlreadyExists $ createDirRecursive newDirPerms binDir
|
liftIO $ createDirRecursive' binDir
|
||||||
|
|
||||||
-- first delete the old symlinks (this fixes compatibility issues
|
-- first delete the old symlinks (this fixes compatibility issues
|
||||||
-- with old ghcup)
|
-- with old ghcup)
|
||||||
@ -424,7 +424,7 @@ setCabal ver = do
|
|||||||
|
|
||||||
-- symlink destination
|
-- symlink destination
|
||||||
Settings {dirs = Dirs {..}} <- lift ask
|
Settings {dirs = Dirs {..}} <- lift ask
|
||||||
liftIO $ hideError AlreadyExists $ createDirRecursive newDirPerms binDir
|
liftIO $ createDirRecursive' binDir
|
||||||
|
|
||||||
whenM (liftIO $ fmap not $ doesFileExist (binDir </> targetFile))
|
whenM (liftIO $ fmap not $ doesFileExist (binDir </> targetFile))
|
||||||
$ throwE
|
$ throwE
|
||||||
@ -1024,7 +1024,7 @@ compileCabal dls tver bghc jobs patchdir PlatformRequest{..} = do
|
|||||||
]
|
]
|
||||||
|
|
||||||
tmp <- lift withGHCupTmpDir
|
tmp <- lift withGHCupTmpDir
|
||||||
liftIO $ createDirRecursive newDirPerms (tmp </> [rel|bin|])
|
liftIO $ createDirRecursive' (tmp </> [rel|bin|])
|
||||||
newEnv <- lift $ addToCurrentEnv (("PREFIX", toFilePath tmp) : ghcEnv)
|
newEnv <- lift $ addToCurrentEnv (("PREFIX", toFilePath tmp) : ghcEnv)
|
||||||
lift $ $(logDebug) [i|Environment: #{newEnv}|]
|
lift $ $(logDebug) [i|Environment: #{newEnv}|]
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ getDownloads urlSource = do
|
|||||||
else -- access in less than 5 minutes, re-use file
|
else -- access in less than 5 minutes, re-use file
|
||||||
liftIO $ readFile json_file
|
liftIO $ readFile json_file
|
||||||
else do
|
else do
|
||||||
liftIO $ createDirRecursive newDirPerms cacheDir
|
liftIO $ createDirRecursive' cacheDir
|
||||||
getModTime >>= \case
|
getModTime >>= \case
|
||||||
Just modTime -> dlWithMod modTime json_file
|
Just modTime -> dlWithMod modTime json_file
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
@ -330,7 +330,7 @@ download dli dest mfn
|
|||||||
scheme = view (dlUri % uriSchemeL' % schemeBSL') dli
|
scheme = view (dlUri % uriSchemeL' % schemeBSL') dli
|
||||||
cp = do
|
cp = do
|
||||||
-- destination dir must exist
|
-- destination dir must exist
|
||||||
liftIO $ hideError AlreadyExists $ createDirRecursive newDirPerms dest
|
liftIO $ createDirRecursive' dest
|
||||||
destFile <- getDestFile
|
destFile <- getDestFile
|
||||||
fromFile <- parseAbs path
|
fromFile <- parseAbs path
|
||||||
liftIO $ copyFile fromFile destFile Strict
|
liftIO $ copyFile fromFile destFile Strict
|
||||||
@ -340,7 +340,7 @@ download dli dest mfn
|
|||||||
lift $ $(logInfo) [i|downloading: #{uri'}|]
|
lift $ $(logInfo) [i|downloading: #{uri'}|]
|
||||||
|
|
||||||
-- destination dir must exist
|
-- destination dir must exist
|
||||||
liftIO $ hideError AlreadyExists $ createDirRecursive newDirPerms dest
|
liftIO $ createDirRecursive' dest
|
||||||
destFile <- getDestFile
|
destFile <- getDestFile
|
||||||
|
|
||||||
-- download
|
-- download
|
||||||
|
@ -36,7 +36,7 @@ import GHCup.Utils.Prelude
|
|||||||
import GHCup.Utils.String.QQ
|
import GHCup.Utils.String.QQ
|
||||||
|
|
||||||
#if !defined(TAR)
|
#if !defined(TAR)
|
||||||
import Codec.Archive
|
import Codec.Archive hiding ( Directory )
|
||||||
#endif
|
#endif
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Exception.Safe
|
import Control.Exception.Safe
|
||||||
@ -621,3 +621,25 @@ runBuildAction bdir instdir action = do
|
|||||||
when (keepDirs == Never || keepDirs == Errors) $ liftIO $ deleteDirRecursive
|
when (keepDirs == Never || keepDirs == Errors) $ liftIO $ deleteDirRecursive
|
||||||
bdir
|
bdir
|
||||||
pure v
|
pure v
|
||||||
|
|
||||||
|
|
||||||
|
-- | More permissive version of 'createDirRecursive'. This doesn't
|
||||||
|
-- error when the destination is a symlink to a directory.
|
||||||
|
createDirRecursive' :: Path b -> IO ()
|
||||||
|
createDirRecursive' p =
|
||||||
|
handleIO (\e -> if isAlreadyExistsError e then isSymlinkDir e else throwIO e)
|
||||||
|
. createDirRecursive newDirPerms
|
||||||
|
$ p
|
||||||
|
|
||||||
|
where
|
||||||
|
isSymlinkDir e = do
|
||||||
|
ft <- getFileType p
|
||||||
|
case ft of
|
||||||
|
SymbolicLink -> do
|
||||||
|
rp <- canonicalizePath p
|
||||||
|
rft <- getFileType rp
|
||||||
|
case rft of
|
||||||
|
Directory -> pure ()
|
||||||
|
_ -> throwIO e
|
||||||
|
_ -> throwIO e
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ Here we define our main logger.
|
|||||||
module GHCup.Utils.Logger where
|
module GHCup.Utils.Logger where
|
||||||
|
|
||||||
import GHCup.Types
|
import GHCup.Types
|
||||||
|
import GHCup.Utils
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
@ -69,7 +70,7 @@ initGHCupFileLogging context = do
|
|||||||
Settings {dirs = Dirs {..}} <- ask
|
Settings {dirs = Dirs {..}} <- ask
|
||||||
let logfile = logsDir </> context
|
let logfile = logsDir </> context
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
createDirRecursive newDirPerms logsDir
|
createDirRecursive' logsDir
|
||||||
hideError doesNotExistErrorType $ deleteFile logfile
|
hideError doesNotExistErrorType $ deleteFile logfile
|
||||||
createRegularFile newFilePerms logfile
|
createRegularFile newFilePerms logfile
|
||||||
pure logfile
|
pure logfile
|
||||||
|
Loading…
Reference in New Issue
Block a user