* [ptxdist] [PATCH] powertop: version bump 2.15 -> 2.16.1
@ 2026-10-27 12:04 Sven Püschel
0 siblings, 0 replies; only message in thread
From: Sven Püschel @ 2026-10-27 12:04 UTC (permalink / raw)
To: ptxdist; +Cc: Sven Püschel
In 2.16 meson has been introduced and with 2.16.1 autoconf has been
dropped as a build system. Therefore migrated to meson.
With the update to meson powertop is now installed to /usr/bin instead
of /usr/sbin.
As the meson dependency call in powertop did a fallback to find_library
when the dependency call didn't find the library, it was impossible to
prevent accidentially linking against the libpci library (as PTXdist
doesn't have a mechanism to block a find_library call if the library is
not selected as a dependecy). A discussion resulted in the replacement
of the libpci dependency with a small custom implementation [1].
Therefore backported these changes on top of 2.16.1 and dropped the
pciutils dependency and it's corresponding switch.
Also libtracefs is now a new dependency replacing the previously
vendored libtraceevent library [2].
Also added checksum files for the license.
[1] https://github.com/fenrus75/powertop/issues/229
[2] https://github.com/fenrus75/powertop/commit/2b133ed512c6852cf81cb98831bdfd585c0317bf
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
---
patches/powertop-v2.15/autogen.sh | 1 -
...ibpci-with-a-built-in-pci.ids-parser.patch | 261 ++++++++++++++++++
...ild-dependency-searching-to-not-be-a.patch | 170 ++++++++++++
patches/powertop-v2.16.1/series | 5 +
rules/powertop.in | 16 +-
rules/powertop.make | 26 +-
6 files changed, 450 insertions(+), 29 deletions(-)
delete mode 120000 patches/powertop-v2.15/autogen.sh
create mode 100644 patches/powertop-v2.16.1/0001-Replace-libpci-with-a-built-in-pci.ids-parser.patch
create mode 100644 patches/powertop-v2.16.1/0002-cleanup-meson.build-dependency-searching-to-not-be-a.patch
create mode 100644 patches/powertop-v2.16.1/series
diff --git a/patches/powertop-v2.15/autogen.sh b/patches/powertop-v2.15/autogen.sh
deleted file mode 120000
index 9f8a4cb7d..000000000
--- a/patches/powertop-v2.15/autogen.sh
+++ /dev/null
@@ -1 +0,0 @@
-../autogen.sh
\ No newline at end of file
diff --git a/patches/powertop-v2.16.1/0001-Replace-libpci-with-a-built-in-pci.ids-parser.patch b/patches/powertop-v2.16.1/0001-Replace-libpci-with-a-built-in-pci.ids-parser.patch
new file mode 100644
index 000000000..06f189b7b
--- /dev/null
+++ b/patches/powertop-v2.16.1/0001-Replace-libpci-with-a-built-in-pci.ids-parser.patch
@@ -0,0 +1,261 @@
+From: Arjan van de Ven <arjan@linux.intel.com>
+Date: Fri, 23 Oct 2026 07:51:40 -0700
+Subject: [PATCH] Replace libpci with a built-in pci.ids parser
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+PowerTOP only used libpci for a vendor:device -> name lookup. Parse
+pci.ids directly (hwdata, misc and /usr/share locations) instead, which
+removes the libpci build dependency, the HAVE_NO_PCI auto-detection and
+the permanent libpci leak (valgrind suppression and release-checklist
+exception).
+
+HAVE_NO_PCI is now only a test switch that prevents loading the host's
+pci.ids; tests feed fixtures through pci_ids_parse(). Also silence a
+constant-folded -Wformat-truncation warning in the pt_strcpy test.
+
+Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
+Upstream-Status: Backport [https://github.com/fenrus75/powertop/commit/1f32bb317811230913f37d5461b5ead9a08e325b]
+[Sven: only backported the necessary parts. Skipped test and docs]
+Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
+---
+ meson.build | 10 -----
+ src/lib.cpp | 129 +++++++++++++++++++++++++++++++++++++++++++++++-------------
+ src/lib.h | 3 ++
+ 3 files changed, 105 insertions(+), 37 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 03edae691be6..17ea02e51bf5 100644
+--- a/meson.build
++++ b/meson.build
+@@ -23,11 +23,6 @@ if not ncursesw_dep.found()
+ endif
+ endif
+
+-pciutils_dep = dependency('libpci', required: false)
+-if not pciutils_dep.found()
+- pciutils_dep = cc.find_library('pci', required: false)
+-endif
+-
+ libtracefs_dep = dependency('libtracefs', required: true)
+
+ libnl3_dep = dependency('libnl-3.0', version: '>= 3.0', required: false)
+@@ -74,10 +69,6 @@ if has_libnl20
+ conf_data.set('HAVE_LIBNL20', 1)
+ endif
+
+-if not pciutils_dep.found()
+- conf_data.set('HAVE_NO_PCI', 1)
+-endif
+-
+ check_headers = [
+ 'fcntl.h',
+ 'libintl.h',
+@@ -297,7 +288,6 @@ powertop_exe = executable('powertop',
+ include_directories: [src_inc, include_directories('.')],
+ dependencies: [
+ ncursesw_dep,
+- pciutils_dep,
+ libtracefs_dep,
+ libnl_deps,
+ pthread_dep,
+diff --git a/src/lib.cpp b/src/lib.cpp
+index 7cf5f7c45f4f..3ace47d1c02d 100644
+--- a/src/lib.cpp
++++ b/src/lib.cpp
+@@ -26,6 +26,7 @@
+ #include <algorithm>
+ #include <atomic>
+ #include <cctype>
++#include <charconv>
+ #include <cmath>
+ #include <cstdint>
+ #include <cstdio>
+@@ -40,6 +41,7 @@
+ #include <mutex>
+ #include <sstream>
+ #include <string>
++#include <string_view>
+ #include <utility>
+ #include <vector>
+
+@@ -54,12 +56,6 @@
+ #include "lib.h"
+ #include "test_framework.h"
+
+-#ifndef HAVE_NO_PCI
+-extern "C" {
+-#include <pci/pci.h>
+-}
+-#endif
+-
+ extern void set_notification(const std::string &msg) __attribute__((weak));
+
+ static int kallsyms_read = 0;
+@@ -368,44 +364,123 @@ std::string format_watts(double W, unsigned int len)
+ return buffer;
+ }
+
+-#ifndef HAVE_NO_PCI
+-static struct pci_access *pci_access;
++/*
++ * Minimal pci.ids parser. Format (see pci.ids header):
++ * - '#' comment lines and blank lines are ignored
++ * - "vvvv Vendor name" starts a vendor (column 0, 4 hex digits)
++ * - "<tab>dddd Device name" device of the current vendor
++ * - "<tab><tab>..." subsystem lines, ignored
++ * - "C xx Class name" and later device-class section, ends the vendor list
++ * Vendor and device ids are keyed as (vendor << 16 | device); a device-less
++ * vendor entry uses device id 0 in the separate vendor map.
++ */
++static std::map<uint16_t, std::string> pci_vendor_names;
++static std::map<uint32_t, std::string> pci_device_names;
++static bool pci_ids_loaded;
+
+-std::string pci_id_to_name(uint16_t vendor, uint16_t device)
++/* Parses exactly 4 hex digits at the start of s; returns false otherwise */
++static bool parse_pci_hex4(std::string_view s, uint16_t &out)
+ {
+- const int len = 4096;
+- std::vector<char> buf(len);
+-
+- if (!pci_access) {
+- pci_access = pci_alloc();
+- pci_init(pci_access);
+- }
++ if (s.size() < 4)
++ return false;
++ unsigned int v = 0;
++ auto [ptr, ec] = std::from_chars(s.data(), s.data() + 4, v, 16);
++ if (ec != std::errc() || ptr != s.data() + 4)
++ return false;
++ out = static_cast<uint16_t>(v);
++ return true;
++}
+
+- const char *ret = pci_lookup_name(pci_access, buf.data(), len, PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, vendor, device);
+- return ret ? std::string(ret) : std::string();
++/* Returns the name following the id: skips the separating whitespace */
++static std::string pci_name_after_id(std::string_view s)
++{
++ size_t pos = s.find_first_not_of(" \t", 4);
++ if (pos == std::string_view::npos)
++ return {};
++ return std::string(s.substr(pos));
+ }
+
+-void end_pci_access(void)
++void pci_ids_parse(std::istream &in)
+ {
+- if (pci_access) {
+- pci_cleanup(pci_access);
+- pci_access = nullptr;
++ pci_vendor_names.clear();
++ pci_device_names.clear();
++ pci_ids_loaded = true;
++
++ std::string line;
++ bool have_vendor = false;
++ uint16_t vendor = 0;
++
++ while (std::getline(in, line)) {
++ if (!line.empty() && line.back() == '\r')
++ line.pop_back();
++ if (line.empty() || line[0] == '#')
++ continue;
++
++ if (line[0] == '\t') {
++ if (!have_vendor || line.size() < 2 || line[1] == '\t' || line[1] == '#')
++ continue;
++ uint16_t device;
++ std::string_view body(line);
++ body.remove_prefix(1);
++ if (parse_pci_hex4(body, device))
++ pci_device_names[(uint32_t(vendor) << 16) | device] = pci_name_after_id(body);
++ continue;
++ }
++
++ /* The class section follows the vendor section; nothing more to read */
++ if (line[0] == 'C' && line.size() > 1 && line[1] == ' ')
++ break;
++
++ have_vendor = parse_pci_hex4(line, vendor);
++ if (have_vendor)
++ pci_vendor_names[vendor] = pci_name_after_id(line);
+ }
+ }
+
+-#else
++#ifndef HAVE_NO_PCI
++static void pci_ids_load_system(void)
++{
++ static const char *const paths[] = {
++ "/usr/share/hwdata/pci.ids",
++ "/usr/share/misc/pci.ids",
++ "/usr/share/pci.ids",
++ };
++
++ for (const char *path : paths) {
++ std::ifstream file(path);
++ if (file) {
++ pci_ids_parse(file);
++ return;
++ }
++ }
++ pci_ids_loaded = true; /* no database installed: names stay unknown */
++}
++#endif
+
+-std::string pci_id_to_name([[maybe_unused]] uint16_t vendor, [[maybe_unused]] uint16_t device)
++std::string pci_id_to_name(uint16_t vendor, uint16_t device)
+ {
+- return std::string();
++#ifndef HAVE_NO_PCI
++ if (!pci_ids_loaded)
++ pci_ids_load_system();
++#endif
++
++ auto v = pci_vendor_names.find(vendor);
++ if (v == pci_vendor_names.end())
++ return {};
++
++ auto d = pci_device_names.find((uint32_t(vendor) << 16) | device);
++ if (d == pci_device_names.end())
++ return v->second;
++ return v->second + " " + d->second;
+ }
+
+ void end_pci_access(void)
+ {
++ pci_vendor_names.clear();
++ pci_device_names.clear();
++ pci_ids_loaded = false;
+ }
+
+-#endif /* HAVE_NO_PCI */
+-
+ int utf_ok = -1;
+
+
+diff --git a/src/lib.h b/src/lib.h
+index f3b421ad4f08..582782039b1a 100644
+--- a/src/lib.h
++++ b/src/lib.h
+@@ -31,6 +31,7 @@
+ #ifdef __cplusplus
+
+ #include <format>
++#include <iosfwd>
+ #include <string_view>
+ #include <vector>
+
+@@ -110,6 +111,8 @@ extern std::string format_watts(double W, unsigned int len);
+
+ extern std::string pci_id_to_name(uint16_t vendor, uint16_t device);
+ extern void end_pci_access(void);
++/* Replaces the vendor/device name tables with the contents of a pci.ids stream (exposed for tests) */
++extern void pci_ids_parse(std::istream &in);
+
+
+ extern std::string fmt_prefix(double n);
diff --git a/patches/powertop-v2.16.1/0002-cleanup-meson.build-dependency-searching-to-not-be-a.patch b/patches/powertop-v2.16.1/0002-cleanup-meson.build-dependency-searching-to-not-be-a.patch
new file mode 100644
index 000000000..ebbe4ba50
--- /dev/null
+++ b/patches/powertop-v2.16.1/0002-cleanup-meson.build-dependency-searching-to-not-be-a.patch
@@ -0,0 +1,170 @@
+From: Arjan van de Ven <arjan@linux.intel.com>
+Date: Fri, 23 Oct 2026 08:02:20 -0700
+Subject: [PATCH] cleanup meson.build dependency searching to not be an awful
+ conversion from autoconf
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Upstream-Status: Backport [https://github.com/fenrus75/powertop/commit/993dc340c43b51655fb43c4cfa64883348b30583]
+Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
+---
+ meson.build | 52 ++++++----------------------------------------------
+ src/tuning/iw.c | 27 +--------------------------
+ src/tuning/iw.h | 8 +++-----
+ 3 files changed, 10 insertions(+), 77 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 17ea02e51bf5..76981d610fe1 100644
+--- a/meson.build
++++ b/meson.build
+@@ -12,48 +12,12 @@ cc = meson.get_compiler('c')
+ cpp = meson.get_compiler('cpp')
+
+ # Dependencies
+-ncursesw_dep = dependency('ncursesw', required: false)
+-if not ncursesw_dep.found()
+- ncursesw_dep = dependency('ncurses', required: false)
+-endif
+-if not ncursesw_dep.found()
+- ncursesw_dep = cc.find_library('ncursesw', required: false)
+- if not ncursesw_dep.found()
+- ncursesw_dep = cc.find_library('ncurses', required: true)
+- endif
+-endif
+-
++ncursesw_dep = dependency('ncursesw', required: true)
+ libtracefs_dep = dependency('libtracefs', required: true)
+-
+-libnl3_dep = dependency('libnl-3.0', version: '>= 3.0', required: false)
+-libnlgenl3_dep = dependency('libnl-genl-3.0', version: '>= 3.0', required: false)
+-
+-libnl_deps = []
+-has_libnl20 = false
+-
+-if libnl3_dep.found()
+- libnl_deps += [libnl3_dep]
+- if libnlgenl3_dep.found()
+- libnl_deps += [libnlgenl3_dep]
+- else
+- libnlgenl3_dep = cc.find_library('nl-genl-3', required: true)
+- libnl_deps += [libnlgenl3_dep]
+- endif
+- has_libnl20 = true
+-else
+- libnl20_dep = dependency('libnl-2.0', version: '>= 2.0', required: false)
+- if libnl20_dep.found()
+- libnl_deps = [libnl20_dep]
+- has_libnl20 = true
+- else
+- libnl1_dep = dependency('libnl-1', required: true)
+- libnl_deps = [libnl1_dep]
+- endif
+-endif
+-
++libnl3_dep = dependency('libnl-3.0', version: '>= 3.0', required: true)
++libnlgenl3_dep = dependency('libnl-genl-3.0', version: '>= 3.0', required: true)
+ pthread_dep = dependency('threads')
+ resolv_dep = cc.find_library('resolv', required: true)
+-rt_dep = cc.find_library('rt', required: false)
+
+ # Configuration
+ conf_data = configuration_data()
+@@ -65,10 +29,6 @@ conf_data.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/fenrus75/powertop/
+ conf_data.set_quoted('PACKAGE_URL', 'https://github.com/fenrus75/powertop')
+ conf_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
+
+-if has_libnl20
+- conf_data.set('HAVE_LIBNL20', 1)
+-endif
+-
+ check_headers = [
+ 'fcntl.h',
+ 'libintl.h',
+@@ -289,10 +249,10 @@ powertop_exe = executable('powertop',
+ dependencies: [
+ ncursesw_dep,
+ libtracefs_dep,
+- libnl_deps,
++ libnl3_dep,
++ libnlgenl3_dep,
+ pthread_dep,
+ resolv_dep,
+- rt_dep,
+ ],
+ cpp_args: [
+ '-Wformat',
+@@ -384,4 +344,4 @@ if valgrind.found() and get_option('b_sanitize') == 'none'
+ suite: 'valgrind',
+ )
+ endif
+-endif
++endif
+\ No newline at end of file
+diff --git a/src/tuning/iw.c b/src/tuning/iw.c
+index 0abdabb33e92..0d972ea72ae8 100644
+--- a/src/tuning/iw.c
++++ b/src/tuning/iw.c
+@@ -52,31 +52,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ #include "../lib.h"
+
+
+-#ifndef HAVE_LIBNL20
+-/* libnl 2.0 compatibility code */
+-
+-static inline struct nl_handle *nl_socket_alloc(void)
+-{
+- return nl_handle_alloc();
+-}
+-
+-static inline void nl_socket_free(struct nl_sock *h)
+-{
+- nl_handle_destroy(h);
+-}
+-
+-static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct nl_cache **cache)
+-{
+- struct nl_cache *tmp = genl_ctrl_alloc_cache(h);
+- if (!tmp)
+- return -ENOMEM;
+- *cache = tmp;
+- return 0;
+-}
+-#define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache
+-#endif /* HAVE_LIBNL20 */
+-
+-
+ static int nl80211_init(struct nl80211_state *state)
+ {
+ int err;
+@@ -303,4 +278,4 @@ int get_wifi_power_saving(const char *iface)
+ return 1;
+
+ return enable_power_save;
+-}
++}
+\ No newline at end of file
+diff --git a/src/tuning/iw.h b/src/tuning/iw.h
+index 743a38c896fc..ccfa30ff26ea 100644
+--- a/src/tuning/iw.h
++++ b/src/tuning/iw.h
+@@ -39,9 +39,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ #include "config.h"
+ #endif
+
+-#ifndef HAVE_LIBNL20
+-#define nl_sock nl_handle
+-#endif
++
++
+
+ struct nl80211_state {
+ struct nl_sock *nl_sock;
+@@ -71,5 +70,4 @@ int set_wifi_power_saving(const char *iface, int state);
+
+ #ifdef __cplusplus
+ }
+-#endif
+-
++#endif
+\ No newline at end of file
diff --git a/patches/powertop-v2.16.1/series b/patches/powertop-v2.16.1/series
new file mode 100644
index 000000000..44c28912f
--- /dev/null
+++ b/patches/powertop-v2.16.1/series
@@ -0,0 +1,5 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-Replace-libpci-with-a-built-in-pci.ids-parser.patch
+0002-cleanup-meson.build-dependency-searching-to-not-be-a.patch
+# 7540d4941ff359a8c4a915fb5c37b795 - git-ptx-patches magic
diff --git a/rules/powertop.in b/rules/powertop.in
index 3418bef1b..8f2425261 100644
--- a/rules/powertop.in
+++ b/rules/powertop.in
@@ -4,13 +4,12 @@ menuconfig POWERTOP
tristate
prompt "powertop "
select HOST_GETTEXT
- select HOST_AUTOTOOLS_AUTOCONF_ARCHIVE
+ select HOST_MESON
select NCURSES
select LIBNL3
select LIBC_RESOLV
select LIBC_PTHREAD
- select PCIUTILS if POWERTOP_PCI_SUPPORT
- select PCIUTILS_LIBPCI if POWERTOP_PCI_SUPPORT
+ select LIBTRACEFS
depends on !BUSYBOX_POWERTOP || ALLYES
help
PowerTOP is a Linux tool that finds the software
@@ -27,17 +26,6 @@ menuconfig POWERTOP
convenient screen so that you can see how well your system
is doing, and which components are the biggest problem.
-if POWERTOP
-
-config POWERTOP_PCI_SUPPORT
- bool
- prompt "pci support"
- help
- This adds powertop support for the PCI bus. Should only be
- enabled if you have PCI support.
-
-endif
-
comment "BusyBox' powertop is selected!"
depends on BUSYBOX_POWERTOP
diff --git a/rules/powertop.make b/rules/powertop.make
index 04aadcb60..d7155c620 100644
--- a/rules/powertop.make
+++ b/rules/powertop.make
@@ -15,33 +15,31 @@ PACKAGES-$(PTXCONF_POWERTOP) += powertop
#
# Paths and names
#
-POWERTOP_VERSION := 2.15
-POWERTOP_SHA256 := e58ab3fd7b8ff5f4dd0d17f11848817e7d83c0a6918145ac81de03b5dccf8f49
+POWERTOP_VERSION := 2.16.1
+POWERTOP_SHA256 := 73d5e96d992ed7f040e17c6c9130deebcf42c38990711840981c7afac6f7832f
POWERTOP := powertop-v$(POWERTOP_VERSION)
POWERTOP_SUFFIX := tar.gz
POWERTOP_URL := https://github.com/fenrus75/powertop/archive/refs/tags/v$(POWERTOP_VERSION).$(POWERTOP_SUFFIX)
POWERTOP_SOURCE := $(SRCDIR)/$(POWERTOP).$(POWERTOP_SUFFIX)
POWERTOP_DIR := $(BUILDDIR)/$(POWERTOP)
POWERTOP_LICENSE := GPL-2.0-only
+POWERTOP_LICENSE_FILES := \
+ file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \
+ file://src/main.cpp;startline=1;endline=29;md5=6cc786afdc98b8098452aa4f41300d53
# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------
-POWERTOP_CONF_ENV := \
- $(CROSS_ENV) \
- ac_cv_search_pci_get_dev=$(call ptx/yesno, PTXCONF_POWERTOP_PCI_SUPPORT)
-
#
-# autoconf
+# meson
#
-POWERTOP_CONF_TOOL := autoconf
+POWERTOP_CONF_TOOL := meson
POWERTOP_CONF_OPT := \
- $(CROSS_AUTOCONF_USR) \
- --disable-nls \
- --disable-rpath \
- --without-libiconv-prefix \
- --without-libintl-prefix
+ $(CROSS_MESON_USR) \
+ -Denable-tests=false \
+ -Dnls=false \
+ -Dtest-framework=false
# ----------------------------------------------------------------------------
# Target-Install
@@ -56,7 +54,7 @@ $(STATEDIR)/powertop.targetinstall:
@$(call install_fixup, powertop,AUTHOR,"Marc Kleine-Budde <mkl@pengutronix.de>")
@$(call install_fixup, powertop,DESCRIPTION,missing)
- @$(call install_copy, powertop, 0, 0, 0755, -, /usr/sbin/powertop)
+ @$(call install_copy, powertop, 0, 0, 0755, -, /usr/bin/powertop)
@$(call install_finish, powertop)
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-27 12:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 12:04 [ptxdist] [PATCH] powertop: version bump 2.15 -> 2.16.1 Sven Püschel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox