# Explicitly turn on hardening, if required.
%if (0%{?fedora} && 0%{?fedora} <= 22) || (0%{?rhel} && 0%{?rhel} <= 7)
%global _hardened_build 1
%endif # (0%%{?fedora} && 0%%{?fedora} <= 22) || (0%%{rhel} && 0%%{?rhel} <= 7)
%global pkgname thermal_daemon
Name: thermald
Version: 1.6
Release: 7%{?dist}
Summary: Thermal Management daemon
License: GPLv2+
URL: https://github.com/01org/%{pkgname}
Source0: %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Fixes from upstream.
Patch0: %{url}/commit/a8eba71a95b3b8af0540f6a93877e24bc8c47079.patch#/%{name}-1.6-thd_cdev_target_value_initialized.patch
Patch1: %{url}/commit/6a2344b4a55acc0cba356d0f7c521c0cdb6632e0.patch#/%{name}-1.6-fix_build_warnings_on_32bits.patch
Patch2: %{url}/commit/2a00d1745161c6d11b927f025ff1f4bb44f61d15.patch#/%{name}-1.6-load_preference_from_xml_file.patch
Patch3: %{url}/commit/37a25879239466f2d096fd1a58b2ac7bbc3958f5.patch#/%{name}-1.6-set_default_preference.patch
Patch4: %{url}/commit/35bda2d052b8820cbfce6c1918e3866c6fa3fd76.patch#/%{name}-1.6-update_QCustomPlot_2_0_0_beta.patch
Patch5: %{url}/commit/8e76666785f732aa2c70c626b242cffd566ea434.patch#/%{name}-1.6-distribution_integration_update_RPM_spec_for_1_6.patch
Patch6: %{url}/commit/e311dc88d3acac7eca593efea5d95507b02608da.patch#/%{name}-1.6-remove_duplicate_assignment_to_critical_temp.patch
Patch7: %{url}/commit/7ee77cce542b2ed0421133b01904d5ad0ecdab6f.patch#/%{name}-1.6-thd_parse_check_for_xmlNodeListGetString_NULL_returns.patch
Patch8: %{url}/commit/8f7d49be960dd19edaef452a89b541e4509caef7.patch#/%{name}-1.6-fix_typo_on_field_name_default_prefernce.patch
Patch9: %{url}/commit/18989faac5138213a99f63346e49f4279caad9fb.patch#/%{name}-1.6-dont_terminate_the_thermald_engine_if_thd_engine_is_null.patch
Patch10: %{url}/commit/90169f80a70efd4d5b6101e87666cd355dbd786f.patch#/%{name}-1.6-removed_compile_flags.patch
Patch11: %{url}/commit/93e52afc389c98880b91d61cf47c0603f4654ccd.patch#/%{name}-1.6-android_fix_build_file.patch
Patch12: %{url}/commit/bcbb8ea8e6ced976d4359db9bc4c35a9d8f345ba.patch#/%{name}-1.6-android_fix_compile_errors.patch
Patch13: %{url}/commit/9c5d8354dd8efff340a030c05f7beda03061cd0a.patch#/%{name}-1.6-fix_dbus_re-init_accessing_deleted_pointer.patch
Patch14: %{url}/commit/18d6ca75bbc504aaf9fe862dc1c10c3c65fbe7bd.patch#/%{name}-1.6-initialize_lowest_valid_index_to_prevent_SEGV.patch
Patch15: %{url}/commit/07d7077af1992d52733b0dcf18538690a87b877f.patch#/%{name}-1.6-update_README_to_start_service.patch
Patch16: %{url}/pull/133.patch#/%{name}-1.6-silence_compiler_warnings_and_enable_Werror.patch
# No cpuid.h on other arches.
ExclusiveArch: %{ix86} x86_64
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: dbus-glib-devel
BuildRequires: desktop-file-utils
BuildRequires: gcc-c++
BuildRequires: glib-devel
BuildRequires: libxml2-devel
BuildRequires: systemd
Requires: dbus%{?_isa}
Requires(pre): glibc-common
Requires(pre): shadow-utils
%{?systemd_requires}
%description
%{name} monitors and controls platform temperature.
Thermal issues are important to handle proactively to reduce performance
impact. %{name} uses the existing Linux kernel infrastructure and can
be easily enhanced.
%package monitor
Summary: Application for monitoring %{name}
License: GPLv3+
BuildRequires: qt5-qtbase-devel
Requires: hicolor-icon-theme
Requires: %{name}%{?_isa} == %{version}-%{release}
%description monitor
This package contains an Application to monitor %{name} for system
developers who want to enable application developers and their
customers with the responsive and flexible thermal management,
supporting optimal performance in desktop, clam-shell, mobile and
embedded devices.
%prep
%autosetup -n %{pkgname}-%{version} -p 1
# Create tmpfiles.d config.
%{__mkdir} -p fedora_addons
%{__cat} << EOF > fedora_addons/%{name}.conf
d %{_rundir}/%{name} 0755 root root -
EOF
# Create desktop-file for the monitor-app.
%{__cat} << EOF > fedora_addons/%{name}-monitor.desktop
[Desktop Entry]
Name=%{name} Monitor
Comment=Application for monitoring %{name}
Icon=%{name}-monitor
Categories=System;Settings;
Exec=%{_bindir}/ThermalMonitor
Type=Application
StartupNotify=true
Terminal=false
EOF
# Create icon for the monitor-app.
%{__cat} << EOF > fedora_addons/%{name}-monitor.svg
EOF
# Create ReadMe.txt for the monitor-app.
%{__cat} << EOF > fedora_addons/%{name}-monitor.ReadMe.txt
Running the thermald-monitor-app
--------------------------------
To communicate with thermald via dbus, the user has to be member
of the "power" group. So make sure to add your user id to this
group before using the thermald-monitor-app.
EOF
%{_bindir}/autoreconf -fiv
%build
%configure \
--disable-option-checking \
--disable-silent-rules
%make_build
# Build the monitor-app.
pushd tools/thermal_monitor
%{__mkdir} -p %{_target_platform}
pushd %{_target_platform}
%{qmake_qt5} ..
%make_build
popd
popd
%install
%make_install
# Install management-script.
%{__install} -Dpm 0755 tools/thermald_set_pref.sh \
%{buildroot}%{_bindir}/%{name}-set-pref
# DBus config belongs into %%{_datadir}.
%{__mkdir} -p %{buildroot}%{_datadir}
%{__mv} -f %{buildroot}%{_sysconfdir}/dbus-1/* %{buildroot}%{_datadir}/dbus-1/
# No Upstart.
%{__rm} -fr %{buildroot}%{_sysconfdir}/init
# Setup tmpfiles.d
%{__install} -Dpm 0644 fedora_addons/%{name}.conf \
%{buildroot}%{_tmpfilesdir}/%{name}.conf
%{__install} -dm 0755 %{buildroot}%{_rundir}/%{name}
/bin/echo "%{name}_pid" > %{buildroot}%{_rundir}/%{name}/%{name}.pid
%{__chmod} -c 0644 %{buildroot}%{_rundir}/%{name}/%{name}.pid
# Install the monitor-app.
%{__install} -Dpm 0755 tools/thermal_monitor/%{_target_platform}/ThermalMonitor \
%{buildroot}%{_bindir}/ThermalMonitor
%{__install} -Dpm 0644 fedora_addons/%{name}-monitor.desktop \
%{buildroot}%{_datadir}/applications/%{name}-monitor.desktop
%{__install} -Dpm 0644 fedora_addons/%{name}-monitor.svg \
%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{name}-monitor.svg
%check
%{_bindir}/desktop-file-validate \
%{buildroot}%{_datadir}/applications/*.desktop
%pre
/bin/getent group power >/dev/null || /sbin/groupadd -r power
exit 0
%post
%systemd_post thermald.service
%preun
%systemd_preun thermald.service
%postun
%systemd_postun_with_restart thermald.service
%post monitor
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
%postun monitor
if [ $1 -eq 0 ] ; then
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor \
&>/dev/null || :
fi
%posttrans monitor
%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor \
&>/dev/null || :
%files
%config(noreplace) %{_sysconfdir}/%{name}
%doc README.txt thermal_daemon_usage.txt
%ghost %dir %{_rundir}/%{name}
%ghost %{_rundir}/%{name}/%{name}.pid
%license COPYING
%{_bindir}/%{name}-set-pref
%{_datadir}/dbus-1/system-services/org.freedesktop.%{name}.service
%{_datadir}/dbus-1/system.d/org.freedesktop.%{name}.conf
%{_mandir}/man5/thermal-conf.xml.5*
%{_mandir}/man8/%{name}.8*
%{_sbindir}/%{name}
%{_tmpfilesdir}/%{name}.conf
%{_unitdir}/%{name}.service
%files monitor
%doc fedora_addons/%{name}-monitor.ReadMe.txt
%license tools/thermal_monitor/qcustomplot/GPL.txt
%{_bindir}/ThermalMonitor
%{_datadir}/applications/%{name}-monitor.desktop
%{_datadir}/icons/hicolor/scalable/apps/%{name}-monitor.svg
%changelog
* Thu Jul 27 2017 Fedora Release Engineering - 1.6-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sat Jul 01 2017 Björn Esser - 1.6-6
- Add upstreamed patch to silence compiler warnings
* Sat Jul 01 2017 Björn Esser - 1.6-5
- Replace fix for rhbz#1464548 from upstream commit
- Add upstream patch to fix README
* Fri Jun 30 2017 Björn Esser - 1.6-4
- Add upstream patch to fix ThermalMonitor (rhbz#1464548)
- Add several fixes from upstream
* Tue Apr 11 2017 Björn Esser - 1.6-3
- Explicitly turn on hardening, if required
* Tue Apr 11 2017 Björn Esser - 1.6-2
- Fix missing trailing semicolon in desktop-file
* Tue Apr 11 2017 Björn Esser - 1.6-1
- Initial import (rhbz#1440406)
* Mon Apr 10 2017 Björn Esser - 1.6-0.4
- Use qmake_qt5-macro and build out of tree
* Sat Apr 08 2017 Björn Esser - 1.6-0.3
- Small packaging improvements
* Sat Apr 08 2017 Björn Esser - 1.6-0.2
- Add management-script
* Sat Apr 08 2017 Björn Esser - 1.6-0.1
- Initial rpm-release (rhbz#1440406)