Support OpenSUSE, resolve #5
Unlike [gitkraken](https://github.com/RPM-Outpost/gitkraken), the Mageia support isn't included for now, because the Mageia repositories doesn't provide libcxx, which is required by Discord. Maybe I'll find a solution later...
This commit is contained in:
parent
5a219b3fdb
commit
50a7345ac8
5 changed files with 40 additions and 75 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
# Initializes $installer and $distrib
|
# Initializes $installer and $distrib
|
||||||
if hash dnf 2>/dev/null; then
|
if hash dnf 2>/dev/null; then
|
||||||
# Fedora, CentOS
|
# Fedora, CentOS
|
||||||
installer="dnf install"
|
installer="dnf install --allowerasing"
|
||||||
distrib="redhat"
|
distrib="redhat"
|
||||||
elif hash zypper 2>/dev/null; then
|
elif hash zypper 2>/dev/null; then
|
||||||
# OpenSUSE
|
# OpenSUSE
|
||||||
|
|
@ -57,7 +57,7 @@ manage_dir() {
|
||||||
mkdir -p "$1"
|
mkdir -p "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ask_installpkg [all] [allowerasing]
|
# ask_installpkg [all]
|
||||||
## Asks the user if they want to install the newly created package.
|
## Asks the user if they want to install the newly created package.
|
||||||
ask_installpkg() {
|
ask_installpkg() {
|
||||||
if [[ $1 == "all" || $2 == "all" ]]; then
|
if [[ $1 == "all" || $2 == "all" ]]; then
|
||||||
|
|
@ -69,16 +69,12 @@ ask_installpkg() {
|
||||||
case "$answer" in
|
case "$answer" in
|
||||||
y|Y)
|
y|Y)
|
||||||
cd "$rpm_dir/$arch"
|
cd "$rpm_dir/$arch"
|
||||||
if [[ $1 == "all" || $2 == "all" ]]; then
|
if [[ $1 == "all" ]]; then
|
||||||
rpm_filename=$(find -type f -name '*.rpm' -printf '%P\n')
|
rpm_filename=$(find -type f -name '*.rpm' -printf '%P\n')
|
||||||
else
|
else
|
||||||
rpm_filename=$(find -maxdepth 1 -type f -name '*.rpm' -printf '%P\n' -quit)
|
rpm_filename=$(find -maxdepth 1 -type f -name '*.rpm' -printf '%P\n' -quit)
|
||||||
fi
|
fi
|
||||||
if [[ $1 == "allowerasing" || $2 == "allowerasing" ]]; then
|
sudo_install $rpm_filename
|
||||||
sudo dnf install --allowerasing $rpm_filename
|
|
||||||
else
|
|
||||||
sudo dnf install "$rpm_filename"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Packag$pl not installed."
|
echo "Packag$pl not installed."
|
||||||
|
|
@ -87,11 +83,7 @@ ask_installpkg() {
|
||||||
|
|
||||||
# sudo_install pkg [options]
|
# sudo_install pkg [options]
|
||||||
sudo_install() {
|
sudo_install() {
|
||||||
if [[ $# -eq 1 ]]; then
|
sudo $installer "$@"
|
||||||
sudo $installer "$1"
|
|
||||||
else
|
|
||||||
sudo $installer "$1" $2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# sudo_install_prompt prompt pkg [options]
|
# sudo_install_prompt prompt pkg [options]
|
||||||
|
|
|
||||||
|
|
@ -3,33 +3,45 @@
|
||||||
# This script downloads the latest version of Discord for linux, and creates a package with rpmbuild.
|
# This script downloads the latest version of Discord for linux, and creates a package with rpmbuild.
|
||||||
|
|
||||||
source terminal-colors.sh # Adds color variables
|
source terminal-colors.sh # Adds color variables
|
||||||
source basic-checks.sh # Checks that rpmbuild is available and that the script isn't started as root
|
|
||||||
source common-functions.sh # Adds utilities functions
|
source common-functions.sh # Adds utilities functions
|
||||||
|
source basic-checks.sh # Checks that rpmbuild is available and that the script isn't started as root
|
||||||
|
|
||||||
rpm_dir="$PWD/RPMs"
|
rpm_dir="$PWD/RPMs"
|
||||||
work_dir="$PWD/work"
|
work_dir="$PWD/work"
|
||||||
downloaded_dir="$work_dir/discord"
|
downloaded_dir="$work_dir/discord"
|
||||||
desktop_model="$PWD/discord.desktop"
|
desktop_model="$PWD/discord.desktop"
|
||||||
|
spec_file="$PWD/discord.spec"
|
||||||
arch='x86_64'
|
arch='x86_64'
|
||||||
|
|
||||||
|
# Settings according to the distribution
|
||||||
|
if [[ $distrib == "redhat" ]]; then
|
||||||
|
pkg_req='glibc, alsa-lib, GConf2, libnotify, nspr >= 4.13, nss >= 3.27, libstdc++ >= 6, libX11 >= 1.6, libXtst >= 1.2, libappindicator, libcxx%{?_isa}'
|
||||||
|
elif [[ $distrib == "suse" ]]; then
|
||||||
|
pkg_req='glibc, alsa, gconf2, libnotify, mozilla-nspr >= 4.13, mozilla-nss >= 3.27, libstdc++6, libX11 >= 1.6, libXtst >= 1.2, libappindicator, libc++1'
|
||||||
|
else
|
||||||
|
disp "${red}Sorry, your distribution isn't supported (yet).$reset"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks that the version (stable/canary) is given as a parameter.
|
# Checks that the version (stable/canary) is given as a parameter.
|
||||||
if [[ $# -ne 1 || $1 != "stable" && $1 != "canary" ]]; then
|
if [[ $# -ne 1 || $1 != "stable" && $1 != "canary" ]]; then
|
||||||
disp "${red}Wrong or missing parameters!$reset"
|
disp "${red}Wrong or missing parameters!$reset"
|
||||||
echo 'Usage: create-package.sh stable/canary'
|
echo 'Usage: create-package.sh stable/canary'
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
discord_type="$1"
|
|
||||||
spec_file="$PWD/discord-$discord_type.spec"
|
|
||||||
|
|
||||||
if [[ $discord_type == "canary" ]]; then
|
# Settings according to the discord type (canary or stable)
|
||||||
|
if [[ $1 == "canary" ]]; then
|
||||||
app_name='Discord Canary'
|
app_name='Discord Canary'
|
||||||
exe_name='DiscordCanary'
|
exe_name='DiscordCanary'
|
||||||
|
pkg_name='discord-canary'
|
||||||
download_url='https://discordapp.com/api/download/canary'
|
download_url='https://discordapp.com/api/download/canary'
|
||||||
cut_part=3
|
cut_part=3
|
||||||
desktop_file="$work_dir/discord-canary.desktop"
|
desktop_file="$work_dir/discord-canary.desktop"
|
||||||
else
|
else
|
||||||
app_name='Discord'
|
app_name='Discord'
|
||||||
exe_name='Discord'
|
exe_name='Discord'
|
||||||
|
pkg_name='discord-stable'
|
||||||
download_url='https://discordapp.com/api/download'
|
download_url='https://discordapp.com/api/download'
|
||||||
cut_part=2
|
cut_part=2
|
||||||
desktop_file="$work_dir/discord-stable.desktop"
|
desktop_file="$work_dir/discord-stable.desktop"
|
||||||
|
|
@ -37,7 +49,7 @@ fi
|
||||||
|
|
||||||
# Downloads the discord tar.gz archive and puts its name in the global variable archive_name.
|
# Downloads the discord tar.gz archive and puts its name in the global variable archive_name.
|
||||||
download_discord() {
|
download_discord() {
|
||||||
echo "Downloading discord $discord_type for linux..."
|
echo "Downloading $app_name for linux..."
|
||||||
wget -q --show-progress --content-disposition "${download_url}?platform=linux&format=tar.gz"
|
wget -q --show-progress --content-disposition "${download_url}?platform=linux&format=tar.gz"
|
||||||
archive_name="$(ls *.tar.gz)"
|
archive_name="$(ls *.tar.gz)"
|
||||||
}
|
}
|
||||||
|
|
@ -73,28 +85,27 @@ extract "$archive_name" "$downloaded_dir" "--strip 1" # --strip 1 gets rid of th
|
||||||
|
|
||||||
# Gets the discord's version number + icon file name
|
# Gets the discord's version number + icon file name
|
||||||
echo 'Analysing the files...'
|
echo 'Analysing the files...'
|
||||||
version_number="$(echo "$archive_name" | cut -d'-' -f$cut_part | rev | cut -c 8- | rev)"
|
pkg_version="$(echo "$archive_name" | cut -d'-' -f$cut_part | rev | cut -c 8- | rev)"
|
||||||
# cut -d'-' -fn splits the archive's name around the '-' character, and takes the n-th part
|
# cut -d'-' -fn splits the archive's name around the '-' character, and takes the n-th part
|
||||||
# For example if archive_name is "discord-0.0.1.tar.gz" we get "0.0.1.tar.gz"
|
# For example if archive_name is "discord-0.0.1.tar.gz" we get "0.0.1.tar.gz"
|
||||||
# Then, rev | cut -c 8- | rev reverse the string, removes the first 7 characters, and re-reverse it.
|
# Then, rev | cut -c 8- | rev reverse the string, removes the first 7 characters, and re-reverse it.
|
||||||
# This actually removes the last 8 characters, ie the ".tar.gz" part.
|
# This actually removes the last 8 characters, ie the ".tar.gz" part.
|
||||||
# So in our example we'll get version_number=0.0.1
|
# So in our example we'll get pkg_version=0.0.1
|
||||||
|
|
||||||
cd "$downloaded_dir"
|
cd "$downloaded_dir"
|
||||||
icon_name="$(ls *.png)"
|
icon_name="$(ls *.png)"
|
||||||
echo " -> Version: $version_number"
|
echo " -> Version: $pkg_version"
|
||||||
echo " -> Icon: $icon_name"
|
echo " -> Icon: $icon_name"
|
||||||
|
|
||||||
|
|
||||||
echo 'Creating the .desktop file...'
|
echo 'Generating desktop entry...'
|
||||||
sed "s/@version/$version_number/; s/@icon/$icon_name/; s/@exe/$exe_name/; s/@name/$app_name/; s/@type/$discord_type/"\
|
sed "s/@version/$pkg_version/; s/@icon/$icon_name/; s/@exe/$exe_name/; s/@name/$app_name/; s/@dir/$pkg_name/"\
|
||||||
"$desktop_model" > "$desktop_file"
|
"$desktop_model" > "$desktop_file"
|
||||||
|
|
||||||
|
|
||||||
disp "${yellow}Creating the RPM package (this may take a while)..."
|
disp "${yellow}Creating the RPM package (this may take a while)..."
|
||||||
rpmbuild --quiet -bb "$spec_file" --define "_topdir $work_dir" --define "_rpmdir $rpm_dir"\
|
rpmbuild --quiet -bb "$spec_file" --define "_topdir $work_dir" --define "_rpmdir $rpm_dir"\
|
||||||
--define "version_number $version_number" --define "downloaded_dir $downloaded_dir"\
|
--define "pkg_version $pkg_version" --define "downloaded_dir $downloaded_dir"\
|
||||||
--define "desktop_file $desktop_file"
|
--define "desktop_file $desktop_file" --define "pkg_name $pkg_name" --define "pkg_req $pkg_req"
|
||||||
|
|
||||||
disp "${bgreen}Done!${reset_font}"
|
disp "${bgreen}Done!${reset_font}"
|
||||||
disp "The RPM package is located in the \"RPMs/$arch\" folder."
|
disp "The RPM package is located in the \"RPMs/$arch\" folder."
|
||||||
|
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
# Defined by the caller (ie the script):
|
|
||||||
# version_number
|
|
||||||
# downloaded_dir
|
|
||||||
# desktop_file
|
|
||||||
|
|
||||||
%define install_dir /opt/discord-canary
|
|
||||||
%define apps_dir /usr/share/applications
|
|
||||||
|
|
||||||
Name: discord-canary
|
|
||||||
Version: %{version_number}
|
|
||||||
Release: 1%{?dist}
|
|
||||||
Summary: Free Voice and Text Chat for Gamers.
|
|
||||||
|
|
||||||
Group: Applications/Internet
|
|
||||||
License: Proprietary
|
|
||||||
URL: https://discordapp.com/
|
|
||||||
BuildArch: x86_64
|
|
||||||
Requires: glibc, alsa-lib, GConf2, libnotify, nspr >= 4.13, nss >= 3.27, libstdc++ >= 6, libX11 >= 1.6, libXtst >= 1.2, libappindicator, libcxx%{?_isa}
|
|
||||||
|
|
||||||
%description
|
|
||||||
All-in-one voice and text chat for gamers that’s free, secure, and works on both your desktop and phone.
|
|
||||||
It’s time to ditch Skype and TeamSpeak.
|
|
||||||
|
|
||||||
%prep
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
%install
|
|
||||||
mkdir -p "%{buildroot}%{install_dir}"
|
|
||||||
mkdir -p "%{buildroot}%{apps_dir}"
|
|
||||||
mv "%{downloaded_dir}"/* "%{buildroot}%{install_dir}"
|
|
||||||
cp "%{desktop_file}" "%{buildroot}%{apps_dir}"
|
|
||||||
chmod +x "%{buildroot}%{install_dir}"/*.so
|
|
||||||
|
|
||||||
%files
|
|
||||||
%{install_dir}
|
|
||||||
%{apps_dir}/*
|
|
||||||
|
|
||||||
%post
|
|
||||||
cd "%{install_dir}"
|
|
||||||
sh postinst.sh
|
|
||||||
|
|
@ -3,8 +3,8 @@ Name=@name
|
||||||
Comment=Free voice and text chat for gamers
|
Comment=Free voice and text chat for gamers
|
||||||
StartupWMClass=discord
|
StartupWMClass=discord
|
||||||
Version=1.0
|
Version=1.0
|
||||||
Icon=/opt/discord-@type/@icon
|
Icon=/opt/@dir/@icon
|
||||||
Exec=/opt/discord-@type/@exe
|
Exec=/opt/@dir/@exe
|
||||||
Type=Application
|
Type=Application
|
||||||
Terminal=false
|
Terminal=false
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,24 @@
|
||||||
# Defined by the caller (ie the script):
|
# Defined by the caller (ie the script):
|
||||||
# version_number
|
# pkg_name
|
||||||
|
# pkg_version
|
||||||
|
# pkg_req
|
||||||
# downloaded_dir
|
# downloaded_dir
|
||||||
# desktop_file
|
# desktop_file
|
||||||
|
|
||||||
%define install_dir /opt/discord-stable
|
%define install_dir /opt/discord-stable
|
||||||
%define apps_dir /usr/share/applications
|
%define apps_dir /usr/share/applications
|
||||||
|
%define _build_id_links none
|
||||||
|
|
||||||
Name: discord-stable
|
Name: %{pkg_name}
|
||||||
Version: %{version_number}
|
Version: %{pkg_version}
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: Free Voice and Text Chat for Gamers.
|
Summary: Free Voice and Text Chat for Gamers.
|
||||||
|
|
||||||
Group: Applications/Internet
|
Group: Applications/Internet
|
||||||
License: Proprietary
|
License: Proprietary
|
||||||
URL: https://discordapp.com/
|
URL: https://discordapp.com/
|
||||||
BuildArch: x86_64
|
BuildArch: x86_64
|
||||||
Requires: glibc, alsa-lib, GConf2, libnotify, nspr >= 4.13, nss >= 3.27, libstdc++ >= 6, libX11 >= 1.6, libXtst >= 1.2, libappindicator, libcxx%{?_isa}
|
Requires: %{pkg_req}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
All-in-one voice and text chat for gamers that’s free, secure, and works on both your desktop and phone.
|
All-in-one voice and text chat for gamers that’s free, secure, and works on both your desktop and phone.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue