Name: clash Summary: A rule-based tunnel in Go Version: 1.0.0 Release: 2%{?dist} URL: https://github.com/Dreamacro/clash License: MIT Source0: %{URL}/archive/v%{version}.tar.gz#/%{name}-v%{version}.tar.gz Source1: clash.service Source2: clash@.service BuildRequires: git BuildRequires: wget BuildRequires: compiler(go-compiler) BuildRequires: systemd-rpm-macros %define gobuild(o:) %{expand: # https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12 %global _dwz_low_mem_die_limit 0 %ifnarch ppc64 %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} \\ go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "-X github.com/Dreamacro/clash/constant.Version=%{version} ${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**}; %else %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} \\ go build -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "-X github.com/Dreamacro/clash/constant.Version=%{version} ${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**}; %endif } %description A rule-based tunnel in Go. %prep %setup -q -n %{name}-%{version} %build export GOPATH=$(pwd)/_build mkdir -p $(pwd)/%{_target_platform} export OUT=$(pwd)/%{_target_platform} %gobuild -o $OUT/clash %post %systemd_user_post clash.service %systemd_post clash@.service %preun %systemd_user_preun clash.service %systemd_preun clash@.service %postun %systemd_user_postun_with_restart clash.service %systemd_postun_with_restart clash@*.service %install mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_userunitdir} mkdir -p %{buildroot}%{_unitdir} install -m 0755 -vp %{_target_platform}/* %{buildroot}%{_bindir}/ install -m 0755 -vp %{S:1} %{buildroot}%{_userunitdir}/ install -m 0755 -vp %{S:2} %{buildroot}%{_unitdir}/ %files %defattr(-,root,root,-) %{_bindir}/* %{_userunitdir}/* %{_unitdir}/* %changelog * Mon Jul 27 08:07:58 GMT 2020 Qiyu Yan - 1.0.0-2 - Add unit files, taken from - https://github.com/archlinux/svntogit-community/tree/packages/clash/trunk