@@ -108,10 +108,10 @@ ghcPkg menv pkgDbs args = do
108108getPackageVersionMapWithGlobalDb
109109 :: (MonadCatch m , MonadIO m , MonadThrow m , MonadLogger m )
110110 => EnvOverride
111- -> MiniBuildPlan
111+ -> Maybe MiniBuildPlan
112112 -> [Path Abs Dir ] -- ^ package databases
113113 -> m (Map PackageName Version )
114- getPackageVersionMapWithGlobalDb menv mbp pkgDbs = do
114+ getPackageVersionMapWithGlobalDb menv mmbp pkgDbs = do
115115 gdb <- getGlobalDB menv
116116 -- Use unionsWith max to account for cases where the snapshot introduces a
117117 -- newer version of a global package, see:
@@ -124,17 +124,32 @@ getPackageVersionMapWithGlobalDb menv mbp pkgDbs = do
124124 (M. unionsWith max .
125125 map (M. fromList . rights))
126126 globals <-
127- foldM
128- (\ acc ident ->
129- if versionMatches mbp ident
130- then do
131- hasProfiling <- packageHasProfiling [gdb] ident
132- if hasProfiling
133- then return acc
134- else return (expunge ident acc)
135- else return (expunge ident acc))
136- allGlobals
137- (map fromTuple (M. toList allGlobals))
127+ case mmbp of
128+ Nothing ->
129+ return allGlobals
130+ Just mbp ->
131+ foldM
132+ (\ acc ident ->
133+ let expunge ident acc =
134+ foldr
135+ M. delete
136+ acc
137+ (map
138+ packageIdentifierName
139+ (ident :
140+ getTransInclusiveDeps mbp ident))
141+ in if versionMatches mbp ident
142+ then do
143+ hasProfiling <-
144+ packageHasProfiling
145+ [gdb]
146+ ident
147+ if hasProfiling
148+ then return acc
149+ else return (expunge ident acc)
150+ else return (expunge ident acc))
151+ allGlobals
152+ (map fromTuple (M. toList allGlobals))
138153 rest <-
139154 getPackageVersions
140155 menv
@@ -146,12 +161,6 @@ getPackageVersionMapWithGlobalDb menv mbp pkgDbs = do
146161 (M. unionsWith
147162 max
148163 [globals, rest])
149- where
150- expunge ident acc = do
151- foldr
152- M. delete
153- acc
154- (map packageIdentifierName (ident : getTransInclusiveDeps mbp ident))
155164
156165-- | Get the packages depended on by the given package.
157166versionMatches :: MiniBuildPlan -> PackageIdentifier -> Bool
0 commit comments