UBUNTU: [Packaging] linux-tools: Fix python perf library packaging
BugLink: https://bugs.launchpad.net/bugs/2089411 This currently doesn't work for derivatives because there's a level of indirection missing and the top-level wrapper is looking in the wrong place for the .so library. It should be like this: foo -> linux-tools/<abi>-<flavor>/foo -> <source>-tools-<abi>/foo The previous commit took care of the missing indirection. This commit fixes the wrapper to look in the correct directory for the library. While at it, run it through black and make the wrapper and the .so library non-executable. Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> Acked-by: Agathe Porte <agathe.porte@canonical.com> Signed-off-by: Timo Aaltonen <timo.aaltonen@canonical.com> (backported from commit e3092e36b13ccf423258b2232cff0c4d5841d426 plucky:linux) [juergh: Changed $(DEB_SOURCE) -> $(src_pkg_name)] Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> Acked-by: Kevin Becker <kevin.becker@canonical.com> Acked-by: Agathe Porte <agathe.porte@canonical.com> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
6d1e050a5f
commit
1ecc312721
Vendored
+13
-14
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user