diff --git a/cpupower.path b/cpupower.path new file mode 100644 index 0000000..26e11d3 --- /dev/null +++ b/cpupower.path @@ -0,0 +1,9 @@ +[Unit] +Description=cpupower - wait for the list of frequency governors +After=syslog.target + +[Path] +PathExists=/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors + +[Install] +WantedBy=multi-user.target diff --git a/cpupower.service b/cpupower.service index 44a119b..9a8aa5c 100644 --- a/cpupower.service +++ b/cpupower.service @@ -1,6 +1,7 @@ [Unit] Description=Configure CPU frequency settings After=syslog.target +ConditionPathExists=/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors [Service] Type=oneshot @@ -10,3 +11,4 @@ ExecStart=/usr/bin/cpupower-start.sh [Install] WantedBy=multi-user.target +Also=cpupower.path diff --git a/kernel.spec b/kernel.spec index 4185c71..bdf5753 100644 --- a/kernel.spec +++ b/kernel.spec @@ -29,7 +29,7 @@ %define rpmrel %mkrel 0.%{kpatch}.%{mibrel} %endif %else -%define rpmrel 3 +%define rpmrel 4 %endif # fakerel and fakever never change, they are used to fool @@ -349,10 +349,11 @@ Source2: disable-mrproper-prepare-scripts-configs-in-devel-rpms.patch Source4: README.kernel-sources Source5: kernel.rpmlintrc -# Cpupower: the service, the config and the wrapper script +# Cpupower: the service, the config, etc. Source50: cpupower.service Source51: cpupower.config Source52: cpupower-start.sh +Source53: cpupower.path # Our patch tarball, # see https://abf.rosalinux.ru/soft/kernel-patches-and-configs/ @@ -1038,14 +1039,16 @@ The cpupower tools. %post -n cpupower if [ $1 -ge 0 ]; then - /bin/systemctl enable cpupower >/dev/null 2>&1 || : - /bin/systemctl start cpupower >/dev/null 2>&1 || : +# Do not enable/disable cpupower.service directly, because it should start +# when cpupower.path triggers it. + /bin/systemctl enable cpupower.path >/dev/null 2>&1 || : + /bin/systemctl start cpupower.path >/dev/null 2>&1 || : fi %preun -n cpupower if [ $1 -eq 0 ]; then - /bin/systemctl --no-reload disable cpupower > /dev/null 2>&1 || : - /bin/systemctl stop cpupower > /dev/null 2>&1 || : + /bin/systemctl --no-reload disable cpupower.path > /dev/null 2>&1 || : + /bin/systemctl stop cpupower.path > /dev/null 2>&1 || : fi %package -n cpupower-devel @@ -1836,6 +1839,7 @@ mv cpupower.lang ../ chmod 0755 %{buildroot}%{_libdir}/libcpupower.so* mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig install -m644 %{SOURCE50} %{buildroot}%{_unitdir}/cpupower.service +install -m644 %{SOURCE53} %{buildroot}%{_unitdir}/cpupower.path install -m644 %{SOURCE51} %{buildroot}%{_sysconfdir}/sysconfig/cpupower install -m755 %{SOURCE52} %{buildroot}%{_bindir}/cpupower-start.sh %endif @@ -1953,6 +1957,7 @@ rm -rf %{buildroot} %{_libdir}/libcpupower.so.0 %{_libdir}/libcpupower.so.0.0.0 %{_unitdir}/cpupower.service +%{_unitdir}/cpupower.path %{_mandir}/man[1-8]/cpupower* %config(noreplace) %{_sysconfdir}/sysconfig/cpupower