Package entropy :: Module dep

Module dep

source code


Authors:
Fabio Erculiani <[email protected]>, Slawomir Nizio <[email protected]>

Contact: [email protected]

Copyright: Fabio Erculiani, Slawomir Nizio

License: GPL-2

Entropy dependency functions module. This module contains Entropy package dependency manipulation functions.

Classes
  Dependency
Helper class used to evaluate dependency string containing boolean expressions such as: (dep1 & dep2) | dep 3
  DependencyStringParser
Conditional dependency string parser.
  WrongRewriteRuleError
Exception thrown when the new dep_rewrite mechanism encounters a badly formatted rule.
  DependencyRewriter
Class that implements the new dependency rewrite schema.
Functions
int
isjustname(mypkg)
Checks to see if the depstring is only the package name (no version parts)
source code
 
catpkgsplit(mydata)
Takes a Category/Package-Version-Rev and returns a list of each.
source code
string
dep_getkey(mydep)
Return the category/package-name of a depstring.
source code
 
dep_getcat(mydep)
Extract package category from dependency.
source code
 
remove_cat(mydep)
Drop category part from dependency, if any.
source code
string
dep_getcpv(mydep)
Return the category-package-version with any operators/slot specifications stripped off
source code
string
dep_getslot(mydep)
# Imported from portage.dep # $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
source code
List
dep_getusedeps(depend)
# Imported from portage.dep # $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
source code
 
remove_usedeps(depend)
docstring_title
source code
 
remove_slot(mydep)
# Imported from portage.dep # $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
source code
 
remove_tag_from_slot(slot)
Remove, if present, the tag part from SLOT string.
source code
 
remove_revision(ver)
docstring_title
source code
 
remove_tag(mydep)
docstring_title
source code
 
remove_entropy_revision(mydep)
docstring_title
source code
 
dep_get_entropy_revision(mydep)
docstring_title
source code
 
dep_split_or_deps(mydep)
docstring_title
source code
 
dep_get_spm_revision(mydep)
docstring_title
source code
 
dep_get_match_in_repos(mydep)
docstring_title
source code
 
dep_gettag(mydep)
Retrieve the slot on a depend.
source code
 
remove_package_operators(atom)
docstring_title
source code
 
compare_versions(ver1, ver2)
docstring_title
source code
bool
is_valid_package_tag(tag)
Return whether string is a valid package tag.
source code
 
entropy_compare_package_tags(tag_a, tag_b)
Compare two Entropy package tags using builtin cmp().
source code
list
sort_entropy_package_tags(tags)
Return a sorted list of Entropy package tags.
source code
 
entropy_compare_versions(ver_data, ver_data2) source code
list
get_newer_version(versions)
Return a sorted list of versions
source code
list
get_entropy_newer_version(versions)
Sort a list of entropy package versions.
source code
string or None
get_entropy_package_sha1(package_name)
Extract the SHA1 checksum from a package file name.
source code
 
remove_entropy_package_sha1(package_name)
Remove the SHA1 checksum from a package file name.
source code
string
create_package_filename(category, name, version, package_tag, ext=None, revision=None, sha1=None)
Create package filename string.
source code
string
create_package_relative_path(category, name, version, package_tag, ext=None, revision=None, sha1=None)
Create package relative path, containing the filename string.
source code
string
strip_entropy_package_extension(pkg_path)
Strip entropy package file extension from package path pkg_path.
source code
 
exploit_package_filename(package_name)
This is the inverse function of create_package_filename, and returns a tuple composed by category, name, version, package_tag (None if not set), SHA1 checksum (None if not set), and additional revision (as int).
source code
string
create_package_atom_string(category, name, version, package_tag)
Create Entropy package atom string.
source code
 
expand_dependencies(dependencies, entropy_repository_list, selected_matches=None)
Expand a list of dependencies resolving conditional ones.
source code
Variables
  ver_regexp = re.compile(r'^(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(...
  suffix_regexp = re.compile(r'^(alpha|beta|rc|pre|p)(\d*)$')
  suffix_value = {'alpha': -4, 'beta': -3, 'p': 0, 'pre': -2, 'r...
  endversion_keys = ['pre', 'p', 'alpha', 'beta', 'rc']
  valid_category = re.compile(r'^\w[\w-]*')
  invalid_atom_chars_regexp = re.compile(r'[\(\)\|@]')
  digits_group = re.compile(r'([0-9]+)')
  dep_revmatch = re.compile(r'^r[0-9]')
  tag_regexp = re.compile(r'^([A-Za-z0-9\+_\.-]+)?$')
  sha1_re = re.compile(r'(.*)\.([a-f\d]{40})(.*)')
  __package__ = 'entropy'
Function Details

isjustname(mypkg)

source code 

Checks to see if the depstring is only the package name (no version parts)

Example usage:

>>> isjustname('media-libs/test-3.0')
False
>>> isjustname('test')
True
>>> isjustname('media-libs/test')
True
Parameters:
  • mypkg - the package atom to check
  • mypkg - string
Returns: int
if the package string is not just the package name

catpkgsplit(mydata)

source code 

Takes a Category/Package-Version-Rev and returns a list of each.

Parameters:
  • mydata (string) - data to split
Returns:
  1. If each exists, it returns (cat, pkgname, version, rev)
  2. If cat is not specificed in mydata, cat will be "null"
  3. if rev does not exist it will be '-r0'

dep_getkey(mydep)

source code 

Return the category/package-name of a depstring.

Example usage:

>>> dep_getkey('media-libs/test-3.0')
'media-libs/test'
Parameters:
  • mydep (string) - the depstring to retrieve the category/package-name of
Returns: string
the package category/package-version

dep_getcpv(mydep)

source code 

Return the category-package-version with any operators/slot specifications stripped off

Example usage:

>>> dep_getcpv('>=media-libs/test-3.0')
'media-libs/test-3.0'
Parameters:
  • mydep (string) - the depstring
Returns: string
the depstring with the operator removed

dep_getslot(mydep)

source code 

# Imported from portage.dep # $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $

Retrieve the slot on a depend.

Example usage:

>>> dep_getslot('app-misc/test:3')
'3'
Parameters:
  • mydep (string) - the depstring to retrieve the slot of
Returns: string
the slot

dep_getusedeps(depend)

source code 

# Imported from portage.dep # $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $

Pull a listing of USE Dependencies out of a dep atom.

Example usage:

>>> dep_getusedeps('app-misc/test:3[foo,-bar]')
('foo', '-bar')
Parameters:
  • depend (String) - The depstring to process
Returns: List
List of use flags ( or [] if no flags exist )

remove_usedeps(depend)

source code 

docstring_title

Parameters:
  • depend ()

remove_slot(mydep)

source code 
# Imported from portage.dep
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $

Removes dep components from the right side of an atom:
        * slot
        * use
        * repo

remove_tag_from_slot(slot)

source code 

Remove, if present, the tag part from SLOT string. Packages append the kernel tag to the slot, by comma separating it.

remove_revision(ver)

source code 

docstring_title

Parameters:
  • ver ()

remove_tag(mydep)

source code 

docstring_title

Parameters:
  • mydep ()

remove_entropy_revision(mydep)

source code 

docstring_title

Parameters:
  • mydep ()

dep_get_entropy_revision(mydep)

source code 

docstring_title

Parameters:
  • mydep ()

dep_split_or_deps(mydep)

source code 

docstring_title

Parameters:
  • mydep ()

dep_get_spm_revision(mydep)

source code 

docstring_title

Parameters:
  • mydep ()

dep_get_match_in_repos(mydep)

source code 

docstring_title

Parameters:
  • mydep ()

dep_gettag(mydep)

source code 

Retrieve the slot on a depend.

Example usage:

>>> dep_gettag('app-misc/test#2.6.23-sabayon-r1')
'2.6.23-sabayon-r1'

remove_package_operators(atom)

source code 

docstring_title

Parameters:
  • atom ()

compare_versions(ver1, ver2)

source code 

docstring_title

Parameters:
  • ver1 ()
  • ver2 ()

is_valid_package_tag(tag)

source code 

Return whether string is a valid package tag.

Parameters:
  • tag (string) - package tag to test
Returns: bool
True, if valid

entropy_compare_package_tags(tag_a, tag_b)

source code 
Compare two Entropy package tags using builtin cmp().

@param tag_a: Entropy package tag
@type tag_a: string
@param tag_b: Entropy package tag
@type tag_b: string
return: negative number if tag_a < tag_b, positive number if tag_a > tag_b.
    zero if tag_a == tag_b.
rtype: int

sort_entropy_package_tags(tags)

source code 

Return a sorted list of Entropy package tags.

Parameters:
  • tags (list) - list of Entropy package tags
Returns: list
sorted list of Entropy package tags

get_newer_version(versions)

source code 

Return a sorted list of versions

Parameters:
  • versions (list) - input version list
Returns: list
sorted version list

get_entropy_newer_version(versions)

source code 

Sort a list of entropy package versions.

Parameters:
  • versions (list) - list of package versions
Returns: list
sorted list

get_entropy_package_sha1(package_name)

source code 

Extract the SHA1 checksum from a package file name.

Parameters:
  • package_name (string) - package file name
Returns: string or None
the package SHA1 checksum, if any, or None

remove_entropy_package_sha1(package_name)

source code 

Remove the SHA1 checksum from a package file name.

Parameters:
  • package_name (string) - package file name

create_package_filename(category, name, version, package_tag, ext=None, revision=None, sha1=None)

source code 

Create package filename string.

Parameters:
  • category (string) - package category
  • name (string) - package name
  • version (string) - package version
  • package_tag (string or None) - package tag, if any, or None
  • ext (string) - alternative package file extension
  • sha1 (string) - a SHA1 checksum to add to the file name
Returns: string
package file name string

create_package_relative_path(category, name, version, package_tag, ext=None, revision=None, sha1=None)

source code 

Create package relative path, containing the filename string.

The relative path contains a sub-directory part that is used to distribute files across different directories (to avoid hot spots).

Parameters:
  • category (string) - package category
  • name (string) - package name
  • version (string) - package version
  • package_tag (string or None) - package tag, if any, or None
  • ext (string) - alternative package file extension
  • sha1 (string) - a SHA1 checksum to add to the file name
Returns: string
package file name string

strip_entropy_package_extension(pkg_path)

source code 

Strip entropy package file extension from package path pkg_path.

Parameters:
  • pkg_path (string) - package path
Returns: string
stripped package path

exploit_package_filename(package_name)

source code 
This is the inverse function of create_package_filename, and returns
a tuple composed by category, name, version, package_tag (None if not set),
SHA1 checksum (None if not set), and additional revision (as int).
package_name should be a string like this:
    <category>:<name>-<version>[.<sha1>][~<revision>[#<tag>]][.tbz2]

@param package_name: package file name
@type package_name: string
@return: tuple of strings/int composed by (category, name, version,
    package_tag, revision)
@rtype: tuple
@raise AttributeError: if package_name string passed is improperly formatted

create_package_atom_string(category, name, version, package_tag)

source code 

Create Entropy package atom string.

Parameters:
  • category (string) - package category
  • name (string) - package name
  • version (string) - package version
  • package_tag (string or None) - package tag, if any, or None
Returns: string
package atom string

expand_dependencies(dependencies, entropy_repository_list, selected_matches=None)

source code 
Expand a list of dependencies resolving conditional ones.
NOTE: it automatically handles dependencies metadata extended format:
    [(dep, type), ...]

@param dependencies: list of raw package dependencies, as
    returned by EntropyRepositoryBase.retrieveDependencies{,List}()
@type dependencies: iterable
@param entropy_repository_list: ordered list of EntropyRepositoryBase
    instances used to execute the actual resolution
@type entropy_repository_list: list
@keyword selected_matches: list of preferred package matches used to
    evaluate or-dependencies.
@type selected_matches: set
@return: list (keeping the iterable order when possible) of expanded
    dependencies
@rtype: list
@raise AttributeError: if dependencies structure is unsupported (this
    function supports list of strings, or list of tuples of length 2)


Variables Details

ver_regexp

Value:
re.compile(r'^(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\
d*)*)(-r(\d+))?$')

suffix_value

Value:
{'alpha': -4, 'beta': -3, 'p': 0, 'pre': -2, 'rc': -1}