Skip to content

Commit b016e59

Browse files
wismillulysses4evermergify[bot]
authored
Combine non-installable & non-upgradable packages (#8712)
* Combine non-installable & non-upgradable packages * Typo Co-authored-by: Artem Pelenitsyn <[email protected]> * Remove requireInstalled * Revert "Remove requireInstalled" This reverts commit adfce24. * Comment only [skip ci] --------- Co-authored-by: Artem Pelenitsyn <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 8ec30a0 commit b016e59

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-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: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,24 +395,31 @@ dontUpgradeNonUpgradeablePackages params =
395395
(PackageConstraint (ScopeAnyQualifier pkgname) PackagePropertyInstalled)
396396
ConstraintSourceNonUpgradeablePackage
397397
| 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-
]
398+
, pkgname <- nonUpgradeablePackages
410399
, isInstalled pkgname ]
411400

412401
isInstalled = not . null
413402
. InstalledPackageIndex.lookupPackageName
414403
(depResolverInstalledPkgIndex params)
415404

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

474481
relaxDeps :: UnresolvedSourcePackage -> UnresolvedSourcePackage
475482
relaxDeps srcPkg = srcPkg
@@ -710,7 +717,11 @@ resolveDependencies platform comp pkgConfigDB solver params =
710717
$ fmap (validateSolverResult platform comp indGoals)
711718
$ runSolver solver (SolverConfig reordGoals cntConflicts fineGrained minimize
712719
indGoals noReinstalls
713-
shadowing strFlags allowBootLibs onlyConstrained_ maxBkjumps enableBj
720+
shadowing strFlags allowBootLibs
721+
-- See comment of nonUpgradeablePackages about
722+
-- non-installable and non-upgradable packages.
723+
nonUpgradeablePackages
724+
onlyConstrained_ maxBkjumps enableBj
714725
solveExes order verbosity (PruneAfterFirstSuccess False))
715726
platform comp installedPkgIndex sourcePkgIndex
716727
pkgConfigDB preferences constraints targets

0 commit comments

Comments
 (0)