File LACT.spec of Package LACT

#
# Copyright (c) 2024 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/
#

Name:           LACT
Version:        0.8.4
Release:        0
ExclusiveArch:  x86_64 aarch64
Summary:        Linux AMDGPU Controller
License:        MIT
URL:            https://github.com/ilya-zlobintsev/LACT
Source:         %{name}-%{version}.tar.gz
Source1:        vendor.tar.xz
Source2:        series
Patch1:         dont-strip-it.patch
Patch2:         install-headless.patch
Patch3:         service-use-headless.patch

BuildRequires:  cargo-packaging
BuildRequires:  clang-devel
BuildRequires:  blueprint-compiler
BuildRequires:  pkgconfig(gtk4)
BuildRequires:  pkgconfig(libdrm)
BuildRequires:  pkgconfig(libadwaita-1)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(OpenCL)
BuildRequires:  cargo
BuildRequires:  cargo-auditable

Requires:       %{name}-daemon = %{version}-%{release}

%description
This application allows you to control your AMD GPU on a Linux system.

%package daemon
Summary:        Linux AMDGPU Controller - headless binary
%description daemon
This application allows you to control your AMD GPU on a Linux system.
This package holds a headless binary without all the GUI dependencies.

%prep
%autosetup -a 1 -p 1
mkdir -p .cargo
cat > .cargo/config.toml << EOF
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF

%build
# Устанавливаем окружение вручную, чтобы не зависеть от скрытых флагов макросов
export CARGO_HOME=$PWD/.cargo
export CARGO_FEATURE_VENDORED=1
export RUSTFLAGS="-Clink-arg=-Wl,-z,relro,-z,now -C debuginfo=2 -C strip=none"

# 1. Сборка headless версии (NVIDIA) без флага --locked
cargo auditable build -j4 --offline --release -p lact --no-default-features --features=nvidia

# Сохраняем headless бинарник
mkdir -p bin_output
mv target/release/lact bin_output/lact-headless

# 2. Сборка основной GUI версии
# Мы не делаем cargo clean, чтобы использовать уже собранные общие зависимости
cargo auditable build -j4 --offline --release -p lact

# Возвращаем headless бинарник для установки
mv bin_output/lact-headless target/release/

%install
# Установка через Makefile проекта
%make_install PREFIX="%{_prefix}"

%pre daemon
%service_add_pre lactd.service

%preun daemon
%service_del_preun lactd.service

%post daemon
%service_add_post lactd.service

%postun daemon
%service_del_postun lactd.service

%files
%license LICENSE
%doc README.md
%{_bindir}/lact
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/*/apps/io.github.ilya_zlobintsev.LACT.*
%{_datadir}/metainfo/*.xml

%files daemon
%{_bindir}/lact-headless
%{_unitdir}/lactd.service
%license LICENSE
%doc README.md

%changelog
openSUSE Build Service is sponsored by