%global long_commit b1521b468105ef1ce0110502396fea304c62524e %global short_commit %(echo %{long_commit} | cut -c1-7) Name: soteria Version: 0.3.1^%(date +%%Y%%m%%d)git%{short_commit} Release: 1%{?dist} Summary: GTK4-based polkit authentication agent License: Apache-2.0 URL: https://github.com/ImVaskel/soteria Source: %{url}/archive/%{long_commit}.tar.gz BuildRequires: git BuildRequires: gcc BuildRequires: rust BuildRequires: cargo BuildRequires: gettext BuildRequires: gtk4-devel BuildRequires: polkit-devel BuildRequires: pkgconfig(gtk4) BuildRequires: pkgconfig(polkit-agent-1) Requires: gtk4 Requires: polkit %description Soteria is a polkit authentication agent written in Rust with a GTK4 UI. It is designed to work with any desktop environment or standalone window manager that supports GTK4 and polkit. %prep %autosetup -n %{name}-%{long_commit} %build export POLKIT_AGENT_HELPER_PATH=/usr/lib/polkit-1/polkit-agent-helper-1 export POLKIT_AGENT_SOCKET_PATH=/run/polkit/agent-helper.socket export SOTERIA_DEFAULT_LOCALE_DIR=%{_datadir}/locale %{__cargo} build \ --release \ --locked \ --online for po_file in po/*.po; do lang="${po_file%.po}" lang="${lang#po/}" mkdir -p "mo/${lang}/LC_MESSAGES" msgfmt "${po_file}" -o "mo/${lang}/LC_MESSAGES/%{name}.mo" done %install install -Dpm 0755 target/release/%{name} \ %{buildroot}%{_bindir}/%{name} for mo_file in mo/*/LC_MESSAGES/%{name}.mo; do lang="$(echo "${mo_file}" | cut -d/ -f2)" install -Dpm 0644 "${mo_file}" \ %{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES/%{name}.mo done install -Dpm 0644 /dev/null \ %{buildroot}%{_sysconfdir}/%{name}/config.toml cat > %{buildroot}%{_sysconfdir}/%{name}/config.toml <<'EOF' # Soteria system-wide configuration # See https://github.com/ImVaskel/soteria for full documentation. # # Uncomment and set helper_path only when polkit-agent-helper-1 lives # somewhere other than /usr/lib/polkit-1/polkit-agent-helper-1. # # helper_path = "/usr/lib/polkit-1/polkit-agent-helper-1" EOF %find_lang %{name} %files -f %{name}.lang %license LICENSE %doc README.md %{_bindir}/%{name} %config(noreplace) %{_sysconfdir}/%{name}/config.toml %dir %{_datadir}/locale %changelog %autochangelog