File owncast.spec of Package owncast

#
# spec file for package owncast
#
# Copyright (c) 2025 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/
#


Name:           owncast
Version:        0.2.3
Release:        0
Summary:        Take control over your live stream video by running it yourself
License:        MIT
URL:            https://owncast.online/
Source0:        https://github.com/%{name}/%{name}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
# Generated with `./vendor_web-assets.sh %{version}
Source2:        %{name}-%{version}-web.tar.gz
Source3:        %{name}.sysusers
Source4:        %{name}.service
BuildRequires:  golang(API) = 1.24
BuildRequires:  golang-packaging
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
Requires:       ffmpeg
%{?systemd_ordering}
%sysusers_requires

%description
Owncast is an open source, self-hosted, decentralized, single user live video streaming
and chat server for running your own live streams similar in style to the large mainstream options.

%prep
%autosetup -p1 -a1
tar -xzf %{SOURCE2}

%build
CGO_ENABLED=1
GO_LDFLAGS="${GO_LDFLAGS-} -s -w -linkmode external \
            -X github.com/owncast/owncast/config.VersionNumber=%{version} \
            -X github.com/owncast/owncast/config.BuildPlatform=''"
go build -a -installsuffix cgo -trimpath \
         -mod=vendor -buildmode=pie \
         -ldflags="${GO_LDFLAGS}" \
         -tags sqlite_omit_load_extension \
         -o owncast main.go

%sysusers_generate_pre %{SOURCE3} %{name}

%install
install -D -m 0755 owncast    %{buildroot}%{_sbindir}/owncast
install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf
install -D -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0750 -d %{buildroot}/var/lib/%{name}
install -D -m 0755 -d %{buildroot}/var/log/%{name}

%pre -f %{name}.pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license LICENSE
%doc README.md CONTRIBUTING.md docs/*
%{_sbindir}/owncast
%{_sysusersdir}/%{name}.conf
%{_unitdir}/%{name}.service
%dir  %attr(-,%{name},%{name})  /var/lib/%{name}/
%dir  %attr(-,%{name},%{name})  /var/log/%{name}/

%changelog
openSUSE Build Service is sponsored by