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

Class SpmPlugin

source code


Base class for Source Package Manager plugins

Instance Methods
 
init_singleton(self, output_interface)
Source Package Manager Plugin singleton method.
source code
list
package_metadata_keys(self)
Return a list of package metadata keys available.
source code
string
get_cache_directory(self, root=None)
Return Source Package Manager cache directory path.
source code
string
get_package_metadata(self, package, key)
Return package metadata referenced by "key" argument from available packages repositories.
source code
string or None
get_package_changelog(self, package)
Return ChangeLog content for given package.
source code
string
get_package_build_script_path(self, package)
Return build script path for given package looking through available packages repositories.
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
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_system_packages(self)
Return list of core (system) packages.
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
list
get_security_packages(self, security_property)
Return a list of packages affected by given security property argument.
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
 
get_setting(self, key)
Return Source Package Manager setting referenced by "key"
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
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
list
get_download_mirrors(self, mirror_name)
Return list of download mirror URLs for given mirror name
source code
 
packages_repositories_metadata_update(self)
Executes Source Package Manager available packages repositories metadata update.
source code
 
log_message(self, message)
Log message string to logfile.
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
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
None
generate_package(self, package, file_save_path)
Generate a package tarball file for given package, from running system.
source code
dict
extract_package_metadata(self, package_file)
Extract Source Package Manager package metadata from given file.
source code
bool
enable_package_compile_options(self, package, options)
WARNING: this is an Entropy Server functionality.
source code
bool
disable_package_compile_options(self, package, options)
WARNING: this is an Entropy Server functionality.
source code
dict
get_package_compile_options(self, package)
WARNING: this is an Entropy Server functionality.
source code
dict
get_installed_package_compile_options(self, package, root=None)
Return currently configured compile options (also known as USE flags) for given package.
source code
list
get_installed_package_content(self, package, root=None)
Return list of files/directories owned by package.
source code
list
get_packages(self, categories=None, filter_reinstalls=False)
Return list of packages found in available repositories.
source code
int
compile_packages(self, packages, stdin=None, stdout=None, stderr=None, environ=None, pid_write_func=None, pretend=False, verbose=False, fetch_only=False, build_only=False, no_dependencies=False, ask=False, coloured_output=False, oneshot=False)
Compile given packages using given compile options.
source code
int
remove_packages(self, packages, stdin=None, stdout=None, stderr=None, environ=None, pid_write_func=None, pretend=False, verbose=False, no_dependencies=False, ask=False, coloured_output=False)
Compile given packages using given compile options.
source code
int
print_build_environment_info(self, stdin=None, stdout=None, stderr=None, environ=None, pid_write_func=None, coloured_output=False)
Print build environment info to stdout.
source code
int
environment_update(self, stdout=None, stderr=None)
Hook used by Entropy Client and Entropy Server to ask Source Package Manager to update /etc/profile* and other environment settings around.
source code
list
get_installed_packages(self, categories=None, root=None)
Return list of packages found in installed packages repository.
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
int
assign_uid_to_installed_package(self, package, root=None)
Assign a new Unique Identifier to installed package and return it.
source code
int
resolve_package_uid(self, entropy_repository, entropy_repository_package_id)
This is the bridge between Entropy package repository and its Source Package Manager backend.
source code
string
convert_from_entropy_package_name(self, entropy_package_name)
This function should be able to convert an Entropy package name (atom) to a Source Package Manager one.
source code
dict
search_paths_owners(self, paths, exact_match=True)
Return list of packages owning provided list of paths.
source code
bool
append_metadata_to_package(self, entropy_package_name, package_path)
Append Source Package Manager metadata bits to an Entropy package, known its name and path.
source code
 
package_names_update(self, entropy_repository, entropy_repository_id, entropy_server, entropy_branch)
WARNING: this is an Entropy Server functionality.
source code
int
execute_package_phase(self, package_metadata, phase_name)
Execute Source Package Manager package phase (postinstall, preinstall, preremove, postremove, etc).
source code
 
add_installed_package(self, package_metadata)
Add package installed by Entropy to SPM database too.
source code
 
remove_installed_package(self, package_metadata)
Remove installed package from SPM database.
source code

Inherited from core.Singleton: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
 
get_package_groups()
Return package groups available metadata (Spm categories are grouped into macro categories called "groups").
source code
list
package_phases()
Return a list of available and valid package build phases.
source code
dict
package_phases_map()
Return a map of phases names between Entropy (as keys) and Source Package Manager.
source code
dict
config_files_map()
Return a map composed by configuration file identifiers and their path on disk.
source code
tuple
execute_qa_tests(package_path)
Execute Source Package Manager based QA tests on Entropy package files.
source code
int
entropy_client_post_repository_update_hook(entropy_client, entropy_repository_id)
This function is called by Entropy Client when updating Entropy repositories.
source code
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

Inherited from core.Singleton: __new__

Class Variables
  BASE_PLUGIN_API_VERSION = 3
  PLUGIN_API_VERSION = -1
  SUPPORTED_MATCH_TYPES = []
  PLUGIN_NAME = None
hash(x)
  IS_DEFAULT = False
Properties

Inherited from object: __class__

Method Details

init_singleton(self, output_interface)

source code 

Source Package Manager Plugin singleton method. This method must be reimplemented by subclasses.

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

package_metadata_keys(self)

source code 

Return a list of package metadata keys available.

Returns: list
list of package metadata

package_phases()
Static Method

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

package_phases_map()
Static Method

source code 

Return a map of phases names between Entropy (as keys) and Source Package Manager.

Returns: dict
map of package phases

config_files_map()
Static Method

source code 

Return a map composed by configuration file identifiers and their path on disk. These configuration files are related to Source Package Manager.

Returns: dict
configuration files map

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_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_changelog(self, package)

source code 

Return ChangeLog content for given package.

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

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_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_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_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_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_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_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_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_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

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_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

log_message(self, message)

source code 

Log message string to logfile.

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

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

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

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:

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:

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

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

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_installed_package_compile_options(self, package, root=None)

source code 

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_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?

compile_packages(self, packages, stdin=None, stdout=None, stderr=None, environ=None, pid_write_func=None, pretend=False, verbose=False, fetch_only=False, build_only=False, no_dependencies=False, ask=False, coloured_output=False, oneshot=False)

source code 

Compile given packages using given compile options. Extra compiler options can be set via environmental variables (CFLAGS, LDFLAGS, etc). By default, this function writes to stdout and can potentially interact with user via stdin/stdout/stderr. By default, when build_only=False, compiled packages are installed onto the running system.

Parameters:
  • packages (list) - list of Source Package Manager package names
  • stdin (file object or valid file descriptor number) - custom standard input
  • stdout (file object or valid file descriptor number) - custom standard output
  • stderr (file object or valid file descriptor number) - custom standard error
  • environ (map of environmental variables) - dict
  • pid_write_func (callable function, signature func(int_pid_number)) - function to call with execution pid number
  • pretend (bool) - just show what would be done
  • verbose (bool) - execute compilation in verbose mode
  • fetch_only (bool) - fetch source code only
  • build_only (bool) - do not actually touch live system (don't install compiled
  • no_dependencies (bool) - ignore possible build time dependencies
  • ask (bool) - ask user via stdin before executing the required tasks
  • coloured_output (bool) - allow coloured output
  • oneshot (bool) - when compiled packages are intended to not get recorded into personal user compile preferences (if you are not using a Portage-based SPM, just ignore this)
Returns: int
execution status

remove_packages(self, packages, stdin=None, stdout=None, stderr=None, environ=None, pid_write_func=None, pretend=False, verbose=False, no_dependencies=False, ask=False, coloured_output=False)

source code 

Compile given packages using given compile options. Extra compiler options can be set via environmental variables (CFLAGS, LDFLAGS, etc). By default, this function writes to stdout and can potentially interact with user via stdin/stdout/stderr. By default, when build_only=False, compiled packages are installed onto the running system.

Parameters:
  • packages (list) - list of Source Package Manager package names
  • stdin (file object or valid file descriptor number) - custom standard input
  • stdout (file object or valid file descriptor number) - custom standard output
  • stderr (file object or valid file descriptor number) - custom standard error
  • environ (map of environmental variables) - dict
  • pid_write_func (callable function, signature func(int_pid_number)) - function to call with execution pid number
  • pretend (bool) - just show what would be done
  • verbose (bool) - execute compilation in verbose mode
  • no_dependencies (bool) - ignore possible build time dependencies
  • ask (bool) - ask user via stdin before executing the required tasks
  • coloured_output (bool) - allow coloured output
Returns: int
execution status

print_build_environment_info(self, stdin=None, stdout=None, stderr=None, environ=None, pid_write_func=None, coloured_output=False)

source code 

Print build environment info to stdout.

Parameters:
  • stdin (file object or valid file descriptor number) - custom standard input
  • stdout (file object or valid file descriptor number) - custom standard output
  • stderr (file object or valid file descriptor number) - custom standard error
  • environ (map of environmental variables) - dict
  • pid_write_func (callable function, signature func(int_pid_number)) - function to call with execution pid number
  • coloured_output (bool) - allow coloured output
Returns: int
execution status

environment_update(self, stdout=None, stderr=None)

source code 

Hook used by Entropy Client and Entropy Server to ask Source Package Manager to update /etc/profile* and other environment settings around. Since this is part of the Source Package Manager metaphor it must stay in this class.

Parameters:
  • stdout (file object or valid file descriptor number) - custom standard output
  • stderr (file object or valid file descriptor number) - custom standard error
Returns: int
execution status

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_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

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

resolve_package_uid(self, entropy_repository, entropy_repository_package_id)

source code 

This is the bridge between Entropy package repository and its Source Package Manager backend. Given an EntropyRepository instance and its package identifier (which is available inside it). Return the package Unique Identifier that is bound to it, if available, otherwise return None. This function is used by EntropyRepository to regenerate Entropy<->Spm package bindings.

Parameters:
  • entropy_repository (EntropyRepository) - EntropyRepository instance
  • entropy_repository_package_id (int) - EntropyRepository instance package identifier
Returns: int
bound Source Package Manager Unique Identifier
Raises:

convert_from_entropy_package_name(self, entropy_package_name)

source code 

This function should be able to convert an Entropy package name (atom) to a Source Package Manager one.

Parameters:
  • entropy_package_name (string) - Entropy package name string
Returns: string
Source Package Manager package name string

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

execute_qa_tests(package_path)
Static Method

source code 

Execute Source Package Manager based QA tests on Entropy package files. This method can be used to test Entropy produced packages to make sure that they are fine on this side too. It is called by Entropy QA module (entropy.qa).

Parameters:
  • package_path (string) - path to Entropy package
Returns: tuple
tuple composed by error status and error message (if any). Error status is an int with != 0 values if error occured.

append_metadata_to_package(self, entropy_package_name, package_path)

source code 

Append Source Package Manager metadata bits to an Entropy package, known its name and path.

Parameters:
  • entropy_package_name (string) - Entropy package name
  • package_path (string) - Entropy package path
Returns: bool
True, if metadata has been appended succesfully

package_names_update(self, entropy_repository, entropy_repository_id, entropy_server, entropy_branch)

source code 

WARNING: this is an Entropy Server functionality. Execute the synchronization (if needed) of Source Package Manager package names with Entropy ones, stored inside the passed EntropyRepository instance (entropy_repository) referenced by an unique identifier (entropy_repository_id) for the given Entropy packages branch (entropy_branch). This method must also take care of the Entropy package names update file returned by Entropy server instance (entropy_server) method "get_local_database_treeupdates_file". If your Source Package Manager packages are subject to name changes, you must implement this method to effectively keep Entropy aligned with it.

Parameters:
  • entropy_repository (entropy.db.EntropyRepository) - EntropyRepository instance
  • entropy_repository_id (string) - Entropy Repository unique identifier
  • entropy_server (entropy.server.interfaces.Server instance) - Entropy Server instance
  • entropy_branch (string (SystemSettings['repositories']['branch'])) - Entropy branch string (may be handy to selectively execute updates based on working branch)

execute_package_phase(self, package_metadata, phase_name)

source code 

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

Parameters:
  • package_metadata (dict) - Entropy package phase metadata
  • phase_name (string) - name of the phase to call, must be a valid phase contained in package_phases() output.
Returns: int
phase script exit status
Raises:
  • KeyError - if phase is not available

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

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

entropy_client_post_repository_update_hook(entropy_client, entropy_repository_id)
Static Method

source code 

This function is called by Entropy Client when updating Entropy repositories. Place here all your Source Package Manager bullshit and, remember to return an int form execution status.

Parameters:
  • entropy_client (entropy.client.interfaces.Client.Client) - Entropy Client interface instance
  • entropy_repository_id - Entropy Repository unique identifier
Returns: int
execution status

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