berberman / arch-hs

Distribute hackage packages to archlinux
MIT License
19 stars 4 forks source link

Support flags in arch-hs-diff #12

Closed felixonmars closed 4 years ago

felixonmars commented 4 years ago

It would be nice to support flags as arch-hs, so I can specify -fwarp-tests for the following example:

$ arch-hs-diff HTTP 4000.3.14 4000.3.15
  ⓘ Start running...
  ⓘ Downloading cabal file from https://hackage.haskell.org/package/HTTP-4000.3.14/revision/0.cabal...
  ⓘ Downloading cabal file from https://hackage.haskell.org/package/HTTP-4000.3.15/revision/0.cabal...
Package: HTTP
Version: 4000.3.14  ⇒  4000.3.15
Synopsis: A library for client-side HTTP
URL: https://github.com/haskell/HTTP
Depends:
    base  >=4.3.0.0 && <4.14
    time  >=1.1.2.3 && <1.10
    Win32  >=2.2.0.0 && <2.9
    array  >=0.3.0.2 && <0.6
    bytestring  >=0.9.1.5 && <0.11
    parsec  >=2.0 && <3.2
----------------------------
    base  >=4.3.0.0 && <4.15
    time  >=1.1.2.3 && <1.11
    Win32  >=2.2.0.0 && <2.10
    array  >=0.3.0.2 && <0.6
    bytestring  >=0.9.1.5 && <0.11
    parsec  >=2.0 && <3.2
MakeDepends:
    deepseq  >=1.3.0.0 && <1.5
    HUnit  >=1.2.0.1 && <1.7
    httpd-shed  >=0.4 && <0.5
    mtl  >=1.1.1.0 && <2.3
    pureMD5  >=0.2.4 && <2.2
    split  >=0.1.3 && <0.3
    test-framework  >=0.2.0 && <0.9
    test-framework-hunit  >=0.3.0 && <0.4

  ✔ Success!

Expected result: warp etc listed in makedepends.

It would also be handy if flag changes (new flag, removed flag, etc) are shown if exist.

felixonmars commented 4 years ago

There seems to be some edge cases in combination of flags & conditional dependencies:

$ arch-hs-diff -f HTTP:warp-tests:true HTTP 4000.3.14 4000.3.15
  ⓘ You assigned flags:
HTTP
    ⚐ warp-tests : True

...
Depends:
    base  >=4.3.0.0 && <4.14
    time  >=1.1.2.3 && <1.10
    array  >=0.3.0.2 && <0.6
    bytestring  >=0.9.1.5 && <0.11
    parsec  >=2.0 && <3.2
--------------------------------------
    base  >=4.3.0.0 && <4.15
    time  >=1.1.2.3 && <1.11
    array  >=0.3.0.2 && <0.6
    bytestring  >=0.9.1.5 && <0.11
    parsec  >=2.0 && <3.2
MakeDepends:
    case-insensitive  >=0.4.0.1 && <1.3
    deepseq  >=1.3.0.0 && <1.5
    HUnit  >=1.2.0.1 && <1.7
    httpd-shed  >=0.4 && <0.5
    http-types  >=0.8.0 && <1.0
    mtl  >=1.1.1.0 && <2.3
    pureMD5  >=0.2.4 && <2.2
    split  >=0.1.3 && <0.3
    test-framework  >=0.2.0 && <0.9
    test-framework-hunit  >=0.3.0 && <0.4
    wai  >=2.1.0 && <3.3
    warp  >=2.1.0 && <3.3

The .cabal file, however, has the following conditional dependencies:

  if flag(network-uri)
    Build-depends: network-uri == 2.6.*, network >= 2.6 && < 3.2
  else
    Build-depends: network >= 2.3 && < 2.6

  if flag(warp-tests)
    CPP-Options: -DWARP_TESTS
    build-depends:
                       case-insensitive >= 0.4.0.1 && < 1.3,
                       http-types >= 0.8.0 && < 1.0,
                       wai >= 2.1.0 && < 3.3,
                       warp >= 2.1.0 && < 3.3

    if flag(conduit10)
      build-depends:
                         conduit >= 1.0.8 && < 1.1
    else
      build-depends:
                         conduit >= 1.1 && < 1.4,
                         conduit-extra >= 1.1 && < 1.4

So with network-uri being true by default and warp-tests being true by manually specified, network, network-uri and conduit, conduit-extra were missing from MakeDepends.

berberman commented 4 years ago

It seems that flags will be droped (i.e., all branches of the condition tree are discarded) if they didn't be specified, even if those have default values.

berberman commented 4 years ago

Closed because this feature has been implemented.