Skip to content

Commit 84b22e1

Browse files
juhpmergify[bot]
authored andcommitted
cabal-install-solver: fix pkgconf 1.9 --modversion regression
Check that the numbers of *versions* output is equal to the number of pkgconf's fixes #8923 The pkgconf behavior was reverted upstream in 2.0 (this should cover the case too of checking that equal pkgList lines are output also) (cherry picked from commit 3832bea) # Conflicts: # cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs
1 parent 3f51173 commit 84b22e1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,31 @@ readPkgConfigDb verbosity progdb = handle ioErrorHandler $ do
6767
-- The output of @pkg-config --list-all@ also includes a description
6868
-- for each package, which we do not need.
6969
let pkgNames = map (takeWhile (not . isSpace)) pkgList
70-
(pkgVersions, _errs, exitCode) <-
70+
(outs, _errs, exitCode) <-
7171
getProgramInvocationOutputAndErrors verbosity
7272
(programInvocation pkgConfig ("--modversion" : pkgNames))
73+
<<<<<<< HEAD
7374
case exitCode of
7475
ExitSuccess -> (return . pkgConfigDbFromList . zip pkgNames) (lines pkgVersions)
7576
-- if there's a single broken pc file the above fails, so we fall back into calling it individually
7677
_ -> do
7778
info verbosity ("call to pkg-config --modversion on all packages failed. Falling back to querying pkg-config individually on each package")
7879
pkgConfigDbFromList . catMaybes <$> mapM (getIndividualVersion pkgConfig) pkgNames
80+
=======
81+
let pkgVersions = lines outs
82+
if exitCode == ExitSuccess && length pkgVersions == length pkgNames
83+
then (return . pkgConfigDbFromList . zip pkgNames) pkgVersions
84+
else
85+
-- if there's a single broken pc file the above fails, so we fall back
86+
-- into calling it individually
87+
--
88+
-- Also some implementations of @pkg-config@ do not provide more than
89+
-- one package version, so if the returned list is shorter than the
90+
-- requested one, we fall back to querying one by one.
91+
do
92+
info verbosity ("call to pkg-config --modversion on all packages failed. Falling back to querying pkg-config individually on each package")
93+
pkgConfigDbFromList . catMaybes <$> mapM (getIndividualVersion pkgConfig) pkgNames
94+
>>>>>>> 3832beaf5 (cabal-install-solver: fix pkgconf 1.9 --modversion regression)
7995
where
8096
-- For when pkg-config invocation fails (possibly because of a
8197
-- too long command line).

changelog.d/pr-9391

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
synopsis: fix pkgconfig-depends for pkgconf-1.9
2+
packages: cabal-install-solver
3+
prs: #9391
4+
issues: #8923

0 commit comments

Comments
 (0)