%global debug_package %{nil} %global forgeurl https://github.com/v2fly/v2ray-core Version: 4.31.0 %forgemeta Name: v2ray Release: 1%{?dist} Summary: A platform for building proxies to bypass network restrictions License: MIT URL: %{forgeurl} Source0: %{forgesource} %if 0%{?fedora} BuildRequires: compiler(go-compiler) %else BuildRequires: golang >= 1.15 %endif BuildRequires: systemd-rpm-macros Recommends: v2ray-geoip Recommends: v2ray-domain-list-community %define gocompilerflags -buildmode pie -compiler gc %define gobuild(o:) %{expand: %global _dwz_low_mem_die_limit 0 go build %{?gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**}; } %description v2ray is a set of network tools that help you to build your own computer network. More infomations on https://www.v2fly.org/ %prep %forgesetup %if 0%{?rhel} %global extractdir v2ray-core-%{version} %endif %global gobuilddir %{_builddir}/%{extractdir} %global _src_dir_config %{gobuilddir}/release/config %global _src_dir_unit %{_src_dir_config}/systemd/system sed -i 's|/usr/local/bin|%{_bindir}|' %{_src_dir_unit}/v2ray.service sed -i 's|/usr/local/etc|%{_sysconfdir}|' %{_src_dir_unit}/v2ray.service sed -i 's|/usr/local/bin|%{_bindir}|' %{_src_dir_unit}/v2ray@.service sed -i 's|/usr/local/etc|%{_sysconfdir}|' %{_src_dir_unit}/v2ray@.service %build export GOPROXY='https://proxy.golang.org,direct' export CGO_ENABLED=0 LDFLAGS="-s -w" %gobuild -o %{_builddir}/bin/v2ray %{gobuilddir}/main export BUILDTAGS="confonly" %gobuild -o %{_builddir}/bin/v2ctl %{gobuilddir}/infra/control/main %install # Install v2ray binaries install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vp %{_builddir}/bin/v2ray %{buildroot}%{_bindir}/v2ray install -m 0755 -vp %{_builddir}/bin/v2ctl %{buildroot}%{_bindir}/v2ctl # Install v2ray assets directory install -m 0755 -vd %{buildroot}%{_datadir}/v2ray # Install v2ray systemd unit files install -m 0755 -vd %{buildroot}%{_unitdir} install -m 0644 -vp %{_src_dir_unit}/v2ray.service %{buildroot}%{_unitdir}/v2ray.service install -m 0644 -vp %{_src_dir_unit}/v2ray@.service %{buildroot}%{_unitdir}/v2ray@.service # Install v2ray default config file install -m 0755 -vd %{buildroot}%{_sysconfdir}/v2ray install -m 0644 -vp %{_src_dir_config}/config.json %{buildroot}%{_sysconfdir}/v2ray/config.json %files %license LICENSE %doc README.md # v2ray binaries %{_bindir}/v2ray %{_bindir}/v2ctl # v2ray assets directory %dir %{_datadir}/v2ray # v2ray systemd unit files %{_unitdir}/v2ray.service %{_unitdir}/v2ray@.service # v2ray default config file %dir %{_sysconfdir}/v2ray %config(noreplace) %{_sysconfdir}/v2ray/config.json # Scriptlets Start %post V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')" if [[ -z "$V2RAY_CUSTOMIZE" ]]; then %systemd_post v2ray.service else %systemd_post $V2RAY_CUSTOMIZE fi %preun V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')" if [[ -z "$V2RAY_CUSTOMIZE" ]]; then %systemd_preun v2ray.service else %systemd_preun $V2RAY_CUSTOMIZE fi %postun V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')" if [[ -z "$V2RAY_CUSTOMIZE" ]]; then %systemd_postun_with_restart v2ray.service else %systemd_postun_with_restart $V2RAY_CUSTOMIZE fi # Scriptlets End %changelog * Wed Oct 07 2020 sixg0000d - 4.30.0 - 1 - Make spec file automatically * Sat Sep 26 2020 sixg0000d - 4.29.0 - 0 - Rename some macros. - Minor modify BuildRequires. - Transfor Requires assets to Recommends.