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 http://bugs.opensuse.org/
#


%{!?_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
Url:            http://www.samwel.tk/laptop_mode/
Source:         https://github.com/rickysarraf/%{name}/releases/download/%{version}/%{name}_%{version}.tar.gz
Source1:        laptop-mode-tools.pm-utils-hook
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
%else
BuildRequires:  systemd
BuildRequires:  systemd-rpm-macros
%endif
BuildRequires:  udev
BuildArch:      noarch
%{?systemd_requires}

%description
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.

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

%build

%install
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 ./install.sh

%if 0%{?suse_version} < 1315
install -D -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/pm-utils/power.d/laptop-mode-tools
%endif
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
%endif

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

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

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

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

%files
%defattr(-,root,root)
%dir %{_sysconfdir}/laptop-mode
%config %{_sysconfdir}/laptop-mode/*
%{_sbindir}/*
%dir %{_datadir}/%{name}/
%dir %{_datadir}/%{name}/modules/
%dir %{_datadir}/%{name}/module-helpers/
%{_datadir}/%{name}/modules/*
%{_datadir}/%{name}/module-helpers/lm-polling-daemon
%{_datadir}/%{name}/module-helpers/pm-freeze
%{_datadir}/%{name}/module-helpers/pm-helper
%{_datadir}/%{name}/module-helpers/pm-hibernate
%{_datadir}/%{name}/module-helpers/pm-suspend
%if 0%{?suse_version} < 1315
%dir %{_libexecdir}/pm-utils
%dir %{_libexecdir}/pm-utils/power.d
%dir %{_libexecdir}/pm-utils/sleep.d
%{_libexecdir}/pm-utils/power.d/laptop-mode-tools
%endif
%{_sbindir}/rclaptop-mode
%{_udevdir}/lmt-udev
%{_udevrulesdir}/99-laptop-mode.rules
%if 0%{?suse_version} < 1315
%{_libexecdir}/pm-utils/sleep.d/01laptop-mode
%endif
%{_mandir}/man8/*
%doc README.SUSE
%{_tmpfilesdir}/laptop-mode.conf
%{_unitdir}/laptop-mode.service
%dir %{_datadir}/polkit-1
%dir %{_datadir}/polkit-1/actions
%{_datadir}/polkit-1/actions/org.linux.lmt.gui.policy
%if 0%{?suse_version} >= 1315
%{_unitdir}/laptop-mode.timer
%{_unitdir}/lmt-poll.service
%endif

%changelog
openSUSE Build Service is sponsored by