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