Alternative dependencies in Cabal file

Hi, for a package I need to ensure the user uses a certain package configuration. So how would I rewrite the following pseudo-cabal description? Build-Depends: packageA < X, packageB < Y or packageA >= X && < X', packageB >= Y && < Y' or packageA >= X', packageB >= Y' Build-Depends: ... common dependencies ... where neither A nor B is the base package. Maybe I have to use if/else blocks, but I don't know what conditions to use then. Regards, Matthias

Am Mittwoch 17 März 2010 12:11:53 schrieb Matthias Reisner:
Hi,
for a package I need to ensure the user uses a certain package configuration. So how would I rewrite the following pseudo-cabal description?
Build-Depends: packageA < X, packageB < Y or packageA >= X && < X', packageB >= Y && < Y' or packageA >= X', packageB >= Y'
Build-Depends: ... common dependencies ...
where neither A nor B is the base package. Maybe I have to use if/else blocks, but I don't know what conditions to use then.
Read http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html for a general description of what you can do, I'd try something like in http://hackage.haskell.org/packages/archive/cabal-install/0.8.0/cabal- install.cabal flag oldAB description: ancient packages A and B default: False flag newAB description: shiny new A and B Library blubb build-depends: common, libraries if flag(newAB) build-depends: packageA >= X', packageB >= Y' else if flag(oldAB) build-depends: packageA < X, packageB < Y else build-depends: packageA >= X && < X', packageB >= Y && < Y' If I remember correctly, that tries first to build against the new A and B, that failing, it sets flag newAB to false and tries again, first with the not-so-ancient A and B, hopefully (but I'm not sure about the order in which flags are toggled if the defaults don't give a successful install plan).
Regards,
Matthias

Thanks, I missed that the flags are set dynamically if a dependency cannot be satisfied. Am 17.03.2010 13:23 schrieb Daniel Fischer:
Am Mittwoch 17 März 2010 12:11:53 schrieb Matthias Reisner:
Hi,
for a package I need to ensure the user uses a certain package configuration. So how would I rewrite the following pseudo-cabal description?
Build-Depends: packageA < X, packageB < Y or packageA >= X && < X', packageB >= Y && < Y' or packageA >= X', packageB >= Y'
Build-Depends: ... common dependencies ...
where neither A nor B is the base package. Maybe I have to use if/else blocks, but I don't know what conditions to use then.
Read http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html for a general description of what you can do, I'd try something like in http://hackage.haskell.org/packages/archive/cabal-install/0.8.0/cabal- install.cabal
flag oldAB description: ancient packages A and B default: False
flag newAB description: shiny new A and B
Library blubb build-depends: common, libraries if flag(newAB) build-depends: packageA >= X', packageB >= Y' else if flag(oldAB) build-depends: packageA < X, packageB < Y else build-depends: packageA >= X && < X', packageB >= Y && < Y'
If I remember correctly, that tries first to build against the new A and B, that failing, it sets flag newAB to false and tries again, first with the not-so-ancient A and B, hopefully (but I'm not sure about the order in which flags are toggled if the defaults don't give a successful install plan).
Regards,
Matthias

On Fri, 2010-03-19 at 00:34 +0100, Henning Thielemann wrote:
Matthias Reisner schrieb:
Thanks, I missed that the flags are set dynamically if a dependency cannot be satisfied. Only cabal-install does this, plain Cabal only takes flags that were set by the user.
No, plain Cabal does it too. You're thinking of the fact that only cabal-install does automatic package dependency resolution. Both do automatic flag resolution. Duncan
participants (4)
-
Daniel Fischer
-
Duncan Coutts
-
Henning Thielemann
-
Matthias Reisner