From f417152407d561ac8678e24ab6149128f21d30b8 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Tue, 3 Jun 2014 11:55:06 +0000 Subject: [PATCH] net/mosquitto: Import 1.3.1 from packages This is actively maintained, and will continue to be maintained. Upstream development versions of the package is available at https://github.com/remakeelectric/owrt_pub_feeds Signed-off-by: Karl Palsson --- net/mosquitto/Makefile | 190 ++++++++++++++++++++++ net/mosquitto/files/mosquitto.init | 29 ++++ net/mosquitto/files/mosquitto.uci.convert | 88 ++++++++++ 3 files changed, 307 insertions(+) create mode 100644 net/mosquitto/Makefile create mode 100755 net/mosquitto/files/mosquitto.init create mode 100644 net/mosquitto/files/mosquitto.uci.convert diff --git a/net/mosquitto/Makefile b/net/mosquitto/Makefile new file mode 100644 index 0000000000..776548fedf --- /dev/null +++ b/net/mosquitto/Makefile @@ -0,0 +1,190 @@ +# +# Copyright (C) 2011-2013 OpenWrt.org +# Copyright (C) 2010 Jo-Philipp Wich +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mosquitto +PKG_VERSION:=1.3.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://mosquitto.org/files/source/ +PKG_MD5SUM:=2f2870e965cf6f0b5df4ecaf2a0955d2 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +MAKE_FLAGS+=WITH_MEMORY_TRACKING=no + +define Package/$(PKG_NAME)/default + SECTION:=net + CATEGORY:=Network + TITLE:=mosquitto - an MQTT message broker + URL:=http://www.mosquitto.org/ + MAINTAINER:=Karl Palsson + DEPENDS:= +librt +endef + +define Package/$(PKG_NAME) + $(call Package/mosquitto/default) + TITLE+= (with SSL support) + DEPENDS+= +libopenssl + VARIANT:=ssl +endef + +define Package/$(PKG_NAME)-nossl + $(call Package/$(PKG_NAME)/default) + TITLE+= (without SSL support) + VARIANT:=nossl +endef + +define Package/$(PKG_NAME)/default/description + mosquitto is a message broker that supports v3.1 of the MQ Telemetry +Transport protocol. MQTT provides a lightweight method for +messaging using a publish/subscribe model. + +This package also includes some basic support for configuring via UCI +endef + +define Package/$(PKG_NAME)/description + $(call Package/$(PKG_NAME)/default/description) + This package is built with SSL support +endef + +define Package/$(PKG_NAME)-nossl/description + $(call Package/$(PKG_NAME)/default/description) + This package is built WITHOUT SSL support. +endef + + +define Package/mosquitto-client/default + $(Package/mosquitto/default) + TITLE:= mosquitto - client tools + DEPENDS+=+libcares +endef +define Package/mosquitto-client + $(call Package/mosquitto-client/default) + TITLE+= (With SSL support) + DEPENDS+=+libmosquitto + VARIANT:=ssl +endef +define Package/mosquitto-client-nossl + $(call Package/mosquitto-client/default) + TITLE+= (Without SSL support) + DEPENDS+=+libmosquitto-nossl + VARIANT:=nossl +endef + +define Package/mosquitto-client/default/description + Command line client tools for publishing messages to MQTT servers +and subscribing to topics. +endef + +define Package/mosquitto-client/description +$(call Package/mosquitto-client/default/description) + This package is built with SSL support +endef +define Package/mosquitto-client-nossl/description +$(call Package/mosquitto-client/default/description) + This package is built without SSL support +endef + +define Package/libmosquitto/default + $(Package/mosquitto/default) + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libpthread +librt +libcares + TITLE:= mosquitto - client library +endef + +define Package/libmosquitto + $(call Package/libmosquitto/default) + TITLE+= (With SSL Support) + DEPENDS+= +libopenssl + VARIANT=ssl +endef +define Package/libmosquitto-nossl + $(call Package/libmosquitto/default) + TITLE+= (Without SSL Support) + VARIANT=nossl +endef + +define Package/libmosquitto/default/description + Library required for mosquitto's command line client tools, also for +use by any third party software that wants to communicate with a +mosquitto server. + +Should be useable for communicating with any MQTT v3.1 compatible +server, such as IBM's RSMB, in addition to Mosquitto +endef + +define Package/libmosquitto/description + $(call Package/libmosquitto/default/description) + This package is built with SSL support +endef +define Package/libmosquitto-nossl/description + $(call Package/libmosquitto/default/description) + This package is built without SSL support +endef + + +define Package/$(PKG_NAME)/conffiles +/etc/mosquitto/mosquitto.conf +/etc/config/mosquitto +endef + +Package/$(PKG_NAME)-nossl/conffiles = $(Package/$(PKG_NAME)/conffiles) + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mosquitto $(1)/usr/sbin/mosquitto + $(INSTALL_DIR) $(1)/etc/mosquitto + $(INSTALL_CONF) $(PKG_BUILD_DIR)/mosquitto.conf $(1)/etc/mosquitto/mosquitto.conf + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/mosquitto.init $(1)/etc/init.d/mosquitto + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/mosquitto.uci.convert $(1)/usr/bin +endef +Package/$(PKG_NAME)-nossl/install = $(Package/$(PKG_NAME)/install) + + +define Package/mosquitto-client/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/client/mosquitto_pub $(1)/usr/bin/mosquitto_pub + $(INSTALL_BIN) $(PKG_BUILD_DIR)/client/mosquitto_sub $(1)/usr/bin/mosquitto_sub +endef +Package/mosquitto-client-nossl/install = $(Package/mosquitto-client/install) + +# This installs files into ./staging_dir/. so that you can cross compile from the host +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/lib/mosquitto.h $(1)/usr/include + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libmosquitto.so.1 $(1)/usr/lib/ + $(LN) libmosquitto.so.1 $(1)/usr/lib/libmosquitto.so +endef + +# This installs files on the target. Compare with Build/InstallDev +define Package/libmosquitto/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/libmosquitto.so.1 $(1)/usr/lib/ + $(LN) libmosquitto.so.1 $(1)/usr/lib/libmosquitto.so +endef +Package/libmosquitto-nossl/install = $(Package/libmosquitto/install) + +# Applies to all... +ifeq ($(BUILD_VARIANT),nossl) + MAKE_FLAGS += WITH_TLS=no +endif + +$(eval $(call BuildPackage,$(PKG_NAME))) +$(eval $(call BuildPackage,$(PKG_NAME)-nossl)) +$(eval $(call BuildPackage,libmosquitto)) +$(eval $(call BuildPackage,libmosquitto-nossl)) +$(eval $(call BuildPackage,mosquitto-client)) +$(eval $(call BuildPackage,mosquitto-client-nossl)) diff --git a/net/mosquitto/files/mosquitto.init b/net/mosquitto/files/mosquitto.init new file mode 100755 index 0000000000..aafa105acb --- /dev/null +++ b/net/mosquitto/files/mosquitto.init @@ -0,0 +1,29 @@ +#!/bin/sh /etc/rc.common +# Basic init script for mosquitto +# April 2012, OpenWrt.org +# Provides support for the luci-app-mosquitto package, if installed + +START=80 +APP=`which mosquitto` +USE_UCI_CONFIG=$(uci -q get mosquitto.owrt.use_uci) +if [ $? -eq 1 ]; then + USE_UCI_CONFIG=0 +fi + +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 + +start() { + user_exists mosquitto 200 || user_add mosquitto 200 + if [ "$USE_UCI_CONFIG" -eq 1 ]; then + CONF=/tmp/mosquitto.converted.$$.conf + mosquitto.uci.convert -f $CONF + else + CONF=/etc/mosquitto/mosquitto.conf + fi + service_start $APP -c $CONF +} + +stop() { + service_stop $APP +} diff --git a/net/mosquitto/files/mosquitto.uci.convert b/net/mosquitto/files/mosquitto.uci.convert new file mode 100644 index 0000000000..7932ef18f9 --- /dev/null +++ b/net/mosquitto/files/mosquitto.uci.convert @@ -0,0 +1,88 @@ +#!/bin/sh +# Converts a uci config file into an appropriate mosquitto.conf snippet +# expected to be used in an init file to generate a config file to run from +# Karl Palsson 2012. +# Considered to be released into the public domain + +TCONF=/tmp/mosquitto.generated.$$.conf +while getopts "f:" o; do + case $o in + f) + TCONF=$OPTARG + ;; + esac +done + +if [ -e $TCONF ]; then + echo "Odd, same temporary generated config file already existed: $TCONF" + exit 1 +fi + +echo "Generating mosquitto config file in $TCONF" +NOW=$(date) +echo "# mosquitto.conf file generated from UCI config." >>$TCONF +echo "# Config snippet generated by $0 on $NOW" >>$TCONF +echo "#" >> $TCONF +QQ=$(uci -q get mosquitto.mosquitto.log_dest) +if [ $? = 0 ]; then + for dest in $QQ; do + echo "log_dest $dest" >> $TCONF + done +fi + +QQ=$(uci -q get mosquitto.mosquitto.no_remote_access) +if [ $? = 0 ]; then + if [ "$QQ" -eq 1 ]; then + echo "bind_address 127.0.0.1" >> $TCONF + fi +fi + +HATE_SECTION_COUNT=$(grep config /etc/config/mosquitto | grep bridge | wc -l) +if [ $HATE_SECTION_COUNT -gt 0 ]; then + for i in $(seq $HATE_SECTION_COUNT -1 1); do + NN=$(uci -q get mosquitto.@bridge[-$i].connection) + echo "" >> $TCONF + echo "# Bridge connection from UCI section" >> $TCONF + echo "connection $NN" >> $TCONF + ADDR=$(uci -q get mosquitto.@bridge[-$i].address) + echo "address $ADDR" >> $TCONF + TOPICS=$(uci -q -d';' get mosquitto.@bridge[-$i].topic) + # UGLY! just want to split on the ; :( + echo $TOPICS | sed "s/^/topic /" | sed "s/;/\ntopic /g" >> $TCONF + CS=$(uci -q get mosquitto.@bridge[-$i].cleansession) + if [ $? -eq 0 ]; then + if [ "$CS" -eq 1 ]; then + echo "cleansession true" >> $TCONF + fi + else + echo "cleansession false" >> $TCONF + fi + TRYPRIV=$(uci -q get mosquitto.@bridge[-$i].tryprivate) + if [ $? -eq 0 ]; then + if [ "$TRYPRIV" -eq 1 ]; then + echo "try_private true" >> $TCONF + else + echo "try_private false" >> $TCONF + fi + else + # Override default to avoid crashes with 0.15 brokers :( + echo "try_private false" >> $TCONF + fi + CLIENTID=$(uci -q get mosquitto.@bridge[-$i].clientid) + if [ $? -eq 0 ]; then + echo "clientid $CLIENTID" >> $TCONF + fi + BRIDGEID=$(uci -q get mosquitto.@bridge[-$i].identity) + if [ $? -eq 0 ]; then + echo "bridge_identity $BRIDGEID" >> $TCONF + fi + BRIDGEPSK=$(uci -q get mosquitto.@bridge[-$i].psk) + if [ $? -eq 0 ]; then + echo "bridge_psk $BRIDGEPSK" >> $TCONF + fi + BRIDGETLSVERSION=$(uci -q get mosquitto.@bridge[-$i].tls_version) + if [ $? -eq 0 ]; then + echo "bridge_tls_version $BRIDGETLSVERSION" >> $TCONF + fi + done +fi -- 2.30.2