Subject: bug#25138: failing hackage import

From: Federico Beffa <[email-masked]>
Date: Fri, 9 Dec 2016 23:09:36 +0100

On Fri, Dec 9, 2016 at 9:57 PM, Ludovic Courtès <[email-masked]> wrote:
> I’m seeing a different error:
>
> --8<---------------cut here---------------start------------->8---
> $ git describe
> v0.11.0-3322-gf80b4d2
> $ ./pre-inst-env guix import hackage -t darcs
> Syntax error: unexpected token : (buildable (False)) (at line 494, column 4)
> Syntax error: unexpected end of input
> guix import: error: failed to download cabal file for package 'darcs'
> --8<---------------cut here---------------end--------------->8---
>
> The .cabal file is at
> <https://hackage.haskell.org/package/darcs/darcs.cabal> and the faulty
> line comes from:
>
> --8<---------------cut here---------------start------------->8---
> Executable          darcs
>   if !flag(executable)
>     buildable: False
>   else
>     buildable: True
> --8<---------------cut here---------------end--------------->8---
>
> In addition, this .cabal file has “Build-Type: Custom”, which is
> currently not supported as noted in <https://bugs.gnu.org/23961>.
>
> Federico, WDYT?

The problem is that the name of the flag is 'executable' and the
string 'executable' is also a reserved keyword to define the start of
a cabal file section.  The cabal parser incorrectly dismissed this
keyword as a possible flag name (in the code it is referred to as a
test identifier).  See line 369 of the file 'guix/import/cabal.scm'.
The predicate 'is-id' should be smarter and recognize if the string
'executable' refers to the start of an 'executable section' or not
(and similarly for some other reserved keywords dismissed by the same
procedure).

The predicate 'is-id' dismisses some specific reserved keywords such
as 'executable' because this check is performed before the ones (based
on full lines) such as 'is-exec' which checks for the start of an
executable section.

HTH,
Fede