Commit 280b20a1 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Make the 'upgrade' command take optional deps

Up to now 'upgrade' took no args and tried to upgrade all installed
packages to the latest versions. It retains that mode but also has
a new mode rather like 'cabal install'. The difference is that with
$ cabal install foo
it means install latest version of foo but otherwise prefer the
installed versions of deps of foo, while
$ cabal upgrade foo
means install the latest version of foo and also the latest
versions of all the dependencies of foo.
parent 6f73ea9c
......@@ -85,33 +85,31 @@ data InstallMisc = InstallMisc {
}
-- |Installs the packages needed to satisfy a list of dependencies.
install :: Verbosity
-> PackageDB
-> [Repo]
-> Compiler
-> ProgramConfiguration
-> Cabal.ConfigFlags
-> InstallFlags
-> [UnresolvedDependency]
-> IO ()
install, upgrade
:: Verbosity
-> PackageDB
-> [Repo]
-> Compiler
-> ProgramConfiguration
-> Cabal.ConfigFlags
-> InstallFlags
-> [UnresolvedDependency]
-> IO ()
install verbosity packageDB repos comp conf configFlags installFlags deps =
installWithPlanner planner
verbosity packageDB repos comp conf configFlags installFlags
where
planner :: Planner
planner | null deps = planLocalPackage verbosity comp configFlags
| otherwise = planRepoPackages comp deps
| otherwise = planRepoPackages PreferLatestForSelected comp deps
upgrade :: Verbosity
-> PackageDB
-> [Repo]
-> Compiler
-> ProgramConfiguration
-> Cabal.ConfigFlags
-> InstallFlags
-> IO ()
upgrade verbosity packageDB repos comp =
installWithPlanner (planUpgradePackages comp) verbosity packageDB repos comp
upgrade verbosity packageDB repos comp conf configFlags installFlags deps =
installWithPlanner planner
verbosity packageDB repos comp conf configFlags installFlags
where
planner :: Planner
planner | null deps = planUpgradePackages comp
| otherwise = planRepoPackages PreferAllLatest comp deps
type Planner = Maybe (PackageIndex InstalledPackageInfo)
-> PackageIndex AvailablePackage
......@@ -198,11 +196,12 @@ planLocalPackage verbosity comp configFlags installed available = do
-- | Make an 'InstallPlan' for the given dependencies.
--
planRepoPackages :: Compiler -> [UnresolvedDependency] -> Planner
planRepoPackages comp deps installed available = do
planRepoPackages :: PackagesVersionPreference -> Compiler
-> [UnresolvedDependency] -> Planner
planRepoPackages pref comp deps installed available = do
deps' <- IndexUtils.disambiguateDependencies available deps
return $ resolveDependenciesWithProgress buildOS buildArch (compilerId comp)
installed available PreferLatestForSelected deps'
installed available pref deps'
planUpgradePackages :: Compiler -> Planner
planUpgradePackages comp (Just installed) available = return $
......
......@@ -183,7 +183,8 @@ updateAction verbosityFlag _extraArgs = do
update verbosity (configRepos config)
upgradeAction :: (Cabal.ConfigFlags, InstallFlags) -> [String] -> IO ()
upgradeAction (cflags,iflags) _extraArgs = do
upgradeAction (cflags,iflags) extraArgs = do
pkgs <- either die return (parsePackageArgs extraArgs)
configFile <- defaultConfigFile --FIXME
let verbosity = fromFlagOrDefault normal (Cabal.configVerbosity cflags)
config <- loadConfig verbosity configFile
......@@ -192,7 +193,7 @@ upgradeAction (cflags,iflags) _extraArgs = do
(comp, conf) <- configCompilerAux cflags'
upgrade verbosity
(configPackageDB cflags') (configRepos config)
comp conf cflags' iflags
comp conf cflags' iflags pkgs
fetchAction :: Flag Verbosity -> [String] -> IO ()
fetchAction verbosityFlag extraArgs = do
......
Supports Markdown
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