File pm-profiler.spec of Package pm-profiler

#
# spec file for package pm-profiler
#
# Copyright (c) 2024 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 https://bugs.opensuse.org/
#


Name:           pm-profiler
Version:        0.1_20111222
Release:        0
Summary:        Managing power options on servers
License:        GPL-2.0-only
Group:          System/Management
URL:            https://sourceforge.net/projects/pm-profiler
Source:         %{name}-%{version}.tar.bz2
Source1:        pm-profiler.service
Patch0:         ondemand-kernel3.1.diff
Patch1:         alpm-fix.diff
Patch2:         hal-removal.diff
Patch3:         pm-profiler_cmd.patch
Patch4:         intel_pstate.patch
Patch5:         onbattery.patch
Patch6:         improvements-for-conservative.patch
Patch7:         add-sampling_down_factor.patch
Patch8:         remove-power_savings.patch
Patch9:         update-template.patch
Patch10:        add-rate_limit_us.patch
Patch11:        support-more-devices.patch
BuildRequires:  systemd-rpm-macros
Requires(post): %fillup_prereq
BuildArch:      noarch

%description
Script infrastructure to enable/disable certain power management
functions via simple configuration files. It is intended for server
use.

%prep
%autosetup -p1

%build

%install
# We introduce a link which is stale after install
# and gets valid in %%pre/%%post scripts. Tell the build
# service or it will stop with an error.

export NO_BRP_STALE_LINK_ERROR="yes"

%make_install

mkdir -p %{buildroot}%{_fillupdir}
mv %{buildroot}%{_sysconfdir}/pm-profiler.conf %{buildroot}%{_fillupdir}/sysconfig.%{name}
ln -sf %{_sysconfdir}/sysconfig/pm-profiler %{buildroot}%{_sysconfdir}/pm-profiler.conf
#---systemd support and remove initd support
install -p -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
rm %{buildroot}%{_initddir}/pm-profiler
rm %{buildroot}%{_sbindir}/rcpm-profiler

%check

%find_lang %{name}

%pre
if test -f %{_sysconfdir}/pm-profiler.conf -a ! -L %{_sysconfdir}/pm-profiler.conf; then
    grep "^PM_PROFILER_PROFILE" %{_sysconfdir}/pm-profiler.conf > %{_sysconfdir}/sysconfig/pm-profiler
    rm %{_sysconfdir}/pm-profiler.conf
    ln -sf %{_sysconfdir}/sysconfig/pm-profiler %{_sysconfdir}/pm-profiler.conf
fi
%service_add_pre %{name}.service

%preun
%service_del_preun %{name}.service

%post
%{fillup_only -n pm-profiler}
%service_add_post %{name}.service

%postun
%service_del_postun %{name}.service

%files -f %{name}.lang
%license COPYING
%{_docdir}/pm-profiler
%{_prefix}/lib/pm-profiler
%config(noreplace) %{_sysconfdir}/pm-profiler.conf
%dir %{_sysconfdir}/pm-profiler
%dir %{_sysconfdir}/pm-profiler/balanced_low_latency
%config(noreplace) %{_sysconfdir}/pm-profiler/balanced_low_latency/config
%dir %{_sysconfdir}/pm-profiler/low_latency
%config(noreplace) %{_sysconfdir}/pm-profiler/low_latency/config
%dir %{_sysconfdir}/pm-profiler/powersaving
%config(noreplace) %{_sysconfdir}/pm-profiler/powersaving/config
%dir %{_sysconfdir}/pm-profiler/onbattery
%config(noreplace) %{_sysconfdir}/pm-profiler/onbattery/config
%{_unitdir}/%{name}.service
%{_bindir}/pm-profiler
%{_fillupdir}/sysconfig.%{name}

%changelog
openSUSE Build Service is sponsored by