Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building GNATCOLL in an Alpine Linux Docker Container

I can't seem to get GNATCOLL to compile in an Alpine Linux based Docker Container.

My container so far is:

FROM alpine:edge

# Add extra repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories; \
    echo 'http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories; \
    echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories;

RUN apk add --no-cache build-base coreutils curl-dev gcc-gnat git gmp-dev openssl

# Bootstrap GPRBuild
RUN git clone https://github.com/AdaCore/xmlada.git; \
    git clone https://github.com/AdaCore/gprbuild.git; \
    cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada; \
    cd ..; \
    rm -rf xmlada gprbuild

This works fine and gets me a container with a working GNAT GPR based Ada development environment. The issue comes when I try to install GNATCOLL in this container.

Running docker run -i -t <built_image> the following occurs:

/ # git clone https://github.com/AdaCore/gnatcoll-core.git
<Typical git clone output>
/ # cd gnatcoll-core/
/gnatcoll-core # make setup
/gnatcoll-core # make
gprbuild -p -m --target=x86_64-linux  -j0 -XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD  -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static \
        -XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD gnatcoll.gpr
Setup
   [mkdir]        object directory for project GnatColl
   [mkdir]        library directory for project GnatColl
gnatcoll.gpr:24:06: unknown project file: "gpr"
make: *** [Makefile:128: build-static] Error 4

Based on the discussion in https://github.com/AdaCore/gnatcoll-core/issues/30 I checked my gprbuild version:

/gnatcoll-core # gprbuild --version
GPRBUILD Pro 18.0w (19940713) (x86_64-alpine-linux-musl)
Copyright (C) 2004-2016, AdaCore
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

So it would seem that gprbuild for musl is woefully out of date, leading to an inability to build GNATCOLL. Is there any way to get a more up-to-date version of gprbuild for musl-c? If not is there any other way to get GNATCOLL installed?

like image 333
LambdaBeta Avatar asked Apr 09 '19 15:04

LambdaBeta


People also ask

Is Alpine Linux good for Docker?

Alpine Linux is a super lightweight Linux distribution that's useful for Docker containers.

Why is Alpine Linux used for Docker?

Alpine Linux is a Linux distribution built around musl libc and BusyBox. The image is only 5 MB in size and has access to a package repository that is much more complete than other BusyBox based images. This makes Alpine Linux a great image base for utilities and even production applications.

How do I find the alpine version in a container?

You should be able to run the command alpine -v or alpine -version ... you can also start Alpine and press ? on the main menu to open the main Help page, which will also tell you the version.


1 Answers

The issue is that ./bootstrap.sh in gprbuild doesn't install everything, it just creates a bare minimum gprbuild installation. Additionally it does not build gprlib, which is necessary for gnatcoll and also has to be installed.

The required steps are:

# As before...
git clone https://github.com/AdaCore/xmlada.git
git clone https://github.com/AdaCore/gprbuild.git
cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada

# New: build and install xmlada
cd ../xmlada; ./configure && make && make install

# New: build and install gprbuild fully
cd ../gprbuild
export GPR_PROJECT_PATH=/usr/local/share/gpr
make prefix=/usr/local setup && make all && make install

# New: build and install gprlib
make libgpr.build && make libgpr.install

With these additions I was able to build gnatcoll as specified in its project.

like image 130
LambdaBeta Avatar answered Sep 28 '22 02:09

LambdaBeta