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 ...@@ -38,7 +38,7 @@ import Distribution.Simple.Compiler
import Distribution.Simple.Program.Types import Distribution.Simple.Program.Types
( ConfiguredProgram(programId, programVersion) ) ( ConfiguredProgram(programId, programVersion) )
import Distribution.Simple.Program.Run import Distribution.Simple.Program.Run
( ProgramInvocation(..), programInvocation ( ProgramInvocation(..), IOEncoding(..), programInvocation
, runProgramInvocation, getProgramInvocationOutput ) , runProgramInvocation, getProgramInvocationOutput )
import Distribution.Version import Distribution.Version
( Version(..) ) ( Version(..) )
...@@ -168,21 +168,25 @@ registerInvocation, reregisterInvocation ...@@ -168,21 +168,25 @@ registerInvocation, reregisterInvocation
registerInvocation = registerInvocation' "register" registerInvocation = registerInvocation' "register"
reregisterInvocation = registerInvocation' "update" reregisterInvocation = registerInvocation' "update"
registerInvocation' :: String registerInvocation' :: String
-> ConfiguredProgram -> Verbosity -> PackageDB -> ConfiguredProgram -> Verbosity -> PackageDB
-> Either FilePath InstalledPackageInfo -> Either FilePath InstalledPackageInfo
-> ProgramInvocation -> ProgramInvocation
registerInvocation' cmdname hcPkg verbosity packagedb (Left pkgFile) = registerInvocation' cmdname hcPkg verbosity packagedb (Left pkgFile) =
programInvocation hcPkg $ programInvocation hcPkg args
[cmdname, pkgFile, packageDbOpts packagedb] where
++ verbosityOpts hcPkg verbosity args = [cmdname, pkgFile, packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
registerInvocation' cmdname hcPkg verbosity packagedb (Right pkgInfo) = registerInvocation' cmdname hcPkg verbosity packagedb (Right pkgInfo) =
let args = [cmdname, "-", packageDbOpts packagedb] (programInvocation hcPkg args) {
++ verbosityOpts hcPkg verbosity progInvokeInput = Just (showInstalledPackageInfo pkgInfo),
in (programInvocation hcPkg args) { progInvokeInputEncoding = IOEncodingUTF8
progInvokeInput = Just (showInstalledPackageInfo pkgInfo) }
} where
args = [cmdname, "-", packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
unregisterInvocation :: ConfiguredProgram unregisterInvocation :: ConfiguredProgram
...@@ -213,9 +217,12 @@ hideInvocation hcPkg verbosity packagedb pkgid = ...@@ -213,9 +217,12 @@ hideInvocation hcPkg verbosity packagedb pkgid =
dumpInvocation :: ConfiguredProgram dumpInvocation :: ConfiguredProgram
-> Verbosity -> PackageDB -> ProgramInvocation -> Verbosity -> PackageDB -> ProgramInvocation
dumpInvocation hcPkg verbosity packagedb = dumpInvocation hcPkg verbosity packagedb =
programInvocation hcPkg $ (programInvocation hcPkg args) {
["dump", packageDbOpts packagedb] progInvokeOutputEncoding = IOEncodingUTF8
++ verbosityOpts hcPkg verbosity }
where
args = ["dump", packageDbOpts packagedb]
++ verbosityOpts hcPkg verbosity
packageDbOpts :: PackageDB -> String packageDbOpts :: PackageDB -> String
......
...@@ -90,7 +90,7 @@ import Distribution.InstalledPackageInfo ...@@ -90,7 +90,7 @@ import Distribution.InstalledPackageInfo
, showInstalledPackageInfo ) , showInstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as IPI import qualified Distribution.InstalledPackageInfo as IPI
import Distribution.Simple.Utils import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, writeFileAtomic ( createDirectoryIfMissingVerbose, writeUTF8File, writeFileAtomic
, die, notice, setupMessage ) , die, notice, setupMessage )
import Distribution.System import Distribution.System
( OS(..), buildOS ) ( OS(..), buildOS )
...@@ -148,7 +148,7 @@ register pkg@PackageDescription { library = Just lib } ...@@ -148,7 +148,7 @@ register pkg@PackageDescription { library = Just lib }
writeRegistrationFile installedPkgInfo = do writeRegistrationFile installedPkgInfo = do
notice verbosity ("Creating package registration file: " ++ regFile) notice verbosity ("Creating package registration file: " ++ regFile)
writeFileAtomic regFile (showInstalledPackageInfo installedPkgInfo) writeUTF8File regFile (showInstalledPackageInfo installedPkgInfo)
writeRegisterScript installedPkgInfo = writeRegisterScript installedPkgInfo =
case compilerFlavor (compiler lbi) of case compilerFlavor (compiler lbi) of
...@@ -236,8 +236,8 @@ registerPackageHugs verbosity installedPkgInfo pkg lbi inplace _packageDb = do ...@@ -236,8 +236,8 @@ registerPackageHugs verbosity installedPkgInfo pkg lbi inplace _packageDb = do
when inplace $ die "--inplace is not supported with Hugs" when inplace $ die "--inplace is not supported with Hugs"
let installDirs = absoluteInstallDirs pkg lbi NoCopyDest let installDirs = absoluteInstallDirs pkg lbi NoCopyDest
createDirectoryIfMissingVerbose verbosity True (libdir installDirs) createDirectoryIfMissingVerbose verbosity True (libdir installDirs)
writeFileAtomic (libdir installDirs </> "package.conf") writeUTF8File (libdir installDirs </> "package.conf")
(showInstalledPackageInfo installedPkgInfo) (showInstalledPackageInfo installedPkgInfo)
writeHcPkgRegisterScript :: Verbosity writeHcPkgRegisterScript :: Verbosity
...@@ -251,7 +251,7 @@ writeHcPkgRegisterScript verbosity installedPkgInfo hcPkg packageDb = do ...@@ -251,7 +251,7 @@ writeHcPkgRegisterScript verbosity installedPkgInfo hcPkg packageDb = do
regScript = invocationAsSystemScript buildOS invocation regScript = invocationAsSystemScript buildOS invocation
notice verbosity ("Creating package registration script: " ++ regScriptFileName) notice verbosity ("Creating package registration script: " ++ regScriptFileName)
writeFileAtomic regScriptFileName regScript writeUTF8File regScriptFileName regScript
setFileExecutable regScriptFileName setFileExecutable regScriptFileName
regScriptFileName :: FilePath 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