Developer Guide

Deploy for development

This project uses pip to manage the package. If you want to work on the project yourself you can create the necessary links via:

$ sudo pip3 install -e .

That will install a backlink /usr/bin/kas to this project. Now you are able to call it from anywhere.

Docker image build

Just run:

$ docker build -t <image_name> .

When you need a proxy to access the internet, add:

--build-arg http_proxy=<http_proxy> --build-arg https_proxy=<https_proxy>

to the call.

Class reference documentation

kas.kas Module

This module is the main entry point for kas, setup tool for bitbake based projects

kas.kas.create_logger()[source]

Setup the logging environment

kas.kas.interruption()[source]

Ignore SIGINT/SIGTERM in kas, let them be handled by our sub-processes

kas.kas.kas(argv)[source]

The main entry point of kas.

kas.kas.kas_get_argparser()[source]

Creates a argparser for kas with all plugins.

kas.kas.main()[source]

The main function that operates as a wrapper around kas.

kas.libkas Module

This module contains the core implementation of kas.

class kas.libkas.LogOutput(live)[source]

Handles the log output of executed applications

log_stderr(line)[source]

This method is called when a line over stderr is received.

log_stdout(line)[source]

This method is called when a line over stdout is received.

kas.libkas.find_program(paths, name)[source]

Find a file within the paths array and returns its path.

kas.libkas.get_build_environ(config, build_dir)[source]

Create the build environment variables.

kas.libkas.kasplugin(plugin_class)[source]

A decorator that registeres kas plugins

kas.libkas.repo_checkout(config, repo)[source]

Checks out the correct revision of the repo.

kas.libkas.repos_fetch(config, repos)[source]

Fetches the list of repositories to the kas_work_dir.

kas.libkas.run_cmd(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True)[source]

Runs a command synchronously.

kas.libkas.run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True)[source]

Run a command asynchronously.

kas.libkas.ssh_add_key(env, key)[source]

Add ssh key to the ssh-agent

kas.libkas.ssh_cleanup_agent(config)[source]

Removes the identities and stop the ssh-agent instance

kas.libkas.ssh_no_host_key_check(_)[source]

Disables ssh host key check

kas.libkas.ssh_setup_agent(config, envkeys=None)[source]

Starts the ssh-agent

kas.libcmds Module

This module contain common commands used by kas plugins.

class kas.libcmds.CleanupSSHAgent[source]

Remove all the identities and stop the ssh-agent instance.

class kas.libcmds.Command[source]

An abstract class that defines the interface of a command.

execute(config)[source]

This method executes the command.

class kas.libcmds.Macro[source]

Contains commands and provide method to run them.

add(command)[source]

Appends commands to the command list.

run(config, skip=None)[source]

Runs command from the command list respective to the configuration.

class kas.libcmds.ReposCheckout[source]

Ensures that the right revision of each repo is check out.

class kas.libcmds.ReposFetch[source]

Fetches repositories defined in the configuration

class kas.libcmds.SetupDir[source]

Creates the build directory.

class kas.libcmds.SetupEnviron[source]

Setups the kas environment.

class kas.libcmds.SetupHome[source]

Setups the home directory of kas.

class kas.libcmds.SetupProxy[source]

Setups proxy configuration in the kas environment.

class kas.libcmds.SetupSSHAgent[source]

Setup the ssh agent configuration.

class kas.libcmds.WriteConfig[source]

Writes bitbake configuration files into the build directory.

kas.build Module

The build plugin for kas.

class kas.build.BuildCommand(task)[source]

Implement the bitbake build step.

execute(config)[source]

Executes the bitbake build command.

kas.shell Module

This module contains a kas plugin that opens a shell within the kas environment

class kas.shell.ShellCommand(cmd)[source]

This class implements the command that starts a shell.

kas.config Module

This module contains the implementation of the kas configuration.

class kas.config.Config(filename, target, task=None)[source]

Implements the kas configuration based on config files.

build_dir

The path of the build directory.

get_bblayers_conf_header()[source]

Returns the bblayers.conf header

get_bitbake_target()[source]

Return the bitbake target

get_bitbake_task()[source]

Return the bitbake task

get_distro()[source]

Returns the distro

get_gitlabci_config()[source]

Returns the GitlabCI configuration

get_local_conf_header()[source]

Returns the local.conf header

get_machine()[source]

Returns the machine

get_proxy_config()[source]

Returns the proxy settings

get_repo_dict()[source]

Returns a dictionary containing the repositories with their name (as it is defined in the config file) as key and the Repo instances as value.

get_repo_ref_dir()[source]

The path to the directory that contains the repository references.

get_repos()[source]

Returns the list of repos.

kas_work_dir

The path to the kas work directory.

setup_environ()[source]

Sets the environment variables for process that are started by kas.

kas.config.get_distro_id()[source]

Wrapper around platform.dist to simulate distro.id platform.dist is deprecated and will be removed in python 3.7 Use the ‘distro’ package instead.

kas.repos Module

This module contains the Repo class.

class kas.repos.Repo(url, path, refspec=None, layers=None)[source]

Represents a repository in the kas configuration.

disable_git_operations()[source]

Disabled all git operation for this repository.

kas.includehandler Module

This module implements how includes of configuration files are handled in kas.

class kas.includehandler.GlobalIncludes(top_file)[source]

Implements a handler where every configuration file should contain a dictionary as the base type with and ‘includes’ key containing a list of includes.

The includes can be specified in two ways, as a string containg the relative path from the current file or as a dictionary. The dictionary should have a ‘file’ key, containing the relative path to the include file and optionally a ‘repo’ key, containing the key of the repository. If the ‘repo’ key is missing the value of the ‘file’ key is threated the same as if just a string was defined, meaning the path is relative to the current config file otherwise its relative to the repository path.

The includes are read and merged depth first from top to buttom.

exception kas.includehandler.IncludeException[source]

Class for exceptions that appear in the include mechanism.

class kas.includehandler.IncludeHandler(top_file)[source]

Abstract class that defines the interface of an include handler.

get_config(repos=None)[source]
Parameters:
repos – A dictionary that maps repo name to directory path
Returns:
(config, repos)
config – A dictionary containing the configuration repos – A list of missing repo names that are needed to create a complete configuration
exception kas.includehandler.LoadConfigException(message, filename)[source]

Class for exceptions that appear while loading the configuration file.

kas.includehandler.load_config(filename)[source]

Load the configuration file and test if version is supported.