Skip to content

Commit d415623

Browse files
committed
Combine non-installable & non-upgradable packages
1 parent acbc0f3 commit d415623

File tree

3 files changed

+27
-34
lines changed

3 files changed

+27
-34
lines changed

cabal-install-solver/src/Distribution/Solver/Modular.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import Distribution.Verbosity
6060
-- solver. Performs the necessary translations before and after.
6161
modularResolver :: SolverConfig -> DependencyResolver loc
6262
modularResolver sc (Platform arch os) cinfo iidx sidx pkgConfigDB pprefs pcs pns =
63-
fmap (uncurry postprocess) $ -- convert install plan
63+
uncurry postprocess <$> -- convert install plan
6464
solve' sc cinfo idx pkgConfigDB pprefs gcs pns
6565
where
6666
-- Indices have to be converted into solver-specific uniform index.
@@ -275,7 +275,7 @@ tryToMinimizeConflictSet runSolver sc cs cm =
275275
++ "conflict set: " ++ showCS cs') $
276276
ExhaustiveSearch smallestKnownCS smallestKnownCM
277277
BackjumpLimitReached ->
278-
failWith ("Reached backjump limit while minimizing conflict set.")
278+
failWith "Reached backjump limit while minimizing conflict set."
279279
BackjumpLimitReached
280280
where
281281
varStr = "\"" ++ showVar v ++ "\""

cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ data SolverConfig = SolverConfig {
6767
shadowPkgs :: ShadowPkgs,
6868
strongFlags :: StrongFlags,
6969
allowBootLibInstalls :: AllowBootLibInstalls,
70+
nonInstallablePackages :: [PackageName],
7071
onlyConstrained :: OnlyConstrained,
7172
maxBackjumps :: Maybe Int,
7273
enableBackjumping :: EnableBackjumping,
@@ -142,7 +143,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
142143
prunePhase = (if asBool (avoidReinstalls sc) then P.avoidReinstalls (const True) else id) .
143144
(if asBool (allowBootLibInstalls sc)
144145
then id
145-
else P.requireInstalled (`elem` nonInstallable)) .
146+
else P.requireInstalled (`elem` nonInstallablePackages sc)) .
146147
(case onlyConstrained sc of
147148
OnlyConstrainedAll ->
148149
P.onlyConstrained pkgIsExplicit
@@ -155,23 +156,6 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
155156
pkgIsExplicit :: PN -> Bool
156157
pkgIsExplicit pn = S.member pn allExplicit
157158

158-
-- packages that can never be installed or upgraded
159-
-- If you change this enumeration, make sure to update the list in
160-
-- "Distribution.Client.Dependency" as well
161-
nonInstallable :: [PackageName]
162-
nonInstallable =
163-
L.map mkPackageName
164-
[ "base"
165-
, "ghc-bignum"
166-
, "ghc-prim"
167-
, "ghc-boot"
168-
, "ghc"
169-
, "ghci"
170-
, "integer-gmp"
171-
, "integer-simple"
172-
, "template-haskell"
173-
]
174-
175159
-- When --reorder-goals is set, we use preferReallyEasyGoalChoices, which
176160
-- prefers (keeps) goals only if the have 0 or 1 enabled choice.
177161
--

cabal-install/src/Distribution/Client/Dependency.hs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ import qualified Data.Map as Map
131131
import qualified Data.Set as Set
132132
import Control.Exception
133133
( assert )
134+
import qualified Control.Arrow as list
134135

135136

136137
-- ------------------------------------------------------------
@@ -395,24 +396,31 @@ dontUpgradeNonUpgradeablePackages params =
395396
(PackageConstraint (ScopeAnyQualifier pkgname) PackagePropertyInstalled)
396397
ConstraintSourceNonUpgradeablePackage
397398
| Set.notMember (mkPackageName "base") (depResolverTargets params)
398-
-- If you change this enumeration, make sure to update the list in
399-
-- "Distribution.Solver.Modular.Solver" as well
400-
, pkgname <- [ mkPackageName "base"
401-
, mkPackageName "ghc-bignum"
402-
, mkPackageName "ghc-prim"
403-
, mkPackageName "ghc-boot"
404-
, mkPackageName "ghc"
405-
, mkPackageName "ghci"
406-
, mkPackageName "integer-gmp"
407-
, mkPackageName "integer-simple"
408-
, mkPackageName "template-haskell"
409-
]
399+
, pkgname <- nonUpgradeablePackages
410400
, isInstalled pkgname ]
411401

412402
isInstalled = not . null
413403
. InstalledPackageIndex.lookupPackageName
414404
(depResolverInstalledPkgIndex params)
415405

406+
-- NOTE: the lists of non-upgradable and non-installable packages use to be
407+
-- respectively in this module and in `Distribution.Solver.Modular.Solver`.
408+
-- Since they were kept synced, they are now combined in the following list.
409+
--
410+
-- See: https://github.com/haskell/cabal/issues/8581
411+
nonUpgradeablePackages :: [PackageName]
412+
nonUpgradeablePackages =
413+
[ mkPackageName "base"
414+
, mkPackageName "ghc-bignum"
415+
, mkPackageName "ghc-prim"
416+
, mkPackageName "ghc-boot"
417+
, mkPackageName "ghc"
418+
, mkPackageName "ghci"
419+
, mkPackageName "integer-gmp"
420+
, mkPackageName "integer-simple"
421+
, mkPackageName "template-haskell"
422+
]
423+
416424
addSourcePackages :: [UnresolvedSourcePackage]
417425
-> DepResolverParams -> DepResolverParams
418426
addSourcePackages pkgs params =
@@ -469,7 +477,7 @@ removeBounds relKind relDeps params =
469477
}
470478
where
471479
sourcePkgIndex' :: PackageIndex.PackageIndex UnresolvedSourcePackage
472-
sourcePkgIndex' = fmap relaxDeps $ depResolverSourcePkgIndex params
480+
sourcePkgIndex' = relaxDeps <$> depResolverSourcePkgIndex params
473481

474482
relaxDeps :: UnresolvedSourcePackage -> UnresolvedSourcePackage
475483
relaxDeps srcPkg = srcPkg
@@ -710,7 +718,8 @@ resolveDependencies platform comp pkgConfigDB solver params =
710718
$ fmap (validateSolverResult platform comp indGoals)
711719
$ runSolver solver (SolverConfig reordGoals cntConflicts fineGrained minimize
712720
indGoals noReinstalls
713-
shadowing strFlags allowBootLibs onlyConstrained_ maxBkjumps enableBj
721+
shadowing strFlags allowBootLibs nonUpgradeablePackages
722+
onlyConstrained_ maxBkjumps enableBj
714723
solveExes order verbosity (PruneAfterFirstSuccess False))
715724
platform comp installedPkgIndex sourcePkgIndex
716725
pkgConfigDB preferences constraints targets

0 commit comments

Comments
 (0)