File galene.spec of Package galene

#
# spec file for package galene
#
# Copyright (c) 2026 SUSE LLC and contributors
#
# 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/


%bcond_without  apparmor

Name:           galene
Version:        0.96.3
Release:        0
Summary:        Galène videoconferencing server
License:        MIT
URL:            https://galene.org/
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        %{name}.service
Source3:        %{name}.sysconfig
Source4:        ice-servers.json
Source5:        apparmor-usr.sbin.galene
Source21:       system-user-%{name}.conf
Patch1:         galene-html-sendselect-default.patch
BuildRequires:  go >= 1.21
BuildRequires:  fdupes
BuildRequires:  sysuser-tools

Requires(pre):  %fillup_prereq

%if %{with apparmor}
BuildRequires:  apparmor-abstractions
BuildRequires:  apparmor-rpm-macros
Recommends:     apparmor-abstractions
%endif

%description
Galène is a videoconferencing server implemented in Go which can be
deployed with moderate server resources.

%prep
%autosetup -p 1 -a 1

%build
go build \
   -mod=vendor \
   -buildmode=pie \
   -o bin/%{name}

# galenectl
cd galenectl || exit 11
go build \
   -mod=vendor \
   -buildmode=pie \
   -o ../bin/galenectl
cd .. || exit 11

# system-user
%sysusers_generate_pre %{SOURCE21} user

%install
%fdupes %{buildroot}/%{_prefix}

# Install the binaries
mkdir -p %{buildroot}%{_sbindir}
install -D -m 0755 bin/%{name} %{buildroot}%{_sbindir}/%{name}
install -D -m 0755 bin/galenectl %{buildroot}%{_sbindir}/galenectl

# Install static web content
for file in $(find static -type f); do
  install -D -m 0644 $file %{buildroot}%{_datadir}/%{name}/$file
done

# Install systemd unit and symbolic link
mkdir -p %{buildroot}%{_unitdir}
install -p -m644 %{SOURCE2} %{buildroot}%{_unitdir}/
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

# create config directory and create example config files
mkdir -p %{buildroot}%{_sysconfdir}/%{name}
install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/%{name}/ice-servers.json.example

# AppArmor profile
%if %{with apparmor}
mkdir -p %{buildroot}%{_sysconfdir}/apparmor.d
install -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/apparmor.d/usr.sbin.galene
%endif

# create service directories
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}/groups %{buildroot}%{_sharedstatedir}/%{name}/recordings

# create sysconfig file
mkdir -p %{buildroot}%{_fillupdir}
install -D -m 0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.%{name}

# system user
install -Dm644 %{SOURCE21} %{buildroot}%{_sysusersdir}/system-user-%{name}.conf

%check
%{buildroot}%{_sbindir}/%{name} --help

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

%post
%service_add_post %{name}.service
%{fillup_only galene}
%if %{with apparmor}
%apparmor_reload %{_sysconfdir}/apparmor.d/usr.sbin.galene
%endif

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%doc CHANGES
%doc README
%doc README.FRONTEND
%doc README.PROTOCOL
%license LICENCE
%{_sbindir}/%{name}
%{_sbindir}/galenectl

%dir %{_datadir}/%{name}
%dir %attr(0755, root, root) %{_datadir}/%{name}/static
%{_datadir}/%{name}/static/*

%{_sbindir}/rc%{name}
%{_unitdir}/%{name}.service
%{_sysusersdir}/system-user-%{name}.conf

%dir %attr(0750, root, %{name}) %{_sysconfdir}/%{name}
%config %attr(0640, root, %{name}) %{_sysconfdir}/%{name}/ice-servers.json.example

%{_fillupdir}/sysconfig.%{name}

%dir %attr(0750, root, %{name}) %{_sharedstatedir}/%{name}
%dir %attr(0570, %{name}, root) %{_sharedstatedir}/%{name}/groups
%dir %attr(0750, %{name}, %{name}) %{_sharedstatedir}/%{name}/recordings

%if %{with apparmor}
%dir %{_sysconfdir}/apparmor.d
%config %{_sysconfdir}/apparmor.d/usr.sbin.galene
%endif

%changelog
openSUSE Build Service is sponsored by