portage.util._dyn_libs.LinkageMapELF module

class portage.util._dyn_libs.LinkageMapELF.LinkageMapELF(vardbapi)

Bases: object

Models dynamic linker dependencies.

class _LibGraphNode(key)

Bases: portage.util._dyn_libs.LinkageMapELF.LinkageMapELF._ObjectKey

_generate_object_key(obj, root)

Generate object key for a given object.

Parameters

object (string (example: '/usr/bin/bar')) – path to a file

Return type

2-tuple of types (long, int) if object exists. string if object does not exist.

Returns

  1. 2-tuple of object’s inode and device from a stat call, if object

    exists.

  2. realpath of object if object does not exist.

_key
alt_paths
file_exists()

Determine if the file for this key exists on the filesystem.

Return type

Boolean

Returns

  1. True if the file exists.

  2. False if the file does not exist or is a broken symlink.

class _ObjectKey(obj, root)

Bases: object

Helper class used as _obj_properties keys for objects.

_generate_object_key(obj, root)

Generate object key for a given object.

Parameters

object (string (example: '/usr/bin/bar')) – path to a file

Return type

2-tuple of types (long, int) if object exists. string if object does not exist.

Returns

  1. 2-tuple of object’s inode and device from a stat call, if object

    exists.

  2. realpath of object if object does not exist.

_key
file_exists()

Determine if the file for this key exists on the filesystem.

Return type

Boolean

Returns

  1. True if the file exists.

  2. False if the file does not exist or is a broken symlink.

_clear_cache()
_needed_aux_key = 'NEEDED.ELF.2'
_obj_key(path)
class _obj_properties_class(arch, needed, runpaths, soname, alt_paths, owner)

Bases: object

alt_paths
arch
needed
owner
runpaths
soname
_path_key(path)
_soname_map_class

alias of portage.cache.mappings.slot_dict_class.<locals>.SlotDict

findConsumers(obj, exclude_providers=None, greedy=True)

Find consumers of an object or object key.

This method may be called with a key from _obj_properties. If this method is going to be called with an object key, to avoid not catching shadowed libraries, do not pass new _ObjectKey instances to this method. Instead pass the obj as a string.

In some cases, not all consumers are returned. This may occur when an soname symlink referencing a library is in an object’s runpath while the actual library is not. For example, this problem is noticeable for binutils since it’s libraries are added to the path via symlinks that are gemerated in the /usr/$CHOST/lib/ directory by binutils-config. Failure to recognize consumers of these symlinks makes preserve-libs fail to preserve binutils libs that are needed by these unrecognized consumers.

Note that library consumption via dlopen (common for kde plugins) is currently undetected. However, it is possible to use the corresponding libtool archive (*.la) files to detect such consumers (revdep-rebuild is able to detect them).

The exclude_providers argument is useful for determining whether removal of one or more packages will create unsatisfied consumers. When this option is given, consumers are excluded from the results if there is an alternative provider (which is not excluded) of the required soname such that the consumers will remain satisfied if the files owned by exclude_providers are removed.

Parameters
  • obj (string (example: '/usr/bin/bar') or _ObjectKey) – absolute path to an object or a key from _obj_properties

  • exclude_providers (collection) – A collection of callables that each take a single argument referring to the path of a library (example: ‘/usr/lib/libssl.so.0.9.8’), and return True if the library is owned by a provider which is planned for removal.

  • greedy – If True, then include consumers that are satisfied

by alternative providers, otherwise omit them. Default is True. :type greedy: Boolean :rtype: set of strings (example: set([‘/bin/foo’, ‘/usr/bin/bar’])) :return: The return value is a soname -> set-of-library-paths, where set-of-library-paths satisfy soname.

findProviders(obj)

Find providers for an object or object key.

This method may be called with a key from _obj_properties.

In some cases, not all valid libraries are returned. This may occur when an soname symlink referencing a library is in an object’s runpath while the actual library is not. We should consider cataloging symlinks within LinkageMap as this would avoid those cases and would be a better model of library dependencies (since the dynamic linker actually searches for files named with the soname in the runpaths).

Parameters

obj (string (example: '/usr/bin/bar') or _ObjectKey) – absolute path to an object or a key from _obj_properties

Return type

dict (example: {‘libbar.so’: set([‘/lib/libbar.so.1.5’])})

Returns

The return value is a soname -> set-of-library-paths, where

set-of-library-paths satisfy soname.

getOwners(obj)

Return the package(s) associated with an object. Raises KeyError if the object is unknown. Returns an empty tuple if the owner(s) are unknown.

NOTE: For preserved libraries, the owner(s) may have been previously uninstalled, but these uninstalled owners can be returned by this method since they are registered in the PreservedLibsRegistry.

Parameters

obj (string (example: '/usr/bin/bar')) – absolute path to an object

Return type

tuple

Returns

a tuple of cpv

getSoname(obj)

Return the soname associated with an object.

Parameters

obj (string (example: '/usr/bin/bar')) – absolute path to an object

Return type

string

Returns

soname as a string

Determine whether an object is a “master” symlink, which means that its basename is the same as the beginning part of the soname and it lacks the soname’s version component.

Examples:

libarchive.so.2.8.4 | libarchive.so libproc-3.2.8.so | libproc.so

Parameters

obj (string (example: '/usr/bin/foo')) – absolute path to an object

Return type

Boolean

Returns

  1. True if obj is a master link

  2. False if obj is not a master link

listBrokenBinaries(debug=False)

Find binaries and their needed sonames, which have no providers.

Parameters

debug (Boolean) – Boolean to enable debug output

Return type

dict (example: {‘/usr/bin/foo’: set([‘libbar.so’])})

Returns

The return value is an object -> set-of-sonames mapping, where object is a broken binary and the set consists of sonames needed by object that have no corresponding libraries to fulfill the dependency.

listLibraryObjects()

Return a list of library objects.

Known limitation: library objects lacking an soname are not included.

Return type

list of strings

Returns

list of paths to all providers

listProviders()

Find the providers for all object keys in LinkageMap.

Return type

dict (example: {(123L, 456L): {‘libbar.so’: set([‘/lib/libbar.so.1.5’])}})

Returns

The return value is an object key -> providers mapping, where providers is a mapping of soname -> set-of-library-paths returned from the findProviders method.

rebuild(exclude_pkgs=None, include_file=None, preserve_paths=None)

Raises CommandNotFound if there are preserved libs and the scanelf binary is not available.

Parameters
  • exclude_pkgs (set) – A set of packages that should be excluded from the LinkageMap, since they are being unmerged and their NEEDED entries are therefore irrelevant and would only serve to corrupt the LinkageMap.

  • include_file (String) – The path of a file containing NEEDED entries for a package which does not exist in the vardbapi yet because it is currently being merged.

  • preserve_paths (set) – Libraries preserved by a package instance that is currently being merged. They need to be explicitly passed to the LinkageMap, since they are not registered in the PreservedLibsRegistry yet.