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

# spec file for package laptop-mode-tools
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# 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.69.2
Release:        0
Summary:        The Laptop Mode Tools
License:        GPL-2.0+
Group:          System/Base
Source2:        README.SUSE
Patch1:         laptop-mode-1.53-install_sh.diff
Patch2:         laptop-mode-1.53_conf.diff
Patch4:         laptop-mode-1.49-new-dirty-ratio-defaults.diff
Patch5:         laptop-mode-1.53-fix-pm-utils-sleep-script.diff
Patch6:         laptop-mode-1.53-moblin-enable-intel-hda-powersave.patch
%if 0%{?suse_version} < 1315
BuildRequires:  pm-utils
BuildRequires:  systemd
BuildRequires:  systemd-rpm-macros
BuildRequires:  udev
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.

%setup -q -n %{name}_%{version}
%patch1 -p1
%patch2 -p1
%patch4 -p1
%if 0%{?suse_version} < 1315
%patch5 -p1
%patch6 -p1
cp %{SOURCE2} .


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

%if 0%{?suse_version} < 1315
install -D -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/pm-utils/power.d/laptop-mode-tools
chmod 644 %{buildroot}/%{_mandir}/man8/*
# Don't ship sysvinit script
rm -r %{buildroot}%{_sysconfdir}/init.d
# Hack to remove sysvinit script link in usr/sbin
ln -s service %{buildroot}/%{_sbindir}/rclaptop-mode
%if 0%{?suse_version} >= 1315
# remove pm-utils hook: as soon as DESTDIR is defined, the hook is always installed
rm -rf %{buildroot}%{_libexecdir}/pm-utils

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

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

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

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

%dir %{_sysconfdir}/laptop-mode
%config %{_sysconfdir}/laptop-mode/*
%dir %{_datadir}/%{name}/
%dir %{_datadir}/%{name}/modules/
%dir %{_datadir}/%{name}/module-helpers/
%if 0%{?suse_version} < 1315
%dir %{_libexecdir}/pm-utils
%dir %{_libexecdir}/pm-utils/power.d
%dir %{_libexecdir}/pm-utils/sleep.d
%if 0%{?suse_version} < 1315
%dir %{_datadir}/polkit-1
%dir %{_datadir}/polkit-1/actions
%if 0%{?suse_version} >= 1315

openSUSE Build Service is sponsored by