rescrv / libmacaroons

Macaroons are flexible authorization credentials that support decentralized delegation, attenuation, and verification.
BSD 3-Clause "New" or "Revised" License
491 stars 48 forks source link

No installation documentation + Linux installation problems #43

Closed rogpeppe closed 8 years ago

rogpeppe commented 8 years ago

There seems to be nothing in the repository that documents how to build the libmacaroons library.

I got as far as:

autoconf
./configure
make

At this point, we get this error:

make --no-print-directory all-am
  CC       base64.lo
  CC       macaroons.lo
macaroons.c:48:2: error: #error portability problem
 #error portability problem
  ^
make[1]: *** [macaroons.lo] Error 1
make: *** [all] Error 2

because libbsd (which doesn't exist on Linux) is required. It seems that this is to get the arc4random_buf function, which doesn't exist in Linux. How about using getrandom instead in Linux? ... except that getrandom doesn't appear to exist in Ubuntu 14.04 which I'm using. Perhaps the only decent solution is to open /dev/urandom directly.

If that include is deleted, we then get a bunch of errors like this:

port.c: In function 'macaroon_bin2hex':
port.c:130:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < bin_sz; ++i)
     ^
port.c:130:5: note: use option -std=c99 or -std=gnu99 to compile your code
make[1]: *** [port.lo] Error 1
make: *** [all] Error 2

because declaring variables inside for loops isn't pre-C99 standard C. Having fixed that, it finally compiles (but really it shouldn't because there's no definition of arc4random_buf available - if the declaration in port.c was removed, then at least the compile should fail correctly, but it doesn't because somehow the warnings for use of undeclared functions seem to be disabled).

rogpeppe commented 8 years ago

I tried to run autoconf under Mac OS X 14.1.0 and got errors about undefined macros (AM_INIT_AUTOMAKE, AM_PATH_PYTHON, AC_PYTHON_DEVEL and AM_CONDITIONAL)

As usual the whole autoconf system is almost impossible to debug.

I also tried to get a bit further with compiling under Ubuntu 14.04 by defining a getrandom function that read from /dev/urandom. I got a simple C program working OK, but then I was unable to build the bindings/python code. I get the following cython error:

% make distdir
  PYX      bindings/python/macaroons.c

Error compiling Cython file:
------------------------------------------------------------
...
        MACAROON_V1
        MACAROON_V2
        MACAROON_V2J
    cdef macaroon_format MACAROON_LATEST
    cdef macaroon_format MACAROON_LATEST_JSON
    size_t macaroon_serialize_size_hint(const macaroon* M, macaroon_format f);
                                                                            ^
------------------------------------------------------------

bindings/python/macaroons.pyx:81:77: Syntax error in C variable declaration
make: *** [bindings/python/macaroons.c] Error 1

Unfortunately I'm not familiar enough with cython to know what the problem is here.

rescrv commented 8 years ago

There are installation instructions in the README. I'll expand them to include more details. Since the last release, I added a dependency on libbsd. This is a bsd compatibility layer on Linux, and is not required on BSD. The portability error you encountered is because that library is not installed. I'll add instructions for this into the README.

I'll also lift the loop declarations to make it compile on 14.04. It compiled on newer GCC without issue, so perhaps they've set C99 as standard between the two? In any case, it should work on both, and I'll test it on 14.04.

The problems on OS X stem from not having Automake installed (AM_INIT_AUTOMAKE/AM_CONDITIONAL) and not having autoconf-archive installed (AC_PYTHON_DEVEL).

The Cython problem is likely the "const" literal on that line. Old versions of Cython don't like const.

One of the advantages of Autoconf (and the reason I use it) is that you can build a self-contained tarball that only relies on basic POSIX. I've taken the latest source and put it here: http://rescrv.net/libmacaroons-0.4.dev.tar.gz (it's a snapshot of 2aca74076d, and won't necessarily follow HEAD). This will allow you to skip autoconf if you'd prefer to avoid it. It also contains the C file generated by Cython and will skip invoking Cython unless you modify the PYX.

In short, my TODO is:

rescrv commented 8 years ago

Everything should now work as expected on Ubuntu 14.04. I didn't test other Ubuntu versions, but it does compile on a newer distro and 14.04, so I don't anticipate much trouble on other distributions.

iambibhas commented 6 years ago

@rescrv Hi, Is it possible to have an easier installation and distribution process? What is needed to push to ubuntu main repo or maintain a PPA on launchpad? Is there anything blocking the process?

iambibhas commented 6 years ago

For me, Linux Mint 18, based on ubuntu 16.04, make fails because I don't have cython installed, I think.

-> % make
make --no-print-directory all-am
  PYX      bindings/python/macaroons.c
/bin/bash: cython: command not found
Makefile:1434: recipe for target 'bindings/python/macaroons.c' failed
make[1]: *** [bindings/python/macaroons.c] Error 127
Makefile:592: recipe for target 'all' failed
make: *** [all] Error 2
rescrv commented 6 years ago

@iambibhas If you build a tarball with make distcheck on one machine, machines building from this tarball should not require cython. I explicitly don't include it in the configure.ac check as it is not needed by end-users.

Nothing blocks the process of creating a PPA, but nothing is driving it either. Packaging in compliance with any distribution has never been my strong suit, and most distributions prefer upstream vendors didn't try to take on the role of package maintainer too.

I'm happy to answer questions related to packaging if someone does pick it up.