Name:           livekit
Version:        1.9.11
Release:        alt1
Summary:        LiveKit WebRTC SFU media server
License:        Apache-2.0
Group:          Servers
Url:            https://github.com/livekit/livekit

#https://github.com/livekit/livekit/archive/refs/tags/v%{version}.tar.gz
Source:         %name.tar

# Vendored Go module deps (must contain ./vendor + vendor/modules.txt)
# Create once per version (outside hasher):
#   tarball=v%{version}
#   curl -L -o livekit-%{version}.tar.gz https://github.com/livekit/livekit/archive/refs/tags/${tarball}.tar.gz
#   tar -xf livekit-%{version}.tar.gz
#   cd livekit-%{version}
#   GOTOOLCHAIN=local go mod vendor
#   tar -cJf livekit-server-vendor-%{version}.tar.xz vendor
Source1:        livekit-server-vendor-%{version}.tar.xz

BuildRequires:  golang >= 1.24

%description
LiveKit is an open-source, scalable multi-user WebRTC SFU (Selective Forwarding Unit).
This package provides the livekit-server daemon.

%prep
%setup -a1
#%setup -q -n livekit-%{version}
# unpack vendored deps into the same tree (expects "vendor/" at archive root)
#%setup -q -T -D -a1

%build
# go.mod declares go 1.24.x + toolchain; prevent auto toolchain download
#export GOTOOLCHAIN=local
#export CGO_ENABLED=0

# Force offline build from vendor/
export GOFLAGS="-mod=vendor -trimpath"

go build -buildvcs=false -o livekit-server ./cmd/server

%install
install -Dpm0755 livekit-server %{buildroot}%{_sbindir}/livekit-server
install -Dpm0644 config-sample.yaml %{buildroot}%{_sysconfdir}/livekit/livekit.yaml

%files
#%license LICENSE
#%license NOTICE
%doc README.md CHANGELOG.md NOTICE LICENSE
%{_sbindir}/livekit-server
%config(noreplace) %{_sysconfdir}/livekit/livekit.yaml
