Commit fbadad3b authored by tibbe's avatar tibbe
Browse files

Merge branch 'do-not-freeze-non-required-installed-packages' of https://github.com/benarmston/cabal

parents 99d912d3 883a1f65
......@@ -33,10 +33,11 @@ import Distribution.Client.Sandbox.Types
( SandboxPackageInfo(..) )
import Distribution.Package
( packageId, packageName, packageVersion )
( PackageIdentifier, packageId, packageName, packageVersion )
import Distribution.Simple.Compiler
( Compiler(compilerId), PackageDBStack )
import Distribution.Simple.PackageIndex (PackageIndex)
import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Simple.Program
( ProgramConfiguration )
import Distribution.Simple.Setup
......@@ -132,7 +133,9 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
solver
resolverParams
return $ InstallPlan.toList installPlan
return $ either id
(error "planPackages: installPlan contains broken packages")
(pruneInstallPlan installPlan pkgSpecifiers)
where
resolverParams =
......@@ -157,6 +160,25 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
shadowPkgs = fromFlag (freezeShadowPkgs freezeFlags)
maxBackjumps = fromFlag (freezeMaxBackjumps freezeFlags)
-- | Remove all unneeded packages from an install plan.
--
-- A package is unneeded if it is not a dependency (directly or
-- transitively) of any of the 'PackageSpecifier SourcePackage's. This is
-- useful for removing previously installed packages which are no longer
-- required from the install plan.
pruneInstallPlan :: InstallPlan.InstallPlan
-> [PackageSpecifier SourcePackage]
-> Either [PlanPackage] [(PlanPackage, [PackageIdentifier])]
pruneInstallPlan installPlan pkgSpecifiers =
mapLeft PackageIndex.allPackages $ PackageIndex.dependencyClosure pkgIdx pkgIds
where
pkgIdx = PackageIndex.fromList $ InstallPlan.toList installPlan
pkgIds = [ packageId pkg | SpecificSourcePackage pkg <- pkgSpecifiers ]
mapLeft f (Left v) = Left $ f v
mapLeft _ (Right v) = Right v
freezePackages :: Verbosity -> [PlanPackage] -> IO ()
freezePackages verbosity pkgs = do
pkgEnv <- fmap (createPkgEnv . addConstraints) $ loadUserConfig verbosity ""
......
Markdown is supported
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