File alchemy-viewer.spec of Package alchemy-viewer
%define _product_name Alchemy
%global _product_name_ %{lower:%{_product_name}}
%define _product_branch Beta
%define _product_branch_ %{lower:%{_product_branch}}
%define _arch x86_64
%define _baseversion 7.1.9.2516
%global _product_install %{_product_name_}-%{_product_branch_}
%global installdir_name %{_product_install}-install
%global desktopfilename %{_product_install}-viewer
%global installation_prefix /opt/%{installdir_name}
Name: %{_product_name_}-viewer
Version: %{_baseversion}_%{_product_branch_}
%global _version_ %{gsub %{_baseversion} %. _}
%global _package_name %{_product_name}_%{_product_branch}_%{_version_}_%{_arch}
Release: 1
Summary: A Second Life client with focus on performance and code correctness
License: Apache-2.0
URL: https://www.%{_product_name_}viewer.org
Source0: https://github.com/%{_product_name}Viewer/%{_product_name}/releases/download/%{_baseversion}-%{_product_branch_}/%{_package_name}.tar.zst
Source99: %{name}.rpmlintrc
Requires: libGLU1 libglvnd libidn libjpeg-turbo libpng libxml2-2 libXss1 Mesa nss libopenal1 libSDL2-2_0-0 vlc zlib dbus-1-glib libsystemd0 switcheroo-control
Requires(post): xdg-utils
BuildRequires: zstd
BuildRequires: fdupes
# Gamemode support
Recommends: gamemode
# OpenAL support
Suggests: alsa-lib
Suggests: libalut0
# SLVoice support
#Suggests: lib32-libidn11 lib32-libsndfile lib32-util-linux lib32-gstreamer0.10
# PulseAudio support
Suggests: libpulse0
# Intel, Radeon, Nouveau support
Suggests: Mesa-libGL1
# NVIDIA support
#Suggests: nvidia-libgl nvidia-utils
# More up-to-date, less buggy SLVoice support
Suggests: wine
# File picker portal
Suggests: xdg-desktop-portal
ExclusiveArch: %{_arch}
AutoReqProv: no
%description
A Second Life client with focus on performance and code correctness - Beta.
%prep
%autosetup -n %{_package_name}
%build
%install
build_data_file="./build_data.json"
if [ -f "${build_data_file}" ]; then
version=$(sed -n 's/.*"Version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${build_data_file}")
channel_base=$(sed -n 's/.*"Channel Base"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${build_data_file}")
channel=$(sed -n 's/.*"Channel"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${build_data_file}")
else
echo "Error: File ${build_data_file} not found." >&2
exit 1
fi
echo "Installing ${channel} version ${version}"
install_root="%{buildroot}%{installation_prefix}"
desktop_entries_dir="%{_datadir}/applications"
mkdir -p "$install_root" || die "Failed to create installation directory!"
echo " - Installing to $install_root"
cp -a * "$install_root/" || die "Failed to complete the installation!"
# Install Desktop entry
#
# Check for the Release channel. This channel should not have the channel name in its launcher.
if [ "$channel" = "%{_product_name} Release" ]; then
launcher_name=%{_product_name}
else
launcher_name=$channel
fi
desktop_entry="\
[Desktop Entry]\n\
Version=1.4\n\
Name=${launcher_name}\n\
GenericName=Second Life Viewer\n\
Comment=Client for the On-line Virtual World, Second Life\n\
Exec=%{installation_prefix}/%{_product_name_}\n\
Icon=%{desktopfilename}\n\
Terminal=false\n\
Type=Application\n\
Categories=Game;Simulation;\n\
StartupNotify=true\n\
StartupWMClass=${channel}\n\
PrefersNonDefaultGPU=true\n\
Actions=DefaultGPU;\n\
\n\
[Desktop Action DefaultGPU]\n\
Exec=env __GLX_VENDOR_LIBRARY_NAME="" %{installation_prefix}/%{_product_name_}\n\
Name=Launch on default GPU\n\
\n\
"
#The above adds some options when the shortcut is right-clicked, to launch on the default (usually integrated) GPU.
# NOTE: DO NOT CHANGE THE "GenericName" FIELD - ONLY CHANGE THE "Name" FIELD. (This is to ensure that searching "Second Life" will show all the viewers installed in a user's system, regardless of their canonical name.)
printf "Installing desktop file..."
printf "%b" "${desktop_entry}" > "${install_root}/%{desktopfilename}".desktop
install -Dm644 "${install_root}/%{desktopfilename}".desktop %{buildroot}${desktop_entries_dir}/%{desktopfilename}.desktop
install -Dm644 "${install_root}/%{_product_name_}_icon.png" %{buildroot}%{_datadir}/icons/%{desktopfilename}.png
# Install secondlife:// URL handler
#
newhandler="secondlifeprotocol_%{desktopfilename}.desktop"
handlerpath="%{buildroot}${desktop_entries_dir}/${newhandler}"
desired_handler="%{installation_prefix}/etc/handle_secondlifeprotocol.sh"
cat >"${handlerpath}" <<EOFnew
[Desktop Entry]
Version=1.4
Name="Second Life URL handler"
Comment="secondlife:// URL handler"
Type=Application
Exec=$desired_handler %u
Icon=%{desktopfilename}
Terminal=false
StartupNotify=true
NoDisplay=true
MimeType=x-scheme-handler/secondlife;
EOFnew
%fdupes -s %{buildroot}
%post
xdg-mime default secondlifeprotocol_%{desktopfilename}.desktop x-scheme-handler/secondlife
%{installation_prefix}/etc/chrome_sandboxing_permissions_setup.sh
%files
%{installation_prefix}
%{_datadir}/applications/%{desktopfilename}.desktop
%{_datadir}/applications/secondlifeprotocol_%{desktopfilename}.desktop
%{_datadir}/icons/%{desktopfilename}.png