File open5gs.spec of Package open5gs

#
# spec file for package open5gs
#
# Copyright (c) 2018, Martin Hauke <mardnh@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define open5gs_user  open5gs
%define open5gs_group open5gs
%define sover 1.2.4
Name:           open5gs
Version:        1.2.4
Release:        0
Summary:        Open Source based 3GPP EPC (metapackage)
License:        AGPL-3.0-only
Group:          Productivity/Telephony/Servers
URL:            https://open5gs.org
#Git-Clone:     https://github.com/open5gs/open5gs.git
Source:         https://github.com/open5gs/open5gs/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        open5gs-subprojects.tar.gz
Source2:        open5gs-tmpfile
Source3:        open5gs-metapackage
Source99:       open5gs-rpmlintrc
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  libgcrypt-devel
BuildRequires:  lksctp-tools-devel
BuildRequires:  meson
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(gnutls)
BuildRequires:  pkgconfig(libidn)
BuildRequires:  pkgconfig(libmongoc-1.0) >= 1.3.1
BuildRequires:  pkgconfig(yaml-0.1) >= 0.1.4
Requires:       open5gs-common = %{version}
Requires:       open5gs-mme = %{version}
Requires:       open5gs-sgw = %{version}
Requires:       open5gs-pgw = %{version}
Requires:       open5gs-pcrf = %{version}
Requires:       open5gs-hss = %{version}
%{?systemd_requires}

%description
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This is a metapackage that depends on all the Open5GS parts.
(MME, SGW, PGW, HSS, PCRF)

%package -n open5gs-common
Summary:        Open Source based 3GPP EPC (Shared Files)
Group:          Productivity/Telephony/Servers
Requires:       logrotate
Requires(pre):  shadow

%description -n open5gs-common
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This package contains some core libraries/plugins required by the other
binary packages such as open5gs-{mme,sgw,pgw,pcrf,hss}.

%package -n open5gs-mme
Summary:        Open Source based 3GPP EPC MME (Mobility Management Entity)
Group:          Productivity/Telephony/Servers
Requires:       open5gs-common = %{version}

%description -n open5gs-mme
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This package provides the MME (Mobility Management Engine), which
terminates the S1 interfaces from the eNodeBs cells in the cellular
network, and interfaces via S11 to the SGW as well as via S6a to the
HSS.

%package -n open5gs-sgw
Summary:        Open Source based 3GPP EPC SGW (Serving Gateway)
Group:          Productivity/Telephony/Servers
Requires:       open5gs-common = %{version}

%description -n open5gs-sgw
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This package provides the SGW (Serving Gateway) which is situated
between the MME and PGW.  It implements the S11 interface to the MME,
and the S5 interface to the PGW.

%package -n open5gs-pgw
Summary:        Open Source based 3GPP EPC PGW (Packet Data Network Gateway)
Group:          Productivity/Telephony/Servers
Requires:       open5gs-common = %{version}

%description -n open5gs-pgw
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This package provides the PGW or PDN-GW (Packet Data Network Gateway)
element of the EPC, i.e. the gateway between the EPC and the external
packet data network, such as the public Internet.  It implements the S5
interface towards the S-GW, the SGi interface towards the Internet,
and the S7 interface towards the PCRF.

%package -n open5gs-pcrf
Summary:        Open Source based 3GPP EPC PCRF (Policy and Charging Rules Function)
Group:          Productivity/Telephony/Servers
Requires:       open5gs-common = %{version}

%description -n open5gs-pcrf
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This package contains the PCRF (Policy and Charging Rules Function),
which controls the service quality (QoS) of individual connections and
how to account/charge related traffic.  It implements the Gx interface
towards the PGW using the DIAMETER protocol.

%package -n open5gs-hss
Summary:        Open Source based 3GPP EPC HSS (Home Subscriber Server)
Group:          Productivity/Telephony/Servers
Requires:       open5gs-common = %{version}

%description -n open5gs-hss
Open5GS is a C-language Open Source implementation of the 3GPP Evolved
Packet Core, i.e. the core network of an LTE network.

This package provides the HSS (Home Subscriber Server) element of the
EPC, i.e. the central database of mobile network subscribers, with
their IMSI, MSISDN, cryptographic key materials, service subscription
information, etc.  It implements the S6a interface towards the MME
using the DIAMETER protocol.

%prep
%setup -q
cp %{_sourcedir}/open5gs-metapackage README-metapackage
tar xzf %{SOURCE1} -C subprojects/

%build
# FIXME: you should use %%meson macros
meson build --prefix=%{_prefix} --buildtype=release
ninja -C build

%install
DESTDIR=%{buildroot} ninja -C build install
#
install -d %{buildroot}/%{_sysconfdir}/open5gs
install -d %{buildroot}/%{_sysconfdir}/freeDiameter
install -d %{buildroot}/%{_unitdir}
install -d %{buildroot}%{_localstatedir}/log/open5gs
install -d %{buildroot}/%{_sysconfdir}/logrotate.d
install -m 0644 build/configs/logrotate/open5gs %{buildroot}%{_sysconfdir}/logrotate.d/
install -d -m 0755 %{buildroot}%{_tmpfilesdir}/
install -D -m 0644 %{_sourcedir}/open5gs-tmpfile %{buildroot}%{_tmpfilesdir}/open5gs.conf
#
install -m 0644 build/configs/freeDiameter/cacert.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
#
install -m 0644 build/configs/open5gs/hss.yaml %{buildroot}/%{_sysconfdir}/open5gs/
install -m 0644 build/configs/freeDiameter/hss.conf %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/hss.cert.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/hss.key.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/systemd/open5gs-hssd.service %{buildroot}/%{_unitdir}/
#
install -m 0644 build/configs/open5gs/mme.yaml %{buildroot}/%{_sysconfdir}/open5gs/
install -m 0644 build/configs/freeDiameter/mme.conf %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/mme.cert.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/mme.key.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/systemd/open5gs-mmed.service %{buildroot}/%{_unitdir}/
#
install -m 0644 build/configs/open5gs/pcrf.yaml %{buildroot}/%{_sysconfdir}/open5gs/
install -m 0644 build/configs/freeDiameter/pcrf.conf %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/pcrf.cert.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/pcrf.key.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/systemd/open5gs-pcrfd.service %{buildroot}/%{_unitdir}/
#
install -m 0644 build/configs/open5gs/pgw.yaml %{buildroot}/%{_sysconfdir}/open5gs/
install -m 0644 build/configs/freeDiameter/pgw.conf %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/pgw.cert.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/freeDiameter/pgw.key.pem %{buildroot}/%{_sysconfdir}/freeDiameter/
install -m 0644 build/configs/systemd/open5gs-pgwd.service %{buildroot}/%{_unitdir}/
#
install -m 0644 build/configs/open5gs/sgw.yaml %{buildroot}/%{_sysconfdir}/open5gs/
install -m 0644 build/configs/systemd/open5gs-sgwd.service %{buildroot}/%{_unitdir}/

%pre -n open5gs-common
# Create open5gs user/group
getent group %{open5gs_group} >/dev/null || %{_sbindir}/groupadd -r %{open5gs_group}
getent passwd %{open5gs_user} >/dev/null || %{_sbindir}/useradd  -g %{open5gs_group} -s /bin/false -r -c "%{open5gs_user}" -d /run/open5gs/ %{open5gs_user}

%post -n open5gs-common
%tmpfiles_create %{_tmpfilesdir}/open5gs.conf
/sbin/ldconfig
%postun -n open5gs-common -p /sbin/ldconfig

%pre    -n open5gs-hss %service_add_pre    open5gs-hssd.service
%post   -n open5gs-hss %service_add_post   open5gs-hssd.service
%preun  -n open5gs-hss %service_del_preun  open5gs-hssd.service
%postun -n open5gs-hss %service_del_postun open5gs-hssd.service
%pre    -n open5gs-mme %service_add_pre    open5gs-mmed.service
%post   -n open5gs-mme %service_add_post   open5gs-mmed.service
%preun  -n open5gs-mme %service_del_preun  open5gs-mmed.service
%postun -n open5gs-mme %service_del_postun open5gs-mmed.service
%pre    -n open5gs-pcrf %service_add_pre    open5gs-pcrfd.service
%post   -n open5gs-pcrf %service_add_post   open5gs-pcrfd.service
%preun  -n open5gs-pcrf %service_del_preun  open5gs-pcrfd.service
%postun -n open5gs-pcrf %service_del_postun open5gs-pcrfd.service
%pre    -n open5gs-pgw %service_add_pre    open5gs-pgwd.service
%post   -n open5gs-pgw %service_add_post   open5gs-pgwd.service
%preun  -n open5gs-pgw %service_del_preun  open5gs-pgwd.service
%postun -n open5gs-pgw %service_del_postun open5gs-pgwd.service
%pre    -n open5gs-sgw %service_add_pre    open5gs-sgwd.service
%post   -n open5gs-sgw %service_add_post   open5gs-sgwd.service
%preun  -n open5gs-sgw %service_del_preun  open5gs-sgwd.service
%postun -n open5gs-sgw %service_del_postun open5gs-sgwd.service

%files
%doc README-metapackage

%files -n open5gs-common
%license LICENSE
%doc README.md
%dir %{_sysconfdir}/open5gs
%dir %{_sysconfdir}/freeDiameter
%config %{_sysconfdir}/freeDiameter/cacert.pem
%dir %{_localstatedir}/log/open5gs
%config(noreplace) %{_sysconfdir}/logrotate.d/open5gs
%{_tmpfilesdir}/open5gs.conf
%ghost %dir /run/open5gs-epcd
%ghost %dir /run/open5gs-hssd
%ghost %dir /run/open5gs-mmed
%ghost %dir /run/open5gs-pcrfd
%ghost %dir /run/open5gs-pgwd
%ghost %dir /run/open5gs-sgwd
%attr(0750,%{open5gs_user},%{open5gs_group}) %{_var}/log/open5gs
####
%dir %{_libdir}/freeDiameter
%{_libdir}/freeDiameter/dbg_msg_dumps.fdx
%{_libdir}/freeDiameter/dict_dcca.fdx
%{_libdir}/freeDiameter/dict_dcca_3gpp.fdx
%{_libdir}/freeDiameter/dict_mip6i.fdx
%{_libdir}/freeDiameter/dict_nas_mipv6.fdx
%{_libdir}/freeDiameter/dict_nasreq.fdx
%{_libdir}/freeDiameter/dict_rfc5777.fdx
#
%{_libdir}/libfdcore.so
%{_libdir}/libfdcore.so.1.3.2
%{_libdir}/libfdcore.so.7
#
%{_libdir}/libfdproto.so
%{_libdir}/libfdproto.so.1.3.2
%{_libdir}/libfdproto.so.7
#
%{_libdir}/libogsapp.so
%{_libdir}/libogsapp.so.1
%{_libdir}/libogsapp.so.%{sover}
#
%{_libdir}/libogsasn1c-common.so
%{_libdir}/libogsasn1c-common.so.1
%{_libdir}/libogsasn1c-common.so.%{sover}
#
%{_libdir}/libogsasn1c-s1ap.so
%{_libdir}/libogsasn1c-s1ap.so.1
%{_libdir}/libogsasn1c-s1ap.so.%{sover}
#
%{_libdir}/libogscore.so
%{_libdir}/libogscore.so.1
%{_libdir}/libogscore.so.%{sover}
#
%{_libdir}/libogscrypt.so
%{_libdir}/libogscrypt.so.1
%{_libdir}/libogscrypt.so.%{sover}
#
%{_libdir}/libogsdbi.so
%{_libdir}/libogsdbi.so.1
%{_libdir}/libogsdbi.so.%{sover}
#
%{_libdir}/libogsdiameter-common.so
%{_libdir}/libogsdiameter-common.so.1
%{_libdir}/libogsdiameter-common.so.%{sover}
#
%{_libdir}/libogsdiameter-gx.so
%{_libdir}/libogsdiameter-gx.so.1
%{_libdir}/libogsdiameter-gx.so.%{sover}
#
%{_libdir}/libogsdiameter-rx.so
%{_libdir}/libogsdiameter-rx.so.1
%{_libdir}/libogsdiameter-rx.so.%{sover}
#
%{_libdir}/libogsdiameter-s6a.so
%{_libdir}/libogsdiameter-s6a.so.1
%{_libdir}/libogsdiameter-s6a.so.%{sover}
#
%{_libdir}/libogsgtp.so
%{_libdir}/libogsgtp.so.1
%{_libdir}/libogsgtp.so.%{sover}
#
%{_libdir}/libogsnas.so
%{_libdir}/libogsnas.so.1
%{_libdir}/libogsnas.so.%{sover}
#
%{_libdir}/libogspfcp.so
%{_libdir}/libogspfcp.so.1
%{_libdir}/libogspfcp.so.%{sover}
#
%{_libdir}/libogss1ap.so
%{_libdir}/libogss1ap.so.1
%{_libdir}/libogss1ap.so.%{sover}
#
%{_libdir}/libogssctp.so
%{_libdir}/libogssctp.so.1
%{_libdir}/libogssctp.so.%{sover}
#
%files -n open5gs-mme
%config %{_sysconfdir}/freeDiameter/mme.conf
%config %{_sysconfdir}/freeDiameter/mme.cert.pem
%config %{_sysconfdir}/freeDiameter/mme.key.pem
%config %{_sysconfdir}/open5gs/mme.yaml
%{_bindir}/open5gs-mmed
%{_unitdir}/open5gs-mmed.service

%files -n open5gs-sgw
%config %{_sysconfdir}/open5gs/sgw.yaml
%{_bindir}/open5gs-sgwd
%{_unitdir}/open5gs-sgwd.service

%files -n open5gs-pgw
%config %{_sysconfdir}/freeDiameter/pgw.conf
%config %{_sysconfdir}/freeDiameter/pgw.cert.pem
%config %{_sysconfdir}/freeDiameter/pgw.key.pem
%config %{_sysconfdir}/open5gs/pgw.yaml
%{_bindir}/open5gs-pgwd
%{_unitdir}/open5gs-pgwd.service

%files -n open5gs-pcrf
%config %{_sysconfdir}/freeDiameter/pcrf.conf
%config %{_sysconfdir}/freeDiameter/pcrf.cert.pem
%config %{_sysconfdir}/freeDiameter/pcrf.key.pem
%config %{_sysconfdir}/open5gs/pcrf.yaml
%{_bindir}/open5gs-pcrfd
%{_unitdir}/open5gs-pcrfd.service

%files -n open5gs-hss
%config %{_sysconfdir}/freeDiameter/hss.conf
%config %{_sysconfdir}/freeDiameter/hss.cert.pem
%config %{_sysconfdir}/freeDiameter/hss.key.pem
%config %{_sysconfdir}/open5gs/hss.yaml
%{_bindir}/open5gs-hssd
%{_unitdir}/open5gs-hssd.service

%changelog