File discord-installer.spec of Package discord-installer

#
# spec file for package discord-installer
#
# Copyright (c) 2018 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/
#

Name:           discord-installer
Version:        0.0.11
Release:        0
Summary:        Downloads and installs Discord with libffmpeg.so provided in their package
License:        SUSE-NonFree
Group:          Amusements/Games/Other
Url:            https://discordapp.com/
BuildRoot:		%{_tmppath}/%{name}-%{version}-build
BuildRequires:	wget
ExclusiveArch:  x86_64
Provides:       discord
Conflicts:      discord
Requires:       wget libgtk-2_0-0 libnotify-tools libasound2 gconf2 mozilla-nss dbus-1-glib libXtst6 libX11-6 libstdc++6 libc++1 libatomic1

%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

%build

%install
mkdir -p %{buildroot}/opt/Discord/locales
mkdir -p %{buildroot}/opt/Discord/resources/bootstrap
mkdir -p %{buildroot}%{_datadir}/applications
mkdir -p %{buildroot}%{_datadir}/icons/hicolor/256x256/apps

%post
if wget --spider "https://discordapp.com/api/download?platform=linux&format=tar.gz" > /dev/null 2>&1; then
    echo "Installing Discord to '/opt/Discord'..."
    # download Discord tar
    wget -nv "https://discordapp.com/api/download?platform=linux&format=tar.gz" -O /tmp/discord-install.tar.gz || \
    { echo "Failed to download Discord "; exit 2; }
    if pgrep Discord ; then
    	pkill Discord
    	sleep 1
    	pkill -9 Discord
    fi
    # extract Discord tar to /opt/Discord and then remove tar
    tar xf /tmp/discord-install.tar.gz --overwrite -C /opt || { echo "Failed to extract Discord tar"; exit 2; }
    rm -f /tmp/discord-install.tar.gz
    # fix Exec line in .desktop file
    sed -i 's%^Exec=.*%Exec=discord%g' /opt/Discord/discord.desktop || { echo "Failed to fix discord.desktop"; exit 2; }
    # move .desktop file to /usr/share/applications/discord.desktop
    mv /opt/Discord/discord.desktop %{_datadir}/applications/discord.desktop || { echo "Failed to move discord.desktop"; exit 2; }
    # copy icon to /usr/share/icons/hicolor/256x256/apps/discord.png
    cp /opt/Discord/discord.png %{_datadir}/icons/hicolor/256x256/apps/discord.png || { echo "Failed to move discord.png"; exit 2; }
    # create symlink for /opt/Discord/Discord binary to /usr/bin/discord
    chmod +x /opt/Discord/Discord
	ln -sf /opt/Discord/Discord %{_bindir}/discord || { echo "Failed to create symlink to %{_bindir}/discord"; exit 2; }
    # run included postinst.sh
    chmod +x /opt/Discord/postinst.sh || { echo "Failed to make postinst.sh executable"; exit 2; }
    /opt/Discord/postinst.sh || { echo "Failed to run postinst.sh"; exit 2; }
    echo "Discord installed to '/opt/Discord'"
else
    echo "Could not connect to download server"
    exit 0
fi

%files
%dir /opt/Discord
%dir /opt/Discord/locales
%dir /opt/Discord/resources
%dir /opt/Discord/resources/bootstrap
%dir %{_datadir}/applications
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/256x256
%dir %{_datadir}/icons/hicolor/256x256/apps
%ghost /opt/Discord/blink_image_resources_200_percent.pak
%ghost /opt/Discord/content_resources_200_percent.pak
%ghost /opt/Discord/content_shell.pak
%ghost /opt/Discord/Discord
%ghost /opt/Discord/discord.png
%ghost /opt/Discord/icudtl.dat
%ghost /opt/Discord/libffmpeg.so
%ghost /opt/Discord/libnode.so
%ghost /opt/Discord/natives_blob.bin
%ghost /opt/Discord/pdf_viewer_resources.pak
%ghost /opt/Discord/postinst.sh
%ghost /opt/Discord/snapshot_blob.bin
%ghost /opt/Discord/ui_resources_200_percent.pak
%ghost /opt/Discord/views_resources_200_percent.pak
%ghost /opt/Discord/locales/am.pak
%ghost /opt/Discord/locales/ar.pak
%ghost /opt/Discord/locales/bg.pak
%ghost /opt/Discord/locales/bn.pak
%ghost /opt/Discord/locales/ca.pak
%ghost /opt/Discord/locales/cs.pak
%ghost /opt/Discord/locales/da.pak
%ghost /opt/Discord/locales/de.pak
%ghost /opt/Discord/locales/el.pak
%ghost /opt/Discord/locales/en-GB.pak
%ghost /opt/Discord/locales/en-US.pak
%ghost /opt/Discord/locales/es-419.pak
%ghost /opt/Discord/locales/es.pak
%ghost /opt/Discord/locales/et.pak
%ghost /opt/Discord/locales/fake-bidi.pak
%ghost /opt/Discord/locales/fa.pak
%ghost /opt/Discord/locales/fil.pak
%ghost /opt/Discord/locales/fi.pak
%ghost /opt/Discord/locales/fr.pak
%ghost /opt/Discord/locales/gu.pak
%ghost /opt/Discord/locales/he.pak
%ghost /opt/Discord/locales/hi.pak
%ghost /opt/Discord/locales/hr.pak
%ghost /opt/Discord/locales/hu.pak
%ghost /opt/Discord/locales/id.pak
%ghost /opt/Discord/locales/it.pak
%ghost /opt/Discord/locales/ja.pak
%ghost /opt/Discord/locales/kn.pak
%ghost /opt/Discord/locales/ko.pak
%ghost /opt/Discord/locales/lt.pak
%ghost /opt/Discord/locales/lv.pak
%ghost /opt/Discord/locales/ml.pak
%ghost /opt/Discord/locales/mr.pak
%ghost /opt/Discord/locales/ms.pak
%ghost /opt/Discord/locales/nb.pak
%ghost /opt/Discord/locales/nl.pak
%ghost /opt/Discord/locales/pl.pak
%ghost /opt/Discord/locales/pt-BR.pak
%ghost /opt/Discord/locales/pt-PT.pak
%ghost /opt/Discord/locales/ro.pak
%ghost /opt/Discord/locales/ru.pak
%ghost /opt/Discord/locales/sk.pak
%ghost /opt/Discord/locales/sl.pak
%ghost /opt/Discord/locales/sr.pak
%ghost /opt/Discord/locales/sv.pak
%ghost /opt/Discord/locales/sw.pak
%ghost /opt/Discord/locales/ta.pak
%ghost /opt/Discord/locales/te.pak
%ghost /opt/Discord/locales/th.pak
%ghost /opt/Discord/locales/tr.pak
%ghost /opt/Discord/locales/uk.pak
%ghost /opt/Discord/locales/vi.pak
%ghost /opt/Discord/locales/zh-CN.pak
%ghost /opt/Discord/locales/zh-TW.pak
%ghost /opt/Discord/resources/app.asar
%ghost /opt/Discord/resources/electron.asar
%ghost /opt/Discord/resources/bootstrap/discord_desktop_core.zip
%ghost /opt/Discord/resources/bootstrap/discord_erlpack.zip
%ghost /opt/Discord/resources/bootstrap/discord_game_utils.zip
%ghost /opt/Discord/resources/bootstrap/discord_rpc.zip
%ghost /opt/Discord/resources/bootstrap/discord_spellcheck.zip
%ghost /opt/Discord/resources/bootstrap/discord_utils.zip
%ghost /opt/Discord/resources/bootstrap/discord_voice.zip
%ghost /opt/Discord/resources/bootstrap/manifest.json
%ghost %{_datadir}/applications/discord.desktop
%ghost %{_datadir}/icons/hicolor/256x256/apps/discord.png
%ghost %{_bindir}/discord

%changelog
openSUSE Build Service is sponsored by