File softether.spec of Package softether

#
# spec file for package softether
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 https://bugs.opensuse.org/
#


%define majorversion 4
%define minorversion 38
%define buildversion 9760
%define buildrelease rtm
Name:           softether
Version:        %{majorversion}.%{minorversion}.%{buildversion}
Release:        0
Summary:        An Open-Source Free Cross-platform Multi-protocol VPN Program
License:        Apache-2.0
Group:          Productivity/Networking/Security
URL:            http://www.softether.org/
Source0:        https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/archive/v%{majorversion}.%{minorversion}-%{buildversion}-rtm.tar.gz
Source1:        softether-vpnbridge.service
Source2:        softether-vpnclient.service
Source3:        softether-vpnserver.service
# RSA_generate_key.3
# "Key sizes with num < 1024..."
Patch1:         softethervpn-RsaCheck-bit-size.diff
BuildRequires:  fdupes
BuildRequires:  ncurses-devel
BuildRequires:  openssl-devel
BuildRequires:  readline-devel
BuildRequires:  zlib-devel
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}

%description
SoftEther VPN is one of the world's most powerful and easy-to-use
multi-protocol VPN software.
It runs on Windows, Linux, Mac, FreeBSD, and Solaris.

%prep
%setup -q -n SoftEtherVPN_Stable-%{majorversion}.%{minorversion}-%{buildversion}-%{buildrelease}
%patch1 -p1
sed -i 's/\r$//' ChangeLog LICENSE README
# obey CFLAGS
sed -i 's|OPTIONS_COMPILE_RELEASE=|OPTIONS_COMPILE_RELEASE+=|' src/makefiles/linux_*

%build
export OPTIONS_COMPILE_RELEASE="%{optflags} -Wno-return-type"
# FIXME: you should use the %%configure macro
./configure
make %{?_smp_mflags}

%install
install -d %{buildroot}%{_libexecdir}/softether
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_sbindir}

for component in vpnbridge vpnclient vpnserver vpncmd; do
  mv bin/${component} %{buildroot}%{_libexecdir}/softether/
  echo "#!/bin/sh" > %{buildroot}%{_bindir}/softether-${component}
  echo "%{_libexecdir}/softether/${component}/${component}" >> %{buildroot}%{_bindir}/softether-${component}
  chmod +x %{buildroot}%{_bindir}/softether-${component}
  if [ "${component}" != "vpncmd" ]; then
      ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcsoftether-${component}
  fi
  echo "exit $?" >> %{buildroot}%{_bindir}/softether-${component}
done

install -d %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/softether-vpnbridge.service
install -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/softether-vpnclient.service
install -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/softether-vpnserver.service

%fdupes %{buildroot}%{_prefix}

%pre
%service_add_pre softether-vpnbridge.service softether-vpnclient.service softether-vpnserver.service

%post
%service_add_post softether-vpnbridge.service softether-vpnclient.service softether-vpnserver.service

%preun
%service_del_preun softether-vpnbridge.service softether-vpnclient.service softether-vpnserver.service

%postun
%service_del_postun softether-vpnbridge.service softether-vpnclient.service softether-vpnserver.service

%files
%license LICENSE
%doc ChangeLog README
%{_bindir}/softether-vpnserver
%{_bindir}/softether-vpnbridge
%{_bindir}/softether-vpnclient
%{_bindir}/softether-vpncmd
%{_sbindir}/rcsoftether-vpnserver
%{_sbindir}/rcsoftether-vpnbridge
%{_sbindir}/rcsoftether-vpnclient
%{_libexecdir}/softether
%{_unitdir}/softether-vpnbridge.service
%{_unitdir}/softether-vpnclient.service
%{_unitdir}/softether-vpnserver.service

%changelog
openSUSE Build Service is sponsored by