kersing / packet_forwarder

Multi protocol packet forwarder supporting the TTN gateway-connector protocol.
Other
85 stars 56 forks source link

qsort_r in jitqueue.c can be changed to qsort_s for Alpine? #17

Open sbiermann opened 6 years ago

sbiermann commented 6 years ago

Hi, as reported here: https://github.com/jpmeijers/ttn-resin-gateway-rpi/issues/10, i can not build a alpine docker image in case of qsort_r is not implemented in Alpine Linux. It seems that is the last point which needs to be changed for building an Alpine docker image. Is it possible to change it to a supported qsort in Alpine (qsort_s for example)? Kind regards Stefan

kersing commented 6 years ago

Not without breaking the build for other systems.

Can you share your build files/changes?

sbiermann commented 6 years ago

My experience with c is limited, so my simple though was to add a ifdefine alpine than use qsort_s and everything else uses qsort_r. But i'm not sure if it will be working.

Yes, i can, you can find my latest changes under: https://github.com/sbiermann/ttn-resin-gateway-rpi

There are some modifications on the Dockerfile.template and one line in the build.sh script (https://github.com/sbiermann/ttn-resin-gateway-rpi/blob/master/dev/build.sh#L65)

docker -f Dockerfile.template build . runs since compiling the mp_packet_forwarder classes.

kersing commented 6 years ago

Qsort_s and qsort_r do not use the same arguments so code modifications will be required. I will investigate if it can be done without too much effort when I have some spare time. (Will not be for a couple of weeks)

kersing commented 6 years ago

@sbiermann I don't know what you do differently, however when I try to build for RPi2 on resin I'm not even getting to the compile stage, installing the build packages fails:

[main]  Step 3/14 : RUN apk update &&     apk add wget build-base linux-headers libc6-compat git pkgconfig protobuf protobuf-dev automake libtool autoconf python-dev py-rpigpio
[main]   ---> Running in 44bd6b24a8bc
[main]  fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/aarch64/APKINDEX.tar.gz
[main]  fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/aarch64/APKINDEX.tar.gz
[main]  v3.7.0-119-gc6946cd412 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
[main]  v3.7.0-117-g9584b2309e [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
[main]  OK: 8863 distinct packages available
[main]    py-rpigpio (missing):
[main]  ERROR: unsatisfiable constraints:
[main]  
[main]      required by: world[py-rpigpio]

BTW, it would be nice if your cloned repo allowed posting issues, then I would be able to log this against that repo as it is not really an issue for this one.

sbiermann commented 6 years ago

The main problem seems to be that resin.io uses a cross compiler in there cloud environment for build arm images on a x64 machines. It fetches aarch64 package list and it seems that there is no py-rpigpio, which makes sense because RPi is running on a arm cpu and not a on a x64.

I build it directly on a RPi3 (it builds faster than my iC880a gateway PiZeroW) without resin.io. It is a pure Raspbian Jessie with Docker installed via curl -sSL https://get.docker.com | sh.

pi@raspberrypi ~/ttn-resin-gateway-rpi $ docker build -f Dockerfile.template . Sending build context to Docker daemon 3.542MB Step 1/14 : FROM alpine:3.7 AS buildstep ---> 889c6315e8d7 Removing intermediate container 614e0a846c89 Step 2/14 : WORKDIR /opt/ttn-gateway/ ---> e86232e6985e Removing intermediate container 946370333c77 Step 3/14 : RUN apk update && apk add wget build-base linux-headers libc6-compat git pkgconfig protobuf protobuf-dev automake libtool autoconf python-dev py-rpigpio ---> Running in 99148043814c fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/armhf/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/armhf/APKINDEX.tar.gz v3.7.0-120-g883b5fe496 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main] v3.7.0-117-g9584b2309e [http://dl-cdn.alpinelinux.org/alpine/v3.7/community] OK: 8873 distinct packages available (1/50) Upgrading musl (1.1.18-r2 -> 1.1.18-r3) ... (46/50) Installing sqlite-libs (3.21.0-r0) (47/50) Installing python2 (2.7.14-r2) (48/50) Installing py-rpigpio (0.6.2-r1) (49/50) Installing python2-dev (2.7.14-r2) (50/50) Installing wget (1.19.2-r1) Executing busybox-1.27.2-r6.trigger Executing ca-certificates-20171114-r0.trigger OK: 231 MiB in 59 packages

Issues are now activated, i'm not sure why it was disabled by default.