Commit 414aed98 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Package registration files are always UTF8

As is the output from ghc-pkg dump.
parent 869d4561
......@@ -38,7 +38,7 @@ import Distribution.Simple.Compiler
import Distribution.Simple.Program.Types
( ConfiguredProgram(programId, programVersion) )
import Distribution.Simple.Program.Run
( ProgramInvocation(..), programInvocation
( ProgramInvocation(..), IOEncoding(..), programInvocation
, runProgramInvocation, getProgramInvocationOutput )
import Distribution.Version
( Version(..) )
......@@ -168,21 +168,25 @@ registerInvocation, reregisterInvocation
registerInvocation = registerInvocation' "register"
reregisterInvocation = registerInvocation' "update"
registerInvocation' :: String
-> ConfiguredProgram -> Verbosity -> PackageDB
-> Either FilePath InstalledPackageInfo
-> ProgramInvocation
registerInvocation' cmdname hcPkg verbosity packagedb (Left pkgFile) =
programInvocation hcPkg $
[cmdname, pkgFile, packageDbOpts packagedb]
programInvocation hcPkg args
where
args = [cmdname, pkgFile, packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
registerInvocation' cmdname hcPkg verbosity packagedb (Right pkgInfo) =
let args = [cmdname, "-", packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
in (programInvocation hcPkg args) {
progInvokeInput = Just (showInstalledPackageInfo pkgInfo)
(programInvocation hcPkg args) {
progInvokeInput = Just (showInstalledPackageInfo pkgInfo),
progInvokeInputEncoding = IOEncodingUTF8
}
where
args = [cmdname, "-", packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
unregisterInvocation :: ConfiguredProgram
......@@ -213,8 +217,11 @@ hideInvocation hcPkg verbosity packagedb pkgid =
dumpInvocation :: ConfiguredProgram
-> Verbosity -> PackageDB -> ProgramInvocation
dumpInvocation hcPkg verbosity packagedb =
programInvocation hcPkg $
["dump", packageDbOpts packagedb]
(programInvocation hcPkg args) {
progInvokeOutputEncoding = IOEncodingUTF8
}
where
args = ["dump", packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
......
......@@ -90,7 +90,7 @@ import Distribution.InstalledPackageInfo
, showInstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as IPI
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, writeFileAtomic
( createDirectoryIfMissingVerbose, writeUTF8File, writeFileAtomic
, die, notice, setupMessage )
import Distribution.System
( OS(..), buildOS )
......@@ -148,7 +148,7 @@ register pkg@PackageDescription { library = Just lib }
writeRegistrationFile installedPkgInfo = do
notice verbosity ("Creating package registration file: " ++ regFile)
writeFileAtomic regFile (showInstalledPackageInfo installedPkgInfo)
writeUTF8File regFile (showInstalledPackageInfo installedPkgInfo)
writeRegisterScript installedPkgInfo =
case compilerFlavor (compiler lbi) of
......@@ -236,7 +236,7 @@ registerPackageHugs verbosity installedPkgInfo pkg lbi inplace _packageDb = do
when inplace $ die "--inplace is not supported with Hugs"
let installDirs = absoluteInstallDirs pkg lbi NoCopyDest
createDirectoryIfMissingVerbose verbosity True (libdir installDirs)
writeFileAtomic (libdir installDirs </> "package.conf")
writeUTF8File (libdir installDirs </> "package.conf")
(showInstalledPackageInfo installedPkgInfo)
......@@ -251,7 +251,7 @@ writeHcPkgRegisterScript verbosity installedPkgInfo hcPkg packageDb = do
regScript = invocationAsSystemScript buildOS invocation
notice verbosity ("Creating package registration script: " ++ regScriptFileName)
writeFileAtomic regScriptFileName regScript
writeUTF8File regScriptFileName regScript
setFileExecutable regScriptFileName
regScriptFileName :: FilePath
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment