File QvPlugin-Trojan.spec of Package QvPlugin-Trojan

#
# spec file for package QvPlugin-Trojan
#
# Copyright (c) 2020 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 http://bugs.opensuse.org/
#

# disable debug packages, use explicit glibc-langpack follow openSUSE:Tools/obs-service-tar_scm
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
%global debug_package %{nil}
%define locale_package glibc-langpack-en
%endif

Name:           QvPlugin-Trojan
Version:        ?_?
Release:        0
Summary:        Trojan plugin for Qv2ray
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
License:        GPL-3.0-only
Url:            https://github.com/Qv2ray/QvPlugin-Trojan
Source:         %{name}-%{version}.tar.gz
%if 0%{?suse_version}
BuildRequires:  libqt5-qtbase-common-devel
BuildRequires:  libQt5Core-devel
BuildRequires:  libQt5Gui-devel
BuildRequires:  libQt5Network-devel
BuildRequires:  libQt5Widgets-devel
BuildRequires:  libopenssl-devel >= 1.1.0
BuildRequires:  libboost_system-devel >= 1.66.0
BuildRequires:  libboost_program_options-devel >= 1.66.0
BuildRequires:  ninja
%else
BuildRequires:  qt5-qtbase-devel
BuildRequires:  openssl-devel >= 1.1.0
BuildRequires:  boost-system >= 1.66.0
BuildRequires:  %{locale_package}
BuildRequires:  ninja-build
%endif
BuildRequires:  boost-devel >= 1.66.0

%define interface_version %(iv=%{version} && echo ${iv%.*})
Requires:       Qv2ray-Plugin-Interface = %{interface_version}

## needed libboost_system.so and libboost_program_options.so on Fedora
%if 0%{?fedora_version}
Requires:  boost-system >= 1.66.0
Requires:  boost-program-options
%endif

%description
A Trojan plugin for Qv2ray.

%prep
%setup -q
%define BUILD_SOURCE %{_builddir}/%{name}-%{version}
%define BUILD_DIR %{_builddir}/%{name}-%{version}/build
mkdir -p %{BUILD_DIR}

%build
%if 0%{?centos_version}
cd %{BUILD_DIR}
cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -GNinja 
%else
cmake -S %{BUILD_SOURCE} -B %{BUILD_DIR} \
    -DCMAKE_BUILD_TYPE=Release \
    -GNinja 
%endif
ninja -C %{BUILD_DIR}

%install
install -Dm 0644 %{BUILD_DIR}/libQvTrojanPlugin.so %{buildroot}%{_datadir}/qv2ray/plugins/libQvTrojanPlugin.so

%post
# notify restart qv2ray after first installation
if [ "$1" -le 1 ]; then
mkdir -p %{_localstatedir}/adm/update-messages
cat > %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something << EOF
INFO: You may need to restart your Qv2ray several time to load & enable this plugin.
EOF
fi

%postun

%files
%{_datadir}/qv2ray/plugins/libQvTrojanPlugin.so
%dir %{_datadir}/qv2ray
%dir %{_datadir}/qv2ray/plugins

%changelog

openSUSE Build Service is sponsored by