Skip to content

Commit

Permalink
no longer pre-filter broken packages for modular solver
Browse files Browse the repository at this point in the history
The modular solver can now deal with broken packages in the
index. I have, however, discovered, that broken packages were
filtered before even passing the installed package index to
the solver. I have made that filtering conditional on using
the topdown solver for now.

Related is the issue that we should not warn about possible
breakage of already broken packages. So we now exclude
already broken packages when considering whether an install
plan contains dangerous reinstalls.
  • Loading branch information
kosmikus committed Apr 8, 2012
1 parent 37a85af commit d280399
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
8 changes: 7 additions & 1 deletion cabal-install/Distribution/Client/Dependency.hs
Expand Up @@ -367,7 +367,13 @@ resolveDependencies platform comp solver params =
noReinstalls
shadowing
maxBkjumps = dontUpgradeBasePackage
. hideBrokenInstalledPackages
-- TODO:
-- The modular solver can properly deal with broken packages
-- and won't select them. So the 'hideBrokenInstalledPackages'
-- function should be moved into a module that is specific
-- to the Topdown solver.
. (if solver /= Modular then hideBrokenInstalledPackages
else id)
$ params

preferences = interpretPackagesPreference
Expand Down
18 changes: 13 additions & 5 deletions cabal-install/Distribution/Client/Install.hs
Expand Up @@ -358,13 +358,21 @@ checkPrintPlan verbosity installed installPlan installFlags pkgSpecifiers = do
let lPlan = linearizeInstallPlan installed installPlan
-- Are any packages classified as reinstalls?
let reinstalledPkgs = concatMap (extractReinstalls . snd) lPlan
-- Packages that are already broken.
let oldBrokenPkgs =
map Installed.installedPackageId
. PackageIndex.reverseDependencyClosure installed
. map (Installed.installedPackageId . fst)
. PackageIndex.brokenPackages
$ installed
let excluded = reinstalledPkgs ++ oldBrokenPkgs
-- Packages that are reverse dependencies of replaced packages are very
-- likely to be broken.
let brokenPkgs =
filter (\ p -> not (Installed.installedPackageId p `elem` reinstalledPkgs))
-- likely to be broken. We exclude packages that are already broken.
let newBrokenPkgs =
filter (\ p -> not (Installed.installedPackageId p `elem` excluded))
(PackageIndex.reverseDependencyClosure installed reinstalledPkgs)
let containsReinstalls = not (null reinstalledPkgs)
let breaksPkgs = not (null brokenPkgs)
let breaksPkgs = not (null newBrokenPkgs)

let adaptedVerbosity
| containsReinstalls && not overrideReinstall = verbosity `max` verbose
Expand All @@ -383,7 +391,7 @@ checkPrintPlan verbosity installed installPlan installFlags pkgSpecifiers = do
then do
(if dryRun || overrideReinstall then warn verbosity else die) $ unlines $
"The following packages are likely to be broken by the reinstalls:"
: map (display . Installed.sourcePackageId) brokenPkgs
: map (display . Installed.sourcePackageId) newBrokenPkgs
++ if overrideReinstall
then if dryRun then [] else
["Continuing even though the plan contains dangerous reinstalls."]
Expand Down

0 comments on commit d280399

Please sign in to comment.