gentoo-haskell / hackport

A command line tool to generate Gentoo ebuilds from Hackage packages.
GNU General Public License v3.0
55 stars 21 forks source link

Fix ebuild output in the presence of `||` in `build-depends` #127

Open hololeap opened 1 year ago

hololeap commented 1 year ago

Currently, hackport is generating invalid ebuilds in the presence of || in the .cabal file's dependency constraints.


Here is an example with aeson-extra-0.5.1.1:

hololeap commented 1 year ago

This only affects dependency atoms using the = operator slot, which are only output to RDEPEND (library dependencies but not test-suite dependencies in the .cabal file).

A trick is to list the version constraints and slot operator separately:

diff --git a/dev-haskell/aeson-extra/aeson-extra-0.5.1.1.ebuild b/dev-haskell/aeson-extra/aeson-extra-0.5.1.1.ebuild
index 141caa6146..65b9474275 100644
--- a/dev-haskell/aeson-extra/aeson-extra-0.5.1.1.ebuild
+++ b/dev-haskell/aeson-extra/aeson-extra-0.5.1.1.ebuild
@@ -26,8 +26,9 @@ RDEPEND=">=dev-haskell/attoparsec-0.11.3.4:=[profile?] <dev-haskell/attoparsec-0
        >=dev-haskell/unordered-containers-0.2:=[profile?] <dev-haskell/unordered-containers-0.3:=[profile?]
        >=dev-haskell/vector-0.10:=[profile?] <dev-haskell/vector-0.14:=[profile?]
        >=dev-lang/ghc-8.4.3:=
-       || ( ( >=dev-haskell/aeson-1.5.4.1:=[profile?] <dev-haskell/aeson-1.6:=[profile?] )
-               ( >=dev-haskell/aeson-2.0:=[profile?] <dev-haskell/aeson-2.2:=[profile?] ) )
+       || ( ( >=dev-haskell/aeson-1.5.4.1[profile?] <dev-haskell/aeson-1.6[profile?] )
+               ( >=dev-haskell/aeson-2.0[profile?] <dev-haskell/aeson-2.2[profile?] ) )
+       dev-haskell/aeson:=
 "
 DEPEND="${RDEPEND}
        >=dev-haskell/cabal-2.2.0.1

Writing it like this retains the wanted semantics and does not trigger the error.

hololeap commented 1 year ago

Duplicate of https://github.com/gentoo-haskell/hackport/issues/58