%global gover 1.20.12 %global proj_name v2fly Name: v2ray Version: 5.12.1 Release: 1%{?dist} Summary: The core of the network forwarding toolkit Project V License: MIT URL: https://github.com/%{proj_name}/%{name}-core Source0: https://github.com/%{proj_name}/%{name}-core/archive/v%{version}/%{name}-core-v%{version}.tar.gz Source1: v2ray.xml Source2: https://github.com/%{proj_name}/geoip/releases/latest/download/geoip.dat Source3: https://github.com/%{proj_name}/domain-list-community/releases/latest/download/dlc.dat Source4: https://dl.google.com/go/go%{gover}.linux-amd64.tar.gz Patch0: systemd-unit-file.patch %if !(0%{?rhel} < 8) BuildRequires: golang >= 1.20 %endif BuildRequires: git >= 1.8 BuildRequires: gcc BuildRequires: systemd-units Requires: systemd-units Requires: v2ray-geoip %description The core of Project V, which is a series of tools for network forwarding. %package firewalld Summary: The example firewalld service file. BuildArch: noarch %description firewalld The example firewalld service file. %package geoip Summary: The geoip data file. BuildArch: noarch %description geoip The geoip data file. %global debug_package %{nil} %prep %if 0%{?rhel} < 8 %setup -b 4 -n go %endif %setup -q -n %{name}-core-%{version} %if 0%{?fedora} >= 38 %patch 0 -p1 %else %patch0 -p1 %endif cp %{_sourcedir}/%{name}.xml ./ %build export GO111MODULE=on %if 0%{?rhel} < 8 export GOPATH=$(pwd)/../gopath export GOROOT=$(pwd)/../go export PATH=$PATH:$GOROOT/bin %endif %define ldflags "-s -w -buildid= -X github.com/v2fly/v2ray-core/v5.codename=%{?dist} -X github.com/v2fly/v2ray-core/v5.build=fedora-copr -X github.com/v2fly/v2ray-core/v5.version=%{version}" go build -o v2ray -buildmode=pie -compiler gc -gcflags -trimpath=%{gopath} -asmflags -trimpath=%{gopath} -ldflags %{ldflags} ./main %pre [ -d "/usr/bin/v2ray" ] && rm -rf "/usr/bin/v2ray" || true %install install -d %{buildroot}%{_bindir} install -d %{buildroot}%{_datadir}/%{name} install -d %{buildroot}%{_sysconfdir}/%{name} install -d %{buildroot}%{_usr}/lib/firewalld/services/ install -d %{buildroot}%{_localstatedir}/log/%{name} install -d %{buildroot}%{_unitdir} install -p -m 0755 %{name} %{buildroot}%{_bindir}/%{name} install -p -m 0644 $(pwd)/release/config/systemd/system/%{name}.service %{buildroot}%{_unitdir}/%{name}.service install -p -m 0644 $(pwd)/release/config/systemd/system/%{name}@.service %{buildroot}%{_unitdir}/%{name}@.service install -p -m 0644 $(pwd)/release/config/vpoint_vmess_freedom.json %{buildroot}%{_sysconfdir}/%{name}/config.json install -p -m 0644 $(pwd)/v2ray.xml %{buildroot}%{_usr}/lib/firewalld/services/v2ray.xml install -p -m 0644 %{_sourcedir}/geoip.dat %{buildroot}%{_datadir}/%{name}/geoip.dat install -p -m 0644 %{_sourcedir}/dlc.dat %{buildroot}%{_datadir}/%{name}/geosite.dat %post [ -f "/usr/bin/v2ray/geoip.dat" ] && rm -f /usr/bin/v2ray/geoip.dat || true [ -f "/usr/bin/v2ray/geosite.dat" ] && rm -f /usr/bin/v2ray/geosite.dat || true %files %defattr(-,root,root,-) %license LICENSE %{_bindir}/%{name} %attr(-, root, root) %{_unitdir}/%{name}.service %attr(-, root, root) %{_unitdir}/%{name}@.service %config(noreplace) %{_sysconfdir}/%{name}/config.json %files geoip %{_datadir}/%{name}/geoip.dat %{_datadir}/%{name}/geosite.dat %files firewalld %config(noreplace) %{_usr}/lib/firewalld/services/v2ray.xml %changelog