# Generated by go2rpm 1 %bcond_without check %global build_timestamp %(date +"%Y%m%d") # https://github.com/Dreamacro/clash %global goipath github.com/Dreamacro/clash Version: 1.8.0 %gometa %global common_description %{expand: A rule-based tunnel in Go.} %global golicenses LICENSE %global godocs docs README.md Name: clash Release: %autorelease Summary: A rule-based tunnel in Go License: GPLv3 URL: %{gourl} Source0: %{gosource} Source1: clash.service Source2: clash@.service BuildRequires: systemd-rpm-macros BuildRequires: golang(github.com/Dreamacro/go-shadowsocks2/core) BuildRequires: golang(github.com/Dreamacro/go-shadowsocks2/shadowaead) BuildRequires: golang(github.com/Dreamacro/go-shadowsocks2/shadowstream) BuildRequires: golang(github.com/go-chi/chi/v5) BuildRequires: golang(github.com/go-chi/cors) BuildRequires: golang(github.com/go-chi/render) BuildRequires: golang(github.com/gofrs/uuid) BuildRequires: golang(github.com/gorilla/websocket) BuildRequires: golang(github.com/insomniacslk/dhcp/dhcpv4) BuildRequires: golang(github.com/miekg/dns) BuildRequires: golang(github.com/oschwald/geoip2-golang) BuildRequires: golang(github.com/sirupsen/logrus) BuildRequires: golang(go.etcd.io/bbolt) BuildRequires: golang(go.uber.org/atomic) BuildRequires: golang(go.uber.org/automaxprocs/maxprocs) BuildRequires: golang(golang.org/x/crypto/argon2) BuildRequires: golang(golang.org/x/crypto/chacha20poly1305) BuildRequires: golang(golang.org/x/net/http2) BuildRequires: golang(golang.org/x/net/publicsuffix) BuildRequires: golang(golang.org/x/sync/singleflight) BuildRequires: golang(golang.org/x/sys/unix) BuildRequires: golang(gopkg.in/yaml.v2) %if %{with check} # Tests BuildRequires: golang(github.com/docker/docker/api/types) BuildRequires: golang(github.com/docker/docker/api/types/container) BuildRequires: golang(github.com/docker/docker/client) BuildRequires: golang(github.com/docker/go-connections/nat) BuildRequires: golang(github.com/stretchr/testify/assert) %endif %description %{common_description} %gopkg %prep %goprep chmod -x docs/logo.png %build export LDFLAGS="-X github.com/Dreamacro/clash/constant.Version=%{version} \ -X github.com/Dreamacro/clash/constant.BuildTime=%{build_timestamp} \ $LDFLAGS" %gobuild -o %{gobuilddir}/bin/clash %{goipath} %install %gopkginstall install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vd %{buildroot}%{_userunitdir} install -m 0755 -vd %{buildroot}%{_unitdir} install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ install -m 0755 -vp %{S:1} %{buildroot}%{_userunitdir}/ install -m 0755 -vp %{S:2} %{buildroot}%{_unitdir}/ %if %{with check} %check # some ckecks needs docker daemon and networking # so we need to ignore the result of tests # but we can leave the left part running to see # the results. %gocheck ||: %endif %post %systemd_user_post clash.service %systemd_post clash@.service %preun %systemd_user_preun clash.service # disable --now seems don't work here. if [ $1 -eq 0 ] && [ -x /usr/bin/systemctl ] ; then # Package removal, not upgrade /usr/bin/systemctl --no-reload stop clash@*.service || : /usr/bin/systemctl --no-reload disable clash@.service || : fi %postun %systemd_user_postun_with_restart clash.service %systemd_postun_with_restart clash@*.service %files %license LICENSE %doc docs README.md %{_bindir}/clash %{_userunitdir}/clash.service %{_unitdir}/clash@.service %gopkgfiles %changelog %autochangelog