Commit dfd1fc35 authored by Duncan Coutts's avatar Duncan Coutts

New development branch, version 0.7

Update to development version of Cabal
parent f064be60
...@@ -37,7 +37,8 @@ import Distribution.Client.SetupWrapper ...@@ -37,7 +37,8 @@ import Distribution.Client.SetupWrapper
( setupWrapper, SetupScriptOptions(..), defaultSetupScriptOptions ) ( setupWrapper, SetupScriptOptions(..), defaultSetupScriptOptions )
import Distribution.Simple.Compiler import Distribution.Simple.Compiler
( CompilerId(..), Compiler(compilerId), PackageDB(..) ) ( CompilerId(..), Compiler(compilerId)
, PackageDB(..), PackageDBStack )
import Distribution.Simple.Program (ProgramConfiguration ) import Distribution.Simple.Program (ProgramConfiguration )
import Distribution.Simple.Configure (getInstalledPackages) import Distribution.Simple.Configure (getInstalledPackages)
import Distribution.Simple.Setup import Distribution.Simple.Setup
...@@ -69,7 +70,7 @@ import Distribution.Verbosity as Verbosity ...@@ -69,7 +70,7 @@ import Distribution.Verbosity as Verbosity
-- | Configure the package found in the local directory -- | Configure the package found in the local directory
configure :: Verbosity configure :: Verbosity
-> PackageDB -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
...@@ -77,10 +78,10 @@ configure :: Verbosity ...@@ -77,10 +78,10 @@ configure :: Verbosity
-> ConfigExFlags -> ConfigExFlags
-> [String] -> [String]
-> IO () -> IO ()
configure verbosity packageDB repos comp conf configure verbosity packageDBs repos comp conf
configFlags configExFlags extraArgs = do configFlags configExFlags extraArgs = do
installed <- getInstalledPackages verbosity comp packageDB conf installed <- getInstalledPackages verbosity comp packageDBs conf
available <- getAvailablePackages verbosity repos available <- getAvailablePackages verbosity repos
progress <- planLocalPackage verbosity comp configFlags configExFlags progress <- planLocalPackage verbosity comp configFlags configExFlags
...@@ -114,12 +115,12 @@ configure verbosity packageDB repos comp conf ...@@ -114,12 +115,12 @@ configure verbosity packageDB repos comp conf
-- Hack: we typically want to allow the UserPackageDB for finding the -- Hack: we typically want to allow the UserPackageDB for finding the
-- Cabal lib when compiling any Setup.hs even if we're doing a global -- Cabal lib when compiling any Setup.hs even if we're doing a global
-- install. However we also allow looking in a specific package db. -- install. However we also allow looking in a specific package db.
-- TODO: if we specify a specific db then we do not look in the user usePackageDB = if UserPackageDB `elem` packageDBs
-- package db but we probably should ie [global, user, specific] then packageDBs
usePackageDB = if packageDB == GlobalPackageDB then UserPackageDB else packageDBs ++ [UserPackageDB],
else packageDB, usePackageIndex = if UserPackageDB `elem` packageDBs
usePackageIndex = if packageDB == GlobalPackageDB then Nothing then index
else index, else Nothing,
useProgramConfig = conf, useProgramConfig = conf,
useDistPref = fromFlagOrDefault useDistPref = fromFlagOrDefault
(useDistPref defaultSetupScriptOptions) (useDistPref defaultSetupScriptOptions)
......
...@@ -43,7 +43,7 @@ import Distribution.Package ...@@ -43,7 +43,7 @@ import Distribution.Package
( PackageIdentifier, packageName, packageVersion, Dependency(..) ) ( PackageIdentifier, packageName, packageVersion, Dependency(..) )
import qualified Distribution.Simple.PackageIndex as PackageIndex import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.Compiler import Distribution.Simple.Compiler
( Compiler(compilerId), PackageDB ) ( Compiler(compilerId), PackageDBStack )
import Distribution.Simple.Program import Distribution.Simple.Program
( ProgramConfiguration ) ( ProgramConfiguration )
import Distribution.Simple.Configure import Distribution.Simple.Configure
...@@ -148,14 +148,14 @@ fetchPackage verbosity repo pkgid = do ...@@ -148,14 +148,14 @@ fetchPackage verbosity repo pkgid = do
-- |Fetch a list of packages and their dependencies. -- |Fetch a list of packages and their dependencies.
fetch :: Verbosity fetch :: Verbosity
-> PackageDB -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
-> [UnresolvedDependency] -> [UnresolvedDependency]
-> IO () -> IO ()
fetch verbosity packageDB repos comp conf deps = do fetch verbosity packageDBs repos comp conf deps = do
installed <- getInstalledPackages verbosity comp packageDB conf installed <- getInstalledPackages verbosity comp packageDBs conf
AvailablePackageDb available availablePrefs AvailablePackageDb available availablePrefs
<- getAvailablePackages verbosity repos <- getAvailablePackages verbosity repos
deps' <- IndexUtils.disambiguateDependencies available deps deps' <- IndexUtils.disambiguateDependencies available deps
......
...@@ -71,7 +71,8 @@ import qualified Distribution.Client.Win32SelfUpgrade as Win32SelfUpgrade ...@@ -71,7 +71,8 @@ import qualified Distribution.Client.Win32SelfUpgrade as Win32SelfUpgrade
import Paths_cabal_install (getBinDir) import Paths_cabal_install (getBinDir)
import Distribution.Simple.Compiler import Distribution.Simple.Compiler
( CompilerId(..), Compiler(compilerId), PackageDB(..) ) ( CompilerId(..), Compiler(compilerId)
, PackageDB(..), PackageDBStack )
import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration) import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration)
import Distribution.Simple.Configure (getInstalledPackages) import Distribution.Simple.Configure (getInstalledPackages)
import qualified Distribution.Simple.InstallDirs as InstallDirs import qualified Distribution.Simple.InstallDirs as InstallDirs
...@@ -123,7 +124,7 @@ data InstallMisc = InstallMisc { ...@@ -123,7 +124,7 @@ data InstallMisc = InstallMisc {
-- |Installs the packages needed to satisfy a list of dependencies. -- |Installs the packages needed to satisfy a list of dependencies.
install, upgrade install, upgrade
:: Verbosity :: Verbosity
-> PackageDB -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
...@@ -166,7 +167,7 @@ type Planner = Maybe (PackageIndex InstalledPackageInfo) ...@@ -166,7 +167,7 @@ type Planner = Maybe (PackageIndex InstalledPackageInfo)
installWithPlanner :: installWithPlanner ::
Planner Planner
-> Verbosity -> Verbosity
-> PackageDB -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
...@@ -174,10 +175,10 @@ installWithPlanner :: ...@@ -174,10 +175,10 @@ installWithPlanner ::
-> ConfigExFlags -> ConfigExFlags
-> InstallFlags -> InstallFlags
-> IO () -> IO ()
installWithPlanner planner verbosity packageDB repos comp conf installWithPlanner planner verbosity packageDBs repos comp conf
configFlags configExFlags installFlags = do configFlags configExFlags installFlags = do
installed <- getInstalledPackages verbosity comp packageDB conf installed <- getInstalledPackages verbosity comp packageDBs conf
available <- getAvailablePackages verbosity repos available <- getAvailablePackages verbosity repos
progress <- planner installed available progress <- planner installed available
...@@ -229,12 +230,12 @@ installWithPlanner planner verbosity packageDB repos comp conf ...@@ -229,12 +230,12 @@ installWithPlanner planner verbosity packageDB repos comp conf
-- Hack: we typically want to allow the UserPackageDB for finding the -- Hack: we typically want to allow the UserPackageDB for finding the
-- Cabal lib when compiling any Setup.hs even if we're doing a global -- Cabal lib when compiling any Setup.hs even if we're doing a global
-- install. However we also allow looking in a specific package db. -- install. However we also allow looking in a specific package db.
-- TODO: if we specify a specific db then we do not look in the user usePackageDB = if UserPackageDB `elem` packageDBs
-- package db but we probably should ie [global, user, specific] then packageDBs
usePackageDB = if packageDB == GlobalPackageDB then UserPackageDB else packageDBs ++ [UserPackageDB],
else packageDB, usePackageIndex = if UserPackageDB `elem` packageDBs
usePackageIndex = if packageDB == GlobalPackageDB then Nothing then index
else index, else Nothing,
useProgramConfig = conf, useProgramConfig = conf,
useDistPref = fromFlagOrDefault useDistPref = fromFlagOrDefault
(useDistPref defaultSetupScriptOptions) (useDistPref defaultSetupScriptOptions)
......
...@@ -27,7 +27,8 @@ import Distribution.PackageDescription.Configuration ...@@ -27,7 +27,8 @@ import Distribution.PackageDescription.Configuration
( flattenPackageDescription ) ( flattenPackageDescription )
import Distribution.Simple.Configure (getInstalledPackages) import Distribution.Simple.Configure (getInstalledPackages)
import Distribution.Simple.Compiler (Compiler,PackageDB) import Distribution.Simple.Compiler
( Compiler, PackageDBStack )
import Distribution.Simple.Program (ProgramConfiguration) import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.Simple.Utils (equating, comparing, notice) import Distribution.Simple.Utils (equating, comparing, notice)
import Distribution.Simple.Setup (fromFlag) import Distribution.Simple.Setup (fromFlag)
...@@ -64,15 +65,15 @@ import System.Directory ...@@ -64,15 +65,15 @@ import System.Directory
-- |Show information about packages -- |Show information about packages
list :: Verbosity list :: Verbosity
-> PackageDB -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
-> ListFlags -> ListFlags
-> [String] -> [String]
-> IO () -> IO ()
list verbosity packageDB repos comp conf listFlags pats = do list verbosity packageDBs repos comp conf listFlags pats = do
Just installed <- getInstalledPackages verbosity comp packageDB conf Just installed <- getInstalledPackages verbosity comp packageDBs conf
AvailablePackageDb available _ <- getAvailablePackages verbosity repos AvailablePackageDb available _ <- getAvailablePackages verbosity repos
let pkgs | null pats = (PackageIndex.allPackages installed let pkgs | null pats = (PackageIndex.allPackages installed
,PackageIndex.allPackages available) ,PackageIndex.allPackages available)
...@@ -103,17 +104,17 @@ list verbosity packageDB repos comp conf listFlags pats = do ...@@ -103,17 +104,17 @@ list verbosity packageDB repos comp conf listFlags pats = do
simpleOutput = fromFlag (listSimpleOutput listFlags) simpleOutput = fromFlag (listSimpleOutput listFlags)
info :: Verbosity info :: Verbosity
-> PackageDB -> PackageDBStack
-> [Repo] -> [Repo]
-> Compiler -> Compiler
-> ProgramConfiguration -> ProgramConfiguration
-> InfoFlags -> InfoFlags
-> [UnresolvedDependency] --FIXME: just package names? or actually use the constraint -> [UnresolvedDependency] --FIXME: just package names? or actually use the constraint
-> IO () -> IO ()
info verbosity packageDB repos comp conf _listFlags deps = do info verbosity packageDBs repos comp conf _listFlags deps = do
AvailablePackageDb available _ <- getAvailablePackages verbosity repos AvailablePackageDb available _ <- getAvailablePackages verbosity repos
deps' <- IndexUtils.disambiguateDependencies available deps deps' <- IndexUtils.disambiguateDependencies available deps
Just installed <- getInstalledPackages verbosity comp packageDB conf Just installed <- getInstalledPackages verbosity comp packageDBs conf
let deps'' = [ name | UnresolvedDependency (Dependency name _) _ <- deps' ] let deps'' = [ name | UnresolvedDependency (Dependency name _) _ <- deps' ]
let pkgs = (concatMap (PackageIndex.lookupPackageName installed) deps'' let pkgs = (concatMap (PackageIndex.lookupPackageName installed) deps''
,concatMap (PackageIndex.lookupPackageName available) deps'') ,concatMap (PackageIndex.lookupPackageName available) deps'')
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module Distribution.Client.Setup module Distribution.Client.Setup
( globalCommand, GlobalFlags(..), globalRepos ( globalCommand, GlobalFlags(..), globalRepos
, configureCommand, ConfigFlags(..), filterConfigureFlags, configPackageDB' , configureCommand, ConfigFlags(..), filterConfigureFlags
, configureExCommand, ConfigExFlags(..), defaultConfigExFlags , configureExCommand, ConfigExFlags(..), defaultConfigExFlags
, configureExOptions , configureExOptions
, installCommand, InstallFlags(..), installOptions, defaultInstallFlags , installCommand, InstallFlags(..), installOptions, defaultInstallFlags
...@@ -195,15 +195,6 @@ configureCommand = (Cabal.configureCommand defaultProgramConfiguration) { ...@@ -195,15 +195,6 @@ configureCommand = (Cabal.configureCommand defaultProgramConfiguration) {
configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags] configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags]
configureOptions = commandOptions configureCommand configureOptions = commandOptions configureCommand
configPackageDB' :: ConfigFlags -> PackageDB
configPackageDB' config =
fromFlagOrDefault defaultDB (configPackageDB config)
where
defaultDB = case configUserInstall config of
NoFlag -> UserPackageDB
Flag True -> UserPackageDB
Flag False -> GlobalPackageDB
filterConfigureFlags :: ConfigFlags -> Version -> ConfigFlags filterConfigureFlags :: ConfigFlags -> Version -> ConfigFlags
filterConfigureFlags flags cabalLibVersion filterConfigureFlags flags cabalLibVersion
| cabalLibVersion >= Version [1,3,10] [] = flags | cabalLibVersion >= Version [1,3,10] [] = flags
......
...@@ -37,7 +37,7 @@ import Distribution.InstalledPackageInfo ...@@ -37,7 +37,7 @@ import Distribution.InstalledPackageInfo
import Distribution.Simple.Configure import Distribution.Simple.Configure
( configCompiler, getInstalledPackages ) ( configCompiler, getInstalledPackages )
import Distribution.Simple.Compiler import Distribution.Simple.Compiler
( CompilerFlavor(GHC), Compiler, PackageDB(..) ) ( CompilerFlavor(GHC), Compiler, PackageDB(..), PackageDBStack )
import Distribution.Simple.Program import Distribution.Simple.Program
( ProgramConfiguration, emptyProgramConfiguration ( ProgramConfiguration, emptyProgramConfiguration
, rawSystemProgramConf, ghcProgram ) , rawSystemProgramConf, ghcProgram )
...@@ -73,7 +73,7 @@ import Data.Char ( isSpace ) ...@@ -73,7 +73,7 @@ import Data.Char ( isSpace )
data SetupScriptOptions = SetupScriptOptions { data SetupScriptOptions = SetupScriptOptions {
useCabalVersion :: VersionRange, useCabalVersion :: VersionRange,
useCompiler :: Maybe Compiler, useCompiler :: Maybe Compiler,
usePackageDB :: PackageDB, usePackageDB :: PackageDBStack,
usePackageIndex :: Maybe (PackageIndex InstalledPackageInfo), usePackageIndex :: Maybe (PackageIndex InstalledPackageInfo),
useProgramConfig :: ProgramConfiguration, useProgramConfig :: ProgramConfiguration,
useDistPref :: FilePath, useDistPref :: FilePath,
...@@ -85,7 +85,7 @@ defaultSetupScriptOptions :: SetupScriptOptions ...@@ -85,7 +85,7 @@ defaultSetupScriptOptions :: SetupScriptOptions
defaultSetupScriptOptions = SetupScriptOptions { defaultSetupScriptOptions = SetupScriptOptions {
useCabalVersion = AnyVersion, useCabalVersion = AnyVersion,
useCompiler = Nothing, useCompiler = Nothing,
usePackageDB = UserPackageDB, usePackageDB = [GlobalPackageDB, UserPackageDB],
usePackageIndex = Nothing, usePackageIndex = Nothing,
useProgramConfig = emptyProgramConfiguration, useProgramConfig = emptyProgramConfiguration,
useDistPref = defaultDistPref, useDistPref = defaultDistPref,
...@@ -277,20 +277,30 @@ externalSetupMethod verbosity options pkg bt mkargs = do ...@@ -277,20 +277,30 @@ externalSetupMethod verbosity options pkg bt mkargs = do
when outOfDate $ do when outOfDate $ do
debug verbosity "Setup script is out of date, compiling..." debug verbosity "Setup script is out of date, compiling..."
(_, conf, _) <- configureCompiler options' (_, conf, _) <- configureCompiler options'
--TODO: get Cabal's GHC module to export a GhcOptions type and render func
rawSystemProgramConf verbosity ghcProgram conf $ rawSystemProgramConf verbosity ghcProgram conf $
ghcVerbosityOptions verbosity ghcVerbosityOptions verbosity
++ ["--make", setupHsFile, "-o", setupProgFile ++ ["--make", setupHsFile, "-o", setupProgFile
,"-odir", setupDir, "-hidir", setupDir ,"-odir", setupDir, "-hidir", setupDir
,"-i", "-i" ++ workingDir ] ,"-i", "-i" ++ workingDir ]
++ (case usePackageDB options' of ++ ghcPackageDbOptions (usePackageDB options')
GlobalPackageDB -> ["-no-user-package-conf"]
UserPackageDB -> []
SpecificPackageDB db -> ["-no-user-package-conf"
,"-package-conf", db])
++ if packageName pkg == PackageName "Cabal" ++ if packageName pkg == PackageName "Cabal"
then [] then []
else ["-package", display cabalPkgid] else ["-package", display cabalPkgid]
where cabalPkgid = PackageIdentifier (PackageName "Cabal") cabalLibVersion where
cabalPkgid = PackageIdentifier (PackageName "Cabal") cabalLibVersion
ghcPackageDbOptions :: PackageDBStack -> [String]
ghcPackageDbOptions dbstack = case dbstack of
(GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs
(GlobalPackageDB:dbs) -> "-no-user-package-conf"
: concatMap specific dbs
_ -> ierror
where
specific (SpecificPackageDB db) = [ "-package-conf", db ]
specific _ = ierror
ierror = error "internal error: unexpected package db stack"
invokeSetupScript :: [String] -> IO () invokeSetupScript :: [String] -> IO ()
invokeSetupScript args = do invokeSetupScript args = do
......
...@@ -25,7 +25,7 @@ import Distribution.Client.Setup ...@@ -25,7 +25,7 @@ import Distribution.Client.Setup
, UploadFlags(..), uploadCommand , UploadFlags(..), uploadCommand
, reportCommand , reportCommand
, unpackCommand, UnpackFlags(..) , unpackCommand, UnpackFlags(..)
, parsePackageArgs, configPackageDB' ) , parsePackageArgs )
import Distribution.Simple.Setup import Distribution.Simple.Setup
( BuildFlags(..), buildCommand ( BuildFlags(..), buildCommand
, HaddockFlags(..), haddockCommand , HaddockFlags(..), haddockCommand
...@@ -55,6 +55,8 @@ import Distribution.Client.SrcDist (sdist) ...@@ -55,6 +55,8 @@ import Distribution.Client.SrcDist (sdist)
import Distribution.Client.Unpack (unpack) import Distribution.Client.Unpack (unpack)
import qualified Distribution.Client.Win32SelfUpgrade as Win32SelfUpgrade import qualified Distribution.Client.Win32SelfUpgrade as Win32SelfUpgrade
import Distribution.Simple.Compiler
( PackageDB(..), PackageDBStack )
import Distribution.Simple.Program (defaultProgramConfiguration) import Distribution.Simple.Program (defaultProgramConfiguration)
import Distribution.Simple.Command import Distribution.Simple.Command
import Distribution.Simple.Configure (configCompilerAux) import Distribution.Simple.Configure (configCompilerAux)
...@@ -347,3 +349,28 @@ win32SelfUpgradeAction (pid:path:rest) = ...@@ -347,3 +349,28 @@ win32SelfUpgradeAction (pid:path:rest) =
-> fromMaybe Verbosity.normal (Verbosity.intToVerbosity (read [n])) -> fromMaybe Verbosity.normal (Verbosity.intToVerbosity (read [n]))
_ -> Verbosity.normal _ -> Verbosity.normal
win32SelfUpgradeAction _ = return () win32SelfUpgradeAction _ = return ()
--
-- Utils (transitionary)
--
-- | Currently the user interface specifies the package dbs to use with just a
-- single valued option, a 'PackageDB'. However internally we represent the
-- stack of 'PackageDB's explictly as a list. This function converts encodes
-- the package db stack implicit in a single packagedb.
--
-- TODO: sort this out, make it consistent with the command line UI
implicitPackageDbStack :: Bool -> Maybe PackageDB -> PackageDBStack
implicitPackageDbStack userInstall packageDbFlag
| userInstall = GlobalPackageDB : UserPackageDB : extra
| otherwise = GlobalPackageDB : extra
where
extra = case packageDbFlag of
Just (SpecificPackageDB db) -> [SpecificPackageDB db]
_ -> []
configPackageDB' :: ConfigFlags -> PackageDBStack
configPackageDB' cfg =
implicitPackageDbStack userInstall (flagToMaybe (configPackageDB cfg))
where
userInstall = fromFlagOrDefault True (configUserInstall cfg)
Name: cabal-install Name: cabal-install
Version: 0.6.2 Version: 0.7
Synopsis: The command-line interface for Cabal and Hackage. Synopsis: The command-line interface for Cabal and Hackage.
Description: Description:
The \'cabal\' command-line program simplifies the process of managing The \'cabal\' command-line program simplifies the process of managing
...@@ -74,7 +74,7 @@ Executable cabal ...@@ -74,7 +74,7 @@ Executable cabal
Paths_cabal_install Paths_cabal_install
build-depends: base >= 2 && < 4, build-depends: base >= 2 && < 4,
Cabal >= 1.6 && < 1.7, Cabal >= 1.7.1 && < 1.9,
filepath >= 1.0, filepath >= 1.0,
network >= 1 && < 3, network >= 1 && < 3,
HTTP >= 4000.0.2 && < 4001, HTTP >= 4000.0.2 && < 4001,
......
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