%global _build_id_links none %global debug_package %{nil} %global upstream_version 1.14.0-rc.1-reF1nd %global software_name sing-box Name: sing-box-ref1nd-testing Version: %{lua:print((rpm.expand("%upstream_version"):gsub("-", ".")))} Release: 1%{?dist} Summary: The universal proxy platform License: GPL-3.0-or-later URL: https://sing-box.sagernet.org/ # Source0 unpacks to sing-box-%%{upstream_version}/ (archive prefix set by the # vendor workflow). Filenames follow the Debian quilt orig naming # (_%%{deb_up}.orig.tar.gz) so one file serves both RPM and DEB builds. Source0: %{name}_1.14.0.rc.1.reF1nd.orig.tar.gz # Vendored Go modules (Debian-style orig-vendor component: contents of vendor/ only). Source1: %{name}_1.14.0.rc.1.reF1nd.orig-vendor.tar.gz BuildRequires: git, curl, tar, gcc, make, golang, systemd-rpm-macros, clang, llvm, kernel-headers %{?systemd_requires} Provides: %{software_name} = %{version}-%{release} Conflicts: %{software_name} Obsoletes: %{name} < %{version}-%{release} %description The universal proxy platform. %package bash-completion Summary: Bash completion for %{name} BuildArch: noarch Requires: %{name} = %{version}-%{release} Requires: bash-completion Supplements: (%{name} and bash-completion) Conflicts: %{software_name}-bash-completion Obsoletes: %{name}-bash-completion < %{version}-%{release} %description bash-completion Bash command line completion support for %{name}. %package zsh-completion Summary: Zsh completion for %{name} BuildArch: noarch Requires: %{name} = %{version}-%{release} Requires: zsh Supplements: (%{name} and zsh) Conflicts: %{software_name}-zsh-completion Obsoletes: %{name}-zsh-completion < %{version}-%{release} %description zsh-completion Zsh command line completion support for %{name}. %package fish-completion Summary: Fish completion for %{name} BuildArch: noarch Requires: fish Supplements: (%{name} and fish) Conflicts: %{software_name}-fish-completion Obsoletes: %{name}-fish-completion < %{version}-%{release} %description fish-completion Fish command line completion support for %{name}. %prep %autosetup -p1 -n %{software_name}-%{upstream_version} # Use vendored Go modules to minimize network access during build. # (In mock/Koji, network is typically disabled; without vendor/ this will fail.) # Source1 is a Debian-style orig-vendor component (contents of vendor/ only). mkdir -p vendor tar -xf %{SOURCE1} -C vendor if [ ! -f vendor/modules.txt ]; then echo "ERROR: vendor/modules.txt not found in Source1." >&2 exit 1 fi %build _base_tags=with_gvisor,with_quic,with_wireguard,with_utls,with_tailscale,with_clash_api,with_acme,with_dhcp,with_ebpf %ifarch riscv64 _tags=$_base_tags %else _tags=$_base_tags,with_purego,with_naive_outbound %endif # with_ebpf regenerates the embedded BPF objects from common/ebpf/native/*.bpf.c. # Upstream's `make ebpf_generate` cannot run in an offline build root: it pins # Android NDK r29 Clang (for bit-reproducible output) and needs bpf2go, which # is not part of the vendored Go modules. Compile the objects directly with # system clang instead. The flags below mirror common/ebpf/Makefile BPF_CFLAGS # plus bpf2go's built-in flags; verified to reproduce `make ebpf_generate` # output bit-for-bit. The committed bpfgen/*.go wrappers embed these .o files. if echo "$_tags" | grep -qw with_ebpf; then (cd common/ebpf _bpf_cflags="-mcpu=v1 -O2 -g0 -ffreestanding -mllvm -disable-block-placement -mllvm -disable-branch-fold -nostdinc -Inative -isystem $(clang -print-resource-dir)/include -isystem /usr/include" for _src in cgroup shared_network; do for _tgt in bpfel bpfeb; do env -u CPATH -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH \ clang $_bpf_cflags \ -Wunused-command-line-argument -target $_tgt \ -c native/$_src.bpf.c -o internal/bpfgen/${_src}_${_tgt}.o \ -fno-ident -fdebug-prefix-map=native=native -fdebug-compilation-dir . -g \ '-D__BPF_TARGET_MISSING="GCC error \"The eBPF is using target specific macros, please provide -target that is not bpf, bpfel or bpfeb\""' llvm-strip -g internal/bpfgen/${_src}_${_tgt}.o llvm-objcopy --remove-section=.BTF --remove-section=.BTF.ext internal/bpfgen/${_src}_${_tgt}.o done done) fi # Prefer offline build: do not use module proxy or sumdb. export GOPROXY=off export GOSUMDB=off export GOMODCACHE="$PWD/.gomodcache" CGO_ENABLED=1 go build \ -v \ -trimpath \ -buildmode=pie \ -mod=vendor \ -modcacherw \ -buildvcs=false \ -tags "$_tags" \ -ldflags " -X \"github.com/sagernet/sing-box/constant.Version=%{upstream_version}\" -s -w -buildid= -checklinkname=0" \ ./cmd/%{software_name} echo "u %{software_name} - \"Sing-box Service\" - -" > "release/config/%{software_name}.sysusers" install -d completions ./%{software_name} completion bash > completions/bash ./%{software_name} completion fish > completions/fish ./%{software_name} completion zsh > completions/zsh echo -n \ '// Allow sing-box to set domain and default-route polkit.addRule(function(action, subject) { if ((action.id == "org.freedesktop.resolve1.set-domains" || action.id == "org.freedesktop.resolve1.set-default-route" || action.id == "org.freedesktop.resolve1.set-dns-servers") && subject.user == "sing-box") { return polkit.Result.YES; } });' > release/config/%{software_name}.rules %install install -Dsm755 %{software_name} -t %{buildroot}%{_bindir} %ifnarch riscv64 install -Dsm755 vendor/github.com/sagernet/cronet-go/lib/linux_$(go env GOARCH)/libcronet.so \ %{buildroot}/usr/lib/libcronet.so %endif install -Dm644 "release/config/config.json" -t %{buildroot}%{_sysconfdir}/%{software_name} install -Dm644 "release/config/%{software_name}.service" -t %{buildroot}/usr/lib/systemd/system install -Dm644 "release/config/%{software_name}@.service" -t %{buildroot}/usr/lib/systemd/system install -Dm644 "release/config/%{software_name}.sysusers" %{buildroot}/usr/lib/sysusers.d/%{software_name}.conf install -Dm644 "release/config/%{software_name}.rules" %{buildroot}%{_datadir}/polkit-1/rules.d/%{software_name}.rules install -Dm644 "completions/bash" %{buildroot}%{_datadir}/bash-completion/completions/%{software_name} install -Dm644 "completions/fish" %{buildroot}%{_datadir}/fish/vendor_completions.d/%{software_name}.fish install -Dm644 "completions/zsh" %{buildroot}%{_datadir}/zsh/site-functions/_%{software_name} install -dm755 %{buildroot}%{_datadir}/%{software_name} %pre %if 0%{?suse_version} %service_add_pre %{software_name}.service %{software_name}@.service %endif %post %if 0%{?suse_version} %service_add_post %{software_name}.service %{software_name}@.service %else %systemd_post %{software_name}.service %{software_name}@.service %endif %preun %if 0%{?suse_version} %service_del_preun %{software_name}.service %{software_name}@.service %else %systemd_preun %{software_name}.service %{software_name}@.service %endif %postun %if 0%{?suse_version} %service_del_postun %{software_name}.service %{software_name}@.service %else %systemd_postun %{software_name}.service %{software_name}@.service %endif %files %license LICENSE %{_bindir}/%{software_name} %ifnarch riscv64 /usr/lib/libcronet.so %endif %dir %{_sysconfdir}/%{software_name} %config(noreplace) %{_sysconfdir}/%{software_name}/config.json /usr/lib/systemd/system/%{software_name}*.service /usr/lib/sysusers.d/%{software_name}.conf %dir %{_datadir}/polkit-1/rules.d %{_datadir}/polkit-1/rules.d/%{software_name}.rules %dir %{_datadir}/%{software_name} %files bash-completion %{_datadir}/bash-completion/completions/%{software_name} %files zsh-completion %dir %{_datadir}/zsh %dir %{_datadir}/zsh/site-functions %{_datadir}/zsh/site-functions/_%{software_name} %files fish-completion %dir %{_datadir}/fish %dir %{_datadir}/fish/vendor_completions.d %{_datadir}/fish/vendor_completions.d/%{software_name}.fish %changelog * Mon Dec 22 2025 Sim0n - 1.13.0.alpha.32.reF1nd-3 - carry libcronet.so * Sun Dec 21 2025 Sim0n - 1.13.0.alpha.32.reF1nd-2 - pure go mod * Sat Aug 16 2025 Sim0n - 1.13.0-alpha.2-reF1nd - Change config file install behavior * Sat Aug 16 2025 Sim0n - 1.13.0-alpha.2-reF1nd - Bump version - Change default config file name * Thu Aug 14 2025 Sim0n - 1.13.0-alpha.1-reF1nd - Bump version * Tue Aug 12 2025 Sim0n - 1.12.1-reF1nd - Bump version * Mon Aug 04 2025 Sim0n - 1.12.0-reF1nd1 - Add golang to BuildRequires and remove manual go download. - Add gcc and make to BuildRequires for CGO support. * Fri Aug 01 2025 Sim0n - 1.12.0.rc.3.reF1nd-1 - Initial package release