aboutsummaryrefslogtreecommitdiff
path: root/CabalHelper/Compile.hs
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2017-06-12 04:23:44 +0200
committerDaniel Gröber <dxld@darkboxed.org>2017-06-12 04:23:44 +0200
commita8551e48ccb189202d8c7aa587c50044d7c41471 (patch)
tree910d160faac37655097bfaeaba04add5ce6c610d /CabalHelper/Compile.hs
parent2bc14d2f812c300ad32fe41c53c30405bab61502 (diff)
Fix unpackCabalHEAD again due to old 'process'
Diffstat (limited to 'CabalHelper/Compile.hs')
-rw-r--r--CabalHelper/Compile.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/CabalHelper/Compile.hs b/CabalHelper/Compile.hs
index 5071e15..2d0007d 100644
--- a/CabalHelper/Compile.hs
+++ b/CabalHelper/Compile.hs
@@ -375,9 +375,16 @@ unpackCabalHEAD tmpdir = do
let dir = tmpdir </> "cabal-head.git"
url = "https://github.com/haskell/cabal.git"
ExitSuccess <- rawSystem "git" [ "clone", "--depth=1", url, dir]
- let git_rev_parse = (proc "git" ["rev-parse", "HEAD"]) { cwd = Just dir }
- commit <- trim <$> readCreateProcess git_rev_parse ""
+ commit <-
+ withDirectory_ dir $ trim <$> readProcess "git" ["rev-parse", "HEAD"] ""
return (dir </> "Cabal", commit)
+ where
+ withDirectory_ :: FilePath -> IO a -> IO a
+ withDirectory_ dir action =
+ bracket
+ (liftIO getCurrentDirectory)
+ (liftIO . setCurrentDirectory)
+ (\_ -> liftIO (setCurrentDirectory dir) >> action)
errorInstallCabal :: Version -> FilePath -> a
errorInstallCabal cabalVer _distdir = panic $ printf "\