File system76-driver.spec of Package system76-driver

# The following tag is to get correct syntax highlighting for this file in vim text editor
# vim: syntax=spec

%global python_pkgdir system76driver
%define systemd_sleepdir %{_systemd_util_dir}/system-sleep
%global python_entrypoint system76-driver
%global upstream_pkg system76-driver

%{?sle15_python_module_pythons}
Name:       system76-driver
Version:    24.04.5
Release:    1
Summary:    System76 Driver
License:    GPL-3.0-only
URL:        https://github.com/pop-os/%{name}
Source0:    https://github.com/szydell/%{name}/archive/refs/tags/%{name}-%{version}-1.tar.gz#/%{name}-%{version}-1.tar.gz

BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module pyflakes}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module wheel}
# Test dependencies
BuildRequires:  %{python_module dbus-python}
BuildRequires:  %{python_module distro}
BuildRequires:  %{python_module evdev}
BuildRequires:  %{python_module gobject}
BuildRequires:  typelib-1_0-Gtk-3_0
# end
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  systemd-rpm-macros

Requires:       systemd
Requires:       polkit

BuildArch:      noarch
%{?systemd_ordering}

Requires:       python-dbus-python
Requires:       python-distro
Requires:       python-evdev
Requires:       python-gobject
Requires:       typelib-1_0-Gtk-3_0
Requires:       %{upstream_pkg}-common = %{version}-%{release}

Provides:       %{upstream_pkg} = %{version}
Conflicts:      %{upstream_pkg} < %{version}

Requires(post): update-alternatives
Requires(postun): update-alternatives

%python_subpackages

%description
This program installs drivers and provides restore functionality for System76 machines.

%package -n %{upstream_pkg}-common
Summary:        Comon files for %{upstream_pkg}
Group:          Documentation/Other

%description -n %{upstream_pkg}-common
Comon files for %{upstream_pkg}.

%prep
%autosetup -p1 -n %{name}-%{name}-%{version}-1
sed -i -e 's#/usr/bin/pyflakes3#%{_bindir}/pyflakes#' \
       -e "/'system76driver\.tests'/d" \
       setup.py

%build
%pyproject_wheel

%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}/%{python_pkgdir}*

for bin in %{python_entrypoint} %{python_entrypoint}-cli; do
%python_clone -a %{buildroot}%{_bindir}/$bin
done

#install -D -m 0755 system76-driver-pkexec -t "%%{buildroot}%%{_bindir}"
install -D -m 0644 com.system76.pkexec.system76-driver.policy -t "%{buildroot}%{_datadir}/polkit-1/actions/"
install -D -m 0700 system76-nm-restart -t "%{buildroot}%{systemd_sleepdir}"
install -D -m 0700 system76-thunderbolt-reload  -t "%{buildroot}%{systemd_sleepdir}"
#install -D -m 0700 system76-atlantic-reload  -t "%%{buildroot}%%{systemd_sleepdir}"

%check
%{python_expand #
    $python setup.py test --skip-gtk
}

%post
%python_install_alternative %{python_entrypoint} %{python_entrypoint}-cli

%postun
%python_uninstall_alternative %{python_entrypoint} %{python_entrypoint}-cli


%files %{python_files}
%{python_sitelib}/%{python_pkgdir}*.dist-info
%{python_sitelib}/%{python_pkgdir}
%python_alternative %{_bindir}/%{python_entrypoint}
%python_alternative %{_bindir}/%{python_entrypoint}-cli

%files -n %{upstream_pkg}-common
%doc README.md
%license LICENSE

%dir %{_datadir}/applications
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/scalable
%dir %{_datadir}/icons/hicolor/scalable/apps
%dir %{_datadir}/polkit-1
%dir %{_datadir}/polkit-1/actions
%dir %{systemd_sleepdir}

%{_datadir}/applications/system76-driver.desktop
%{_datadir}/icons/hicolor/scalable/apps/system76-driver.svg

%{_datadir}/polkit-1/actions/com.system76.pkexec.system76-driver.policy
%{systemd_sleepdir}/*

%changelog
openSUSE Build Service is sponsored by