From 39bfba866e8aafbe037a7ab70c669bcd582a07c2 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Tue, 7 Jan 2025 01:24:22 +0800 Subject: [PATCH] fix build with latest gettext (cherry picked from commit 433ada4c41f7f823bdae61ab79bb0c44ebbc40af) --- ...configure-to-support-ncurses-w-tinfo.patch | 38 +++++++++++++++++++ ...riscv-t-head-1520-cpu-identification.patch | 38 +++++++++++++++++++ powertop-2.15-gettext-0.19.patch | 15 ++++++++ powertop.service | 12 ++++++ powertop.spec | 31 ++++++++++----- powertop.yaml | 2 +- 6 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 backport-powertop-2.15-fix-configure-to-support-ncurses-w-tinfo.patch create mode 100644 backport-powertop-2.15-fixed-riscv-t-head-1520-cpu-identification.patch create mode 100644 powertop-2.15-gettext-0.19.patch diff --git a/backport-powertop-2.15-fix-configure-to-support-ncurses-w-tinfo.patch b/backport-powertop-2.15-fix-configure-to-support-ncurses-w-tinfo.patch new file mode 100644 index 0000000..346ef5f --- /dev/null +++ b/backport-powertop-2.15-fix-configure-to-support-ncurses-w-tinfo.patch @@ -0,0 +1,38 @@ +From c339df50d858041255bb759fe8a6a54ce369409b Mon Sep 17 00:00:00 2001 +From: Zentaro Kavanagh +Date: Thu, 14 Jun 2018 13:13:37 -0700 +Subject: [PATCH] Fix configure to support ncurses w/ tinfo + +- The existing code checked for both ncursesw and ncurses and if + both were not found, NCURSES_LIBS was not set correctly. +- Removed redundant concatenation to $LIBS since the makefile.am + already maps NCURSES_LIBS into LIBS. +- Patch sent upstream to powertop mailing list [1] + +[1] - https://lists.01.org/pipermail/powertop/2018-June/002021.html +--- + configure.ac | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index a69cf619..c698818b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -116,10 +116,13 @@ AC_CHECK_FUNCS([ \ + + AC_SEARCH_LIBS([clock_gettime], [rt]) + +-PKG_CHECK_MODULES([NCURSES], [ncursesw ncurses], [LIBS="$LIBS $ncurses_LIBS"], [ +- AC_SEARCH_LIBS([delwin], [ncursesw ncurses], [], [ +- AC_MSG_ERROR([ncurses is required but was not found]) +- ], []) ++PKG_CHECK_MODULES([ncursesw], [ncursesw], ++ [NCURSES_CFLAGS="$ncursesw_CFLAGS"; NCURSES_LIBS="$ncursesw_LIBS"], [ ++ PKG_CHECK_MODULES([NCURSES], [ncurses], [], [ ++ AC_SEARCH_LIBS([delwin], [ncursesw ncurses], [], [ ++ AC_MSG_ERROR([ncurses is required but was not found]) ++ ]) ++ ]) + ]) + + has_libpci=0 diff --git a/backport-powertop-2.15-fixed-riscv-t-head-1520-cpu-identification.patch b/backport-powertop-2.15-fixed-riscv-t-head-1520-cpu-identification.patch new file mode 100644 index 0000000..6ed341e --- /dev/null +++ b/backport-powertop-2.15-fixed-riscv-t-head-1520-cpu-identification.patch @@ -0,0 +1,38 @@ +From 184b2f4dd43dfbec64654ba9dce6aa6645717ca1 Mon Sep 17 00:00:00 2001 +From: Renat Sabitov +Date: Thu, 2 Nov 2023 22:03:05 +1000 +Subject: [PATCH] Fixed RISCV T-Head 1520 CPU identification + +--- + src/cpu/cpu.cpp | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp +index eb1578d9..ca1e3a74 100644 +--- a/src/cpu/cpu.cpp ++++ b/src/cpu/cpu.cpp +@@ -174,6 +174,8 @@ static void handle_one_cpu(unsigned int number, char *vendor, int family, int mo + file.open(filename, ios::in); + if (file) { + file >> core_number; ++ if (core_number == (unsigned int) -1) ++ core_number = number; + file.close(); + } + +@@ -300,11 +302,13 @@ void enumerate_cpus(void) + } + /* on x86 and others 'bogomips' is last + * on ARM it *can* be bogomips, or 'CPU revision' +- * on POWER, it's revision ++ * on POWER, it's 'revision' ++ * on RISCV64 it's 'isa' + */ + if (strncasecmp(line, "bogomips\t", 9) == 0 + || strncasecmp(line, "CPU revision\t", 13) == 0 +- || strncmp(line, "revision", 8) == 0) { ++ || strncmp(line, "revision", 8) == 0 ++ || strncmp(line, "isa\t", 4) == 0) { + if (number == -1) { + /* Not all /proc/cpuinfo include "processor\t". */ + number = 0; diff --git a/powertop-2.15-gettext-0.19.patch b/powertop-2.15-gettext-0.19.patch new file mode 100644 index 0000000..ed4e260 --- /dev/null +++ b/powertop-2.15-gettext-0.19.patch @@ -0,0 +1,15 @@ +--- powertop-2.15/configure.ac.orig 2025-01-07 00:36:37.491841200 +0800 ++++ powertop-2.15/configure.ac 2025-01-07 00:37:15.629889400 +0800 +@@ -26,7 +26,11 @@ + AC_SUBST([GETTEXT_PACKAGE]) + AM_SILENT_RULES([yes]) + AM_GNU_GETTEXT([external]) +-AM_GNU_GETTEXT_VERSION([0.18.2]) ++dnl Support for _REQUIRE_VERSION was added in gettext 0.19.6. If both ++dnl _REQUIRE_VERSION and _VERSION are present, the _VERSION is ignored. ++dnl We use both for compatibility with other programs in the Autotools family. ++AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6]) ++AM_GNU_GETTEXT_VERSION([0.19.6]) + + m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + AX_REQUIRE_DEFINED([AX_ADD_FORTIFY_SOURCE]) diff --git a/powertop.service b/powertop.service index 96669ae..48005e6 100644 --- a/powertop.service +++ b/powertop.service @@ -2,6 +2,18 @@ Description=PowerTOP autotuner [Service] +# added automatically, for details please see +# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort +ProtectSystem=full +ProtectHome=true +PrivateDevices=true +ProtectHostname=true +ProtectClock=true +ProtectKernelModules=true +ProtectKernelLogs=true +ProtectControlGroups=true +RestrictRealtime=true +# end of automatic additions Type=oneshot ExecStart=/usr/sbin/powertop --auto-tune diff --git a/powertop.spec b/powertop.spec index 262e699..6787491 100644 --- a/powertop.spec +++ b/powertop.spec @@ -1,17 +1,26 @@ Name: powertop Version: 2.15 -Release: 1 +Release: 2 Summary: Power consumption tool for Linux -License: GPLv2 -URL: http://01.org/powertop/ -Source0: http://github.com/fenrus75/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz +License: GPL-2.0-only AND LGPL-2.1-only AND ISC +URL: https://github.com/fenrus75/powertop +Source0: https://github.com/fenrus75/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz Source1: powertop.service Patch1: backport-powertop-2.7-always-create-params.patch +Patch2: powertop-2.15-gettext-0.19.patch +Patch6001: backport-powertop-2.15-fix-configure-to-support-ncurses-w-tinfo.patch +Patch6002: backport-powertop-2.15-fixed-riscv-t-head-1520-cpu-identification.patch BuildRequires: autoconf autoconf-archive automake libtool BuildRequires: gcc gcc-c++ systemd -BuildRequires: gettext-devel ncurses-devel pciutils-devel zlib-devel libnl3-devel +BuildRequires: gettext-devel +BuildRequires: pkgconfig(bash-completion) +BuildRequires: pkgconfig(libnl-3.0) >= 3.0 +BuildRequires: pkgconfig(libnl-genl-3.0) >= 3.0 +BuildRequires: pkgconfig(libpci) +BuildRequires: pkgconfig(ncursesw) +BuildRequires: pkgconfig(zlib) Requires(post): coreutils %{?systemd_requires} Provides: bundled(kernel-event-lib) @@ -42,8 +51,6 @@ touch $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name}/{saved_parameters.powertop, install -Dpm 644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/powertop.service -%pre - %preun %systemd_preun powertop.service @@ -56,8 +63,8 @@ install -Dpm 644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/powertop.service touch %{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results.powertop} &> /dev/null || : %files -f %{name}.lang -%defattr(-,root,root) -%doc COPYING README.md README.traceevent CONTRIBUTE.md TODO +%license COPYING +%doc README.md README.traceevent CONTRIBUTE.md TODO %{_sbindir}/powertop %{_unitdir}/powertop.service %dir %{_localstatedir}/cache/powertop @@ -68,8 +75,12 @@ touch %{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results. %files help %{_mandir}/man8/powertop.8* - %changelog +* Tue Jan 07 2025 Funda Wang - 2.15-2 +- fix build with latest gettext +- harden systemd service file from openSUSE +- add patch regarding risc-v arch support + * Sat May 6 2023 panxiaohe - 2.15-1 - update to 2.15 diff --git a/powertop.yaml b/powertop.yaml index 3f305d1..e2dc4ff 100644 --- a/powertop.yaml +++ b/powertop.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: "fenrus75/powertop" tag_prefix: "^v" -seperator: +separator: -- Gitee