Commit e869d803 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

InstallPlan util to replace a ready package with an installed one

There are two cases in which we replace source packages with ones that
are already installed: during planning when we improve the plan by
replacing configured source packages with pre-existing packages from the
store, but also there's just the case of skipping over a local package
that is already built and up to date. In the latter case we're replacing
a package in the Configured state not with one in the PreExisting state,
but with one in the Installed state, as if it had been built and
installed (which in a sense of course it has).

This new util is for the latter case.
parent 150c3189
......@@ -30,6 +30,7 @@ module Distribution.Client.InstallPlan (
failed,
remove,
preexisting,
preinstalled,
showPlanIndex,
showInstallPlan,
......@@ -519,6 +520,24 @@ preexisting pkgid ipkg plan = assert (invariant plan') plan'
$ planIndex plan
}
-- | Replace a ready package with an installed one. The installed one
-- must have exactly the same dependencies as the source one was configured
-- with.
--
preinstalled :: (HasUnitId ipkg, PackageFixedDeps ipkg,
HasUnitId srcpkg, PackageFixedDeps srcpkg)
=> UnitId
-> Maybe ipkg -> iresult
-> GenericInstallPlan ipkg srcpkg iresult ifailure
-> GenericInstallPlan ipkg srcpkg iresult ifailure
preinstalled pkgid mipkg buildResult plan = assert (invariant plan') plan'
where
plan' = plan { planIndex = PackageIndex.insert installed (planIndex plan) }
Just installed = do
Configured pkg <- PackageIndex.lookupUnitId (planIndex plan) pkgid
rpkg <- lookupReadyPackage plan pkg
return (Installed rpkg mipkg buildResult)
-- | Transform an install plan by mapping a function over all the packages in
-- the plan. It can consistently change the 'UnitId' of all the packages,
-- while preserving the same overall graph structure.
......
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