Skip to content

Commit

Permalink
Merge pull request #9520 from haskell/mergify/bp/3.10/pr-9391
Browse files Browse the repository at this point in the history
cabal-install-solver: fix pkgconf 1.9 --modversion regression (backport #9391)
  • Loading branch information
mergify[bot] authored Dec 15, 2023
2 parents 83ecb5c + c21eef4 commit 204948f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,22 @@ readPkgConfigDb verbosity progdb = handle ioErrorHandler $ do
-- The output of @pkg-config --list-all@ also includes a description
-- for each package, which we do not need.
let pkgNames = map (takeWhile (not . isSpace)) pkgList
(pkgVersions, _errs, exitCode) <-
(outs, _errs, exitCode) <-
getProgramInvocationOutputAndErrors verbosity
(programInvocation pkgConfig ("--modversion" : pkgNames))
case exitCode of
ExitSuccess -> (return . pkgConfigDbFromList . zip pkgNames) (lines pkgVersions)
-- if there's a single broken pc file the above fails, so we fall back into calling it individually
_ -> do
info verbosity ("call to pkg-config --modversion on all packages failed. Falling back to querying pkg-config individually on each package")
pkgConfigDbFromList . catMaybes <$> mapM (getIndividualVersion pkgConfig) pkgNames
let pkgVersions = lines outs
if exitCode == ExitSuccess && length pkgVersions == length pkgNames
then (return . pkgConfigDbFromList . zip pkgNames) pkgVersions
else
-- if there's a single broken pc file the above fails, so we fall back
-- into calling it individually
--
-- Also some implementations of @pkg-config@ do not provide more than
-- one package version, so if the returned list is shorter than the
-- requested one, we fall back to querying one by one.
do
info verbosity ("call to pkg-config --modversion on all packages failed. Falling back to querying pkg-config individually on each package")
pkgConfigDbFromList . catMaybes <$> mapM (getIndividualVersion pkgConfig) pkgNames
where
-- For when pkg-config invocation fails (possibly because of a
-- too long command line).
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/pr-9391
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
synopsis: fix pkgconfig-depends for pkgconf-1.9
packages: cabal-install-solver
prs: #9391
issues: #8923

0 comments on commit 204948f

Please sign in to comment.