Package entropy :: Package spm :: Package plugins :: Module skel :: Class SpmPlugin

Class SpmPlugin

source code


Base class for Source Package Manager plugins

Instance Methods
 
add_installed_package(self, package_metadata)
Add package installed by Entropy to SPM database too.
source code
int
assign_uid_to_installed_package(self, package, root=None)
Assign a new Unique Identifier to installed package and return it.
source code
 
configure_installed_package(self, package_metadata)
Configure installed package.
source code
bool
disable_package_compile_options(self, package, options)
WARNING: this is an Entropy Server functionality.
source code
bool
enable_package_compile_options(self, package, options)
WARNING: this is an Entropy Server functionality.
source code
int
execute_package_phase(self, package, build_script_path, phase_name, work_dir=None, licenses_accepted=None)
Execute Source Package Manager package phase (postinstall, preinstall, preremove, postremove, etc).
source code
dict
extract_package_metadata(self, package_file)
Extract Source Package Manager package metadata from given file.
source code
None
generate_package(self, package, file_save_path)
Generate a package tarball file for given package, from running system.
source code
string
get_cache_directory(self, root=None)
Return Source Package Manager cache directory path.
source code
list
get_download_mirrors(self, mirror_name)
Return list of download mirror URLs for given mirror name
source code
string
get_installed_package_build_script_path(self, package, root=None)
Return build script path for given package looking into installed packages repository.
source code
dict
get_installed_package_compile_options(self, package, root=None)
WARNING: this is an Entropy Server functionality.
source code
list
get_installed_package_content(self, package, root=None)
Return list of files/directories owned by package.
source code
string
get_installed_package_metadata(self, package, key, root=None)
Return package metadata referenced by "key" argument from installed packages repository.
source code
list
get_installed_packages(self, categories=None, root=None)
Return list of packages found in installed packages repository.
source code
list
get_merge_protected_paths(self)
Return a list of paths (either directories or files) whose are protected from direct merge requiring user approval.
source code
 
get_merge_protected_paths_mask(self)
Return a list of unprotected paths (either directories or files) which reside inside a protected path (see get_merge_protected_paths()).
source code
string
get_package_build_script_path(self, package)
Return build script path for given package looking through available packages repositories.
source code
list
get_package_categories(self)
Return list of package categories in available packages repositories.
source code
dict
get_package_category_description_metadata(self, category)
Return metadata for given package category containing description in all the available languages.
source code
string or None
get_package_changelog(self, package)
Return ChangeLog content for given package.
source code
dict
get_package_compile_options(self, package)
WARNING: this is an Entropy Server functionality.
source code
string
get_package_metadata(self, package, key)
Return package metadata referenced by "key" argument from available packages repositories.
source code
dict
get_package_sets(self, builtin_sets)
Package sets are groups of packages meant to ease user installation and removal of large amount of applications or libraries.
source code
list
get_packages(self, categories=None, filter_reinstalls=False)
Return list of packages found in available repositories.
source code
dict
get_security_advisory_metadata(self, advisory_id)
Return Source Package Manager package security advisory metadata for given security advisory identifier.
source code
list
get_security_packages(self, security_property)
Return a list of packages affected by given security property argument.
source code
 
get_setting(self, key)
Return Source Package Manager setting referenced by "key"
source code
list
get_system_packages(self)
Return list of core (system) packages.
source code
string
get_user_installed_packages_file(self, root=None)
Return path to file containing list (one per line) of packages installed by user (in Portage world, this is the world file).
source code
 
init_singleton(self, output_interface)
Source Package Manager Plugin singleton method.
source code
 
log_message(self, message)
Log message string to logfile.
source code
string or list or None
match_installed_package(self, package, match_all=False, root=None)
Match a package looking through installed packages repository using the given match term argument (package).
source code
string or list or None
match_package(self, package, match_type=None)
Match a package looking through available packages repositories using the given match term argument (package) and match type (validity defined by subclasses).
source code
list
package_metadata_keys(self)
Return a list of package metadata keys available.
source code
list
package_phases(self)
Return a list of available and valid package build phases.
source code
 
packages_repositories_metadata_update(self)
Executes Source Package Manager available packages repositories metadata update.
source code
 
remove_installed_package(self, package_metadata)
Remove installed package from SPM database.
source code
dict
search_paths_owners(self, paths, exact_match=True)
Return list of packages owning provided list of paths.
source code

Inherited from core.Singleton: is_destroyed, is_singleton

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods
int
entropy_install_setup_hook(entropy_client, package_metadata)
This function is called by Entropy Client during package metadata setup.
source code
int
entropy_install_unpack_hook(entropy_client, package_metadata)
This function is called by Entropy Client during package installation, unpack phase.
source code
 
get_package_groups()
Return package groups available metadata (Spm categories are grouped into macro categories called "groups").
source code

Inherited from core.Singleton: __new__

Class Variables
  BASE_PLUGIN_API_VERSION = 0
  PLUGIN_API_VERSION = -1
  SUPPORTED_MATCH_TYPES = []
Properties

Inherited from object: __class__

Method Details

add_installed_package(self, package_metadata)

source code 

Add package installed by Entropy to SPM database too.
"package_metadata" is a dictionary featuring the following (relevant)
keys:
    ['accept_license', 'imagedir', 'xpakpath', 'slot', 'pkgdbpath',
     'versiontag', 'version', 'xpakstatus', 'unpackdir', 'revision',
     'category', 'repository', 'xpakdir', 'name', 'install_source',
    ]

@param package_metadata: Entropy package metadata
@type package_metadata: dict
@return: SPM installed package UID or -1
@rtype: int

assign_uid_to_installed_package(self, package, root=None)

source code 

Assign a new Unique Identifier to installed package and return it.

Parameters:
  • package (string) - package name
  • root (string) - specify an alternative root directory "/"
Returns: int
assigned Unique Identifier

configure_installed_package(self, package_metadata)

source code 

Configure installed package. Some SPM require users to do manual
stuff on packages.
"package_metadata" is a dictionary featuring the following (relevant)
keys:
    ['accept_license', 'imagedir', 'xpakpath', 'slot', 'pkgdbpath',
     'versiontag', 'version', 'xpakstatus', 'unpackdir', 'revision',
     'category', 'repository', 'xpakdir', 'name', 'install_source',
     'removeatom'
    ]

@param package_metadata: Entropy package metadata
@type package_metadata: dict
@return: execution status
@rtype: int

disable_package_compile_options(self, package, options)

source code 

WARNING: this is an Entropy Server functionality. Disable compile options (also known as USE flags) for package. Compile options are intended to be features that package can expose to other packages or directly to user.

Parameters:
  • package (string) - package name
  • options (string) - list of compile options to disable
Returns: bool
enable status, True if disabled, False if not

enable_package_compile_options(self, package, options)

source code 

WARNING: this is an Entropy Server functionality. Enable compile options (also known as USE flags) for package. Compile options are intended to be features that package can expose to other packages or directly to user.

Parameters:
  • package (string) - package name
  • options (string) - list of compile options to enable
Returns: bool
enable status, True if enabled, False if not

entropy_install_setup_hook(entropy_client, package_metadata)
Static Method

source code 

This function is called by Entropy Client during package metadata setup. It is intended to be used to inject additional metadata (that would be used afterwards in other entropy_install_* hooks) to entropy package install metadata. Note: for performance reasons, this is a static method !

Parameters:
  • entropy_client (entropy.client.interfaces.Client.Client) - Entropy Client interface instance
  • package_metadata (dict) - Entropy package metadata
Returns: int
execution status

entropy_install_unpack_hook(entropy_client, package_metadata)
Static Method

source code 

This function is called by Entropy Client during package installation, unpack phase. It is intended to be used to extract, if required, Source Package Manager metadata from Entropy packages useful for installing package into Source Package Manager plugin too. For example, PortagePlugin uses this hook to extract xpak metadata from entropy package files and setup Portage directories. Note: for performance reasons, this is a static method !

Parameters:
  • entropy_client (entropy.client.interfaces.Client.Client) - Entropy Client interface instance
  • package_metadata (dict) - Entropy package metadata
Returns: int
execution status

execute_package_phase(self, package, build_script_path, phase_name, work_dir=None, licenses_accepted=None)

source code 

Execute Source Package Manager package phase (postinstall, preinstall, preremove, postremove, etc).

Parameters:
  • package (string) - package name
  • build_script_path (string) - path to Source Package Manager build script to call
  • phase_name (string) - name of the phase to call, must be a valid phase contained in package_phases() output.
  • work_dir (string) - specify a work directory if required by your SPM
  • licenses_accepted (list) - list of license names already accepted that can be given to Source Package Manager (to skip its license acceptance verification stuff, for example)
Returns: int
phase script exit status
Raises:
  • KeyError - if phase is not available

extract_package_metadata(self, package_file)

source code 

Extract Source Package Manager package metadata from given file.

Parameters:
  • package_file (string) - path to valid SPM package file
Returns: dict
package metadata extracted
Raises:

generate_package(self, package, file_save_path)

source code 

Generate a package tarball file for given package, from running system. All the information is recomposed from system.

Parameters:
  • package (string) - package name
  • file_save_path (string) - exact path (including file name and extension) where package file is saved
Returns: None
None
Raises:

get_cache_directory(self, root=None)

source code 

Return Source Package Manager cache directory path.

Parameters:
  • root (string) - specify an alternative root directory "/"
Returns: string
cache directory

get_download_mirrors(self, mirror_name)

source code 

Return list of download mirror URLs for given mirror name

Parameters:
  • mirror_name (string) - mirror name
Returns: list
list of download URLs

get_installed_package_build_script_path(self, package, root=None)

source code 

Return build script path for given package looking into installed packages repository.

Parameters:
  • package (string) - package name
  • root (string) - specify an alternative root directory "/"
Returns: string
build script path

get_installed_package_compile_options(self, package, root=None)

source code 

WARNING: this is an Entropy Server functionality. Return currently configured compile options (also known as USE flags) for given package. There can be different kinds of compile options so a dictionary should be returned with compile options identifier as key and list of options as value. This method looks into installed packages repository.

Parameters:
  • package (string) - package name
  • root (string) - specify an alternative root directory "/"
Returns: dict
compile options

get_installed_package_content(self, package, root=None)

source code 

Return list of files/directories owned by package.

Parameters:
  • package (string) - package name
  • root (string) - specify an alternative root directory "/"
Returns: list
list of files/directories owned by package

get_installed_package_metadata(self, package, key, root=None)

source code 

Return package metadata referenced by "key" argument from installed packages repository.

Parameters:
  • package (string) - package identifier
  • key (string) - metadata key (name)
  • root (string) - specify an alternative root directory "/"
Returns: string
package metadata value

get_installed_packages(self, categories=None, root=None)

source code 

Return list of packages found in installed packages repository. Extra "filtering" arguments can be passed like "categories", which will make this method returning only packages found in given category list.

Parameters:
  • categories (iterable) - list of package categories to look into
  • root (string) - specify an alternative root directory "/"
Returns: list
list of installed packages found

get_merge_protected_paths(self)

source code 

Return a list of paths (either directories or files) whose are protected from direct merge requiring user approval.

Returns: list
list of protected paths

get_package_build_script_path(self, package)

source code 

Return build script path for given package looking through available packages repositories.

Parameters:
  • package (string) - package name
Returns: string
build script path

get_package_categories(self)

source code 

Return list of package categories in available packages repositories.

Returns: list
list of package categories

get_package_category_description_metadata(self, category)

source code 

Return metadata for given package category containing description in all the available languages. Data is returned in dict form, locale names as key, description text as value.

Parameters:
  • category (string) - package category name
Returns: dict
category description metadata

get_package_changelog(self, package)

source code 

Return ChangeLog content for given package.

Parameters:
  • package (string) - package name
Returns: string or None
changelog

get_package_compile_options(self, package)

source code 

WARNING: this is an Entropy Server functionality. Return currently configured compile options (also known as USE flags) for given package. There can be different kinds of compile options so a dictionary should be returned with compile options identifier as key and list of options as value. This method looks through available packages repositories.

Parameters:
  • package (string) - package name
Returns: dict
compile options

get_package_metadata(self, package, key)

source code 

Return package metadata referenced by "key" argument from available packages repositories.

Parameters:
  • package (string) - package name
  • key (string) - metadata key (name)
Returns: string
package metadata value

get_package_sets(self, builtin_sets)

source code 

Package sets are groups of packages meant to ease user installation and removal of large amount of applications or libraries. The difference between package groups is that sets can be referenced anywhere inside Entropy, while the former is just a simple way to group pacakge categories, usually too hard to understand (for eg. "sys-apps" or "app-misc", where user has no clue about the meaning of these). Third party implementations of SPM can just return empty data if this feature is not wanted or implementable.

Parameters:
  • builtin_sets (bool) - if True, also return SPM built-in package sets
Returns: dict
dictionary featuring set name as key, list (set) of package dependencies as value

get_packages(self, categories=None, filter_reinstalls=False)

source code 

Return list of packages found in available repositories. Extra "filtering" arguments can be passed like "categories", which will make this method returning only packages found in given category list and "filter_reinstalls" which will actually filter out packages already installed (with no updates nor downgrades available).

Parameters:
  • categories (iterable) - list of package categories to look into
  • filter_reinstalls (bool) - enable reinstall packages filter
Returns: list
list of available packages found

To Do: improve method, move filter_reinstalls to another function?

get_security_advisory_metadata(self, advisory_id)

source code 

Return Source Package Manager package security advisory metadata for given security advisory identifier.

Parameters:
  • advisory_id (string) - security advisory identifier
Returns: dict
advisory metadata

get_security_packages(self, security_property)

source code 

Return a list of packages affected by given security property argument. Valid security_property values are: affected, new, all.

Parameters:
  • security_property (string) - packages security property
Returns: list
list of packages affected by given security property

get_setting(self, key)

source code 

Return Source Package Manager setting referenced by "key"

Parameters:
  • key (string) - source package manager setting
Raises:
  • KeyError - if setting is not available

get_system_packages(self)

source code 

Return list of core (system) packages. Core packages are usually consider vital for basic system operativity.

Returns: list
list of system packages

get_user_installed_packages_file(self, root=None)

source code 

Return path to file containing list (one per line) of packages installed by user (in Portage world, this is the world file).

Parameters:
  • root (string) - specify an alternative root directory "/"
Returns: string
path to installed packages list file

init_singleton(self, output_interface)

source code 

Source Package Manager Plugin singleton method. This method must be reimplemented by subclasses. At this stage, you should also consider to tweak etpConst['spm'] content (importing etpConst from entropy.const).

Parameters:
  • output_interface (entropy.output.TextInterface based instances) - Entropy output interface
Raises:
  • NotImplementedError() - when method is not reimplemented

log_message(self, message)

source code 

Log message string to logfile.

Parameters:
  • message (string) - message string to log

match_installed_package(self, package, match_all=False, root=None)

source code 

Match a package looking through installed packages repository using the given match term argument (package).

Parameters:
  • package (string) - package string to match inside installed packages repository
  • match_all (bool) - return all the matching packages, not just the best
  • root (string) - specify an alternative root directory "/"
Returns: string or list or None
matched package (atom) or None
Raises:
  • KeyError - if match_type is not valid

match_package(self, package, match_type=None)

source code 

Match a package looking through available packages repositories using the given match term argument (package) and match type (validity defined by subclasses).

Parameters:
  • package (string) - package string to match inside available repositories
  • match_type (string) - match type
Returns: string or list or None
matched package (atom) or None
Raises:
  • KeyError - if match_type is not valid

package_metadata_keys(self)

source code 

Return a list of package metadata keys available.

Returns: list
list of package metadata

package_phases(self)

source code 

Return a list of available and valid package build phases. Default value is ["setup", "preinstall", "postinstall", "preremove", "postremove"]

Returns: list
list of available and valid package build phases

remove_installed_package(self, package_metadata)

source code 

Remove installed package from SPM database.
"package_metadata" is a dictionary featuring the following (relevant)
keys:
    ['accept_license', 'imagedir', 'xpakpath', 'slot', 'pkgdbpath',
     'versiontag', 'version', 'xpakstatus', 'unpackdir', 'revision',
     'category', 'repository', 'xpakdir', 'name', 'install_source',
     'removeatom'
    ]

@param package_metadata: Entropy package metadata
@type package_metadata: dict
@return: execution status
@rtype: int

search_paths_owners(self, paths, exact_match=True)

source code 

Return list of packages owning provided list of paths. A dictionary is returned containing package name as key and list of matched paths as value.

Parameters:
  • paths (list) - list of paths to resolve
  • exact_match (bool) - match paths exactly
Returns: dict
packages owning list of paths