Skip to content

Commit

Permalink
Distribution/Gentoo/GHC.hs: traverse /var/db/pkg only once to find gh…
Browse files Browse the repository at this point in the history
…c installs

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information
Sergei Trofimovich committed Dec 23, 2013
1 parent a0d385f commit a9c1e51
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Distribution/Gentoo/GHC.hs
Expand Up @@ -151,19 +151,19 @@ oldGhcPkgs v =
-- some crazy user hasn't deleted one of these dirs
-- libFronts' <- filterM doesDirectoryExist libFronts
pkgs <- liftM notGHC
$ concatMapM (checkLibDir v thisGhc') libFronts
$ checkLibDirs v thisGhc' libFronts
return pkgs

-- Find packages installed by other versions of GHC in this possible
-- library directory.
checkLibDir :: Verbosity -> BSFilePath -> BSFilePath -> IO [Package]
checkLibDir v thisGhc libDir =
do vsay v $ "checkLibDir ghc lib: " ++ show (thisGhc, libDir)
checkLibDirs :: Verbosity -> BSFilePath -> [BSFilePath] -> IO [Package]
checkLibDirs v thisGhc libDirs =
do vsay v $ "checkLibDir ghc libs: " ++ show (thisGhc, libDirs)
pkgsHaveContent (hasDirMatching wanted)
where
wanted dir = isValid dir && (not . isInvalid) dir

isValid = isGhcLibDir libDir
isValid dir = any (\ldir -> isGhcLibDir ldir dir) libDirs

-- Invalid if it's this GHC
isInvalid fp = fp == thisGhc || BS.isPrefixOf (thisGhc `BS.snoc` pathSeparator) fp
Expand Down

0 comments on commit a9c1e51

Please sign in to comment.