%global proj_name SagerNet Name: sing-box Version: 1.10.1 Release: 1%{?dist} Summary: The universal proxy platform. License: GPL-3.0-or-later URL: https://github.com/%{proj_name}/%{name} Source0: https://github.com/%{proj_name}/%{name}/archive/v%{version}/%{name}-v%{version}.tar.gz Source1: https://github.com/%{proj_name}/sing-geoip/releases/latest/download/geoip.db Source2: https://github.com/%{proj_name}/sing-geosite/releases/latest/download/geosite.db Source3: sing-box.sysusers %if 0%{?fedora} >= 38 Patch: systemd-unit-file.patch %else Patch0: systemd-unit-file.patch %endif BuildRequires: golang >= 1.18 BuildRequires: git >= 1.8.3.1 BuildRequires: gcc BuildRequires: systemd-units BuildRequires: systemd-rpm-macros %{?sysusers_requires_compat} Requires: systemd-units Requires: sing-box-geo %description The universal proxy platform. %package geo Summary: The geoip data file. BuildArch: noarch %description geo The geo database file. %global debug_package %{nil} %global source_date_epoch_from_changelog 0 %prep %setup -q -n %{name}-%{version} %if 0%{?fedora} >= 38 %patch 0 -p1 %else %patch0 -p1 %endif %build %define tags_go118 with_grpc,with_dhcp,with_wireguard,with_utls,with_reality_server,with_acme,with_clash_api,with_v2ray_api,with_gvisor %define tags_go120 with_quic,with_ech %if 0%{?fedora} >= 38 || 0%{?rhel} >= 8 %define tags %{tags_go118},%{tags_go120} %else %define tags %{tags_go118} %endif %define ldflags "-X 'github.com/sagernet/sing-box/constant.Version=%{version}-%{release}' -s -w -buildid=" go env -w GOPROXY=https://proxy.golang.org,direct go build -o sing-box -buildmode=pie -compiler gc -gcflags -trimpath -ldflags %{ldflags} -tags %{tags} ./cmd/sing-box %install install -d %{buildroot}%{_bindir} install -d %{buildroot}%{_datadir}/%{name} install -d %{buildroot}%{_sysconfdir}/%{name} install -d %{buildroot}%{_localstatedir}/log/%{name} install -d %{buildroot}%{_sysusersdir} install -d %{buildroot}%{_unitdir} install -d %{buildroot}%{_sharedstatedir}/%{name} install -p -m 0755 %{name} %{buildroot}%{_bindir}/%{name} install -p -m 0644 release/config/%{name}.service %{buildroot}%{_unitdir}/%{name}.service install -p -m 0644 release/config/%{name}@.service %{buildroot}%{_unitdir}/%{name}@.service install -p -m 0644 release/config/config.json %{buildroot}%{_sysconfdir}/%{name}/config.json install -p -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf install -p -m 0644 %{_sourcedir}/geoip.db %{buildroot}%{_datadir}/%{name}/geoip.db install -p -m 0644 %{_sourcedir}/geosite.db %{buildroot}%{_datadir}/%{name}/geosite.db %pre %sysusers_create_compat %{SOURCE3} %post chown -R sagernet:sagernet %{_sharedstatedir}/%{name} %files %defattr(-,root,root,-) %license LICENSE %{_bindir}/%{name} %attr(-, root, root) %{_unitdir}/%{name}.service %attr(-, root, root) %{_unitdir}/%{name}@.service %{_sysusersdir}/%{name}.conf %config(noreplace) %{_sysconfdir}/%{name}/config.json %{_sharedstatedir}/%{name} %files geo %{_datadir}/%{name}/geoip.db %{_datadir}/%{name}/geosite.db %changelog