portage.dbapi.bintree module

exception portage.dbapi.bintree.UseCachedCopyOfRemoteIndex

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class portage.dbapi.bintree.binarytree(_unused=<class 'DeprecationWarning'>, pkgdir=None, virtual=<class 'DeprecationWarning'>, settings=None)

Bases: object

this tree scans for a list of all packages available in PKGDIR

_allocate_filename(cpv)
_allocate_filename_multi(cpv)
_ensure_dir(path)

Create the specified directory. Also, copy gid and group mode bits from self.pkgdir if possible. :param cat_dir: Absolute path of the directory to be created. :type cat_dir: String

_eval_use_flags(cpv, metadata)
_file_permissions(path)
_get_digests(pkg)
_inject_file(pkgindex, cpv, filename)

Add a package to internal data structures, and add an entry to the given pkgindex. :param pkgindex: The PackageIndex instance to which an entry

will be added.

Parameters
  • cpv (_pkg_str) – A _pkg_str instance corresponding to the package being injected.

  • filename (string) – Absolute file path of the package to inject.

Return type

dict

Returns

A dict corresponding to the new entry which has been added to pkgindex. This may be used to access the checksums which have just been generated.

_is_specific_instance(cpv)
_load_pkgindex()
_max_build_id(cpv)
static _merge_pkgindex_header(src, dest)

Merge Packages header settings from src to dest, in order to propagate implicit IUSE and USE_EXPAND settings for use with binary and installed packages. Values are appended, so the result is a union of elements from src and dest.

Pull in ARCH if it’s not defined, since it’s used for validation by emerge’s profile_check function, and also for KEYWORDS logic in the _getmaskingstatus function.

Parameters
_new_pkgindex()
static _parse_build_id(filename)
_pkgindex_entry(cpv)

Performs checksums, and gets size and mtime via lstat. Raises InvalidDependString if necessary. :rtype: dict :return: a dict containing entry for the give cpv.

_pkgindex_version_supported(pkgindex)
_pkgindex_write(pkgindex)
_populate_additional(repos)
_populate_local(reindex=True)

Populates the binarytree with local package metadata.

Parameters

reindex (bool) – detect added / modified / removed packages and regenerate the index file if necessary

_populate_remote(getbinpkg_refresh=True)
_propagate_config(config)

Propagate implicit IUSE and USE_EXPAND settings from the binary package database to a config instance. If settings are not available to propagate, then this will do nothing and return False.

Parameters

config (portage.config) – config instance

Return type

bool

Returns

True if settings successfully propagated, False if settings were not available to propagate.

_read_metadata(filename, st, keys=None)

Read metadata from a binary package. The returned metadata dictionary will contain empty strings for any values that are undefined (this is important because the _pkg_str class distinguishes between missing and undefined values).

Parameters
  • filename (string) – File path of the binary package

  • st (os.stat_result) – stat result for the binary package

  • keys (iterable) – optional list of specific metadata keys to retrieve

Return type

dict

Returns

package metadata

_update_pkgindex_header(header)

Add useful settings to the Packages file header, for use by binhost clients.

This will return silently if the current profile is invalid or does not have an IUSE_IMPLICIT variable, since it’s useful to maintain a cache of implicit IUSE settings for use with binary packages.

dep_bestmatch(mydep)

compatibility method – all matches, not just visible ones

digestCheck(pkg)

Verify digests for the given package and raise DigestException if verification fails. :rtype: bool :return: True if digests could be located, False otherwise.

exists_specific(cpv)
get_pkgindex_uri(cpv)

Returns the URI to the Packages file for a given package.

getname(cpv, allocate_new=None)

Returns a file location for this package. If cpv has both build_time and build_id attributes, then the path to the specific corresponding instance is returned. Otherwise, allocate a new path and return that. When allocating a new path, behavior depends on the binpkg-multi-instance FEATURES setting.

getslot(mycatpkg)

Get a slot for a catpkg; assume it exists.

gettbz2(pkgname)

Fetches the package from a remote site, if necessary. Attempts to resume if the file appears to be partially downloaded.

inject(cpv, filename=None)

Add a freshly built package to the database. This updates $PKGDIR/Packages with the new package metadata (including MD5). :param cpv: The cpv of the new package to inject :type cpv: string :param filename: File path of the package to inject, or None if it’s

already in the location returned by getname()

Return type

_pkg_str or None

Returns

A _pkg_str instance on success, or None on failure.

isremote(pkgname)

Returns true if the package is kept remotely and it has not been downloaded (or it is only partially downloaded).

move_ent(mylist, repo_match=None)
populate(getbinpkgs=False, getbinpkg_refresh=True, add_repos=())

Populates the binarytree with package metadata.

Parameters
  • getbinpkgs (bool) – include remote packages

  • getbinpkg_refresh (bool) – attempt to refresh the cache of remote package metadata if getbinpkgs is also True

  • add_repos (sequence) – additional binary package repositories

prevent_collision(cpv)
property root
class portage.dbapi.bintree.bindbapi(mybintree=None, **kwargs)

Bases: portage.dbapi.virtual.fakedbapi

_categories = None
_category_re = re.compile('^\\w[-.+\\w]*$')
_clear_cache()
static _cmp_cpv(cpv1, cpv2)
static _cpv_sort_ascending(cpv_list)

Use this to sort self.cp_list() results in ascending order. It sorts in place and returns None.

_instance_key_cpv(cpv, support_string=False)
_instance_key_multi_instance(cpv, support_string=False)
_iter_match(atom, cpv_iter)
_iter_match_repo(atom, cpv_iter)
_iter_match_slot(atom, cpv_iter)
_iter_match_use(atom, cpv_iter)
  1. Check for required IUSE intersection (need implicit IUSE here).

  2. Check enabled/disabled flag states.

_iuse_implicit_cnstr(pkg, metadata)

Construct a callable that checks if a given USE flag should be considered to be a member of the implicit IUSE for the given package.

Parameters
Returns

a callable that accepts a single USE flag argument, and returns True only if the USE flag should be considered to be a member of the implicit IUSE for the given package.

Return type

callable

_known_keys = frozenset({'BDEPEND', 'CHOST', 'DEFINED_PHASES', 'DEPEND', 'DESCRIPTION', 'EAPI', 'HOMEPAGE', 'IDEPEND', 'INHERITED', 'IUSE', 'KEYWORDS', 'LICENSE', 'PDEPEND', 'PROPERTIES', 'RDEPEND', 'REQUIRED_USE', 'RESTRICT', 'SLOT', 'SRC_URI', 'USE', 'repository'})
_match_use(atom, pkg, metadata, ignore_profile=False)
_pkg_str(cpv, repo)

This is used to contruct _pkg_str instances on-demand during matching. If cpv is a _pkg_str instance with slot attribute, then simply return it. Otherwise, fetch metadata and construct a _pkg_str instance. This may raise KeyError or InvalidData.

_pkg_str_aux_keys = ('EAPI', 'KEYWORDS', 'SLOT', 'repository', 'BUILD_ID', 'BUILD_TIME', '_mtime_')
_repoman_iuse_implicit_cnstr(pkg, metadata)

In repoman’s version of _iuse_implicit_cnstr, account for modifications of the self.settings reference between calls.

_set_multi_instance(multi_instance)

Enable or disable multi_instance mode. This should before any packages are injected, so that all packages are indexed with the same implementation of self._instance_key.

_use_mutable = False
aux_get(mycpv, wants, myrepo=None)

Return the metadata keys in mylist for mycpv Args:

mycpv - “sys-apps/foo-1.0” mylist - [“SLOT”,”DEPEND”,”HOMEPAGE”] myrepo - The repository name.

Returns:

a list of results, in order of keys in mylist, such as: [“0”,”>=sys-libs/bar-1.0”,”http://www.foo.com”] or [] if mycpv not found’

aux_update(cpv, values)
Args:
cpv - “sys-apps/foo-1.0”

metadata_updates = { key : newvalue }

Returns:

None

property categories

Use self.cp_all() to generate a category list. Mutable instances can delete the self._categories attribute in cases when the cached categories become invalid and need to be regenerated.

clear()

Remove all packages.

close_caches()
cp_all(sort=False)

Implement this in a child class Args

sort - return sorted results

Returns:

A list of strings 1 per CP in the datastore

cp_list(*pargs, **kwargs)
cpv_all()

Return all CPVs in the db Args:

None

Returns:

A list of Strings, 1 per CPV

This function relies on a subclass implementing cp_all, this is why the hasattr is there

cpv_exists(cpv, myrepo=None)
cpv_inject(cpv, **kwargs)

Adds a cpv to the list of available packages. See the exclusive_slots constructor parameter for behavior with respect to SLOT metadata. :param mycpv: cpv for the package to inject :type mycpv: str :param metadata: dictionary of raw metadata for aux_get() calls :param metadata: dict

cpv_remove(cpv)

Removes a cpv from the list of available packages.

getfetchsizes(pkg)

This will raise MissingSignature if SIZE signature is not available, or InvalidSignature if SIZE signature is invalid.

invalidentry(mypath)
match(*pargs, **kwargs)

Given a dependency, try to find packages that match Args:

origdep - Depend atom use_cache - Boolean indicating if we should use the cache or not NOTE: Do we ever not want the cache?

Returns:

a list of packages that match origdep

move_slot_ent(mylist, repo_match=None)

This function takes a sequence: Args:

mylist: a sequence of (atom, originalslot, newslot) repo_match: callable that takes single repo_name argument

and returns True if the update should be applied

Returns:

The number of slotmoves this function did

unpack_contents(pkg, dest_dir, loop=None)

Unpack package contents to a directory. This method is a coroutine.

Parameters
  • pkg (_pkg_str or portage.config) – package to unpack

  • dest_dir (str) – destination directory

unpack_metadata(pkg, dest_dir, loop=None)

Unpack package metadata to a directory. This method is a coroutine.

Parameters
  • pkg (_pkg_str or portage.config) – package to unpack

  • dest_dir (str) – destination directory

update_ents(updates, onProgress=None, onUpdate=None)

Update metadata of all packages for package moves. :param updates: A list of move commands, or dict of {repo_name: list} :type updates: list or dict :param onProgress: A progress callback function :type onProgress: a callable that takes 2 integer arguments: maxval and curval :param onUpdate: A progress callback function called only

for packages that are modified by updates.

property writable

Check if PKGDIR is writable, or permissions are sufficient to create it if it does not exist yet. :rtype: bool :return: True if PKGDIR is writable or can be created,

False otherwise