projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix Windows build
[ghc-hetmet.git]
/
utils
/
ghc-pkg
/
Main.hs
diff --git
a/utils/ghc-pkg/Main.hs
b/utils/ghc-pkg/Main.hs
index
ae7aca3
..
a469ee7
100644
(file)
--- a/
utils/ghc-pkg/Main.hs
+++ b/
utils/ghc-pkg/Main.hs
@@
-52,8
+52,11
@@
import qualified Data.ByteString.Lazy as B
import qualified Data.Binary as Bin
import qualified Data.Binary.Get as Bin
import qualified Data.Binary as Bin
import qualified Data.Binary.Get as Bin
-#if __GLASGOW_HASKELL__ < 612
+#if __GLASGOW_HASKELL__ < 612 || defined(mingw32_HOST_OS)
import Foreign
import Foreign
+#endif
+
+#if __GLASGOW_HASKELL__ < 612
import Foreign.C
import System.Posix.Internals
#if __GLASGOW_HASKELL__ >= 611
import Foreign.C
import System.Posix.Internals
#if __GLASGOW_HASKELL__ >= 611
@@
-729,7
+732,7
@@
changeDBDir verbosity cmds db = do
do_cmd (AddPackage p) = do
let file = location db </> display (installedPackageId p) <.> "conf"
when (verbosity > Normal) $ putStrLn ("writing " ++ file)
do_cmd (AddPackage p) = do
let file = location db </> display (installedPackageId p) <.> "conf"
when (verbosity > Normal) $ putStrLn ("writing " ++ file)
- writeFileAtomic file utf8 (showInstalledPackageInfo p)
+ writeFileUtf8Atomic file (showInstalledPackageInfo p)
do_cmd (ModifyPackage p) =
do_cmd (AddPackage p)
do_cmd (ModifyPackage p) =
do_cmd (AddPackage p)
@@
-1151,7
+1154,7
@@
writeNewConfig verbosity filename ipis = do
let shown = concat $ intersperse ",\n "
$ map (show . convertPackageInfoOut) ipis
fileContents = "[" ++ shown ++ "\n]"
let shown = concat $ intersperse ",\n "
$ map (show . convertPackageInfoOut) ipis
fileContents = "[" ++ shown ++ "\n]"
- writeFileAtomic filename utf8 fileContents
+ writeFileUtf8Atomic filename fileContents
`catch` \e ->
if isPermissionError e
then die (filename ++ ": you don't have permission to modify this file")
`catch` \e ->
if isPermissionError e
then die (filename ++ ": you don't have permission to modify this file")
@@
-1557,10
+1560,12
@@
writeBinaryFileAtomic targetFile obj =
hSetBinaryMode h True
B.hPutStr h (Bin.encode obj)
hSetBinaryMode h True
B.hPutStr h (Bin.encode obj)
-writeFileAtomic :: FilePath -> TextEncoding -> String -> IO ()
-writeFileAtomic targetFile encoding content =
+writeFileUtf8Atomic :: FilePath -> String -> IO ()
+writeFileUtf8Atomic targetFile content =
withFileAtomic targetFile $ \h -> do
withFileAtomic targetFile $ \h -> do
- hSetEncoding h encoding
+#if __GLASGOW_HASKELL__ >= 612
+ hSetEncoding h utf8
+#endif
hPutStr h content
-- copied from Cabal's Distribution.Simple.Utils, except that we want
hPutStr h content
-- copied from Cabal's Distribution.Simple.Utils, except that we want