Name:                mosquitto
Version:             2.1.1
Release:             1
Summary:             Open Source MQTT v3.1/v3.1.1 Broker
License:             EPL-1.0
URL:                 https://mosquitto.org/
Source0:             https://mosquitto.org/files/source/%{name}-%{version}.tar.gz
Source1:             mosquitto-sysusers.conf
Patch0001:           add-usage-output.patch
Patch0002:           fix-usage-exit-code.patch
BuildRequires:       gcc-c++ make
BuildRequires:       cmake >= 3.5
BuildRequires:       c-ares-devel
BuildRequires:       cjson-devel
BuildRequires:       libargon2-devel
BuildRequires:       libedit-devel
BuildRequires:       libwebsockets-devel
BuildRequires:       openssl-devel
BuildRequires:       sqlite-devel
BuildRequires:       systemd-devel
BuildRequires:       uthash-devel
BuildRequires:       /usr/bin/xsltproc
BuildRequires:       docbook-style-xsl
Conflicts:           mosquitto-devel < 2.0.20-3
%{?sysusers_requires_compat}
%{?systemd_requires}

%description
Mosquitto is an open source message broker that implements the MQ Telemetry
Transport protocol version 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 micro-controllers
like the Arduino.

%package devel
Requires:            %{name} = %{version}-%{release}
Summary:             Development files for %{name}

%description devel
Development headers and libraries for %{name}

%prep
%autosetup -p1

%build
%cmake \
    -DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir} \
    -DWITH_SRV=ON \
    -DWITH_WEBSOCKETS=ON \
    -DWITH_WEBSOCKETS_BUILTIN=OFF \
    -DWITH_SYSTEMD=ON \
    -DWITH_TESTS=OFF \
    -DWITH_BUNDLED_DEPS=OFF
%cmake_build

%install
%cmake_install

cp %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf.example %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf

install -Dp -m 0644 service/systemd/%{name}.service.notify %{buildroot}%{_unitdir}/%{name}.service
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/mosquitto.conf

%pre
%sysusers_create_compat %{S:1}

%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service

%files
%license LICENSE.txt
%doc ChangeLog.txt CONTRIBUTING.md README.md
%{_bindir}/*
%{_sbindir}/*
%{_libdir}/*.so.*
%{_libdir}/mosquitto_*.so
%{_sysusersdir}/mosquitto.conf
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %{_sysconfdir}/%{name}/*.example
%{_unitdir}/%{name}.service
%{_mandir}/man1/*.1*
%{_mandir}/man5/*.5*
%{_mandir}/man7/*.7*
%{_mandir}/man8/*.8*

%files devel
%{_includedir}/*.h
%{_includedir}/%{name}
%{_libdir}/libmosquitto*.so
%{_libdir}/pkgconfig/*.pc
%{_mandir}/man3/*.3*

%changelog
* Thu Feb 05 2026 Funda Wang <fundawang@yeah.net> - 2.1.1-1
- update to 2.1.1

* Mon Jul 14 2025 Funda Wang <fundawang@yeah.net> - 2.0.22-1
- update to 2.0.22

* Tue Nov 12 2024 Funda Wang <fundawang@yeah.net> - 2.0.20-3
- move mosquitto_dynamic_security into main package

* Mon Nov 11 2024 Funda Wang <fundawang@yeah.net> - 2.0.20-2
- adopt to new cmake macro

* Fri Oct 18 2024 Funda Wang <fundawang@yeah.net> - 2.0.20-1
- Update to 2.0.20

* Fri Jul 05 2024 yaoxin <yao_xin001@hoperun.com> - 2.0.18-1
- Update to 2.0.18
  * Fix crash on subscribe under certain unlikely conditions.
  * Fix mosquitto_rr not honouring `-R`.
  * Fix `max_queued_messages 0` stopping clients from receiving messages.
  * Fix `max_inflight_messages` not being set correctly.
  * Fix `mosquitto_passwd -U` backup file creation.

* Wed Sep 13 2023 yaoxin <yao_xin001@hoperun.com> - 2.0.16-1
- Update to 2.0.16 for fix CVE-2021-34431,CVE-2023-28366 and CVE-2023-3592

* Wed May 10 2023 Ge Wang <wang__ge@126.com> - 2.0.15-1
- Update to version 2.0.15

* Mon May 9 2022 caodongxia <caodongxia@h-partners.com> - 1.6.15-7
- License compliance rectification

* Thu Feb 24 2022 yaoxin <yaoxin30@huawei.com> - 1.6.15-6
- Fix CVE-2021-34432 and modify the CVE-2021-41039.patch.

* Thu Dec 30 2021 houyingchao <houyingchao@huawei.com> - 1.6.15-5
- Fix CVE-2021-41039

* Thu Sep 30 2021 lingsheng <lingsheng@huawei.com> - 1.6.15-4
- fix usage exit code

* Thu Sep 30 2021 lingsheng <lingsheng@huawei.com> - 1.6.15-3
- add usage output

* Fri Sep 24 2021 zhengyaohui <zhengyaohui1@huawei.com> - 1.6.15-2
- add buildrequires make

* Tue Sep 7 2021 zhengyaohui <zhengyaohui1@huawei.com> - 1.6.15-1
- package init