Coverage for src/debputy/plugin/debputy/shlib_metadata_detectors.py: 100%
17 statements
« prev ^ index » next coverage.py v7.6.0, created at 2025-01-27 13:59 +0000
« prev ^ index » next coverage.py v7.6.0, created at 2025-01-27 13:59 +0000
1from typing import List
3from debputy import elf_util
4from debputy.elf_util import ELF_LINKING_TYPE_DYNAMIC
5from debputy.plugin.api import (
6 VirtualPath,
7 PackageProcessingContext,
8)
9from debputy.plugin.api.impl import BinaryCtrlAccessorProvider
11SKIPPED_DEBUG_DIRS = [
12 "lib",
13 "lib64",
14 "usr",
15 "bin",
16 "sbin",
17 "opt",
18 "dev",
19 "emul",
20 ".build-id",
21]
23SKIP_DIRS = {f"./usr/lib/debug/{subdir}" for subdir in SKIPPED_DEBUG_DIRS}
26def _walk_filter(fs_path: VirtualPath, children: List[VirtualPath]) -> bool:
27 if fs_path.path in SKIP_DIRS:
28 children.clear()
29 return False
30 return True
33def detect_shlibdeps(
34 fs_root: VirtualPath,
35 ctrl: BinaryCtrlAccessorProvider,
36 _context: PackageProcessingContext,
37) -> None:
38 elf_files_to_process = elf_util.find_all_elf_files(
39 fs_root,
40 walk_filter=_walk_filter,
41 with_linking_type=ELF_LINKING_TYPE_DYNAMIC,
42 )
44 if not elf_files_to_process:
45 return
47 ctrl.dpkg_shlibdeps(elf_files_to_process)