Skip to content

Commit

Permalink
Deduplicate packages in the install plan after the solver removes qua…
Browse files Browse the repository at this point in the history
…lifiers.

Fixes #4026
  • Loading branch information
grayjay committed Oct 26, 2016
1 parent 74bc5ba commit 9378165
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cabal-install/Distribution/Solver/Modular.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ module Distribution.Solver.Modular
-- and finally, we have to convert back the resulting install
-- plan.

import Data.Function
( on )
import Data.List
( nubBy )
import Data.Map as M
( fromListWith )
import Distribution.Compat.Graph
( IsNode(..) )
import Distribution.Solver.Modular.Assignment
( toCPs )
import Distribution.Solver.Modular.ConfiguredConversion
Expand Down Expand Up @@ -44,8 +50,12 @@ modularResolver sc (Platform arch os) cinfo iidx sidx pkgConfigDB pprefs pcs pns
where
pair lpc = (pcName $ unlabelPackageConstraint lpc, [lpc])

-- Results have to be converted into an install plan.
postprocess a rdm = map (convCP iidx sidx) (toCPs a rdm)
-- Results have to be converted into an install plan. 'convCP' removes
-- package qualifiers, which means that linked packages become duplicates
-- and can be removed.
-- TODO: Use ordNubBy instead of nubBy.
postprocess a rdm = nubBy ((==) `on` nodeKey) $
map (convCP iidx sidx) (toCPs a rdm)

-- Helper function to extract the PN from a constraint.
pcName :: PackageConstraint -> PN
Expand Down

0 comments on commit 9378165

Please sign in to comment.