in scripts/elf_ubuntu_dependency_analyzer.py [0:0]
def get_package_info(lib_path):
"""
Get package information for a given library path.
Args:
lib_path (str): The path to the library.
Returns:
tuple: A tuple containing the package name and full package information.
"""
if lib_path.startswith('/usr/local/cloudberry-db'):
return "cloudberry-custom", f"Cloudberry custom library: {lib_path}"
dpkg_output = run_command(['dpkg', '-S', lib_path])
if dpkg_output:
package_name = dpkg_output.split(':')[0]
return package_name, dpkg_output.strip()
# List of core system libraries that might not be individually tracked by dpkg
core_libs = {
'libc.so': 'libc6',
'libm.so': 'libc6',
'libdl.so': 'libc6',
'libpthread.so': 'libc6',
'libresolv.so': 'libc6',
'librt.so': 'libc6',
'libgcc_s.so': 'libgcc-s1',
'libstdc++.so': 'libstdc++6',
'libz.so': 'zlib1g',
'libbz2.so': 'libbz2-1.0',
'libpam.so': 'libpam0g',
'libaudit.so': 'libaudit1',
'libcap-ng.so': 'libcap-ng0',
'libkeyutils.so': 'libkeyutils1',
'liblzma.so': 'liblzma5',
'libcom_err.so': 'libcomerr2'
}
lib_name = os.path.basename(lib_path)
for core_lib, package in core_libs.items():
if lib_name.startswith(core_lib):
return package, f"Core system library: {lib_path}"
# If not a recognized core library, return as system library
file_output = run_command(['file', lib_path])
if file_output:
return "system-library", f"System library: {lib_path} - {file_output.strip()}"
return None