Coverage for src/debputy/plugins/debputy/shlib_metadata_detectors.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2026-01-16 17:20 +0000

1from debputy import elf_util 

2from debputy.elf_util import ELF_LINKING_TYPE_DYNAMIC 

3from debputy.plugin.api import ( 

4 VirtualPath, 

5 PackageProcessingContext, 

6) 

7from debputy.plugin.api.impl import BinaryCtrlAccessorProvider 

8 

9SKIPPED_DEBUG_DIRS = [ 

10 "lib", 

11 "lib64", 

12 "usr", 

13 "bin", 

14 "sbin", 

15 "opt", 

16 "dev", 

17 "emul", 

18 ".build-id", 

19] 

20 

21SKIP_DIRS = {f"./usr/lib/debug/{subdir}" for subdir in SKIPPED_DEBUG_DIRS} 

22 

23 

24def _walk_filter(fs_path: VirtualPath, children: list[VirtualPath]) -> bool: 

25 if fs_path.path in SKIP_DIRS: 

26 children.clear() 

27 return False 

28 return True 

29 

30 

31def detect_shlibdeps( 

32 fs_root: VirtualPath, 

33 ctrl: BinaryCtrlAccessorProvider, 

34 _context: PackageProcessingContext, 

35) -> None: 

36 elf_files_to_process = elf_util.find_all_elf_files( 

37 fs_root, 

38 walk_filter=_walk_filter, 

39 with_linking_type=ELF_LINKING_TYPE_DYNAMIC, 

40 ) 

41 

42 if not elf_files_to_process: 

43 return 

44 

45 ctrl.dpkg_shlibdeps(elf_files_to_process)