File Qv2ray-preview.spec of Package Qv2ray-preview

#
# spec file for package Qv2ray
#
# 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
%define interface_version 3

Name:           Qv2ray-preview
Version:        2.1.2
Release:        0
Summary:        Unleash Your V2Ray
License:        GPL-3.0-only
Group:          Productivity/Networking/Web/Proxy
Url:            https://github.com/Qv2ray/Qv2ray
Source0:        Qv2ray-%{version}.tar.gz
%if 0%{?suse_version}
# for openSUSE
BuildRequires:  libqt5-qtbase-common-devel >= 5.11
BuildRequires:  libQt5Core-devel
BuildRequires:  libQt5Gui-devel
BuildRequires:  libQt5Network-devel
BuildRequires:  libQt5Widgets-devel
BuildRequires:  libQt5Concurrent-devel
BuildRequires:  libqt5-linguist-devel
BuildRequires:  libqt5-qtsvg-devel
BuildRequires:  grpc-devel
BuildRequires:  update-desktop-files
BuildRequires:  golang-packaging
BuildRequires:  ninja
%if 0%{?suse_version} >= 1550
## for abseil-cpp about absl::xx realted not found
## maybe related upstream change: https://build.opensuse.org/package/rdiff/devel:tools/grpc?linkrev=base&rev=72
BuildRequires:  abseil-cpp-devel
%endif
%else
# for Fedora/CentOS/ ...
BuildRequires:  qt5-qtbase-devel >= 5.11
BuildRequires:  qt5-linguist
BuildRequires:  qt5-qtsvg-devel
BuildRequires:  grpc-devel
BuildRequires:  grpc-plugins
BuildRequires:  %{locale_package}
BuildRequires:  desktop-file-utils
BuildRequires:  ninja-build
%endif
BuildRequires:  protobuf-devel
BuildRequires:  libcurl-devel

Requires:       openssl
Conflicts:      Qv2ray
Provides:       Qv2ray-Plugin-Interface = %{interface_version}
%if 0%{?suse_version} || 0%{?fedora_version} || 0%{?centos_version} >= 800 
Recommends:     v2ray-core
%endif

%description
Qv2ray, A Qt frontend for v2ray. Written in c++.
Features:
    * Cross-platform, multi-distribution support
    * Versatile Host Importing
    * Subscriptions
    * Built-in Host Editors
    * (Almost) Full Functionality Support
    * Real-time Speed & Data Usage Monitoring
    * Latency Testing (TCP) 
More detail Please check https://qv2ray.net

This is the dev branch of Qv2ray.

%prep
%setup -qn Qv2ray-%{version}
%define INSTALL_PREFIX %{buildroot}/usr
%define BUILD_SOURCE %{_builddir}/Qv2ray-%{version}
%define BUILD_DIR %{_builddir}/Qv2ray-%{version}/build
mkdir -p %{BUILD_DIR}

%build
# build
export _QV2RAY_BUILD_INFO_="Qv2ray dev branch built by openSUSE Build Service"
export _QV2RAY_BUILD_EXTRA_INFO_="(Official Build) $(uname -a | cut -d ' ' -f3,13), Qt $(pkg-config --modversion Qt5Core)"
%if 0%{?centos_version}
cd %{BUILD_DIR}
cmake .. \
%else
cmake -S %{BUILD_SOURCE} -B %{BUILD_DIR} \
%endif
    -DCMAKE_INSTALL_PREFIX="%{INSTALL_PREFIX}" \
    -DQV2RAY_TRANSLATION_PATH="/usr/share/qv2ray/lang" \
    -DQV2RAY_DEFAULT_VCORE_PATH="/usr/bin/v2ray" \
    -DQV2RAY_DEFAULT_VASSETS_PATH="/usr/share/v2ray" \
    -DQV2RAY_DISABLE_AUTO_UPDATE=ON \
    -DQV2RAY_ZXING_PROVIDER="module" \
    -DCMAKE_BUILD_TYPE=Release \
    -GNinja 
ninja -C %{BUILD_DIR}

%install
ninja -C %{BUILD_DIR} install

## keep this useless section to make Leap happy
%if 0%{?suse_version}
%suse_update_desktop_file -r qv2ray Network RemoteAccess
%endif

%post
%postun

%files
%license LICENSE
%doc README.md
%{_bindir}/qv2ray
%{_datadir}/applications/qv2ray.desktop
%{_datadir}/icons/hicolor
%{_datadir}/metainfo/qv2ray.metainfo.xml
%{_datadir}/qv2ray/lang/*.qm
%{_datadir}/qv2ray/plugins/*
%dir %{_datadir}/qv2ray
%dir %{_datadir}/qv2ray/lang
%dir %{_datadir}/qv2ray/plugins

%changelog

openSUSE Build Service is sponsored by