Skip to content
Snippets Groups Projects
Commit 5eb39f4e authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

When parsing ghc-pkg output, only look at the first package.conf file for...

When parsing ghc-pkg output, only look at the first package.conf file for GlobalPackageDB and SpecificPackageDB, and all package.conf files for UserPackageDB.
Before, we would consider user packages when fulfilling dependencies
for global installs. ghc-pkg will refuse to install packages globally if they
use user packages. Thus, without this patch, global installs can fail when you have user packages installed.
parent 9aaf8e2a
No related merge requests found
......@@ -226,8 +226,9 @@ getInstalledPackages verbosity packagedb conf = do
--TODO: use --simple-output flag for easier parsing
str <- rawSystemProgramStdoutConf verbosity ghcPkgProgram conf
[packageDbGhcPkgFlag packagedb, "list"]
let keep_line s = ':' `notElem` s && not ("Creating" `isPrefixOf` s)
str1 = unlines (filter keep_line (lines str))
let str1 = case packagedb of
UserPackageDB -> allFiles str
_ -> firstFile str
str2 = filter (`notElem` ",(){}") str1
--
case pCheck (readP_to_S (many (skipSpaces >> parsePackageId)) str2) of
......@@ -241,6 +242,13 @@ getInstalledPackages verbosity packagedb conf = do
pCheck :: [(a, [Char])] -> [a]
pCheck rs = [ r | (r,s) <- rs, all isSpace s ]
allFiles str = unlines $ filter keep_line $ lines str
where keep_line s = ':' `notElem` s && not ("Creating" `isPrefixOf` s)
firstFile str = unlines $ takeWhile (not . file_line) $
drop 1 $ dropWhile (not . file_line) $ lines str
where file_line s = ':' `elem` s && not ("Creating" `isPrefixOf` s)
-- -----------------------------------------------------------------------------
-- Building
......
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