File scx-tools.spec of Package scx-tools

#
# spec file for package scx
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# 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/
#
# Spec file borrowed from SirLucjan thank you Sir

%define _lto_cflags %{nil}
%define libbpf_min_ver 1.4
%define llvm_min_ver 17

Name:           scx-tools
Version:        1.0.18+git20251117.ad8d7f5
Release:        0
Summary:        Sched_ext Tools
License:        GPL-2.0-only
URL:            https://github.com/sched-ext/scx-loader
Source0:        scx-loader-%{version}.tar.zst
Source1:        vendor.tar.zst

BuildRequires:  bpftool >= 7.5.0
BuildRequires:  clang >= %{llvm_min_ver}
BuildRequires:  libbpf-devel >= %{libbpf_min_ver}
BuildRequires:  lld
BuildRequires:  llvm >= %{llvm_min_ver}
BuildRequires:  pkgconfig
BuildRequires:  rust+cargo >= 1.82
BuildRequires:  zstd
BuildRequires:  pkgconfig(libbpf) >= %{libbpf_min_ver}
BuildRequires:  pkgconfig(systemd)
ExclusiveArch:  %{rust_arches}
Requires:  scx

%description
scx_loader: A DBUS Interface for Managing sched_ext Schedulers

%prep
%autosetup -n scx-loader-%{version} -a1

%build
export CARGO_HOME=%{_builddir}/.cargo
cargo build --release --frozen --all-features --workspace

%install

# Install all built executables (skip .so and .d files)
find target/release \
    -maxdepth 1 -type f -executable ! -name '*.so' ! -name 'xtask' \
    -exec install -Dm755 -t %{buildroot}%{_bindir} {} +

# Install runtime assets via xtask
# (systemd units, D-Bus services, configs, sample files)
./target/release/xtask install --destdir %{buildroot}

%pre
%service_add_pre scx_loader.service

%post
%service_add_post scx_loader.service

%preun
%service_del_preun scx_loader.service

%postun
%service_del_postun scx_loader.service

%files

# Binaries
%{_bindir}/*

# Systemd service
%{_unitdir}/scx_loader.service

# DBus service and configuration
%{_datadir}/dbus-1/system-services/org.scx.Loader.service
%{_datadir}/dbus-1/system.d/org.scx.Loader.conf
%{_datadir}/dbus-1/interfaces/org.scx.Loader.xml

# Polkit authorization policy for scx-loader
%{_datadir}/polkit-1/actions/org.scx.Loader.policy

# Configuration files
%dir /%{_datadir}/scx_loader
%{_datadir}/scx_loader/config.toml

%changelog
openSUSE Build Service is sponsored by