Skip to contentSkip to conversation

Update package mosquitto

PATCH New Titouan Christophe 2 participants 7 messages Aug 3, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Update package mosquitto

This patchset extend the mosquitto integration with Buildroot's build system and systemd, thanks to configuration options that have been introduced in mosquitto 1.5. Finally, it updates the help text in Config.in and add myself to the DEVELOPERS.

Changes in v2:
- Explicit dependency on systemd when enabled
- Broker needs dylibs
- Update help text and DEVELOPERS

Titouan Christophe (3):
package/mosquitto: allow to build as static lib package/mosquitto: extend systemd integration package/mosquitto: update help text in Config.in

 DEVELOPERS                          |  1 +
 package/mosquitto/Config.in         | 31 +++++++++++++++++------------
 package/mosquitto/mosquitto.mk      | 19 +++++++++++++++++-
 package/mosquitto/mosquitto.service | 10 ----------
 4 files changed, 37 insertions(+), 24 deletions(-)
 delete mode 100644 package/mosquitto/mosquitto.service
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/3 package/mosquitto: allow to build as static lib

Since version 1.5, it is possible to build mosquitto as a static lib.

However, the broker still needs a toolchain with support for shared libraries, because it contains code to dynamically load modules at runtime. This code makes use of dlfcn.h, which is only available for dylib enabled systems.

---
 package/mosquitto/Config.in    |  9 +++------
 package/mosquitto/mosquitto.mk | 12 ++++++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)
package/mosquitto/Config.in +3 -6
index c7373d9a84..8f2561c2d8 100644
@@ -1,6 +1,5 @@
 config BR2_PACKAGE_MOSQUITTO
 	bool "mosquitto"
-	depends on !BR2_STATIC_LIBS # builds .so
 	help
 	  Mosquitto is an open source message broker that implements
 	  the MQ Telemetry Transport protocol versions 3.1 and
@@ -16,12 +15,10 @@ config BR2_PACKAGE_MOSQUITTO_BROKER
 	bool "install the mosquitto broker"
 	default y
 	depends on BR2_USE_MMU # fork()
+	depends on !BR2_STATIC_LIBS # include <dlfcn.h>
 	depends on BR2_PACKAGE_MOSQUITTO
 	help
 	  Build and install the mosquitto broker onto target.
 
-comment "mosquitto broker needs a system with MMU"
-	depends on BR2_PACKAGE_MOSQUITTO && !BR2_USE_MMU
-
-comment "mosquitto needs a toolchain w/ dynamic library"
-	depends on BR2_STATIC_LIBS
+comment "mosquitto broker needs a system with MMU; toolchain w/ dynamic library"
+	depends on BR2_PACKAGE_MOSQUITTO && (!BR2_USE_MMU || BR2_STATIC_LIBS)
package/mosquitto/mosquitto.mk +12 -0
index a172afcc53..eb39f0af6e 100644
@@ -17,6 +17,18 @@ MOSQUITTO_MAKE_OPTS = \
 	WITH_WRAP=no \
 	WITH_DOCS=no
 
+ifeq ($(BR2_SHARED_LIBS),y)
+MOSQUITTO_MAKE_OPTS += WITH_STATIC_LIBRARIES=no
+else
+MOSQUITTO_MAKE_OPTS += WITH_STATIC_LIBRARIES=yes
+endif
+
+ifeq ($(BR2_STATIC_LIBS),y)
+MOSQUITTO_MAKE_OPTS += WITH_SHARED_LIBRARIES=no
+else
+MOSQUITTO_MAKE_OPTS += WITH_SHARED_LIBRARIES=yes
+endif
+
 # adns uses getaddrinfo_a
 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
 MOSQUITTO_MAKE_OPTS += WITH_ADNS=yes
Signature · 1 line
2.21.0
#2 lore raw

PATCH 1/3 package/mosquitto: allow to build as static lib

Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Titouan" == Titouan Christophe <[email protected]> writes:

Since version 1.5, it is possible to build mosquitto as a static lib. However, the broker still needs a toolchain with support for shared libraries, because it contains code to dynamically load modules at runtime. This code makes use of dlfcn.h, which is only available for dylib enabled systems.

---
 package/mosquitto/Config.in    |  9 +++------
 package/mosquitto/mosquitto.mk | 12 ++++++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)
package/mosquitto/Config.in +1 -1
index c7373d9a84..8f2561c2d8 100644
@@ -1,6 +1,5 @@
 config BR2_PACKAGE_MOSQUITTO
 	bool "mosquitto"
-	depends on !BR2_STATIC_LIBS # builds .so
 	help
 	  Mosquitto is an open source message broker that implements
 	  the MQ Telemetry Transport protocol versions 3.1 and
@@ -16,12 +15,10 @@ config BR2_PACKAGE_MOSQUITTO_BROKER
 	bool "install the mosquitto broker"
 	default y
 	depends on BR2_USE_MMU # fork()
+	depends on !BR2_STATIC_LIBS # include <dlfcn.h>
 	depends on BR2_PACKAGE_MOSQUITTO

package/mosquitto/Config.in config BR2_PACKAGE_MOSQUITTO_BROKER · line 24

Quoted 10 lines
package/mosquitto/Config.in +2 -5
 	help
 	  Build and install the mosquitto broker onto target.
 
-comment "mosquitto broker needs a system with MMU"
-	depends on BR2_PACKAGE_MOSQUITTO && !BR2_USE_MMU
-
-comment "mosquitto needs a toolchain w/ dynamic library"
-	depends on BR2_STATIC_LIBS
+comment "mosquitto broker needs a system with MMU; toolchain w/ dynamic library"
+	depends on BR2_PACKAGE_MOSQUITTO && (!BR2_USE_MMU || BR2_STATIC_LIBS)

Not your fault, but this message should not mention MMU (as the user cannot change it) and only be displayed if mosquitto && mmu && static.

Committed with that fixed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 2/3 package/mosquitto: extend systemd integration

In reply to Titouan Christophe

Since version 1.5, mosquitto can be built with explicit support for systemd. If enabled, libmosquitto will link against libsystemd: when started, the mosquitto broker notifies systemd that it is ready (ie. initialized and ready to accept connections), so that services that depend on the mqtt broker can be started only at that point.

To enable this feature, the systemd service config file needs to change to Type=notify. Upstream now provides such a file, so we can remove ours.

---
 package/mosquitto/mosquitto.mk      |  7 ++++++-
 package/mosquitto/mosquitto.service | 10 ----------
 2 files changed, 6 insertions(+), 11 deletions(-)
 delete mode 100644 package/mosquitto/mosquitto.service
package/mosquitto/mosquitto.mk +6 -1
index eb39f0af6e..6de6fc804f 100644
@@ -29,6 +29,11 @@ else
 MOSQUITTO_MAKE_OPTS += WITH_SHARED_LIBRARIES=yes
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD),y)
+MOSQUITTO_MAKE_OPTS += WITH_SYSTEMD=yes
+MOSQUITTO_DEPENDENCIES += systemd
+endif
+
 # adns uses getaddrinfo_a
 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
 MOSQUITTO_MAKE_OPTS += WITH_ADNS=yes
@@ -102,7 +107,7 @@ define MOSQUITTO_INSTALL_INIT_SYSV
 endef
 
 define MOSQUITTO_INSTALL_INIT_SYSTEMD
-	$(INSTALL) -D -m 644 package/mosquitto/mosquitto.service \
+	$(INSTALL) -D -m 644 $(@D)/service/systemd/mosquitto.service.notify \
 		$(TARGET_DIR)/usr/lib/systemd/system/mosquitto.service
 	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
 	ln -fs ../../../../usr/lib/systemd/system/mosquitto.service \
package/mosquitto/mosquitto.service deleted +0 -10
deleted file mode 100644
index 2d1939d1c7..0000000000
@@ -1,10 +0,0 @@
-[Unit]
-Description=Mosquitto MQTT broker
-
-[Service]
-ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
-ExecReload=/bin/kill -HUP $MAINPID
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
Signature · 1 line
2.21.0
#4 lore raw

PATCH 2/3 package/mosquitto: extend systemd integration

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Titouan" == Titouan Christophe <[email protected]> writes:

Since version 1.5, mosquitto can be built with explicit support for systemd. If enabled, libmosquitto will link against libsystemd: when started, the mosquitto broker notifies systemd that it is ready (ie. initialized and ready to accept connections), so that services that depend on the mqtt broker can be started only at that point.

Quoted 5 lines

To enable this feature, the systemd service config file needs to change to Type=notify. Upstream now provides such a file, so we can remove ours.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

PATCH v2 3/3 package/mosquitto: update help text in Config.in

In reply to Titouan Christophe

(and add myself to DEVELOPERS)

---
 DEVELOPERS                  |  1 +
 package/mosquitto/Config.in | 22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)
DEVELOPERS +1 -0
index 74f52d26fd..a2017ef593 100644
@@ -2247,6 +2247,7 @@ N:	Timo Ketola <[email protected]>
 F:	package/fbgrab/
 
 N:	Titouan Christophe <[email protected]>
+F:	package/mosquitto/
 F:	package/redis/
 
 N:	Trent Piepho <[email protected]>
package/mosquitto/Config.in +15 -7
index 8f2561c2d8..272035f18b 100644
@@ -1,13 +1,21 @@
 config BR2_PACKAGE_MOSQUITTO
 	bool "mosquitto"
 	help
-	  Mosquitto is an open source message broker that implements
-	  the MQ Telemetry Transport protocol versions 3.1 and
-	  3.1.1. MQTT provides a lightweight method of carrying out
-	  messaging using a publish/subscribe model. This makes it
-	  suitable for "machine to machine" messaging such as with low
-	  power sensors or mobile devices such as phones, embedded
-	  computers or microcontrollers like the Arduino.
+	  Eclipse Mosquitto is an open source (EPL/EDL licensed) message
+	  broker that implements the MQTT protocol versions 5.0, 3.1.1
+	  and 3.1. Mosquitto is lightweight and is suitable for use on
+	  all devices from low power single board computers to full
+	  servers.
+
+	  The MQTT protocol provides a lightweight method of carrying
+	  out messaging using a publish/subscribe model. This makes it
+	  suitable for Internet of Things messaging such as with low
+	  power sensors or mobile devices such as phones,
+	  embedded computers or microcontrollers.
+
+	  The Mosquitto project also provides a C library for
+	  implementing MQTT clients, and the very popular mosquitto_pub
+	  and mosquitto_sub command line MQTT clients.
 
 	  http://mosquitto.org/
 
Signature · 1 line
2.21.0