File discord.spec of Package discord
#
# spec file for package discord
#
# Copyright (c) 2022 SUSE LLC.
# Copyright (c) 2021 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#
# Require bash for extglob in install section.
%global _buildshell /bin/bash
%global __requires_exclude ^(libffmpeg|libnode).*
%global __provides_exclude ^(libffmpeg|libnode).*
# This is to enable build with patent encoumbered codecs. Not allowed in OBS
%bcond_with x264
Name: discord
Version: 0.0.20
Release: 0
Summary: Voice and Text Chat for Gamers
License: SUSE-NonFree
Group: Productivity/Networking/Instant Messenger
URL: https://discordapp.com/
Source0: https://dl.discordapp.net/apps/linux/%{version}/%{name}-%{version}.tar.gz
#Source0: https://discordapp.com/api/download?platform=linux&format=tar.gz
Source2: discord-symbolic.svg
Source3: https://raw.githubusercontent.com/flathub/com.discordapp.Discord/master/com.discordapp.Discord.appdata.xml
Source99: PERMISSION
ExclusiveArch: x86_64
BuildRequires: desktop-file-utils
BuildRequires: hicolor-icon-theme
BuildRequires: update-desktop-files
BuildRequires: unzip
Requires: libatomic1
Conflicts: discord
#Patent free ffmpeg config
#Snippets from https://github.com/orionhealth/electron-packager-plugin-non-proprietary-codecs-ffmpeg/blob/master/src/downloadFFMPEG.js
%define electronVersion 10.4.3
%define ffmpegarch x64
%define ffmpegplatform linux
%define ffmpegFileName ffmpeg-v%{electronVersion}-%{ffmpegplatform}-%{ffmpegarch}.zip
#eg. https://github.com/electron/electron/releases/download/v1.6.11/ffmpeg-v1.6.11-linux-x64.zip
Source1: https://github.com/electron/electron/releases/download/v%{electronVersion}/%{ffmpegFileName}
%description
Discord is a voice and text chat for gamers. The Text chat supports
inline images and videos. Voice chat includes a jitter buffer,
automatic gain control, noise suppression, echo cancellation.
Server-to-client communications are encrypted.
%prep
%setup -q -n Discord
%setup -q -T -a 1 -c -n ffmpeg
%build
%if %{with x264}
# nothing to do
:
%else
rm %{_builddir}/Discord/libffmpeg.so
cp %{_builddir}/ffmpeg/libffmpeg.so %{_builddir}/Discord/
%endif
%install
cd %{_builddir}/Discord
install -Dm644 discord.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
desktop-file-install \
--dir=%{buildroot}%{_datadir}/applications \
--set-key=Exec \
--set-value=%{_bindir}/%{name} \
%{name}.desktop
install -Dm755 chrome-sandbox %{buildroot}%{_libdir}/%{name}/chrome-sandbox
install -Dm755 libffmpeg.so %{buildroot}%{_libdir}/%{name}/libffmpeg.so
install -Dm755 libEGL.so %{buildroot}%{_libdir}/%{name}/libEGL.so
install -Dm755 libGLESv2.so %{buildroot}%{_libdir}/%{name}/libGLESv2.so
install -Dm644 %{SOURCE2} %{buildroot}%{_datadir}/icons/hicolor/symbolic/apps/%{name}-symbolic.svg
install -Dm644 %{SOURCE3} %{buildroot}%{_datadir}/appdata/com.discordapp.Discord.appdata.xml
# install share
mkdir -p %{buildroot}%{_libdir}/%{name}
shopt -s extglob
cp -r !(discord*|*.so) %{buildroot}%{_libdir}/%{name}
shopt -u extglob
# fix missing icon in some environments
ln -sf %{_datadir}/icons/hicolor/256x256/apps/%{name}.png %{buildroot}%{_libdir}/%{name}
# Executable checks for resources in its directory so it cannot be in bin.
mkdir -p %{buildroot}%{_bindir}
ln -s %{_libdir}/%{name}/Discord %{buildroot}%{_bindir}/%{name}
%post
%if 0%{?suse_version} < 1500
%desktop_database_post
%endif
chmod 0755 %{_libdir}/%{name}/Discord
%if 0%{?suse_version} < 1500
%postun
%desktop_database_postun
%endif
%files
%defattr(-,root,root)
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
%{_datadir}/icons/hicolor/symbolic/apps/%{name}-symbolic.svg
%{_datadir}/appdata/com.discordapp.Discord.appdata.xml
%{_libdir}/%{name}
%changelog