File HeroicGamesLauncher.spec of Package HeroicGamesLauncher
#
# spec file for package HeroicGamesLauncher
#
# Copyright (c) 2025 SUSE LLC
#
# 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/
#
%define python_flavor python3
%define skip_python2 1
%define legendary_version 0.20.37
%define gogdl_version 1.1.2
%define nile_version 1.1.2
%define comet_version 0.3.1
%define heroic_epic_version 0.4
%define VulkanHelper_version 0.1.0
%global rustflags -C debuginfo=2 -C link-arg=-s
%if "x%{?rust_tier1_arches}" == "x"
%global rust_tier1_arches noarch
%endif
%ifarch x86_64
%global bin_subdir x64
%global arch_flag --x64
%global bin_subdir_opposite arm64
%endif
%ifarch aarch64
%global bin_subdir arm64
%global arch_flag --arm64
%global bin_subdir_opposite x64
%endif
Name:           HeroicGamesLauncher
Version:        2.18.1
Release:        0
Summary:        Native GOG, Epic Games and Amazon Games launcher for Linux
License:        GPL-3.0-only
URL:            https://heroicgameslauncher.com/
Source:         %{name}-%{version}.tar.xz
Source1:        legendary-0.20.37.tar.xz
Source2:        heroic-gogdl-1.1.2.tar.xz
Source3:        nile-1.1.2.tar.xz
Source4:        comet-0.3.1.tar.xz
Source5:        heroic-epic-integration-0.4.tar.xz
Source6:        pnpm-offline-store.tar.xz
Source7:        VulkanHelper-0.1.0.tar.xz
Source8:        vendor.tar.zst
Source9:        vendor.tar.xz
BuildRequires:  c++_compiler
BuildRequires:  glibc
BuildRequires:  git
BuildRequires:  jq
BuildRequires:  unzip
BuildRequires:  fdupes
BuildRequires:  cmake
BuildRequires:  cmake
BuildRequires:  make
BuildRequires:  vulkan-devel
BuildRequires:  pkgconfig
BuildRequires:  openssl-devel
BuildRequires:  protobuf-devel
BuildRequires:  mingw64-cross-gcc
BuildRequires:  mingw64-cross-gcc-c++
BuildRequires:  mingw64-cross-cmake
BuildRequires:  mingw64-cross-pkg-config
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module requests < 3.0}
BuildRequires:  %{python_module wheel}
BuildRequires:  %{python_module json5 >= 0.9}
BuildRequires:  %{python_module platformdirs >= 4.0}
BuildRequires:  %{python_module pycryptodome >= 3.0}
BuildRequires:  %{python_module zstandard >= 0.22}
BuildRequires:  %{python_module protobuf >= 4.0}
BuildRequires:  python313-filelock
BuildRequires:  python313-PyInstaller
BuildRequires:  npm
BuildRequires:  pnpm
BuildRequires:  nodejs
BuildRequires:  nodejs-vite
BuildRequires:  nodejs-electron
BuildRequires:  nodejs-electron-devel
BuildRequires:  rust
BuildRequires:  cargo
BuildRequires:  cargo-packaging
BuildRequires:  zstd
BuildRequires:  meson
Recommends:     gamemode%{?_isa}
Recommends:     libvkd3d%{?_isa}
Recommends:     mangohud%{?_isa}
Recommends:     wine-staging%{?_isa}
Recommends:     winetricks%{?_isa}
Requires:       electron
Requires:       ca-certificates
ExclusiveArch:  %{x86_64} %{aarch64} %{rust_tier1_arches}
Provides:       heroic-games-launcher = %{version}
Obsoletes:      heroic-games-launcher < %{version}
Conflicts:      heroic-games-launcher-bin
%description
Heroic is an open source game launcher that lets you run games from GOG, Epic Games and Amazon using Wine/Proton and system Electron.
%prep
%autosetup -n %{name}-%{version}
%setup -T -D -a1   # legendary
%setup -T -D -a2   # heroic-gogdl
%setup -T -D -a3   # nile
%setup -T -D -a4   # comet
%setup -T -D -a5   # heroic-epic-integration
%setup -T -D -a6   # pnpm-offline-store
%setup -T -D -a7   # VulkanHelper-main
tar -xf %SOURCE8 -C comet-%{comet_version}/
tar -xf %SOURCE9 -C VulkanHelper-%{VulkanHelper_version}/
sed -i -e "s/Exec=heroic-run /Exec=heroic /" flatpak/com.heroicgameslauncher.hgl.desktop
cp %{_sourcedir}/release_tags public/bin/.release_tags
%build
# Remove precompiled binaries to build from source
rm public/bin/%{bin_subdir}/linux/vulkan-helper
# Build legendary using PyInstaller
pushd legendary-%{legendary_version}
pyinstaller --onefile --name legendary legendary/cli.py
popd
# Build heroic-gogdl using PyInstaller
pushd heroic-gogdl-%{gogdl_version}
pyinstaller --onefile --name gogdl gogdl/cli.py
popd
# Build nile using PyInstaller
pushd nile-%{nile_version}
cat >> pyproject.toml <<'PYEOF'
[tool.setuptools.packages.find]
where = ["."]
include = ["nile", "nile.*"]
[tool.setuptools.package-data]
"nile" = ["assets/**/*"]
PYEOF
pyinstaller --onefile --name nile nile/cli.py
popd
# Build comet rust/cargo
pushd comet-%{comet_version}
%{cargo_build}
popd
# Build comet (Windows executable) with meson/mingw
pushd comet-%{comet_version}/dummy-service
meson setup builddir --cross-file meson/x86_64-w64-mingw32.ini
meson compile -C builddir
popd
# Build heroic-epic-integration (Windows executable) with meson/mingw
pushd heroic-epic-integration-%{heroic_epic_version}
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../windows.cmake ..
make
popd
# Build VulkanHelper rust/cargo
pushd VulkanHelper-%{VulkanHelper_version}
%{cargo_build}
popd
# Build Heroic Games Launcher
export HOME=%{_builddir}/%{name}-%{version}
export npm_config_nodedir="/usr/include/electron"
export ELECTRON_BUILDER_DISABLE_DOWNLOAD=true
export ELECTRON_MIRROR="file://"
export PATH=$PWD/node_modules/.bin:$PATH
pnpm config set store-dir .pnpm-store
pnpm install --store-dir .pnpm-store --frozen-lockfile --ignore-scripts --strict-peer-dependencies=false --offline
pnpm run download-helper-binaries
pnpm dist:linux %{arch_flag} --dir
%ifarch aarch64
mv dist/linux-arm64-unpacked dist/linux-unpacked
%endif
mkdir -p dist/linux-unpacked/resources/app.asar.unpacked/build
cp build/{icon.icns,icon.png,icon-light.png,icon-dark.png,mac-icon.icns,win_icon.ico} dist/linux-unpacked/resources/app.asar.unpacked/build
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir_opposite}/
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/register-scheme/src
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/@parcel
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/@rollup
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/@swc
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/term-size
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/unimported
rm -rf dist/linux-unpacked/resources/app.asar.unpacked/node_modules/@unrs
%install
install -d %{buildroot}%{_libdir}/Heroic %{buildroot}%{_bindir} %{buildroot}%{_datadir}/{applications,pixmaps,metainfo}
install -d %{_builddir}/%{name}-%{version}/dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/linux
install -d %{_builddir}/%{name}-%{version}/dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/win32
cp legendary-0.20.37/dist/legendary dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/linux/legendary
cp heroic-gogdl-1.1.2/dist/gogdl dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/linux/gogdl
cp nile-1.1.2/dist/nile dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/linux/nile
cp target/release/comet dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/linux/comet
cp target/release/vulkan-helper dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/linux//vulkan-helper
cp comet-0.3.1/dummy-service/builddir/GalaxyCommunication.exe dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/win32/GalaxyCommunication.exe
cp heroic-epic-integration-0.4/build/heroic-epic-integration.exe dist/linux-unpacked/resources/app.asar.unpacked/build/bin/%{bin_subdir}/win32/EpicGamesLauncher.exe
cp -a dist/linux-unpacked/. %{buildroot}%{_libdir}/Heroic/
ln -sf %{_libdir}/Heroic/heroic %{buildroot}%{_bindir}/heroic
install -m 644 flatpak/com.heroicgameslauncher.hgl.png %{buildroot}%{_datadir}/pixmaps/
install -m 644 flatpak/com.heroicgameslauncher.hgl.desktop %{buildroot}%{_datadir}/applications/
install -m 644 flatpak/templates/com.heroicgameslauncher.hgl.metainfo.xml.template \
    %{buildroot}%{_datadir}/metainfo/com.heroicgameslauncher.hgl.metainfo.xml
find %{buildroot}%{_libdir}/Heroic -type f -path "*/node_modules/*" -name "*.js" -print0 | xargs -0 chmod -x
find %{buildroot}%{_libdir}/Heroic -type f -path "*/node_modules/*" -name "*.js" -exec sed -i '1s|^#!.*||' {} \;
find %{buildroot}%{_libdir}/Heroic -type f \( -name "*.node" -o -perm /111 \) -exec %{__strip} --strip-unneeded {} \; || true
%fdupes %{buildroot}%{_libdir}/Heroic
%check
test -x dist/linux-unpacked/heroic
%files
%license COPYING
%doc README.md
%{_bindir}/heroic
%{_libdir}/Heroic/
%{_datadir}/pixmaps/com.heroicgameslauncher.hgl.png
%{_datadir}/applications/com.heroicgameslauncher.hgl.desktop
%{_datadir}/metainfo/com.heroicgameslauncher.hgl.metainfo.xml
%changelog