kentauros.modules.builder package

Submodules

kentauros.modules.builder.abstract module

This module contains the abstract Builder class, which is then inherited by actual builders.

class kentauros.modules.builder.abstract.Builder(package)[source]

Bases: kentauros.modules.module.PkgModule

This class is the base class for all builders. It’s only real function is to provide a unified API for builder classes and store the package to which the builder belongs.

Parameters:package (Package) – package to which this builder belongs
Variables:bpkg (Package) – stores the package argument given at initialisation
build()[source]

This method executes the builder commands.

export()[source]

This method exports the built packages (if any) to the directory specified for package exports.

status() → dict[source]

This method is expected to return a dictionary of statistics about the respective builder.

kentauros.modules.builder.abstract.LOG_PREFIX = 'ktr/builder'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

kentauros.modules.builder.mock module

This module contains the MockBuilder class, which can be used to build binary packages from src.rpm packages.

kentauros.modules.builder.mock.LOG_PREFIX = 'ktr/builder/mock'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

class kentauros.modules.builder.mock.MockBuild(mock: str, path: str, dist: str = None)[source]

Bases: object

This helper class is used for the actual execution of mock.

Parameters:
  • mock (str) – path of the used mock binary
  • path (str) – path of the SRPM package that will be built
  • dist (str) – chroot that the package will be built in
Variables:
  • mock (str) – stores the path of the used mock binary
  • path (str) – stores the path of the SRPM package that will be built
  • dist (str) – stores the chroot that the package will be built in
build() → int[source]

This method starts the mock build (and waits for already running builds with the same chroot to finish before that).

Returns:int – return code of the subprocess call
get_command() → list[source]

This method returns the argument list needed by the subprocess method call, assembled from dist and path.

Returns:list – argument list for consumption by subprocess methods
class kentauros.modules.builder.mock.MockBuilder(package)[source]

Bases: kentauros.modules.builder.abstract.Builder

This Builder subclass is used to hold information and methods for executing a local package build using mock. At class instantiation, it checks for existence of the mock binary. If it is not found in $PATH, this instance is set to inactive.

Parameters:package (Package) – package for which this mock/srpm builder is for
Variables:active (bool) – determines if this instance is active
build() → bool[source]

This method constructs the MockBuilder instances, which contain the commands for executing the builds, and executes them in turn. It also checks if the executing user is allowed to execute a mock build by checking if $USER is “root” or if the user is in the “mock” group.

If no source packages are found in the specified directory (PACKDIR), the build terminates without executing mock. If SRPM packages are found, only the most recent (biggest version number, determined just by sorting!) is built, for all specified chroots.

After the last mock invocation, a list of successful and unsuccessful builds is printed.

Returns:boolTrue if all builds succeeded, False if not
clean() → bool[source]

This method is expected to clean up a sub-module’s files and folders, if it creates any during its execution.

Returns:bool – boolean indicating whether cleaning up was successful
execute() → bool[source]

This method is expected to execute the package module and return a boolean, indicating whether the execution finished successfully or not.

Returns:bool – boolean indicating whether the execution was successful
export() → bool[source]

This method copies the build results (if any) from the mock result directory to the directory specified for binary package exports.

Returns:boolTrue if successful, False if not
get_active() → bool[source]
Returns:bool – boolean value indicating whether this builder should be active
get_dists() → list[source]
Returns:list – list of chroots that are going to be used for sequential builds
get_export() → bool[source]
Returns:bool – boolean value indicating whether this builder should export built packages
get_keep() → bool[source]
Returns:bool – boolean value indicating whether this builder should keep source packages
imports() → dict[source]

This method is expected to return a dictionary of statistics about a module that has not yet been imported into the package database.

Returns:dict – dictionary containing the sub-module’s imported stats
status() → dict[source]

This method is expected to return a dictionary of statistics about the respective builder.

status_string() → str[source]

This method is expected to return a string describing the status of this module.

Returns:str – string containing module statistics
verify() → bool[source]

This method runs several checks to ensure mock builds can proceed. It is automatically executed at package initialisation. This includes:

  • checks if all expected keys are present in the configuration file
  • checks if the mock binary is installed and can be found on the system
  • checks if the current user is allowed to run builds with mock
  • checks if the current user is root (building as root is strongly discouraged)
Returns:bool – verification success
exception kentauros.modules.builder.mock.MockError(value='')[source]

Bases: Exception

This custom exception will be raised when errors occur during parsing of mock configuration files.

Parameters:value (str) – informational string accompanying the exception
kentauros.modules.builder.mock.get_default_mock_dist() → str[source]

This helper function tries to figure out which dist is the default one.

Returns:str – dist string in default format
kentauros.modules.builder.mock.get_dist_from_mock_config(dist: str) → str[source]

This helper function tries to read the “real” dist string from a custom dist config file.

Parameters:dist (str) – name of the custom dist
Returns:str – name of the underlying “standard” dist
kentauros.modules.builder.mock.get_dist_result_path(dist: str) → str[source]

This helper function constructs the mock result path for a given dist string.

Parameters:dist (str) – name of the standard dist
Returns:str – path pointing to the mock result directory for this dist
kentauros.modules.builder.mock.get_mock_cmd() → str[source]

This function tries to determine the correct mock binary path. If something is messing with the $PATH environment variable, it will try to account for that. If mock is not installed (or cannot be found within $PATH, this function will raise an Exception.

Raises:subprocess.CalledProcessError
Returns:str – path to the mock binary

Module contents

This subpackage contains the quasi-abstract Builder class and its MockBuilder subclass, which are used to hold information about the configured local builder for binary packages. This includes only MockBuilder right now, but should be extensible for other builders without need for architectural changes. Additionally, this file contains a dictionary which maps BuilderType enums to their respective class constructors.

kentauros.modules.builder.BUILDER_TYPE_DICT = {<BuilderType.MOCK: 1>: <class 'kentauros.modules.builder.mock.MockBuilder'>}

This dictionary maps BuilderType enum members to their respective Builder subclass constructors.