File QvPlugin-Command.spec of Package QvPlugin-Command
#
# spec file for package QvPlugin-Command
#
# 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-Command
Version: ?_?
Release: 0
Summary: Run any commands when something happens in 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-Command
Source: %{name}-%{version}.tar.gz
%if 0%{?suse_version}
BuildRequires: libqt5-qtbase-common-devel
BuildRequires: libQt5Core-devel
BuildRequires: libQt5Gui-devel
BuildRequires: libQt5Widgets-devel
BuildRequires: ninja
%else
BuildRequires: qt5-qtbase-devel
BuildRequires: %{locale_package}
BuildRequires: ninja-build
%endif
%define interface_version %(iv=%{version} && echo ${iv%.*})
Requires: Qv2ray-Plugin-Interface = %{interface_version}
%description
A Qv2ray plugin which let you run any commands when something happens in 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 \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-GNinja
%endif
ninja -C %{BUILD_DIR}
%install
install -Dm 0644 %{BUILD_DIR}/libQvCommandPlugin.so %{buildroot}%{_datadir}/qv2ray/plugins/libQvCommandPlugin.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/libQvCommandPlugin.so
%dir %{_datadir}/qv2ray
%dir %{_datadir}/qv2ray/plugins
%changelog