Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vigevenoj/a911eef4a6cbaa306247 to your computer and use it in GitHub Desktop.
Save vigevenoj/a911eef4a6cbaa306247 to your computer and use it in GitHub Desktop.
Building mosquitto on centos 6 with websocket support
sudo yum install wget mercurial cmake openssl-devel c-ares-devel libuuid-devel
wget https://github.com/warmcat/libwebsockets/archive/v2.1.0.tar.gz
tar xf v2.1.0.tar.gz
cd libwebsockets-2.1.0
mkdir build; cd build
cmake .. -DLIB_SUFFIX=64
sudo make install
echo "/usr/local/lib64" | sudo tee -a /etc/ld.so.conf.d/libwebsockets.conf
sudo ldconfig
ldconfig -p | grep libwebsockets
cd
wget https://github.com/eclipse/mosquitto/archive/v1.4.10.tar.gz
tar xf v1.4.10.tar.gz
cd mosquitto-1.4.10
make WITH_LIBWEBSOCKETS=yes binary
# Edit ./man/Makefile to comment out the `all` and `dist` targets
# Edit ./man/Makefile to comment out all of the work in the `install` target
sudo make install
# sudo ln -s /usr/local/lib64/libwebsockets.so.4.0.0 /usr/lib/libwebsockets.so.4.0.0 # not needed
# I forgot how to make an rpm from these instructions
# TODO
# - initscript
Summary: An Open Source MQTT v3.1 Broker
Name: mosquitto
Version: 1.4.3
Release: 0.1
License: BSD
Group: Applications
Source0: http://mosquitto.org/files/source/%{name}-%{version}.tar.gz
#Patch1: mosquitto.config.patch
# Source0-md5: cd879f5964311501ba8e2275add71484
URL: http://mosquitto.org/
#BuildRequires: cmake
BuildRequires: libwebsockets
BuildRequires: libstdc++-devel
BuildRequires: tcp_wrappers-devel
BuildRequires: tcp_wrappers
BuildRequires: openssl-devel
BuildRequires: python-devel
#BuildRequires: python-modules
BuildRequires: python-setuptools
BuildRequires: rpm-python
#BuildRequires: rpmbuild(macros) >= 1.219
#BuildRequires: sqlite3-devel >= 3.5
Requires(postun): /usr/sbin/groupdel
Requires(postun): /usr/sbin/userdel
Requires(pre): /usr/bin/id
#Requires(pre): /usr/bin/getgid
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
#Suggests: %{name}-clients
Provides: group(mosquitto)
Provides: user(mosquitto)
#BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Mosquitto is an open source (BSD licensed) message broker that
implements the MQ Telemetry Transport protocol version 3.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 micro-controllers like the
Arduino.
%package clients
Summary: Mosquitto command line pub/sub clients
Group: Applications/Networking
Requires: libmosquitto = %{version}-%{release}
%description clients
This is two MQTT version 3 clients. The first can publish messages to
a broker, the second can subscribe to multiple topics on a broker.
%package -n libmosquitto
Summary: MQTT C client library
Group: Development/Libraries
%description -n libmosquitto
This is a library that provides a means of implementing MQTT version 3
clients. MQTT provides a lightweight method of carrying out messaging
using a publish/subscribe model.
%package -n libmosquitto-devel
Summary: MQTT C client library development files
Group: Development/Libraries
Group: Development/Libraries
Requires: libmosquitto = %{version}-%{release}
%description -n libmosquitto-devel
This is a library that provides a means of implementing MQTT version 3
clients. MQTT provides a lightweight method of carrying out messaging
using a publish/subscribe model.
%package -n libmosquittopp
Summary: MQTT C++ client library
Group: Development/Libraries
%description -n libmosquittopp
This is a library that provides a means of implementing MQTT version 3
clients. MQTT provides a lightweight method of carrying out messaging
using a publish/subscribe model.
%package -n libmosquittopp-devel
Summary: MQTT C++ client library development files
Group: Development/Libraries
Requires: libmosquittopp = %{version}-%{release}
%description -n libmosquittopp-devel
This is a library that provides a means of implementing MQTT version 3
clients. MQTT provides a lightweight method of carrying out messaging
using a publish/subscribe model.
%prep
%setup -q
#%patch1 -p0
%build
install -d build
cd build
%cmake \
-DUSE_LIBWRAP:BOOL=OFF \
-DWITH_WEBSOCKETS:BOOL=ON \
-DWITH_DOCS=OFF \
..
%{__make}
cd ..
#make WITH_WRAP=yes WITH_WEBSOCKETS=yes WITH_DOCS=no
%install
rm -rf $RPM_BUILD_ROOT
%{__make} -C build install \
DESTDIR=$RPM_BUILD_ROOT
#make install DESTDIR=$RPM_BUILD_ROOT prefix=/usr
rm $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/*.example
%clean
rm -rf $RPM_BUILD_ROOT
%pre
# User needs to be present before install so permissions can be set.
getent group mosquitto >/dev/null || /usr/sbin/groupadd -r mosquitto
getent passwd mosquitto >/dev/null || /usr/sbin/useradd -r -g mosquitto -d /var/lib/mosquitto -s /bin/false -c "Mosquitto broker" mosquitto
if [ "$1" = "0" ]; then
%userremove mosquitto
%groupremove mosquitto
fi
%post -n libmosquitto -p /sbin/ldconfig
%postun -n libmosquitto -p /sbin/ldconfig
%post -n libmosquittopp -p /sbin/ldconfig
%postun -n libmosquittopp -p /sbin/ldconfig
%files
%defattr(644,root,root,755)
#%doc LICENSE.txt readme.txt *.example
%dir %{_sysconfdir}/%{name}
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/%{name}.conf
%attr(755,root,root) %{_bindir}/mosquitto_passwd
%attr(755,root,root) %{_sbindir}/mosquitto
%files clients
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/mosquitto_pub
%attr(755,root,root) %{_bindir}/mosquitto_sub
%files -n libmosquitto
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/libmosquitto.so.*
#%ghost %{_libdir}/libmosquitto.so.1
%files -n libmosquitto-devel
%defattr(644,root,root,755)
#%{_mandir}/man3/libmosquitto.3*
%{_libdir}/libmosquitto.so
%{_includedir}/mosquitto.h
%{_includedir}/mosquitto_plugin.h
%files -n libmosquittopp
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/libmosquittopp.so.*
%ghost %{_libdir}/libmosquittopp.so.1
%files -n libmosquittopp-devel
%defattr(644,root,root,755)
%{_libdir}/libmosquittopp.so
%{_includedir}/mosquittopp.h
@poorevil
Copy link

very helpful

@solidpulse
Copy link

Thanks a lot

@galyathee
Copy link

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment