Commit 26051e59 authored by Duncan Coutts's avatar Duncan Coutts

Change the terminology used in source code for available/source packages

Rather than 'available' packages, the source now refers consistently to
'source' packages. This is a bit clearer.
parent b6922aef
......@@ -116,11 +116,11 @@ fromPlanPackage :: Platform -> CompilerId
-> Maybe (BuildReport, Repo)
fromPlanPackage (Platform arch os) comp planPackage = case planPackage of
InstallPlan.Installed pkg@(ConfiguredPackage (AvailablePackage {
InstallPlan.Installed pkg@(ConfiguredPackage (SourcePackage {
packageSource = RepoTarballPackage repo _ _ }) _ _) result
-> Just $ (BuildReport.new os arch comp pkg (Right result), repo)
InstallPlan.Failed pkg@(ConfiguredPackage (AvailablePackage {
InstallPlan.Failed pkg@(ConfiguredPackage (SourcePackage {
packageSource = RepoTarballPackage repo _ _ }) _ _) result
-> Just $ (BuildReport.new os arch comp pkg (Left result), repo)
......
......@@ -18,10 +18,10 @@ import Distribution.Client.Dependency
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan (InstallPlan)
import Distribution.Client.IndexUtils as IndexUtils
( getAvailablePackages, getInstalledPackages )
( getSourcePackages, getInstalledPackages )
import Distribution.Client.Setup
( ConfigExFlags(..), configureCommand, filterConfigureFlags )
import Distribution.Client.Types as Available
import Distribution.Client.Types as Source
import Distribution.Client.SetupWrapper
( setupWrapper, SetupScriptOptions(..), defaultSetupScriptOptions )
......@@ -64,11 +64,11 @@ configure :: Verbosity
configure verbosity packageDBs repos comp conf
configFlags configExFlags extraArgs = do
installed <- getInstalledPackages verbosity comp packageDBs conf
available <- getAvailablePackages verbosity repos
installedPkgIndex <- getInstalledPackages verbosity comp packageDBs conf
sourcePkgDb <- getSourcePackages verbosity repos
progress <- planLocalPackage verbosity comp configFlags configExFlags
installed available
installedPkgIndex sourcePkgDb
notice verbosity "Resolving dependencies..."
maybePlan <- foldProgress logMsg (return . Left) (return . Right)
......@@ -76,15 +76,15 @@ configure verbosity packageDBs repos comp conf
case maybePlan of
Left message -> do
info verbosity message
setupWrapper verbosity (setupScriptOptions installed) Nothing
setupWrapper verbosity (setupScriptOptions installedPkgIndex) Nothing
configureCommand (const configFlags) extraArgs
Right installPlan -> case InstallPlan.ready installPlan of
[pkg@(ConfiguredPackage (AvailablePackage _ _ (LocalUnpackedPackage _)) _ _)] ->
[pkg@(ConfiguredPackage (SourcePackage _ _ (LocalUnpackedPackage _)) _ _)] ->
configurePackage verbosity
(InstallPlan.planPlatform installPlan)
(InstallPlan.planCompiler installPlan)
(setupScriptOptions installed)
(setupScriptOptions installedPkgIndex)
configFlags pkg extraArgs
_ -> die $ "internal error: configure install plan should have exactly "
......@@ -120,17 +120,17 @@ configure verbosity packageDBs repos comp conf
planLocalPackage :: Verbosity -> Compiler
-> ConfigFlags -> ConfigExFlags
-> PackageIndex InstalledPackage
-> AvailablePackageDb
-> SourcePackageDb
-> IO (Progress String String InstallPlan)
planLocalPackage verbosity comp configFlags configExFlags installed
(AvailablePackageDb _ availablePrefs) = do
planLocalPackage verbosity comp configFlags configExFlags installedPkgIndex
(SourcePackageDb _ packagePrefs) = do
pkg <- readPackageDescription verbosity =<< defaultPackageDesc verbosity
let -- We create a local package and ask to resolve a dependency on it
localPkg = AvailablePackage {
packageInfoId = packageId pkg,
Available.packageDescription = pkg,
packageSource = LocalUnpackedPackage "."
localPkg = SourcePackage {
packageInfoId = packageId pkg,
Source.packageDescription = pkg,
packageSource = LocalUnpackedPackage "."
}
resolverParams =
......@@ -151,14 +151,14 @@ planLocalPackage verbosity comp configFlags configExFlags installed
(configConfigurationsFlags configFlags) ]
$ standardInstallPolicy
installed
(AvailablePackageDb mempty availablePrefs)
installedPkgIndex
(SourcePackageDb mempty packagePrefs)
[SpecificSourcePackage localPkg]
return (resolveDependencies buildPlatform (compilerId comp) resolverParams)
-- | Call an installer for an 'AvailablePackage' but override the configure
-- | Call an installer for an 'SourcePackage' but override the configure
-- flags with the ones given by the 'ConfiguredPackage'. In particular the
-- 'ConfiguredPackage' specifies an exact 'FlagAssignment' and exactly
-- versioned package dependencies. So we ignore any previous partial flag
......@@ -172,7 +172,7 @@ configurePackage :: Verbosity
-> [String]
-> IO ()
configurePackage verbosity platform comp scriptOptions configFlags
(ConfiguredPackage (AvailablePackage _ gpkg _) flags deps) extraArgs =
(ConfiguredPackage (SourcePackage _ gpkg _) flags deps) extraArgs =
setupWrapper verbosity
scriptOptions (Just pkg) configureCommand configureFlags extraArgs
......
......@@ -42,7 +42,7 @@ module Distribution.Client.Dependency (
addConstraints,
addPreferences,
setPreferenceDefault,
addAvailablePackages,
addSourcePackages,
hideInstalledPackagesSpecific,
hideInstalledPackagesAllVersions,
) where
......@@ -53,8 +53,8 @@ import Distribution.Client.PackageIndex (PackageIndex)
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan (InstallPlan)
import Distribution.Client.Types
( AvailablePackageDb(AvailablePackageDb)
, AvailablePackage(..), InstalledPackage )
( SourcePackageDb(SourcePackageDb)
, SourcePackage(..), InstalledPackage )
import Distribution.Client.Dependency.Types
( DependencyResolver, PackageConstraint(..)
, PackagePreferences(..), InstalledPreference(..)
......@@ -93,8 +93,8 @@ data DepResolverParams = DepResolverParams {
depResolverConstraints :: [PackageConstraint],
depResolverPreferences :: [PackagePreference],
depResolverPreferenceDefault :: PackagesPreferenceDefault,
depResolverInstalled :: PackageIndex InstalledPackage,
depResolverAvailable :: PackageIndex AvailablePackage
depResolverInstalledPkgIndex :: PackageIndex InstalledPackage,
depResolverSourcePkgIndex :: PackageIndex SourcePackage
}
......@@ -112,7 +112,7 @@ data PackagesPreferenceDefault =
-- | Always prefer the installed versions over ones that would need to be
-- installed. Secondarily, prefer latest versions (eg the latest installed
-- version or if there are none then the latest available version).
-- version or if there are none then the latest source version).
| PreferAllInstalled
-- | Prefer the latest version for packages that are explicitly requested
......@@ -138,16 +138,16 @@ data PackagePreference =
| PackageInstalledPreference PackageName InstalledPreference
basicDepResolverParams :: PackageIndex InstalledPackage
-> PackageIndex AvailablePackage
-> PackageIndex SourcePackage
-> DepResolverParams
basicDepResolverParams installed available =
basicDepResolverParams installedPkgIndex sourcePkgIndex =
DepResolverParams {
depResolverTargets = [],
depResolverConstraints = [],
depResolverPreferences = [],
depResolverPreferenceDefault = PreferLatestForSelected,
depResolverInstalled = installed,
depResolverAvailable = available
depResolverInstalledPkgIndex = installedPkgIndex,
depResolverSourcePkgIndex = sourcePkgIndex
}
addTargets :: [PackageName]
......@@ -193,14 +193,16 @@ dontUpgradeBasePackage params =
-- below when there are no targets and thus no dep on base.
-- Need to refactor contraints separate from needing packages.
isInstalled = not . null
. PackageIndex.lookupPackageName (depResolverInstalled params)
. PackageIndex.lookupPackageName
(depResolverInstalledPkgIndex params)
addAvailablePackages :: [AvailablePackage]
-> DepResolverParams -> DepResolverParams
addAvailablePackages pkgs params =
addSourcePackages :: [SourcePackage]
-> DepResolverParams -> DepResolverParams
addSourcePackages pkgs params =
params {
depResolverAvailable = foldl (flip PackageIndex.insert)
(depResolverAvailable params) pkgs
depResolverSourcePkgIndex =
foldl (flip PackageIndex.insert)
(depResolverSourcePkgIndex params) pkgs
}
hideInstalledPackagesSpecific :: [PackageId]
......@@ -208,8 +210,9 @@ hideInstalledPackagesSpecific :: [PackageId]
hideInstalledPackagesSpecific pkgids params =
--TODO: this should work using exclude constraints instead
params {
depResolverInstalled = foldl' (flip PackageIndex.deletePackageId)
(depResolverInstalled params) pkgids
depResolverInstalledPkgIndex =
foldl' (flip PackageIndex.deletePackageId)
(depResolverInstalledPkgIndex params) pkgids
}
hideInstalledPackagesAllVersions :: [PackageName]
......@@ -217,9 +220,9 @@ hideInstalledPackagesAllVersions :: [PackageName]
hideInstalledPackagesAllVersions pkgnames params =
--TODO: this should work using exclude constraints instead
params {
depResolverInstalled =
depResolverInstalledPkgIndex =
foldl' (flip PackageIndex.deletePackageName)
(depResolverInstalled params) pkgnames
(depResolverInstalledPkgIndex params) pkgnames
}
......@@ -228,10 +231,11 @@ hideBrokenInstalledPackages params =
hideInstalledPackagesSpecific pkgids params
where
pkgids = map packageId
. PackageIndex.reverseDependencyClosure (depResolverInstalled params)
. PackageIndex.reverseDependencyClosure
(depResolverInstalledPkgIndex params)
. map (packageId . fst)
. PackageIndex.brokenPackages
$ depResolverInstalled params
$ depResolverInstalledPkgIndex params
upgradeDependencies :: DepResolverParams -> DepResolverParams
......@@ -244,15 +248,16 @@ reinstallTargets params =
standardInstallPolicy :: PackageIndex InstalledPackage
-> AvailablePackageDb
-> [PackageSpecifier AvailablePackage]
-> SourcePackageDb
-> [PackageSpecifier SourcePackage]
-> DepResolverParams
standardInstallPolicy
installed (AvailablePackageDb available availablePrefs) pkgSpecifiers
installedPkgIndex (SourcePackageDb sourcePkgIndex sourcePkgPrefs)
pkgSpecifiers
= addPreferences
[ PackageVersionPreference name ver
| (name, ver) <- Map.toList availablePrefs ]
| (name, ver) <- Map.toList sourcePkgPrefs ]
. addConstraints
(concatMap pkgSpecifierConstraints pkgSpecifiers)
......@@ -263,11 +268,11 @@ standardInstallPolicy
. hideInstalledPackagesSpecific
[ packageId pkg | SpecificSourcePackage pkg <- pkgSpecifiers ]
. addAvailablePackages
. addSourcePackages
[ pkg | SpecificSourcePackage pkg <- pkgSpecifiers ]
$ basicDepResolverParams
installed available
installedPkgIndex sourcePkgIndex
-- ------------------------------------------------------------
......@@ -296,15 +301,16 @@ resolveDependencies platform comp params
resolveDependencies platform comp params =
fmap (mkInstallPlan platform comp)
$ defaultResolver platform comp installed available
$ defaultResolver platform comp installedPkgIndex sourcePkgIndex
preferences constraints targets
where
DepResolverParams
targets constraints
prefs defpref
installed available = dontUpgradeBasePackage
. hideBrokenInstalledPackages
$ params
installedPkgIndex
sourcePkgIndex = dontUpgradeBasePackage
. hideBrokenInstalledPackages
$ params
preferences = interpretPackagesPreference
(Set.fromList targets) defpref prefs
......@@ -316,8 +322,8 @@ resolveDependencies platform comp params =
mkInstallPlan :: Platform
-> CompilerId
-> [InstallPlan.PlanPackage] -> InstallPlan
mkInstallPlan platform comp pkgs =
case InstallPlan.new platform comp (PackageIndex.fromList pkgs) of
mkInstallPlan platform comp pkgIndex =
case InstallPlan.new platform comp (PackageIndex.fromList pkgIndex) of
Right plan -> plan
Left problems -> error $ unlines $
"internal error: could not construct a valid install plan."
......@@ -375,12 +381,12 @@ interpretPackagesPreference selected defaultPref prefs =
-- It simply means preferences for installed packages will be ignored.
--
resolveWithoutDependencies :: DepResolverParams
-> Either [ResolveNoDepsError] [AvailablePackage]
-> Either [ResolveNoDepsError] [SourcePackage]
resolveWithoutDependencies (DepResolverParams targets constraints
prefs defpref installed available) =
prefs defpref installedPkgIndex sourcePkgIndex) =
collectEithers (map selectPackage targets)
where
selectPackage :: PackageName -> Either ResolveNoDepsError AvailablePackage
selectPackage :: PackageName -> Either ResolveNoDepsError SourcePackage
selectPackage pkgname
| null choices = Left $! ResolveUnsatisfiable pkgname requiredVersions
| otherwise = Right $! maximumBy bestByPrefs choices
......@@ -389,7 +395,8 @@ resolveWithoutDependencies (DepResolverParams targets constraints
-- Constraints
requiredVersions = packageConstraints pkgname
pkgDependency = Dependency pkgname requiredVersions
choices = PackageIndex.lookupDependency available pkgDependency
choices = PackageIndex.lookupDependency sourcePkgIndex
pkgDependency
-- Preferences
PackagePreferences preferredVersions preferInstalled
......@@ -399,7 +406,8 @@ resolveWithoutDependencies (DepResolverParams targets constraints
(installPref pkg, versionPref pkg, packageVersion pkg)
installPref = case preferInstalled of
PreferLatest -> const False
PreferInstalled -> isJust . PackageIndex.lookupPackageId installed
PreferInstalled -> isJust . PackageIndex.lookupPackageId
installedPkgIndex
. packageId
versionPref pkg = packageVersion pkg `withinRange` preferredVersions
......
......@@ -22,7 +22,7 @@ import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan
( PlanPackage(..) )
import Distribution.Client.Types
( AvailablePackage(..), ConfiguredPackage(..), InstalledPackage(..) )
( SourcePackage(..), ConfiguredPackage(..), InstalledPackage(..) )
import Distribution.Client.Dependency.Types
( DependencyResolver, PackageConstraint(..)
, PackagePreferences(..), InstalledPreference(..)
......@@ -105,9 +105,9 @@ explore pref (ChoiceNode _ choices) =
(_, node') = maximumBy (bestByPref pkgname) choice
where
topSortNumber choice = case fst (head choice) of
InstalledOnly (InstalledPackageEx _ i _) -> i
AvailableOnly (UnconfiguredPackage _ i _) -> i
InstalledAndAvailable _ (UnconfiguredPackage _ i _) -> i
InstalledOnly (InstalledPackageEx _ i _) -> i
SourceOnly (UnconfiguredPackage _ i _) -> i
InstalledAndSource _ (UnconfiguredPackage _ i _) -> i
bestByPref pkgname = case packageInstalledPreference of
PreferLatest ->
......@@ -115,8 +115,8 @@ explore pref (ChoiceNode _ choices) =
PreferInstalled ->
comparing (\(p,_) -> (isInstalled p, isPreferred p, packageId p))
where
isInstalled (AvailableOnly _) = False
isInstalled _ = True
isInstalled (SourceOnly _) = False
isInstalled _ = True
isPreferred p = packageVersion p `withinRange` preferredVersions
(PackagePreferences preferredVersions packageInstalledPreference)
= pref pkgname
......@@ -181,11 +181,11 @@ searchSpace configure constraints selected changes next =
packageConstraints :: SelectedPackage -> [TaggedDependency]
packageConstraints = either installedConstraints availableConstraints
. preferAvailable
. preferSource
where
preferAvailable (InstalledOnly pkg) = Left pkg
preferAvailable (AvailableOnly pkg) = Right pkg
preferAvailable (InstalledAndAvailable _ pkg) = Right pkg
preferSource (InstalledOnly pkg) = Left pkg
preferSource (SourceOnly pkg) = Right pkg
preferSource (InstalledAndSource _ pkg) = Right pkg
installedConstraints (InstalledPackageEx _ _ deps) =
[ TaggedDependency InstalledConstraint (thisPackageVersion dep)
| dep <- deps ]
......@@ -235,12 +235,12 @@ topDownResolver = ((((((mapMessages .).).).).).) . topDownResolver'
--
topDownResolver' :: Platform -> CompilerId
-> PackageIndex InstalledPackage
-> PackageIndex AvailablePackage
-> PackageIndex SourcePackage
-> (PackageName -> PackagePreferences)
-> [PackageConstraint]
-> [PackageName]
-> Progress Log Failure [PlanPackage]
topDownResolver' platform comp installed available
topDownResolver' platform comp installedPkgIndex sourcePkgIndex
preferences constraints targets =
fmap (uncurry finalise)
. (\cs -> search configure preferences cs initialPkgNames)
......@@ -250,17 +250,17 @@ topDownResolver' platform comp installed available
configure = configurePackage platform comp
constraintSet :: Constraints
constraintSet = Constraints.empty
(annotateInstalledPackages topSortNumber installed')
(annotateAvailablePackages constraints topSortNumber available')
(installed', available') = selectNeededSubset installed available
initialPkgNames
topSortNumber = topologicalSortNumbering installed' available'
(annotateInstalledPackages topSortNumber installedPkgIndex')
(annotateSourcePackages constraints topSortNumber sourcePkgIndex')
(installedPkgIndex', sourcePkgIndex') =
selectNeededSubset installedPkgIndex sourcePkgIndex initialPkgNames
topSortNumber = topologicalSortNumbering installedPkgIndex' sourcePkgIndex'
initialPkgNames = Set.fromList targets
finalise selected' constraints' =
PackageIndex.allPackages
. fst . improvePlan installed' constraints'
. fst . improvePlan installedPkgIndex' constraints'
. PackageIndex.fromList
$ finaliseSelectedPackages preferences selected' constraints'
......@@ -293,12 +293,12 @@ addTopLevelConstraints (PackageInstalledConstraint pkg:deps) cs =
configurePackage :: Platform -> CompilerId -> ConfigurePackage
configurePackage platform comp available spkg = case spkg of
InstalledOnly ipkg -> Right (InstalledOnly ipkg)
AvailableOnly apkg -> fmap AvailableOnly (configure apkg)
InstalledAndAvailable ipkg apkg -> fmap (InstalledAndAvailable ipkg)
(configure apkg)
InstalledOnly ipkg -> Right (InstalledOnly ipkg)
SourceOnly apkg -> fmap SourceOnly (configure apkg)
InstalledAndSource ipkg apkg -> fmap (InstalledAndSource ipkg)
(configure apkg)
where
configure (UnconfiguredPackage apkg@(AvailablePackage _ p _) _ flags) =
configure (UnconfiguredPackage apkg@(SourcePackage _ p _) _ flags) =
case finalizePackageDescription flags dependencySatisfiable
platform comp [] p of
Left missing -> Left missing
......@@ -326,14 +326,15 @@ annotateInstalledPackages dfsNumber installed = PackageIndex.fromList
-- | Annotate each available packages with its topological sort number and any
-- user-supplied partial flag assignment.
--
annotateAvailablePackages :: [PackageConstraint]
-> (PackageName -> TopologicalSortNumber)
-> PackageIndex AvailablePackage
-> PackageIndex UnconfiguredPackage
annotateAvailablePackages constraints dfsNumber available = PackageIndex.fromList
[ UnconfiguredPackage pkg (dfsNumber name) (flagsFor name)
| pkg <- PackageIndex.allPackages available
, let name = packageName pkg ]
annotateSourcePackages :: [PackageConstraint]
-> (PackageName -> TopologicalSortNumber)
-> PackageIndex SourcePackage
-> PackageIndex UnconfiguredPackage
annotateSourcePackages constraints dfsNumber sourcePkgIndex =
PackageIndex.fromList
[ UnconfiguredPackage pkg (dfsNumber name) (flagsFor name)
| pkg <- PackageIndex.allPackages sourcePkgIndex
, let name = packageName pkg ]
where
flagsFor = fromMaybe [] . flip Map.lookup flagsMap
flagsMap = Map.fromList
......@@ -352,7 +353,7 @@ annotateAvailablePackages constraints dfsNumber available = PackageIndex.fromLis
-- one possible choice for B in which case we pick that immediately).
--
-- To construct these topological sort numbers we combine and flatten the
-- installed and available package sets. We consider only dependencies between
-- installed and source package sets. We consider only dependencies between
-- named packages, not including versions and for not-yet-configured packages
-- we look at all the possible dependencies, not just those under any single
-- flag assignment. This means we can actually get impossible combinations of
......@@ -360,9 +361,9 @@ annotateAvailablePackages constraints dfsNumber available = PackageIndex.fromLis
-- heuristic.
--
topologicalSortNumbering :: PackageIndex InstalledPackage
-> PackageIndex AvailablePackage
-> PackageIndex SourcePackage
-> (PackageName -> TopologicalSortNumber)
topologicalSortNumbering installed available =
topologicalSortNumbering installedPkgIndex sourcePkgIndex =
\pkgname -> let Just vertex = toVertex pkgname
in topologicalSortNumbers Array.! vertex
where
......@@ -370,14 +371,14 @@ topologicalSortNumbering installed available =
(zip (Graph.topSort graph) [0..])
(graph, _, toVertex) = Graph.graphFromEdges $
[ ((), packageName pkg, nub deps)
| pkgs@(pkg:_) <- PackageIndex.allPackagesByName installed
| pkgs@(pkg:_) <- PackageIndex.allPackagesByName installedPkgIndex
, let deps = [ packageName dep
| pkg' <- pkgs
, dep <- depends pkg' ] ]
++ [ ((), packageName pkg, nub deps)
| pkgs@(pkg:_) <- PackageIndex.allPackagesByName available
| pkgs@(pkg:_) <- PackageIndex.allPackagesByName sourcePkgIndex
, let deps = [ depName
| AvailablePackage _ pkg' _ <- pkgs
| SourcePackage _ pkg' _ <- pkgs
, Dependency depName _ <-
buildDepends (flattenPackageDescription pkg') ] ]
......@@ -387,24 +388,24 @@ topologicalSortNumbering installed available =
-- and looking at the names of all possible dependencies.
--
selectNeededSubset :: PackageIndex InstalledPackage
-> PackageIndex AvailablePackage
-> PackageIndex SourcePackage
-> Set PackageName
-> (PackageIndex InstalledPackage
,PackageIndex AvailablePackage)
selectNeededSubset installed available = select mempty mempty
,PackageIndex SourcePackage)
selectNeededSubset installedPkgIndex sourcePkgIndex = select mempty mempty
where
select :: PackageIndex InstalledPackage
-> PackageIndex AvailablePackage
-> PackageIndex SourcePackage
-> Set PackageName
-> (PackageIndex InstalledPackage
,PackageIndex AvailablePackage)
select installed' available' remaining
| Set.null remaining = (installed', available')
| otherwise = select installed'' available'' remaining''
,PackageIndex SourcePackage)
select installedPkgIndex' sourcePkgIndex' remaining
| Set.null remaining = (installedPkgIndex', sourcePkgIndex')
| otherwise = select installedPkgIndex'' sourcePkgIndex'' remaining''
where
(next, remaining') = Set.deleteFindMin remaining
moreInstalled = PackageIndex.lookupPackageName installed next
moreAvailable = PackageIndex.lookupPackageName available next
moreInstalled = PackageIndex.lookupPackageName installedPkgIndex next
moreSource = PackageIndex.lookupPackageName sourcePkgIndex next
moreRemaining = -- we filter out packages already included in the indexes
-- this avoids an infinite loop if a package depends on itself
-- like base-3.0.3.0 with base-4.0.0.0
......@@ -413,14 +414,18 @@ selectNeededSubset installed available = select mempty mempty
| pkg <- moreInstalled
, dep <- depends pkg ]
++ [ name
| AvailablePackage _ pkg _ <- moreAvailable
| SourcePackage _ pkg _ <- moreSource
, Dependency name _ <-
buildDepends (flattenPackageDescription pkg) ]
installed'' = foldl' (flip PackageIndex.insert) installed' moreInstalled
available'' = foldl' (flip PackageIndex.insert) available' moreAvailable
remaining'' = foldl' (flip Set.insert) remaining' moreRemaining
notAlreadyIncluded name = null (PackageIndex.lookupPackageName installed' name)
&& null (PackageIndex.lookupPackageName available' name)
installedPkgIndex'' = foldl' (flip PackageIndex.insert)
installedPkgIndex' moreInstalled
sourcePkgIndex'' = foldl' (flip PackageIndex.insert)
sourcePkgIndex' moreSource
remaining'' = foldl' (flip Set.insert)
remaining' moreRemaining
notAlreadyIncluded name =
null (PackageIndex.lookupPackageName installedPkgIndex' name)
&& null (PackageIndex.lookupPackageName sourcePkgIndex' name)
-- ------------------------------------------------------------
-- * Post processing the solution
......@@ -434,17 +439,17 @@ finaliseSelectedPackages pref selected constraints =
map finaliseSelected (PackageIndex.allPackages selected)
where
remainingChoices = Constraints.choices constraints
finaliseSelected (InstalledOnly ipkg ) = finaliseInstalled ipkg
finaliseSelected (AvailableOnly apkg) = finaliseAvailable Nothing apkg
finaliseSelected (InstalledAndAvailable ipkg apkg) =
finaliseSelected (InstalledOnly ipkg ) = finaliseInstalled ipkg
finaliseSelected (SourceOnly apkg) = finaliseSource Nothing apkg
finaliseSelected (InstalledAndSource ipkg apkg) =
case PackageIndex.lookupPackageId remainingChoices (packageId ipkg) of
Nothing -> impossible --picked package not in constraints
Just (AvailableOnly _) -> impossible --to constrain to avail only
Just (InstalledOnly _) -> finaliseInstalled ipkg
Just (InstalledAndAvailable _ _) -> finaliseAvailable (Just ipkg) apkg
Just (SourceOnly _) -> impossible --to constrain to avail only
Just (InstalledOnly _) -> finaliseInstalled ipkg
Just (InstalledAndSource _ _) -> finaliseSource (Just ipkg) apkg
finaliseInstalled (InstalledPackageEx pkg _ _) = InstallPlan.PreExisting pkg
finaliseAvailable mipkg (SemiConfiguredPackage pkg flags deps) =
finaliseSource mipkg (SemiConfiguredPackage pkg flags deps) =
InstallPlan.Configured (ConfiguredPackage pkg flags deps')
where
deps' = map (packageId . pickRemaining mipkg) deps
......@@ -689,9 +694,9 @@ showLog (Select selected discarded) = case (selectedMsg, discardedMsg) of
: [ display (packageVersion s') ++ " " ++ kind s'
| s' <- ss ]
kind (InstalledOnly _) = "(installed)"
kind (AvailableOnly _) = "(hackage)"
kind (InstalledAndAvailable _ _) = "(installed or hackage)"
kind (InstalledOnly _) = "(installed)"
kind (SourceOnly _) = "(source)"
kind (InstalledAndSource _ _) = "(installed or source)"
discardedMsg = case discarded of