diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk index 25fec719e243..ef07269722ed 100644 --- a/debian/rules.d/2-binary-arch.mk +++ b/debian/rules.d/2-binary-arch.mk @@ -738,8 +738,8 @@ ifeq ($(do_tools_perf_jvmti),true) install -m755 $(builddirpa)/tools/perf/libperf-jvmti.so $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release) endif ifeq ($(do_tools_perf_python),true) - install -d $(toolspkgdir)/usr/lib/python3/dist-packages/$(src_pkg_name)-tools-$(abi_release) - install -m755 $(builddirpa)/tools/perf/python/perf*.so $(toolspkgdir)/usr/lib/python3/dist-packages/$(src_pkg_name)-tools-$(abi_release) + install -d $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)/lib + install -m644 $(builddirpa)/tools/perf/python/perf.*.so $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)/lib endif endif ifeq ($(do_tools_bpftool),true) diff --git a/debian/rules.d/3-binary-indep.mk b/debian/rules.d/3-binary-indep.mk index 75b8e457b7d0..ab9377497c15 100644 --- a/debian/rules.d/3-binary-indep.mk +++ b/debian/rules.d/3-binary-indep.mk @@ -113,7 +113,7 @@ ifeq ($(do_tools_common),true) ifeq ($(do_tools_perf_python),true) # Python wrapper module for python-perf install -d $(toolspython)/perf - install -m755 debian/tools/python-perf.py $(toolspython)/perf/__init__.py + install -m644 debian/tools/python-perf.py $(toolspython)/perf/__init__.py endif ifeq ($(do_cloud_tools),true) ifeq ($(do_tools_hyperv),true) diff --git a/debian/tools/python-perf.py b/debian/tools/python-perf.py index d572fece82aa..d1991d677dcb 100644 --- a/debian/tools/python-perf.py +++ b/debian/tools/python-perf.py @@ -2,31 +2,30 @@ import os import importlib.util from glob import glob + class KernelNotFoundError(Exception): def __init__(self): kernel_version = os.uname().release - super().__init__(f"WARNING: python perf module not found for kernel {kernel_version}\n\n" - f"You may need to install the following packages for this specific kernel:\n" - f" linux-tools-{kernel_version}-generic\n" - f"You may also want to install of the following package to keep up to date:\n" - f" linux-tools-generic") + flavor = kernel_version.split("-", 2)[2] + super().__init__( + f"\nWARNING: python perf module not found for kernel {kernel_version}\n\n" + f" You may need to install the following package for this specific kernel:\n" + f" linux-tools-{kernel_version}\n\n" + f" You may also want to install the following package to keep up to date:\n" + f" linux-tools-{flavor}" + ) -# Extract ABI number from kernel version -def _get_abi_version(): - _kernel_version = os.uname().release - _parts = _kernel_version.split("-") - return "-".join(_parts[:-1]) # Load the actual python-perf module for the running kernel -_abi_version = _get_abi_version() -_perf_dir = f"/usr/lib/python3/dist-packages/linux-tools-{_abi_version}" +_kernel_version = os.uname().release +_perf_dir = f"/usr/lib/linux-tools/{_kernel_version}/lib" if not os.path.exists(_perf_dir): raise KernelNotFoundError() -_perf_lib = glob(os.path.join(_perf_dir, "*.so"))[-1] +_perf_lib = glob(os.path.join(_perf_dir, "perf.*.so"))[-1] _spec = importlib.util.spec_from_file_location("perf", _perf_lib) _perf = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(_perf) # Expose the 'perf' module. -__all__ = ['perf'] +__all__ = ["perf"]