diff --git a/cabal-install/Distribution/Client/Install.hs b/cabal-install/Distribution/Client/Install.hs index 3a55715a250..048a6cbe3f7 100644 --- a/cabal-install/Distribution/Client/Install.hs +++ b/cabal-install/Distribution/Client/Install.hs @@ -114,8 +114,7 @@ import Distribution.Utils.NubList import Distribution.Simple.Compiler ( CompilerId(..), Compiler(compilerId), compilerFlavor , CompilerInfo(..), compilerInfo, PackageDB(..), PackageDBStack ) -import Distribution.Simple.Program (ProgramConfiguration, - defaultProgramConfiguration) +import Distribution.Simple.Program (ProgramConfiguration) import qualified Distribution.Simple.InstallDirs as InstallDirs import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Simple.PackageIndex (InstalledPackageIndex) @@ -135,6 +134,9 @@ import Distribution.Simple.Utils import Distribution.Simple.InstallDirs as InstallDirs ( PathTemplate, fromPathTemplate, toPathTemplate, substPathTemplate , initialPathTemplateEnv, installDirsTemplateEnv ) +import Distribution.Simple.Configure (interpretPackageDbFlags) +import Distribution.Simple.Register (registerPackage) +import Distribution.Simple.Program.HcPkg (MultiInstance(..)) import Distribution.Package ( PackageIdentifier(..), PackageId, packageName, packageVersion , Package(..) @@ -1083,8 +1085,8 @@ performInstallations verbosity (setupScriptOptions installedPkgIndex cacheLock rpkg) configFlags' - installFlags haddockFlags - cinfo platform pkg rpkg pkgoverride mpath useLogFile + installFlags haddockFlags comp conf + platform pkg rpkg pkgoverride mpath useLogFile where cinfo = compilerInfo comp @@ -1379,7 +1381,8 @@ installUnpackedPackage -> ConfigFlags -> InstallFlags -> HaddockFlags - -> CompilerInfo + -> Compiler + -> ProgramConfiguration -> Platform -> PackageDescription -> ReadyPackage @@ -1389,9 +1392,8 @@ installUnpackedPackage -> IO BuildResult installUnpackedPackage verbosity buildLimit installLock numJobs scriptOptions - configFlags installFlags haddockFlags - cinfo platform pkg rpkg pkgoverride workingDir useLogFile = do - + configFlags installFlags haddockFlags comp conf + platform pkg rpkg pkgoverride workingDir useLogFile = do -- Override the .cabal file if necessary case pkgoverride of Nothing -> return () @@ -1450,19 +1452,31 @@ installUnpackedPackage verbosity buildLimit installLock numJobs withWin32SelfUpgrade verbosity ipid configFlags cinfo platform pkg $ do setup Cabal.copyCommand copyFlags mLogPath - when shouldRegister $ do - setup Cabal.registerCommand registerFlags mLogPath -- Capture installed package configuration file, so that -- it can be incorporated into the final InstallPlan - maybePkgConfs <- maybeGenPkgConfs mLogPath - - return (Right (BuildOk docsResult testsResult maybePkgConfs)) + -- TODO: This is duplicated with + -- Distribution/Client/ProjectBuilding.hs, search for + -- the Note. + ipkgs <- genPkgConfs mLogPath + let ipkgs' = case ipkgs of + [ipkg] -> [ipkg { Installed.installedUnitId = ipid }] + _ -> ipkgs + let packageDBs = interpretPackageDbFlags + (fromFlag (configUserInstall configFlags)) + (configPackageDBs configFlags) + forM_ ipkgs' $ \ipkg' -> + registerPackage verbosity comp conf + NoMultiInstance + packageDBs ipkg' + + return (Right (BuildOk docsResult testsResult ipkgs')) where pkgid = packageId pkg ipid = installedUnitId rpkg - buildCommand' = buildCommand defaultProgramConfiguration + cinfo = compilerInfo comp + buildCommand' = buildCommand conf buildFlags _ = emptyBuildFlags { buildDistPref = configDistPref configFlags, buildVerbosity = toFlag verbosity' @@ -1505,9 +1519,9 @@ installUnpackedPackage verbosity buildLimit installLock numJobs userInstall = fromFlagOrDefault defaultUserInstall (configUserInstall configFlags') - maybeGenPkgConfs :: Maybe FilePath + genPkgConfs :: Maybe FilePath -> IO [Installed.InstalledPackageInfo] - maybeGenPkgConfs mLogPath = + genPkgConfs mLogPath = if shouldRegister then do tmp <- getTemporaryDirectory withTempDirectory verbosity tmp (tempTemplate "pkgConf") $ \dir -> do diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index a58084c9f2d..221716eba93 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -31,6 +31,13 @@ Extra-Source-Files: -- Do NOT edit this section manually; instead, run the script. -- BEGIN gen-extra-source-files tests/IntegrationTests/common.sh + tests/IntegrationTests/custom/custom_dep.sh + tests/IntegrationTests/custom/custom_dep/client/B.hs + tests/IntegrationTests/custom/custom_dep/client/Setup.hs + tests/IntegrationTests/custom/custom_dep/client/client.cabal + tests/IntegrationTests/custom/custom_dep/custom/A.hs + tests/IntegrationTests/custom/custom_dep/custom/Setup.hs + tests/IntegrationTests/custom/custom_dep/custom/custom.cabal tests/IntegrationTests/custom/plain.err tests/IntegrationTests/custom/plain.sh tests/IntegrationTests/custom/plain/A.hs diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep.sh b/cabal-install/tests/IntegrationTests/custom/custom_dep.sh new file mode 100644 index 00000000000..cf22c3a97c8 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep.sh @@ -0,0 +1,8 @@ +. ./common.sh +cd custom_dep +cabal sandbox init +cabal sandbox add-source custom +cabal sandbox add-source client +# Set HOME to something goofy so that we force the user +# database not to be used +HOME=`pwd` cabal install client diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep/client/B.hs b/cabal-install/tests/IntegrationTests/custom/custom_dep/client/B.hs new file mode 100644 index 00000000000..af119169669 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep/client/B.hs @@ -0,0 +1,2 @@ +module B where +import A diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep/client/Setup.hs b/cabal-install/tests/IntegrationTests/custom/custom_dep/client/Setup.hs new file mode 100644 index 00000000000..9a994af677b --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep/client/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep/client/client.cabal b/cabal-install/tests/IntegrationTests/custom/custom_dep/client/client.cabal new file mode 100644 index 00000000000..2bb74b34594 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep/client/client.cabal @@ -0,0 +1,12 @@ +name: client +version: 0.1.0.0 +license: BSD3 +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: >=1.10 + +library + exposed-modules: B + build-depends: base, custom + default-language: Haskell2010 diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/A.hs b/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/A.hs new file mode 100644 index 00000000000..d843c00b782 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/A.hs @@ -0,0 +1 @@ +module A where diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/Setup.hs b/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/Setup.hs new file mode 100644 index 00000000000..9a994af677b --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/custom.cabal b/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/custom.cabal new file mode 100644 index 00000000000..08ce5ceaa3d --- /dev/null +++ b/cabal-install/tests/IntegrationTests/custom/custom_dep/custom/custom.cabal @@ -0,0 +1,15 @@ +-- Initial custom.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/ + +name: custom +version: 0.1.0.0 +license: BSD3 +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Custom +cabal-version: >=1.10 + +library + exposed-modules: A + build-depends: base >=4.7 && <4.8 + default-language: Haskell2010