diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-03-29 03:53:16 +0100 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2019-03-29 03:53:16 +0100 |
commit | a612a11140d93bdaa416f16e2c77a23332e9d656 (patch) | |
tree | cd5ce04a7373fd0f4ad00b5322534deb60faafc8 /src | |
parent | b9204e27abe8e5d6150c2a35d8a525f6aa1cfdb9 (diff) |
Bestow installCabalLibV2 with the message blub
Diffstat (limited to 'src')
-rw-r--r-- | src/CabalHelper/Compiletime/Program/CabalInstall.hs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/CabalHelper/Compiletime/Program/CabalInstall.hs b/src/CabalHelper/Compiletime/Program/CabalInstall.hs index f6c0018..b1c661c 100644 --- a/src/CabalHelper/Compiletime/Program/CabalInstall.hs +++ b/src/CabalHelper/Compiletime/Program/CabalInstall.hs @@ -65,10 +65,25 @@ cabalInstallVersion = do installCabalLibV1 :: Env => GhcVersion -> UnpackedCabalVersion -> IO PackageDbDir installCabalLibV1 ghcVer cabalVer = do - appdir <- appCacheDir - let message (CabalHEAD {}) = return () - message (CabalVersion ver) = do + withSystemTempDirectory "cabal-helper.install-cabal-tmp" $ \tmpdir -> do + installingMessage cabalVer + srcdir <- unpackCabalV1 cabalVer tmpdir + + db <- createPkgDb cabalVer + + callCabalInstall db srcdir ghcVer cabalVer + + return db + +installingMessage :: CabalVersion' a -> IO () +installingMessage = message + where + message (CabalHEAD {}) = return () -- only used for tests + message (CabalVersion ver) = do + appdir <- appCacheDir let sver = showVersion ver + -- TODO: dumping this to stderr is not really acceptable, we need to have + -- a way to let API clients override this! hPutStr stderr $ printf "\ \cabal-helper: Installing a private copy of Cabal because we couldn't\n\ \find the right version in your global/user package-db. This might take a\n\ @@ -82,15 +97,6 @@ installCabalLibV1 ghcVer cabalVer = do \ $ cabal install Cabal --constraint \"Cabal == %s\"\n\ \\n\ \Installing Cabal %s ...\n" appdir sver sver sver - withSystemTempDirectory "cabal-helper.install-cabal-tmp" $ \tmpdir -> do - message cabalVer - srcdir <- unpackCabalV1 cabalVer tmpdir - - db <- createPkgDb cabalVer - - callCabalInstall db srcdir ghcVer cabalVer - - return db callCabalInstall :: Env @@ -195,13 +201,13 @@ cabalWithGHCProgOpts = concat else [] ] --- TODO: This needs the big message blub from above installCabalLibV2 :: Env => GhcVersion -> UnpackedCabalVersion -> PackageEnvFile -> IO () installCabalLibV2 _ghcVer cv (PackageEnvFile env_file) = do exists <- doesFileExist env_file if exists then return () else do + installingMessage cv (target, cwd) <- case cv of CabalVersion cabalVer -> do tmp <- getTemporaryDirectory |