Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg-config uses a more general version scheme #163

Closed
bos opened this issue May 24, 2012 · 17 comments
Closed

pkg-config uses a more general version scheme #163

bos opened this issue May 24, 2012 · 17 comments

Comments

@bos
Copy link
Contributor

bos commented May 24, 2012

(Imported from Trac #170, reported by @dcoutts on 2007-11-05)

From HsOpenSSL.cabal

  --PkgConfig-Depends: openssl >= 0.9.7l
  -- We really should use this instead of the configure
  -- script but Cabal 1.2.2.0 can't handle the weird version
  -- scheme of OpenSSL.
For example:
$ pkg-config --modversion openssl
0.9.8f
Currently Cabal tries to map pkg-config versions to the standard Version type which only allows for a sequence of numbers.

pkg-config uses just strings to represent package versions. It uses code lifted from rpm to compare version strings. See the compare_versions function in pkg-gconfig-0.22/pkg.c from http://pkgconfig.freedesktop.org/releases/pkg-config-0.22.tar.gz

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by @dcoutts on 2007-11-05)

A possibly-better reference for the rpm version string comparison code:
rpmEVRcmp

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by guest on 2008-01-26)

I got

$ cabal install
Resolving dependencies...
Configuring alsa-core-0.5.0.1...
cabal: parsing output of pkg-config --modversion failed
cabal: Error: some packages failed to install:
alsa-core-0.5.0.1 failed during the configure step. The exception was:
ExitFailure 1
because
$ pkg-config --modversion alsa
1.0.14a
I remember that Cabal had functions for parsing version numbers with tags, would this help here?

Newer ALSA versions do not seem to have the version tag anymore.

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by guest on 2011-03-05)

How about using pkg-config's --atleast-version option? Then Cabal does not need to parse the version number at all.

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by @dcoutts on 2011-03-05)

We do need to parse the version because people can use arbitrarily complicated version constraints, not just ">= x.y". I think we just need to do it properly and have pkg-config versions use a different type internally than Version, and use different version comparison code.

@tibbe
Copy link
Member

tibbe commented May 5, 2014

Closing as there's been no activity in years.

We're cleaning up the bug tracker to make it useful again and are thus closing bugs that haven't seen any activity in a long time. Please re-open (or file a new bug) if the problem reappears.

@tibbe tibbe closed this as completed May 5, 2014
@mietek
Copy link
Contributor

mietek commented Jul 30, 2014

This is still an issue.

With pkgconfig-depends: openssl, Cabal fails as follows:

$ cabal build
Resolving dependencies...
Configuring foo-0.0.1...
cabal: parsing output of pkg-config --modversion failed

This is due to the openssl version number format:

$ pkg-config --modversion openssl
0.9.8y

@dcoutts dcoutts reopened this Jul 30, 2014
@ttuegel ttuegel added this to the _|_ milestone Apr 23, 2015
@BardurArantsson
Copy link
Collaborator

@mietek Do you have the ability and/or inclination to help with fixing this issue? If you're keen the Cabal developers are going to be very grateful for any manpower you can offer. Given how long this has gone unaddressed, I fear it'll go on being unresolved otherwise.

I propose this be closed -- if @mietek wants he can reopen. (But please only do so if you want to help address it or know somebody who can.)

@hvr
Copy link
Member

hvr commented Aug 17, 2015

@23Skidoo
For the record, pkg-config seems to use the same version comparison that rpm uses (or used at some point), see http://cgit.freedesktop.org/pkg-config/tree/rpmvercmp.c

@nomeata
Copy link
Contributor

nomeata commented Nov 3, 2015

I have been observing that when building bindings-sane on Debian. @mtolly, are you still planning to fix this?

@mtolly
Copy link
Contributor

mtolly commented Nov 10, 2015

My apologies, this has fallen off my radar for a while now. In #2730 you can see that it got a bit more complicated, and as far as I could tell, clear decisions weren't really reached regarding where the extra tags should be allowed, and whether they should be ignored or actually used for comparison (and, what comparison function should be used). In addition my own reason for needing the fix mostly went away. So, anyone else is certainly free to pick this back up.

@kenta2
Copy link

kenta2 commented Feb 10, 2017

Yet one more package that this bug affects is hlibBladeRF-0.1.0.6 which depends on libbladeRF. Ubuntu 14.04 provides
$ pkg-config --modversion libbladeRF
0.10.0-0.9.0.15.8ba2499

This one almost parses correctly as a tag; the only issue is that simpleParse in Cabal/Distribution/Text.hs assumes tags are Char.isAlphaNum, but the period is not alphanumeric.

@ezyang ezyang modified the milestones: Triaged, Mar 7, 2017
@ezyang
Copy link
Contributor

ezyang commented Mar 7, 2017

Perhaps, as a stopgap, we should just truncate the version string at the point where it stops looking like a normal version? This should be easy to implement, should be a very small change, and will get more packages compiling than before.

@idontgetoutmuch
Copy link
Member

This still seems to be a problem

[nix-shell:~/hmatrix/packages/gsl]$ cabal build
Resolving dependencies...
Configuring hmatrix-gsl-0.18.2.0...
cabal: parsing output of pkg-config --modversion failed

[nix-shell:~/hmatrix/packages/gsl]$ cabal --version
cabal-install version 2.0.0.1
compiled using version 2.0.1.1 of the Cabal library 

[nix-shell:~/hmatrix/packages/gsl]$ pkg-config --version
0.29.2

@23Skidoo
Copy link
Member

23Skidoo commented Mar 1, 2018

#5098 is related.

phadej added a commit that referenced this issue Mar 3, 2019
- #163
Also resolves #5138

Introduce PkgconfigVersion and PkgconfigVersionRange
- `PkgconfigVersion` is compared with `rpmvercmp`
- `PkgconfigVersionRange` is subset of `VersionRange`
    - with `cabal-version` before 3.0 it's parsed like `VersionRange`,
      where version digits are arbitrary integral (leading spaces
      allowed)
    - starting from cabal spec 3.0 `== x.y.*` and `^>=`
      (and set `{ ..  }`) are disallowed.
      Yet, the version literals syntax is relaxed to accept
      alphanumerical + `-.` strings. E.g. openssl's `1.1.0h` is
      accepted.

Lax `PkgconfigVersion` parser is also used to parse
`pkg-config --modversion` output.
phadej added a commit that referenced this issue Mar 3, 2019
- Don't accept leading zeros in Version or VersionRange
- Fixes #163
  (pkg-config uses a more general version scheme)
- Also resolves #5138
- `PkgconfigVersion` is compared with `rpmvercmp`
- `PkgconfigVersionRange` is subset of `VersionRange`
    - with `cabal-version` before 3.0 it's parsed like `VersionRange`,
      where version digits are arbitrary integral (leading spaces
      allowed)
    - starting from cabal spec 3.0 `== x.y.*` and `^>=`
      (and set `{ ..  }`) are disallowed.
      Yet, the version literals syntax is relaxed to accept
      alphanumerical + `-.` strings. E.g. openssl's `1.1.0h` is
      accepted.
- Lax `PkgconfigVersion` parser is also used to parse
  `pkg-config --modversion` output.
phadej added a commit that referenced this issue Mar 3, 2019
- Don't accept leading zeros in Version or VersionRange
- Fixes #163
  (pkg-config uses a more general version scheme)
- Also resolves #5138
- `PkgconfigVersion` is compared with `rpmvercmp`
- `PkgconfigVersionRange` is subset of `VersionRange`
    - with `cabal-version` before 3.0 it's parsed like `VersionRange`,
      where version digits are arbitrary integral (leading spaces
      allowed)
    - starting from cabal spec 3.0 `== x.y.*` and `^>=`
      (and set `{ ..  }`) are disallowed.
      Yet, the version literals syntax is relaxed to accept
      alphanumerical + `-.` strings. E.g. openssl's `1.1.0h` is
      accepted.
- Lax `PkgconfigVersion` parser is also used to parse
  `pkg-config --modversion` output.
phadej added a commit that referenced this issue Mar 3, 2019
- Don't accept leading zeros in Version or VersionRange
- Fixes #163
  (pkg-config uses a more general version scheme)
- Also resolves #5138
- `PkgconfigVersion` is compared with `rpmvercmp`
- `PkgconfigVersionRange` is subset of `VersionRange`
    - with `cabal-version` before 3.0 it's parsed like `VersionRange`,
      where version digits are arbitrary integral (leading spaces
      allowed)
    - starting from cabal spec 3.0 `== x.y.*` and `^>=`
      (and set `{ ..  }`) are disallowed.
      Yet, the version literals syntax is relaxed to accept
      alphanumerical + `-.` strings. E.g. openssl's `1.1.0h` is
      accepted.
- Lax `PkgconfigVersion` parser is also used to parse
  `pkg-config --modversion` output.
phadej added a commit that referenced this issue Mar 3, 2019
- Don't accept leading zeros in Version or VersionRange
- Fixes #163
  (pkg-config uses a more general version scheme)
- Also resolves #5138
- `PkgconfigVersion` is compared with `rpmvercmp`
- `PkgconfigVersionRange` is subset of `VersionRange`
    - with `cabal-version` before 3.0 it's parsed like `VersionRange`,
      where version digits are arbitrary integral (leading spaces
      allowed)
    - starting from cabal spec 3.0 `== x.y.*` and `^>=`
      (and set `{ ..  }`) are disallowed.
      Yet, the version literals syntax is relaxed to accept
      alphanumerical + `-.` strings. E.g. openssl's `1.1.0h` is
      accepted.
- Lax `PkgconfigVersion` parser is also used to parse
  `pkg-config --modversion` output.
@phadej phadej closed this as completed in 01df85e Mar 4, 2019
@phadej
Copy link
Collaborator

phadej commented Mar 4, 2019

@idontgetoutmuch , what does pkg-config --modversion gsl says on your machine?

@amigalemming
Copy link
Contributor

In Debian Buster the package libopenblas-dev has version 0.3.5+ds and Cabal fails to parse that:

$ pkg-config --modversion lapack
0.3.5+ds
$ pkg-config --modversion blas  
0.3.5+ds
$ sudo update-alternatives --config libblas.so-x86_64-linux-gnu
There are 2 choices for the alternative libblas.so-x86_64-linux-gnu (providing /usr/lib/x86_64-linux-gnu/libblas.so).

  Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/x86_64-linux-gnu/openblas/libblas.so   100       auto mode
  1            /usr/lib/x86_64-linux-gnu/blas/libblas.so       10        manual mode
  2            /usr/lib/x86_64-linux-gnu/openblas/libblas.so   100       manual mode

Press <enter> to keep the current choice[*], or type selection number: 

@idontgetoutmuch
Copy link
Member

@idontgetoutmuch , what does pkg-config --modversion gsl says on your machine?

pkg-config --modversion gsl
2.5

But this is very out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.