From 835d60daee1e515cf91d2f43d65daa5a9cba20eb Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <gorbyo@gmail.com>
Date: May 03 2018 07:33:37 +0000
Subject: [PATCH 1/12] Merge #1 `Bump new release 5.1.3`


---

diff --git a/kamailio.spec b/kamailio.spec
index 266900f..0c5d919 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -1,6 +1,6 @@
 %global environment git
 
-%global src_version 5.1.2
+%global src_version 5.1.3
 
 %if %{environment} == git
 %global git_release 22
@@ -10,7 +10,7 @@
 %global build_release   %{git_release}.%{git_shortcommit}
 %global build_source    %{src_version}-%{git_release}-%{git_shortcommit}
 %else
-%global build_release   4
+%global build_release   1
 %global build_source    %{src_version}
 %global build_version   %{src_version}
 %endif
@@ -1666,6 +1666,8 @@ fi
 
 
 %changelog
+* Thu May 03 2018 Oleh Horbachov <gorbyo@gmail.com>
+  - Bump new release 5.1.3
 * Wed Apr 18 2018 Oleh Horbachov <gorbyo@gmail.com>
   - Refactored for build from Github
 * Sun Mar 18 2018 Oleh Horbachov <gorbyo@gmail.com>

From f0a58f1a01d50ae373d19fb4f08ccc23776ed5b9 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <ohorbachov@do7050.kyiv.horbachov.name>
Date: May 03 2018 07:37:25 +0000
Subject: [PATCH 2/12] Set environment release


---

diff --git a/kamailio.spec b/kamailio.spec
index 0c5d919..9480861 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -1,4 +1,4 @@
-%global environment git
+%global environment release
 
 %global src_version 5.1.3
 

From f2867ec3dd1bd5f9554dfb4802088ca7a544b4ca Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <o.horbachov@kwebbl.com>
Date: Oct 24 2018 06:34:54 +0000
Subject: [PATCH 3/12] Add sipcapture


---

diff --git a/kamailio.spec b/kamailio.spec
index 9480861..ae00b4a 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -496,13 +496,12 @@ BuildRequires:  lksctp-tools-devel
 SCTP transport for Kamailio.
 %endif
 
-
-%package    sipcapture-daemon-config
+%package    sipcapture
 Summary:    reference config for sipcapture daemon
 Group:      System Environment/Daemons
-Requires:   kamailio-sipcapture = %{version}
+Requires:   kamailio = %{version}
 
-%description    sipcapture-daemon-config
+%description    sipcapture
 reference config for sipcapture daemon.
 
 
@@ -884,7 +883,7 @@ rm -rf %{buildroot}
 
 
 %if "%{?_unitdir}" != ""
-%post sipcapture-daemon-config
+%post sipcapture
 %tmpfiles_create sipcapture.conf
 /usr/bin/systemctl -q enable sipcapture.service
 %endif
@@ -1539,8 +1538,7 @@ fi
 %doc %{_docdir}/kamailio/modules/README.rtjson
 %{_libdir}/kamailio/modules/rtjson.so
 
-
-%files      sipcapture-daemon-config
+%files      sipcapture
 %defattr(-,root,root)
 %config(noreplace) %{_sysconfdir}/kamailio/kamailio-sipcapture.cfg
 %config(noreplace) %{_sysconfdir}/sysconfig/sipcapture

From f57802e2ee03585553650df5925149b66d5a50fe Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <o.horbachov@kwebbl.com>
Date: Nov 12 2018 12:38:14 +0000
Subject: [PATCH 4/12] Bupm v5.1.6


---

diff --git a/kamailio.spec b/kamailio.spec
index ae00b4a..98c0285 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -1,6 +1,6 @@
 %global environment release
 
-%global src_version 5.1.3
+%global src_version 5.1.6
 
 %if %{environment} == git
 %global git_release 22

From 8b4c212618eb8ece642465c7401e2e3395ac59c0 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <o.horbachov@kwebbl.com>
Date: Nov 12 2018 13:47:16 +0000
Subject: [PATCH 5/12] Add mongodb module


---

diff --git a/kamailio.spec b/kamailio.spec
index 98c0285..0c19e27 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -32,7 +32,7 @@ Conflicts:  kamailio-ims < %{version}, kamailio-java < %{version}, kamailio-json
 Conflicts:  kamailio-lcr < %{version}, kamailio-ldap < %{version}, kamailio-lua < %{version}
 Conflicts:  kamailio-kazoo < %{version}
 Conflicts:  kamailio-rabbitmq < %{version}
-Conflicts:  kamailio-memcached < %{version}, kamailio-mysql < %{version}
+Conflicts:  kamailio-memcached < %{version}, kamailio-mongodb < %{version}, kamailio-mysql < %{version}
 Conflicts:  kamailio-outbound < %{version}, kamailio-perl < %{version}
 Conflicts:  kamailio-postgresql < %{version}, kamailio-presence < %{version}
 Conflicts:  kamailio-python < %{version}
@@ -57,6 +57,7 @@ BuildRequires: bison, flex, gcc, make, redhat-rpm-config
 %bcond_without lua
 %bcond_with kazoo
 %bcond_without memcached
+%bcond_with mongodb
 %bcond_without perl
 %bcond_with rabbitmq
 %bcond_with redis
@@ -75,6 +76,7 @@ BuildRequires: bison, flex, gcc, make, redhat-rpm-config
 %bcond_without lua
 %bcond_without kazoo
 %bcond_without memcached
+%bcond_without mongodb
 %bcond_without perl
 %bcond_without rabbitmq
 %bcond_without redis
@@ -356,6 +358,17 @@ BuildRequires:  libmemcached-devel
 Memcached configuration file support for Kamailio.
 %endif
 
+%if %{with mongodb}
+%package    mongodb
+Summary:    MongoDB database connectivity for Kamailio
+Group:      System Environment/Daemons
+Requires:   kamailio = %{version}
+Requires:   mongo-c-driver
+BuildRequires:  mongo-c-driver-devel
+
+%description    mongodb
+MongoDB database connectivity for Kamailio.
+%endif
 
 %package    mysql
 Summary:    MySQL database connectivity for Kamailio
@@ -748,6 +761,9 @@ make every-module skip_modules="app_mono db_cassandra db_oracle iptrtpproxy \
 %if %{with xmlrpc}
     kmi_xmlrpc \
 %endif
+%if %{with mongodb}
+    kmongodb \
+%endif
     kmysql koutbound \
 %if %{with perl}
     kperl \
@@ -817,6 +833,9 @@ make install-modules-all skip_modules="app_mono db_cassandra db_oracle \
 %if %{with xmlrpc}
     kmi_xmlrpc \
 %endif
+%if %{with mongodb}
+    kmongodb \
+%endif
     kmysql koutbound \
 %if %{with perl}
     kperl \
@@ -1392,6 +1411,14 @@ fi
 %{_libdir}/kamailio/modules/memcached.so
 %endif
 
+%if %{with mongodb}
+%files      mongodb
+%defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.db_mongodb
+%doc %{_docdir}/kamailio/modules/README.ndb_mongodb
+%{_libdir}/kamailio/modules/db_mongodb.so
+%{_libdir}/kamailio/modules/ndb_mongodb.so
+%endif
 
 %files      mysql
 %defattr(-,root,root)

From 1c1bd5648970a5cb31969b6c64a884f9f5cf7466 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <o.horbachov@kwebbl.com>
Date: Nov 12 2018 13:49:15 +0000
Subject: [PATCH 6/12] Add log-systemd


---

diff --git a/kamailio.spec b/kamailio.spec
index 0c19e27..62e972f 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -335,6 +335,18 @@ BuildRequires:  openldap-devel
 LDAP search interface for Kamailio.
 
 
+%if 0%{?rhel} == 7
+%package    log_systemd
+Summary:    Logging to journald backends from Kamailio
+Group:      System Environment/Daemons
+Requires:   kamailio = %{version}
+Requires:   systemd
+BuildRequires: systemd-devel
+
+%description    log_systemd
+This module provides logging to journald systems, replacing the default core logging to syslog.
+%endif
+
 %if %{with lua}
 %package    lua
 Summary:    Lua extensions for Kamailio
@@ -751,7 +763,10 @@ make every-module skip_modules="app_mono db_cassandra db_oracle iptrtpproxy \
 %if %{with rabbitmq}
     krabbitmq \
 %endif
-    kldap
+    kldap \
+%if 0%{?rhel} == 7
+  ksystemd \
+%endif
 %if %{with lua}
     klua \
 %endif
@@ -824,6 +839,9 @@ make install-modules-all skip_modules="app_mono db_cassandra db_oracle \
     krabbitmq \
 %endif
     kldap \
+%if 0%{?rhel} == 7
+  ksystemd \
+%endif
 %if %{with lua}
     klua \
 %endif
@@ -1396,6 +1414,13 @@ fi
 %{_libdir}/kamailio/modules/ldap.so
 
 
+%if 0%{?rhel} == 7
+%files      log_systemd
+%defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.log_systemd
+%{_libdir}/kamailio/modules/log_systemd.so
+%endif
+
 %if %{with lua}
 %files      lua
 %defattr(-,root,root)

From 75bd2b30a688e9af188ff89b33a55b03a4c48eac Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <o.horbachov@kwebbl.com>
Date: Nov 12 2018 13:50:34 +0000
Subject: [PATCH 7/12] rebuild


---

diff --git a/kamailio.spec b/kamailio.spec
index 62e972f..f328e04 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -10,7 +10,7 @@
 %global build_release   %{git_release}.%{git_shortcommit}
 %global build_source    %{src_version}-%{git_release}-%{git_shortcommit}
 %else
-%global build_release   1
+%global build_release   2
 %global build_source    %{src_version}
 %global build_version   %{src_version}
 %endif
@@ -1716,6 +1716,10 @@ fi
 
 
 %changelog
+* Mon Nov 12 2018 Oleh Horbachov <gorbyo@gmail.com>
+  - bump new release 5.1.6
+  - added mogodb module
+  - added log_systemd module
 * Thu May 03 2018 Oleh Horbachov <gorbyo@gmail.com>
   - Bump new release 5.1.3
 * Wed Apr 18 2018 Oleh Horbachov <gorbyo@gmail.com>

From 5c161f2b1fe1fffd72ba749d5ca3e0c0c8dc8368 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <ohorbachov@do7050.kyiv.horbachov.name>
Date: Feb 28 2019 09:46:22 +0000
Subject: [PATCH 8/12] Bump v5.2.1


---

diff --git a/kamailio.spec b/kamailio.spec
index f328e04..3394fa4 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -1,6 +1,6 @@
 %global environment release
 
-%global src_version 5.1.6
+%global src_version 5.2.1
 
 %if %{environment} == git
 %global git_release 22
@@ -10,7 +10,7 @@
 %global build_release   %{git_release}.%{git_shortcommit}
 %global build_source    %{src_version}-%{git_release}-%{git_shortcommit}
 %else
-%global build_release   2
+%global build_release   1
 %global build_source    %{src_version}
 %global build_version   %{src_version}
 %endif
@@ -47,11 +47,42 @@ Conflicts:  kamailio-xmlrpc < %{version}, kamailio-xmpp < %{version}
 Conflicts:  kamailio-uuid < %{version}
 BuildRequires: bison, flex, gcc, make, redhat-rpm-config
 
+%if 0%{?fedora} == 28
+BuildRequires:  python3-devel
+%endif
+
+%if 0%{?fedora} == 28
+%define dist_name fedora
+%define dist_version %{?fedora}
+%bcond_without cnxcc
+%bcond_with dnssec
+%bcond_without geoip
+%bcond_without http_async_client
+%bcond_without ims
+%bcond_without jansson
+%bcond_without json
+%bcond_without lua
+%bcond_without kazoo
+%bcond_without memcached
+%bcond_without mongodb
+%bcond_without perl
+%bcond_with    phonenum
+%bcond_without rabbitmq
+%bcond_without redis
+%bcond_without ruby
+%bcond_without sctp
+%bcond_without websocket
+%bcond_without xmlrpc
+%endif
+
 %if 0%{?rhel} == 6
+%define dist_name rhel
+%define dist_version %{?rhel}
 %bcond_with cnxcc
 %bcond_without dnssec
 %bcond_without geoip
 %bcond_with http_async_client
+%bcond_without ims
 %bcond_with jansson
 %bcond_with json
 %bcond_without lua
@@ -59,18 +90,23 @@ BuildRequires: bison, flex, gcc, make, redhat-rpm-config
 %bcond_without memcached
 %bcond_with mongodb
 %bcond_without perl
+%bcond_with phonenum
 %bcond_with rabbitmq
 %bcond_with redis
+%bcond_with ruby
 %bcond_without sctp
 %bcond_without websocket
 %bcond_without xmlrpc
 %endif
 
 %if 0%{?rhel} == 7
+%define dist_name rhel
+%define dist_version %{?rhel}
 %bcond_without cnxcc
 %bcond_with dnssec
 %bcond_without geoip
 %bcond_without http_async_client
+%bcond_without ims
 %bcond_without jansson
 %bcond_without json
 %bcond_without lua
@@ -78,8 +114,10 @@ BuildRequires: bison, flex, gcc, make, redhat-rpm-config
 %bcond_without memcached
 %bcond_without mongodb
 %bcond_without perl
+%bcond_with    phonenum
 %bcond_without rabbitmq
 %bcond_without redis
+%bcond_without ruby
 %bcond_without sctp
 %bcond_without websocket
 %bcond_without xmlrpc
@@ -98,6 +136,17 @@ platforms or to scale up SIP-to-PSTN gateways, PBX systems or media servers
 like Asterisk™, FreeSWITCH™ or SEMS.
 
 
+%if %{with jansson}
+%package    acc_json
+Summary:    Account transaction information in a JSON dictionary
+Group:      System Environment/Daemons
+Requires:   jansson
+BuildRequires:  jansson-devel
+
+%description    acc_json
+Account transaction information in a JSON dictionary.
+%endif
+
 
 %package    auth-ephemeral
 Summary:    Functions for authentication using ephemeral credentials
@@ -183,6 +232,10 @@ BuildRequires:  openssl-devel
 Requires:   openssl-libs
 BuildRequires:  openssl-devel
 %endif
+%if 0%{?fedora}
+Requires:   openssl-libs
+BuildRequires:  openssl-devel
+%endif
 
 %description    crypto
 This module provides various cryptography tools for use in Kamailio configuration file.  It relies on OpenSSL libraries for cryptographic operations (libssl, libcrypto).
@@ -265,14 +318,16 @@ BuildRequires:  libxml2-devel, libcurl-devel, zlib-devel
 This module implements protocol functions that use the libcurl to communicate with HTTP servers.
 
 
+%if %{with ims}
 %package    ims
 Summary:    IMS modules and extensions module for Kamailio
 Group:      System Environment/Daemons
 Requires:   libxml2, kamailio = %{version}
-BuildRequires:  libxml2-devel
+BuildRequires:  libxml2-devel libmnl-devel
 
 %description    ims
 IMS modules and extensions module for Kamailio.
+%endif
 
 
 %if %{with jansson}
@@ -335,18 +390,6 @@ BuildRequires:  openldap-devel
 LDAP search interface for Kamailio.
 
 
-%if 0%{?rhel} == 7
-%package    log_systemd
-Summary:    Logging to journald backends from Kamailio
-Group:      System Environment/Daemons
-Requires:   kamailio = %{version}
-Requires:   systemd
-BuildRequires: systemd-devel
-
-%description    log_systemd
-This module provides logging to journald systems, replacing the default core logging to syslog.
-%endif
-
 %if %{with lua}
 %package    lua
 Summary:    Lua extensions for Kamailio
@@ -370,6 +413,7 @@ BuildRequires:  libmemcached-devel
 Memcached configuration file support for Kamailio.
 %endif
 
+
 %if %{with mongodb}
 %package    mongodb
 Summary:    MongoDB database connectivity for Kamailio
@@ -382,6 +426,7 @@ BuildRequires:  mongo-c-driver-devel
 MongoDB database connectivity for Kamailio.
 %endif
 
+
 %package    mysql
 Summary:    MySQL database connectivity for Kamailio
 Group:      System Environment/Daemons
@@ -418,6 +463,19 @@ Perl extensions and database driver for Kamailio.
 %endif
 
 
+%if %{with phonenum}
+%package    phonenum
+Summary:    Phonenum module the Kamailio
+Group:      System Environment/Daemons
+Requires:   kamailio = %{version}
+Requires:   libphonenumber
+BuildRequires:  libphonenumber-devel libicu-devel protobuf-devel
+
+%description    phonenum
+Phonenum module the Kamailio.
+%endif
+
+
 %package    postgresql
 Summary:    PostgreSQL database connectivity for Kamailio
 Group:      System Environment/Daemons
@@ -467,12 +525,12 @@ RabbitMQ module for Kamailio.
 Summary:    RADIUS modules for Kamailio
 Group:      System Environment/Daemons
 Requires:   kamailio = %{version}
-%if 0%{?rhel} == 7
-Requires:   freeradius-client
-BuildRequires:  freeradius-client-devel
-%else
+%if 0%{?rhel} == 6
 Requires:   radiusclient-ng
 BuildRequires:  radiusclient-ng-devel
+%else
+Requires:   freeradius-client
+BuildRequires:  freeradius-client-devel
 %endif
 
 %description    radius
@@ -510,6 +568,18 @@ Requires:   kamailio = %{version}
 SIP routing based on JSON specifications.
 
 
+%if %{with ruby}
+%package    ruby
+Summary:    Ruby extensions for Kamailio
+Group:      System Environment/Daemons
+Requires:   kamailio = %{version}
+BuildRequires:  ruby-devel
+
+%description    ruby
+Ruby extensions for Kamailio.
+%endif
+
+
 %if %{with sctp}
 %package    sctp
 Summary:    SCTP transport for Kamailio
@@ -521,12 +591,13 @@ BuildRequires:  lksctp-tools-devel
 SCTP transport for Kamailio.
 %endif
 
-%package    sipcapture
+
+%package    sipcapture-daemon-config
 Summary:    reference config for sipcapture daemon
 Group:      System Environment/Daemons
-Requires:   kamailio = %{version}
+Requires:   kamailio-sipcapture = %{version}
 
-%description    sipcapture
+%description    sipcapture-daemon-config
 reference config for sipcapture daemon.
 
 
@@ -539,6 +610,15 @@ Requires:   kamailio = %{version}
 This module writes SIP traffic and some associated details into local files
 
 
+%package    sipjson
+Summary:    This module serializes SIP message attributes into a JSON document
+Group:      System Environment/Daemons
+Requires:   kamailio = %{version}
+
+%description    sipjson
+This module serializes SIP message attributes into a JSON document
+
+
 %package    smsops
 Summary:    Tools for handling SMS packets in SIP messages
 Group:      System Environment/Daemons
@@ -717,21 +797,27 @@ UUID module for Kamailio.
 
 rm -Rf pkg/kamailio/rhel
 mkdir -p pkg/kamailio/rhel
+rm -Rf pkg/kamailio/fedora
+mkdir -p pkg/kamailio/fedora
+ln -s ../obs pkg/kamailio/fedora/28
 ln -s ../obs pkg/kamailio/rhel/6
 ln -s ../obs pkg/kamailio/rhel/7
 
 
 %build
-%if 0%{?rhel} == 7
+%if 0%{?rhel} == 7|| 0%{?fedora}
 export FREERADIUS=1
 %endif
-make cfg prefix=/usr basedir=%{buildroot} cfg_prefix=%{buildroot} doc_prefix=%{buildroot} \
+make cfg prefix=/usr \
+    basedir=%{buildroot} \
+    cfg_prefix=%{buildroot} \
+    doc_prefix=%{buildroot} \
     doc_dir=%{_docdir}/kamailio/ \
     cfg_target=%{_sysconfdir}/kamailio/ modules_dirs="modules"
 make
 make every-module skip_modules="app_mono db_cassandra db_oracle iptrtpproxy \
     jabber ndb_cassandra osp" \
-%if 0%{?rhel} == 7
+%if 0%{?rhel} == 7 || 0%{?fedora}
     FREERADIUS=1 \
 %endif
     group_include="kstandard kautheph kberkeley kcarrierroute \
@@ -749,7 +835,9 @@ make every-module skip_modules="app_mono db_cassandra db_oracle iptrtpproxy \
 %if %{with http_async_client}
     khttp_async \
 %endif
+%if %{with ims}
     kims \
+%endif
 %if %{with jansson}
     kjansson \
 %endif
@@ -763,10 +851,7 @@ make every-module skip_modules="app_mono db_cassandra db_oracle iptrtpproxy \
 %if %{with rabbitmq}
     krabbitmq \
 %endif
-    kldap \
-%if 0%{?rhel} == 7
-  ksystemd \
-%endif
+    kldap
 %if %{with lua}
     klua \
 %endif
@@ -783,10 +868,16 @@ make every-module skip_modules="app_mono db_cassandra db_oracle iptrtpproxy \
 %if %{with perl}
     kperl \
 %endif
+%if %{with phonenum}
+    kphonenum \
+%endif
     kpostgres kpresence kpython kradius \
 %if %{with redis}
     kredis \
 %endif
+%if %{with ruby}
+    kruby \
+%endif
 %if %{with sctp}
     ksctp \
 %endif
@@ -806,7 +897,7 @@ rm -rf %{buildroot}
 make install
 make install-modules-all skip_modules="app_mono db_cassandra db_oracle \
     iptrtpproxy jabber osp" \
-%if 0%{?rhel} == 7
+%if 0%{?rhel} == 7 || 0%{?fedora}
     FREERADIUS=1 \
 %endif
     group_include="kstandard kautheph kberkeley kcarrierroute \
@@ -824,7 +915,9 @@ make install-modules-all skip_modules="app_mono db_cassandra db_oracle \
 %if %{with http_async_client}
     khttp_async \
 %endif
+%if %{with ims}
     kims \
+%endif
 %if %{with jansson}
     kjansson \
 %endif
@@ -839,9 +932,6 @@ make install-modules-all skip_modules="app_mono db_cassandra db_oracle \
     krabbitmq \
 %endif
     kldap \
-%if 0%{?rhel} == 7
-  ksystemd \
-%endif
 %if %{with lua}
     klua \
 %endif
@@ -858,10 +948,16 @@ make install-modules-all skip_modules="app_mono db_cassandra db_oracle \
 %if %{with perl}
     kperl \
 %endif
+%if %{with phonenum}
+    kphonenum \
+%endif
     kpostgres kpresence kpython kradius \
 %if %{with redis}
     kredis \
 %endif
+%if %{with ruby}
+    kruby \
+%endif
 %if %{with sctp}
     ksctp \
 %endif
@@ -879,21 +975,21 @@ install -d %{buildroot}%{_sharedstatedir}/kamailio
 # On RedHat 6 like
 install -d %{buildroot}%{_var}/run/kamailio
 install -d %{buildroot}%{_sysconfdir}/rc.d/init.d
-install -m755 pkg/kamailio/rhel/%{rhel}/kamailio.init \
+install -m755 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.init \
         %{buildroot}%{_sysconfdir}/rc.d/init.d/kamailio
 %else
 # systemd
 install -d %{buildroot}%{_unitdir}
-install -Dpm 0644 pkg/kamailio/rhel/%{?rhel}/kamailio.service %{buildroot}%{_unitdir}/kamailio.service
-install -Dpm 0644 pkg/kamailio/rhel/%{?rhel}/sipcapture.service %{buildroot}%{_unitdir}/sipcapture.service
-install -Dpm 0644 pkg/kamailio/rhel/%{?rhel}/kamailio.tmpfiles %{buildroot}%{_tmpfilesdir}/kamailio.conf
-install -Dpm 0644 pkg/kamailio/rhel/%{?rhel}/sipcapture.tmpfiles %{buildroot}%{_tmpfilesdir}/sipcapture.conf
+install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.service %{buildroot}%{_unitdir}/kamailio.service
+install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/sipcapture.service %{buildroot}%{_unitdir}/sipcapture.service
+install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.tmpfiles %{buildroot}%{_tmpfilesdir}/kamailio.conf
+install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/sipcapture.tmpfiles %{buildroot}%{_tmpfilesdir}/sipcapture.conf
 %endif
 
 install -d %{buildroot}%{_sysconfdir}/sysconfig
-install -m644 pkg/kamailio/rhel/%{rhel}/kamailio.sysconfig \
+install -m644 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.sysconfig \
         %{buildroot}%{_sysconfdir}/sysconfig/kamailio
-install -m644 pkg/kamailio/rhel/%{rhel}/sipcapture.sysconfig \
+install -m644 pkg/kamailio/%{dist_name}/%{dist_version}/sipcapture.sysconfig \
         %{buildroot}%{_sysconfdir}/sysconfig/sipcapture
 
 
@@ -902,7 +998,11 @@ rm -f %{buildroot}%{_libdir}/kamailio/lib*.so
 
 %pre
 if ! /usr/bin/id kamailio &>/dev/null; then
-       /usr/sbin/useradd -r -g daemon -s /bin/false -c "Kamailio daemon" -d %{_libdir}/kamailio kamailio || \
+       /usr/sbin/useradd --system \
+                         --user-group \
+                         --shell /bin/false \
+                         --comment "Kamailio SIP Server" \
+                         --home-dir %{_rundir}/kamailio kamailio || \
                 %logmsg "Unexpected error adding user \"kamailio\". Aborting installation."
 fi
 
@@ -920,7 +1020,7 @@ rm -rf %{buildroot}
 
 
 %if "%{?_unitdir}" != ""
-%post sipcapture
+%post sipcapture-daemon-config
 %tmpfiles_create sipcapture.conf
 /usr/bin/systemctl -q enable sipcapture.service
 %endif
@@ -1027,6 +1127,7 @@ fi
 %doc %{_docdir}/kamailio/modules/README.siputils
 %doc %{_docdir}/kamailio/modules/README.sl
 %doc %{_docdir}/kamailio/modules/README.sms
+%doc %{_docdir}/kamailio/modules/README.smsops
 %doc %{_docdir}/kamailio/modules/README.speeddial
 %doc %{_docdir}/kamailio/modules/README.sqlops
 %doc %{_docdir}/kamailio/modules/README.ss7ops
@@ -1173,6 +1274,7 @@ fi
 %{_libdir}/kamailio/modules/siputils.so
 %{_libdir}/kamailio/modules/sl.so
 %{_libdir}/kamailio/modules/sms.so
+%{_libdir}/kamailio/modules/smsops.so
 %{_libdir}/kamailio/modules/speeddial.so
 %{_libdir}/kamailio/modules/sqlops.so
 %{_libdir}/kamailio/modules/ss7ops.so
@@ -1240,6 +1342,14 @@ fi
 %{_datadir}/kamailio/dbtext/kamailio/*
 
 
+%if %{with jansson}
+%files      acc_json
+%defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.acc_json
+%{_libdir}/kamailio/modules/acc_json.so
+%endif
+
+
 %files      auth-ephemeral
 %defattr(-,root,root)
 %doc %{_docdir}/kamailio/modules/README.auth_ephemeral
@@ -1335,6 +1445,7 @@ fi
 %doc %{_docdir}/kamailio/modules/README.http_client
 %{_libdir}/kamailio/modules/http_client.so
 
+%if %{with ims}
 %files      ims
 %defattr(-,root,root)
 %{_libdir}/kamailio/libkamailio_ims.so.0
@@ -1347,13 +1458,13 @@ fi
 %doc %{_docdir}/kamailio/modules/README.ims_dialog
 %doc %{_docdir}/kamailio/modules/README.ims_diameter_server
 %doc %{_docdir}/kamailio/modules/README.ims_icscf
+%doc %{_docdir}/kamailio/modules/README.ims_ipsec_pcscf
 %doc %{_docdir}/kamailio/modules/README.ims_isc
 %doc %{_docdir}/kamailio/modules/README.ims_ocs
 %doc %{_docdir}/kamailio/modules/README.ims_qos
 %doc %{_docdir}/kamailio/modules/README.ims_registrar_pcscf
 %doc %{_docdir}/kamailio/modules/README.ims_registrar_scscf
 %doc %{_docdir}/kamailio/modules/README.ims_usrloc_pcscf
-%doc %{_docdir}/kamailio/modules/README.smsops
 %{_libdir}/kamailio/modules/cdp.so
 %{_libdir}/kamailio/modules/cdp_avp.so
 %{_libdir}/kamailio/modules/ims_auth.so
@@ -1361,6 +1472,7 @@ fi
 %{_libdir}/kamailio/modules/ims_dialog.so
 %{_libdir}/kamailio/modules/ims_diameter_server.so
 %{_libdir}/kamailio/modules/ims_icscf.so
+%{_libdir}/kamailio/modules/ims_ipsec_pcscf.so
 %{_libdir}/kamailio/modules/ims_isc.so
 %{_libdir}/kamailio/modules/ims_ocs.so
 %{_libdir}/kamailio/modules/ims_qos.so
@@ -1368,7 +1480,7 @@ fi
 %{_libdir}/kamailio/modules/ims_registrar_scscf.so
 %{_libdir}/kamailio/modules/ims_usrloc_pcscf.so
 %{_libdir}/kamailio/modules/ims_usrloc_scscf.so
-%{_libdir}/kamailio/modules/smsops.so
+%endif
 
 
 %if %{with jansson}
@@ -1414,13 +1526,6 @@ fi
 %{_libdir}/kamailio/modules/ldap.so
 
 
-%if 0%{?rhel} == 7
-%files      log_systemd
-%defattr(-,root,root)
-%doc %{_docdir}/kamailio/modules/README.log_systemd
-%{_libdir}/kamailio/modules/log_systemd.so
-%endif
-
 %if %{with lua}
 %files      lua
 %defattr(-,root,root)
@@ -1436,6 +1541,7 @@ fi
 %{_libdir}/kamailio/modules/memcached.so
 %endif
 
+
 %if %{with mongodb}
 %files      mongodb
 %defattr(-,root,root)
@@ -1445,6 +1551,7 @@ fi
 %{_libdir}/kamailio/modules/ndb_mongodb.so
 %endif
 
+
 %files      mysql
 %defattr(-,root,root)
 %doc %{_docdir}/kamailio/modules/README.db_mysql
@@ -1497,6 +1604,14 @@ fi
 %endif
 
 
+%if %{with phonenum}
+%files      phonenum
+%defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.phonenum
+%{_libdir}/kamailio/modules/phonenum.so
+%endif
+
+
 %files      postgresql
 %defattr(-,root,root)
 %doc %{_docdir}/kamailio/modules/README.db_postgres
@@ -1519,6 +1634,9 @@ fi
 %doc %{_docdir}/kamailio/modules/README.pua
 %doc %{_docdir}/kamailio/modules/README.pua_bla
 %doc %{_docdir}/kamailio/modules/README.pua_dialoginfo
+%if %{with json}
+%doc %{_docdir}/kamailio/modules/README.pua_json
+%endif
 %doc %{_docdir}/kamailio/modules/README.pua_reginfo
 %doc %{_docdir}/kamailio/modules/README.pua_usrloc
 %doc %{_docdir}/kamailio/modules/README.pua_xmpp
@@ -1535,6 +1653,9 @@ fi
 %{_libdir}/kamailio/modules/pua.so
 %{_libdir}/kamailio/modules/pua_bla.so
 %{_libdir}/kamailio/modules/pua_dialoginfo.so
+%if %{with json}
+%{_libdir}/kamailio/modules/pua_json.so
+%endif
 %{_libdir}/kamailio/modules/pua_reginfo.so
 %{_libdir}/kamailio/modules/pua_usrloc.so
 %{_libdir}/kamailio/modules/pua_xmpp.so
@@ -1572,10 +1693,14 @@ fi
 %if %{with redis}
 %files      redis
 %defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.db_redis
 %doc %{_docdir}/kamailio/modules/README.ndb_redis
 %doc %{_docdir}/kamailio/modules/README.topos_redis
+%{_libdir}/kamailio/modules/db_redis.so
 %{_libdir}/kamailio/modules/ndb_redis.so
 %{_libdir}/kamailio/modules/topos_redis.so
+%dir %{_datadir}/kamailio/db_redis
+%{_datadir}/kamailio/db_redis/*
 %endif
 
 
@@ -1590,7 +1715,8 @@ fi
 %doc %{_docdir}/kamailio/modules/README.rtjson
 %{_libdir}/kamailio/modules/rtjson.so
 
-%files      sipcapture
+
+%files      sipcapture-daemon-config
 %defattr(-,root,root)
 %config(noreplace) %{_sysconfdir}/kamailio/kamailio-sipcapture.cfg
 %config(noreplace) %{_sysconfdir}/sysconfig/sipcapture
@@ -1600,6 +1726,14 @@ fi
 %endif
 
 
+%if %{with ruby}
+%files      ruby
+%defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.app_ruby
+%{_libdir}/kamailio/modules/app_ruby.so
+%endif
+
+
 %if %{with sctp}
 %files      sctp
 %defattr(-,root,root)
@@ -1614,6 +1748,12 @@ fi
 %{_libdir}/kamailio/modules/sipdump.so
 
 
+%files      sipjson
+%defattr(-,root,root)
+%doc %{_docdir}/kamailio/modules/README.sipjson
+%{_libdir}/kamailio/modules/sipjson.so
+
+
 %files      snmpstats
 %defattr(-,root,root)
 %{_docdir}/kamailio/modules/README.snmpstats
@@ -1716,10 +1856,6 @@ fi
 
 
 %changelog
-* Mon Nov 12 2018 Oleh Horbachov <gorbyo@gmail.com>
-  - bump new release 5.1.6
-  - added mogodb module
-  - added log_systemd module
 * Thu May 03 2018 Oleh Horbachov <gorbyo@gmail.com>
   - Bump new release 5.1.3
 * Wed Apr 18 2018 Oleh Horbachov <gorbyo@gmail.com>

From 9e9415aa184e218033ba5cf38b27d9742c795980 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <gorbyo@gmail.com>
Date: Feb 28 2019 13:32:13 +0000
Subject: [PATCH 9/12] Add patch peerstatemachine


---

diff --git a/0001-Fix-peerstatemachine.patch b/0001-Fix-peerstatemachine.patch
new file mode 100644
index 0000000..b59c758
--- /dev/null
+++ b/0001-Fix-peerstatemachine.patch
@@ -0,0 +1,25 @@
+From b4e2997cdb38d6c5c5d75bdec2e0a9f1dcf62fae Mon Sep 17 00:00:00 2001
+From: Oleh Horbachov <ohorbachov@do7050.kyiv.horbachov.name>
+Date: Thu, 28 Feb 2019 15:15:27 +0200
+Subject: [PATCH] Fix peerstatemachine
+
+---
+ src/modules/cdp/peerstatemachine.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/modules/cdp/peerstatemachine.c b/src/modules/cdp/peerstatemachine.c
+index 5100e50..5d26605 100644
+--- a/src/modules/cdp/peerstatemachine.c
++++ b/src/modules/cdp/peerstatemachine.c
+@@ -670,7 +670,7 @@ void add_peer_application(peer *p, int id, int vendor, app_type type)
+ 				p->applications[i].vendor == vendor &&
+ 				p->applications[i].type == type) return;
+ 
+-  if (p->applications_cnt > p->applications_max) {
++  if (p->applications_cnt >= p->applications_max) {
+ 		LM_ERR("Too many applications for this peer (max %i), not adding Application %i:%i.\n", p->applications_max, id, vendor);
+ 		return;
+ 	}
+-- 
+2.20.1
+
diff --git a/kamailio.spec b/kamailio.spec
index 3394fa4..bf367a0 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -10,7 +10,7 @@
 %global build_release   %{git_release}.%{git_shortcommit}
 %global build_source    %{src_version}-%{git_release}-%{git_shortcommit}
 %else
-%global build_release   1
+%global build_release   1.1
 %global build_source    %{src_version}
 %global build_version   %{src_version}
 %endif
@@ -22,6 +22,7 @@ Release:    %{build_release}%{dist}
 License:    GPL
 Group:      System Environment/Daemons
 Source:     https://github.com/kamailio/kamailio/archive/%{build_source}.tar.gz
+Patch1:     0001-Fix-peerstatemachine.patch
 URL:        http://kamailio.org/
 Vendor:     kamailio.org
 Conflicts:  kamailio-auth-ephemeral < %{version}, kamailio-bdb < %{version}
@@ -794,6 +795,7 @@ UUID module for Kamailio.
 
 %prep
 %setup -n %{name}-%{build_version}
+%patch1 -p1
 
 rm -Rf pkg/kamailio/rhel
 mkdir -p pkg/kamailio/rhel

From 83fda1e4f41dfbba4fcbb5d11f302b8201cabcf5 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <gorbyo@gmail.com>
Date: Apr 03 2019 17:24:48 +0000
Subject: [PATCH 10/12] Bump v5.2.2


---

diff --git a/kamailio.spec b/kamailio.spec
index bf367a0..229ddfb 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -1,6 +1,6 @@
 %global environment release
 
-%global src_version 5.2.1
+%global src_version 5.2.2
 
 %if %{environment} == git
 %global git_release 22
@@ -10,7 +10,7 @@
 %global build_release   %{git_release}.%{git_shortcommit}
 %global build_source    %{src_version}-%{git_release}-%{git_shortcommit}
 %else
-%global build_release   1.1
+%global build_release   1
 %global build_source    %{src_version}
 %global build_version   %{src_version}
 %endif
@@ -22,7 +22,6 @@ Release:    %{build_release}%{dist}
 License:    GPL
 Group:      System Environment/Daemons
 Source:     https://github.com/kamailio/kamailio/archive/%{build_source}.tar.gz
-Patch1:     0001-Fix-peerstatemachine.patch
 URL:        http://kamailio.org/
 Vendor:     kamailio.org
 Conflicts:  kamailio-auth-ephemeral < %{version}, kamailio-bdb < %{version}
@@ -1858,6 +1857,8 @@ fi
 
 
 %changelog
+* Wed Apr 03 2019 Oleh Horbachov <gorbyo@gmail.com>
+  - Bump new release 5.2.2
 * Thu May 03 2018 Oleh Horbachov <gorbyo@gmail.com>
   - Bump new release 5.1.3
 * Wed Apr 18 2018 Oleh Horbachov <gorbyo@gmail.com>

From a0975a58fe1b31b331593916d765f7990c288ec7 Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <gorbyo@gmail.com>
Date: Apr 03 2019 17:27:46 +0000
Subject: [PATCH 11/12] Remove old patch


---

diff --git a/kamailio.spec b/kamailio.spec
index 229ddfb..fa4d0cf 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -794,7 +794,6 @@ UUID module for Kamailio.
 
 %prep
 %setup -n %{name}-%{build_version}
-%patch1 -p1
 
 rm -Rf pkg/kamailio/rhel
 mkdir -p pkg/kamailio/rhel

From 9aca2f9b6feca5d1f4e1885d5dbe79e7efd01b1a Mon Sep 17 00:00:00 2001
From: Oleh Horbachov <gorbyo@gmail.com>
Date: Jul 02 2019 09:18:45 +0000
Subject: [PATCH 12/12] Update kamailio.spec


bump 5.2.3
---

diff --git a/kamailio.spec b/kamailio.spec
index fa4d0cf..c531ed5 100644
--- a/kamailio.spec
+++ b/kamailio.spec
@@ -1,6 +1,6 @@
 %global environment release
 
-%global src_version 5.2.2
+%global src_version 5.2.3
 
 %if %{environment} == git
 %global git_release 22

