- reportElim (p, deps) =
- debugTraceMsg dflags 2 $
- (ptext (sLit "package") <+> pprPkg p <+>
- ptext (sLit "will be ignored due to missing or recursive dependencies:") $$
- nest 2 (hsep (map (text.display) deps)))
+-- -----------------------------------------------------------------------------
+-- Eliminate shadowed packages, giving the user some feedback
+
+-- later packages in the list should shadow earlier ones with the same
+-- package name/version.
+shadowPackages :: [PackageConfig] -> UnusablePackages
+shadowPackages pkgs
+ = let (_,shadowed) = foldl check (emptyUFM,[]) pkgs
+ in listToFM shadowed
+ where
+ check (pkgmap,shadowed) pkg
+ = (addToUFM pkgmap (packageConfigId pkg) pkg, shadowed')
+ where
+ shadowed'
+ | Just oldpkg <- lookupUFM pkgmap (packageConfigId pkg)
+ = (installedPackageId oldpkg, ShadowedBy (installedPackageId pkg))
+ :shadowed
+ | otherwise
+ = shadowed
+
+-- -----------------------------------------------------------------------------
+
+ignorePackages :: [PackageFlag] -> [PackageConfig] -> UnusablePackages
+ignorePackages flags pkgs = listToFM (concatMap doit flags)
+ where
+ doit (IgnorePackage str) =
+ case partition (matchingStr str) pkgs of
+ (ps, _) -> [ (installedPackageId p, IgnoredWithFlag)
+ | p <- ps ]
+ -- missing package is not an error for -ignore-package,
+ -- because a common usage is to -ignore-package P as
+ -- a preventative measure just in case P exists.
+ doit _ = panic "ignorePackages"