new file mode 100644
@@ -0,0 +1,6 @@
+bin/linux-check-removal usr/bin
+bin/linux-update-symlinks usr/bin
+bin/linux-version usr/bin
+bin/perf usr/bin
+lib/DebianLinux.pm usr/share/perl5
+lib/python3/dist-packages/perf.py usr/lib/python3/dist-packages/
new file mode 100644
@@ -0,0 +1,23 @@
+#!/usr/bin/python3
+# Wrapper to load the kernel-specific version
+# of the python perf module
+
+import platform
+
+uname = platform.uname().release
+kvers = uname.split('.')
+
+if len(kvers) < 2:
+ raise RuntimeError('Could not detect kernel version in: {}'.format(kvers))
+try:
+ perf = __import__('perf_{}_{}'.format(kvers[0], kvers[1]))
+ symbols = [symbol for symbol in perf.__dict__ if not symbol.startswith("_")]
+ globals().update({symbol: getattr(perf, symbol) for symbol in symbols})
+ del perf
+ del symbols
+except ModuleNotFoundError:
+ raise ModuleNotFoundError('perf package not found. Install debian package linux-perf-{}.{}'.format(kvers[0],kvers[1]))
+
+del platform
+del uname
+del kvers
new file mode 100644
@@ -0,0 +1,25 @@
+# Patched version of linux-base that includes perf python wrapper
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2021
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg
+
+SRC_URI = " \
+ apt://${PN} \
+ file://lib/python3/dist-packages/perf.py \
+ file://debian/linux-base.install \
+ "
+
+MAINTAINER ?= "isar-users <isar-users@googlegroups.com>"
+CHANGELOG_V ?= "<orig-version>+isar"
+
+do_prepare_build() {
+ mkdir -p ${S}/lib/python3/dist-packages
+ cp -r ${WORKDIR}/lib ${S}
+ cp -r ${WORKDIR}/debian ${S}
+ cd ${S}
+ deb_add_changelog
+}
This patch adds a wrapper around the versioned python bindings of perf. The wrapper takes care of detecting the current kernel version and loading the perf_<version> module. Then, it mapps this module to just perf, so downstream python modules just have to `import perf` instead of the versioned version. Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> --- .../files/debian/linux-base.install | 6 +++++ .../files/lib/python3/dist-packages/perf.py | 23 +++++++++++++++++ .../recipes-core/linux-base/linux-base_4.6.bb | 25 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 meta-isar/recipes-core/linux-base/files/debian/linux-base.install create mode 100644 meta-isar/recipes-core/linux-base/files/lib/python3/dist-packages/perf.py create mode 100644 meta-isar/recipes-core/linux-base/linux-base_4.6.bb