File laptop-mode-tools.spec of Package laptop-mode-tools

# spec file for package laptop-mode-tools
# Copyright (c) 2020 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

%{!?_tmpfilesdir:%global _tmpfilesdir /usr/lib/tmpfiles.d}
%{!?_udevdir:%global _udevdir  %{_libexecdir}/udev}

Name:           laptop-mode-tools
Version:        1.72.2
Release:        0
Summary:        The Laptop Mode Tools
License:        GPL-2.0-or-later
Group:          System/Base
Source1:        README.SUSE
Patch0:         laptop-mode-1.53_conf.diff
Patch1:         laptop-mode-1.49-new-dirty-ratio-defaults.diff
Patch2:         laptop-mode-1.53-moblin-enable-intel-hda-powersave.patch
# PATCH-FIX-UPSTREAM laptop-mode-tools-1.72.2-fix-name-gui.patch -- gh#rickysarraf/laptop-mode-tools#124
Patch3:         laptop-mode-tools-1.72.2-fix-name-gui.patch
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(udev)
Suggests:       %{name}-gui
BuildArch:      noarch

Laptop Mode Tools is a laptop power saving package for Linux systems.
It allows you to extend the battery life of your laptop, in several
ways. It is the primary way to enable the Laptop Mode feature of the
Linux kernel, which lets your hard drive spin down. In addition, it
allows you to tweak a number of other power-related settings using a
simple configuration file.

%package gui
Summary:        Graphical User Interface for the laptop mode tools
Group:          System/Base
BuildRequires:  update-desktop-files
Requires:       %{name} = %{version}
Requires:       python3-qt5
BuildArch:      noarch

%description gui
This package contains a graphical user interface for laptop-mode-tools.

%autosetup -p1
cp %{SOURCE1} .


DESTDIR=%{buildroot} \
MAN_D=%{_mandir} \
INIT_D="none" \
LIB_D=%{_libdir} \
UDEV_D=%{_udevdir} \
SYSTEMD_UNIT_D=%{_unitdir} \
ACPI=disabled PMU=disabled APM=disabled INSTALL=install ./

# Fix spurious executable permission
chmod 644 %{buildroot}/%{_mandir}/man8/*

# Fix suse-missing-rclink
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rclaptop-mode
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rclmt-poll

# remove pm-utils hook: as soon as DESTDIR is defined, the hook is always installed
rm -rf %{buildroot}%{_libexecdir}/pm-utils

# Fix insufficient category definition
%suse_update_desktop_file -r laptop-mode-tools Settings HardwareSettings

%service_add_pre laptop-mode.service lmt-poll.service

%service_add_post laptop-mode.service lmt-poll.service
systemd-tmpfiles --create %{_tmpfilesdir}/laptop-mode.conf

%service_del_preun laptop-mode.service lmt-poll.service

%service_del_postun laptop-mode.service lmt-poll.service

%license COPYING
%dir %{_sysconfdir}/laptop-mode
%config %{_sysconfdir}/laptop-mode/*
%exclude %{_sbindir}/*gui*
%dir %{_datadir}/%{name}/
%dir %{_datadir}/%{name}/modules/
%dir %{_datadir}/%{name}/module-helpers/

%files gui
%license COPYING
%dir %{_datadir}/polkit-1
%dir %{_datadir}/polkit-1/actions