lopter / lightsd

A daemon with a JSON-RPC API to control your light bulbs
GNU General Public License v3.0
129 stars 15 forks source link

Building lightsd on FreeBSD fails - missing endian.h #14

Closed etenim closed 7 years ago

etenim commented 8 years ago

lightsd version 1.1.2 CMake version 3.5.0 libevent2 version 2.0.22

The problem is that it isn't finding endian.h and running "cmake -DCMAKE_BUILD_TYPE=RELEASE .." fails due to that. "Could not find Endian (missing: ENDIAN_H_PATH)"

From what I can gather by a little research is that Linux and other systems use #include endian.h while it seems FreeBSD and possibly other BSD's use #include sys/endian.h

Creating a directory lightsd/compat/FreeBSD and putting endian.h from FreeBSD's system in there is a workaround that seems to work. However, running make to build lightsd fails with multiple errors. I don't know if that is because of my tinkering with endian.h or if it would fail anyway with a proper fix to that issue.

lopter commented 8 years ago

Hello @etenim !

That's good to know, instead of copying the file; what I'll probably end-up doing is ship compat/FreeBSD/endian.h:

#pragma once

#include <sys/endian.h>

What compilation errors did you get?

etenim commented 8 years ago

@lopter Thank you for accepting this bug and adding it in your to-do list. :-)

I'm attaching the output here, peruse at your leisure: building_lightsd.txt

lopter commented 8 years ago

Thanks, looks like lightsd is just missing some includes. I might have already fixed this in 1.2.0 with the network discovery rework patch.

I'll try to setup Open/FreeBSD buildbot slaves down the road and really add them as a supported target, but it's a pita to setup all of that and therefore fairly low priority.

etenim commented 8 years ago

Great! Dare I ask, any idea as to whether 1.2.0 is to be soon or unknown?

This is really a great project. :-)

lopter commented 8 years ago

As soon as possible really, the code has been ready since early January.

What's holding me back is automating large parts of the development and release process since it will greatly lower the bar for future developments and to on-board contributors. Unfortunately, setting up all of that takes a lot of time and free time has been a very scarce resource for me lately, but I'm being hopeful for April/May!

Thanks 🙇.

kraduk commented 8 years ago

Yes it gets past the cmake part but the issue is with the compile. It does look like a missing include or something as there are lots of undefined references. This is the same before and after applying the network patch. This is on FreeBSD 10-Stable (built 22/03/2016) so ~ 10.3

git apply --stat ../network_discovery.patch

CMakeLists.txt | 4 core/lightsd.h | 16 + lifx/broadcast.c | 99 ++++- lifx/bulb.c | 6 lifx/tagging.h | 2 tests/core/mock_event2.h | 18 + tests/core/tests_utils.c | 36 ++ tests/core/tests_utils.h | 8 tests/lifx/broadcast/CMakeLists.txt | 21 + tests/lifx/broadcast/test_broadcast_send_packet.c | 146 ++++++++ .../lifx/broadcast/test_broadcast_write_callback.c | 368 ++++++++++++++++++++ ...est_broadcast_write_callback_getifaddrs_fails.c | 222 ++++++++++++ tests/lifx/mock_bulb.h | 138 ++++++++ tests/lifx/mock_tagging.h | 55 +++ tests/lifx/wire_proto/CMakeLists.txt | 4 15 files changed, 1108 insertions(+), 35 deletions(-)

make

-- lightsd version: 1.1.2 -- CMake version: 3.5.2 -- Build type: RELEASE -- Target system: FreeBSD 10.3-PRERELEASE amd64 -- Install prefix: /usr/local -- Source directory: /usr/home/krad/lightsd -- Could NOT find Sphinx (missing: SPHINX_EXECUTABLE) -- lightsd runtime directory: /usr/home/krad/lightsd/build -- Configuring done -- Generating done -- Build files have been written to: /usr/home/krad/lightsd/build [ 0%] Built target time_monotonic

[ 0%] Building C object lifx/CMakeFiles/lifx.dir/broadcast.c.o /usr/home/krad/lightsd/lifx/broadcast.c:60:23: error: use of undeclared identifier 'INADDR_BROADCAST' .sin_addr = { INADDR_BROADCAST }, ^ /usr/home/krad/lightsd/lifx/broadcast.c:58:24: error: variable has incomplete type 'struct sockaddr_in' struct sockaddr_in lifx_addr = { ^ /usr/home/krad/lightsd/lifx/broadcast.c:58:12: note: forward declaration of 'struct sockaddr_in' struct sockaddr_in lifx_addr = { ^ /usr/home/krad/lightsd/lifx/broadcast.c:154:30: error: use of undeclared identifier 'IPPROTO_UDP' AF_INET, SOCK_DGRAM, IPPROTO_UDP ^ /usr/home/krad/lightsd/lifx/broadcast.c:185:23: error: use of undeclared identifier 'INADDR_ANY' .sin_addr = { INADDR_ANY }, ^ /usr/home/krad/lightsd/lifx/broadcast.c:183:24: error: variable has incomplete type 'struct sockaddr_in' struct sockaddr_in lifx_addr = { ^ /usr/home/krad/lightsd/lifx/broadcast.c:183:12: note: forward declaration of 'struct sockaddr_in' struct sockaddr_in lifx_addr = { ^

lopter commented 8 years ago

@kraduk thanks for giving this a try, there is indeed a couple more issues there!

I got a VM running and I'll have a patch ready as soon as I figure out the proper way to expose all those symbols hidden behind __XSI_VISIBLE ifdefs. Looks like I'll really have to run a FreeBSD buildbot slave given how pedantic FreeBSD is.

lopter commented 8 years ago

@kraduk, @etenim,

I have updated lopter/lightsd-mq with fix_freebsd_build.patch; feel free to give it a try!

I see you're using other patches from my patch queue, so don't forget to get updated versions of those patches as well, and pay attention to the order defined in the series file. I'll have a Mercurial mirror soon which will make the patch queue a lot easier to use (not to mention tooling to do pre-releases!).

Best

kraduk commented 8 years ago

Good news it compiles 8)

Now i need to learn howto use it correctly. Its not discovering anything, is that normal?

root@hunters6 /usr/home/krad/lightsd/build]# ./core/lightsd -u lightsd -g lightsd -l hunters6.intranet:23456 -v debug [2016-05-05T08:25:37.549348+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:37.549992+01:00] [DEBUG] lightsd: starting discovery timer [2016-05-05T08:25:39.585234+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:41.591206+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:43.600861+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:45.633010+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:47.723023+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:49.785525+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:51.786746+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:53.789897+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it

On 5 May 2016 at 06:39, Louis Opter notifications@github.com wrote:

@kraduk https://github.com/kraduk, @etenim https://github.com/etenim,

I have updated lopter/lightsd-mq https://github.com/lopter/lightsd-mq with fix_freebsd_build.patch https://github.com/lopter/lightsd-mq/blob/225a26b11b1fc75a7444157c11c6b23edfac4da3/fix_freebsd_build.patch; feel free to give it a try!

I see you're using other patches from my patch queue, so don't forget to get updated versions of those patches as well, and pay attention to the order defined in the series https://github.com/lopter/lightsd-mq/blob/225a26b11b1fc75a7444157c11c6b23edfac4da3/series file. I'll have a Mercurial mirror soon which will make the patch queue a lot easier to use (not to mention tooling to do pre-releases!).

Best

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lopter/lightsd/issues/14#issuecomment-217079832

kraduk commented 8 years ago

I should have waited longer 8)

[2016-05-05T08:46:58.433370+01:00] [INFO] lightsd: ECHO_RESPONSE <-- [::ffff:192.168.210.99]:56700 - (Packet from unknown client or gateway, header info: addressable=1, tagged=0, protocol=1024, target= [2016-05-05T08:46:59.884963+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:47:00.437359+01:00] [INFO] lightsd: LIGHT_STATUS <-- [::ffff:192.168.210.99]:56700 - (Packet from unknown client or gateway, header info: addressable=1, tagged=0, protocol=1024, target= [2016-05-05T08:47:01.908169+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:47:02.441212+01:00] [INFO] lightsd: STATE_TEMPERATURE <-- [::ffff:192.168.210.99]:56700 - (Packet from unknown client or gateway, header info: addressable=1, tagged=0, protocol=1024, target= [2016-05-05T08:47:03.929759+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:47:04.437067+01:00] [INFO] lightsd: MESH_INFO <-- [::ffff:192.168.210.99]:56700 - (Packet from unknown client or gateway, header info: addressable=1, tagged=0, protocol=1024, target= [2016-05-05T08:47:05.985513+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:47:06.442169+01:00] [INFO] lightsd: WIFI_INFO <-- [::ffff:192.168.210.99]:56700 - (Packet from unknown client or gateway, header info: addressable=1, tagged=0, protocol=1024, target=d

On 5 May 2016 at 08:27, krad kraduk@gmail.com wrote:

Good news it compiles 8)

Now i need to learn howto use it correctly. Its not discovering anything, is that normal?

root@hunters6 /usr/home/krad/lightsd/build]# ./core/lightsd -u lightsd -g lightsd -l hunters6.intranet:23456 -v debug [2016-05-05T08:25:37.549348+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:37.549992+01:00] [DEBUG] lightsd: starting discovery timer [2016-05-05T08:25:39.585234+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:41.591206+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:43.600861+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:45.633010+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:47.723023+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:49.785525+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:51.786746+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it [2016-05-05T08:25:53.789897+01:00] [DEBUG] lightsd: discovery didn't returned anything in 2000ms, restarting it

On 5 May 2016 at 06:39, Louis Opter notifications@github.com wrote:

@kraduk https://github.com/kraduk, @etenim https://github.com/etenim,

I have updated lopter/lightsd-mq https://github.com/lopter/lightsd-mq with fix_freebsd_build.patch https://github.com/lopter/lightsd-mq/blob/225a26b11b1fc75a7444157c11c6b23edfac4da3/fix_freebsd_build.patch; feel free to give it a try!

I see you're using other patches from my patch queue, so don't forget to get updated versions of those patches as well, and pay attention to the order defined in the series https://github.com/lopter/lightsd-mq/blob/225a26b11b1fc75a7444157c11c6b23edfac4da3/series file. I'll have a Mercurial mirror soon which will make the patch queue a lot easier to use (not to mention tooling to do pre-releases!).

Best

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lopter/lightsd/issues/14#issuecomment-217079832

lopter commented 8 years ago

I should have waited longer 8)

That previous output didn't look very promising though; hope you got it to work!

Discovery usually happens faster than this, typically around a second. If your bulbs aren't discovered in the first five seconds something is probably wrong.

kraduk commented 8 years ago

I haven't had time to play much yet so cant comment. I have got a freebsd startup script for it if you want to include it in your git repo? How would be best to get it to you?

On 5 May 2016 at 15:23, Louis Opter notifications@github.com wrote:

I should have waited longer 8)

That previous output didn't look very promising though; hope you got it to work!

Discovery usually happens faster than this, typically around a second. If your bulbs aren't discovered in the first five seconds something is probably wrong.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lopter/lightsd/issues/14#issuecomment-217167651

kraduk commented 8 years ago

could this be a part of the issue?

git apply ../network_discovery.patch

error: patch failed: CMakeLists.txt:4 error: CMakeLists.txt: patch does not apply error: patch failed: lifx/broadcast.c:17 error: lifx/broadcast.c: patch does not apply

On 6 May 2016 at 11:59, krad kraduk@gmail.com wrote:

I haven't had time to play much yet so cant comment. I have got a freebsd startup script for it if you want to include it in your git repo? How would be best to get it to you?

On 5 May 2016 at 15:23, Louis Opter notifications@github.com wrote:

I should have waited longer 8)

That previous output didn't look very promising though; hope you got it to work!

Discovery usually happens faster than this, typically around a second. If your bulbs aren't discovered in the first five seconds something is probably wrong.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lopter/lightsd/issues/14#issuecomment-217167651

lopter commented 8 years ago

haven't had time to play much yet so cant comment. I have got a freebsd startup script for it if you want to include it in your git repo? How would be best to get it to you?

Sure, feel free to send it to me directly or open a pull-request, anything works.

git apply ../network_discovery.patch error: patch failed: CMakeLists.txt:4 error: CMakeLists.txt: patch does not apply error: patch failed: lifx/broadcast.c:17 error: lifx/broadcast.c: patch does not apply

Here is an archive of the project sources with all the patches applied correctly. I just checked that it builds fine on FreeBSD: lightsd-pre-1.2.0.tar.gz.

kraduk commented 8 years ago

Excellent that looks lots better. I have done a pull req for the rc script. You might want to look at the daemonizing code on freebsd as it doesnt appear to work (on 10-Stable at least ~ March 22 build, but basically 10.3), so i have worked around that with the rc, so its not a real problem. Might even make the handling of failures easier.

May 9 11:35:20 X lightsd[56854]: gateway for site 4c:49:46:58:56:32 at

May 9 11:35:20 X lightsd[56854]: gateway for site 4c:49:46:58:56:32 at

May 9 11:35:21 X lightsd[56854]: bulb d0:73:xx:xx:xx on

May 9 11:35:21 X lightsd[56854]: sending GET_INFO to d0:73:xx:xx:xx () May 9 11:35:21 X lightsd[56854]: bulb d0:73:xx:xx:xx on

May 9 11:35:21 X lightsd[56854]: sending GET_INFO to d0:73:xx:xx:xx () May 9 11:35:21 X lightsd[56854]: sending GET_VERSION to d0:73:xx:xx:xx (C_bedlight) May 9 11:35:21 X lightsd[56854]: sending GET_MESH_FIRMWARE to d0:73:xx:xx:xx (C_bedlight) May 9 11:35:21 X lightsd[56854]: sending GET_VERSION to d0:73:xx:xx:xx (D_bedlight) May 9 11:35:21 X lightsd[56854]: sending GET_MESH_FIRMWARE to d0:73:xx:xx:xx (D_bedlight)

On 6 May 2016 at 17:14, Louis Opter notifications@github.com wrote:

haven't had time to play much yet so cant comment. I have got a freebsd startup script for it if you want to include it in your git repo? How would be best to get it to you?

Sure, feel free to send it to me directly or open a pull-request, anything works.

git apply ../network_discovery.patch error: patch failed: CMakeLists.txt:4 error: CMakeLists.txt: patch does not apply error: patch failed: lifx/broadcast.c:17 error: lifx/broadcast.c: patch does not apply

Here is an archive of the project sources with all the patches applied correctly. I just checked that it builds fine on FreeBSD: lightsd-pre-1.2.0.tar.gz https://github.com/lopter/lightsd/files/252634/lightsd-pre-1.2.0.tar.gz.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lopter/lightsd/issues/14#issuecomment-217487639

etenim commented 8 years ago

Hello @lopter lightsd now builds (and runs) on FreeBSD (10.3) with the latest 1.2.0-rc1 of lightsd!

This is great, thank you!

lopter commented 7 years ago

Fixed!