File trojan-go.spec of Package trojan-go
#
# spec file for package trojan-go
#
# Copyright (c) 2020 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/
#
# disable fedora debug packages, use explicit glibc-langpack follow openSUSE:Tools/obs-service-tar_scm
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version}
%global debug_package %{nil}
%define locale_package glibc-langpack-en
%endif
Name: trojan-go
Version: 0.8.2
Release: 0
Summary: A Trojan proxy written in Go
License: GPL-3.0-only
Group: Productivity/Networking/Web/Proxy
URL: https://github.com/p4gefau1t/trojan-go
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
Source2: geoip.dat
Source3: geosite.dat
BuildRequires: go >= 1.17
%if 0%{?fedora_version}
BuildRequires: %{locale_package}
%endif
BuildRequires: systemd-rpm-macros
BuildRequires: pkgconfig(systemd)
%description
A Trojan proxy written in Go. An unidentifiable mechanism that helps you bypass GFW.
%prep
%setup -q -a 1 -n %{name}-%{version}
%build
go build -mod=vendor -buildmode pie -ldflags="-s -w" -tags "full"
%install
install -d %{buildroot}%{_bindir}
install -m0755 %{name} %{buildroot}%{_bindir}/
install -d %{buildroot}%{_unitdir}/%{name}
install -m0644 example/%{name}.service %{buildroot}%{_unitdir}/
install -m0644 example/%{name}@.service %{buildroot}%{_unitdir}/
install -d %{buildroot}%{_sysconfdir}/%{name}
install -m0644 example/*.json %{buildroot}%{_sysconfdir}/%{name}/
install -d %{buildroot}%{_sbindir}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -d %{buildroot}%{_datadir}/%{name}
install -m0644 %{S:2} %{buildroot}%{_datadir}/%{name}/
install -m0644 %{S:3} %{buildroot}%{_datadir}/%{name}/
install -d %{buildroot}%{_datadir}/%{name}/example
install -m0644 example/* %{buildroot}%{_datadir}/%{name}/example/
%pre
%if 0%{?suse_version}
%service_add_pre %{name}.service %{name}@.service
## No need for Fedora/CentOS
%endif
%post
%if 0%{?suse_version}
%service_add_post %{name}.service %{name}@.service
%else
%systemd_post %{name}.service %{name}@.service
%endif
%preun
%if 0%{?suse_version}
%service_del_preun %{name}.service %{name}@.service
%else
%systemd_preun %{name}.service %{name}@.service
%endif
%postun
%if 0%{?suse_version}
%service_del_postun %{name}.service %{name}@.service
%else
%systemd_postun_with_restart %{name}.service %{name}@.service
%endif
%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}@.service
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*.json
%{_sbindir}/rc%{name}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/geoip.dat
%{_datadir}/%{name}/geosite.dat
%dir %{_datadir}/%{name}/example
%{_datadir}/%{name}/example/*
%changelog