Skip to content
Snippets Groups Projects
Commit 3e13931e authored by Duncan Coutts's avatar Duncan Coutts Committed by Mikhail Glushenkov
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.

(cherry picked from commit e869d803)
parent 9d91e201
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ module Distribution.Client.InstallPlan (
failed,
remove,
preexisting,
preinstalled,
showPlanIndex,
showInstallPlan,
......@@ -520,6 +521,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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment