File v2raya.spec of Package v2raya

#
# spec file for package v2raya
#
# Copyright (c) 2023 SUSE LLC
#
# 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/
#

Name:           v2raya
Version:        2
Release:        0
Summary:        V2Ray Linux client supporting global transparent proxy
License:        AGPL-3.0-only
Group:          Productivity/Networking/Web/Proxy
URL:            https://github.com/v2rayA/v2rayA
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        web.tar.gz
Source3:        v2raya.rpmlintrc
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.21
BuildRequires:  systemd-rpm-macros

Requires:       (v2ray-core or xray-core)
Suggests:       xray-core

%{?systemd_ordering}
%{go_nostrip}
%{go_provides}

%description
A web GUI client of Project V which supports V2Ray, Xray, SS, SSR, Trojan and Pingtunnel

%prep
%autosetup -p1 -a1
tar -zxf %{S:2} -C %{_builddir}/%{name}-%{version}/service/server/router

%build
mv vendor ./service/vendor
cd service
%if 0%{?sle_version} == 150500
sed -i 's/^go 1\.21\.0$/go 1.21/' go.mod
%endif

%goprep .

%gobuild \
    -trimpath \
    -ldflags " \
        -s -w \
        -X 'github.com/v2rayA/v2rayA/conf.Version=%{version}' \
    " .

%install
%goinstall

mv %{buildroot}%{_bindir}/v2rayA %{buildroot}%{_bindir}/%{name}
install -dm 750 %{buildroot}%{_sysconfdir}/default
install -Dm 644 install/universal/%{name}.default %{buildroot}%{_sysconfdir}/default/%{name}
install -dm 750 %{buildroot}%{_sysconfdir}/%{name}

# systemd
install -Dm 644 install/universal/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -Dm 644 install/universal/%{name}-lite.service %{buildroot}%{_userunitdir}/%{name}.service
# desktop
install -Dm 644 install/universal/%{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop
# icon
install -Dm 644 install/universal/%{name}.png %{buildroot}%{_datadir}/icons/hicolor/512x512/apps/%{name}.png

install -d %{buildroot}%{_sbindir}/
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service
%systemd_user_post %{name}.service

%preun
%service_del_preun %{name}.service
%systemd_user_preun %{name}.service

%postun
%service_del_postun %{name}.service
%systemd_user_postun %{name}.service

%files
%license LICENSE
%doc README.md README_zh.md
%{_bindir}/%{name}
%config %{_sysconfdir}/default/%{name}
%dir %{_sysconfdir}/%{name}
%{_unitdir}/%{name}.service
%{_userunitdir}/%{name}.service
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/*
%{_sbindir}/rc%{name}

%changelog
openSUSE Build Service is sponsored by