API reference for the Python implementation of sp-variant
variant: the top-level functions and structures
sp_variant.variant
Build variant definitions and commands.
Config
dataclass
Runtime configuration for the sp-variant library functions.
Source code in python/sp_variant/defs.py
args: list[str] | None = None
class-attribute
instance-attribute
Additional arguments passed to the command.
command: str | None = None
class-attribute
instance-attribute
The main argument: a command to execute, a variant specification to show, etc.
noop: bool = False
class-attribute
instance-attribute
No-operation mode; display what would have been done.
repodir: pathlib.Path | None = None
class-attribute
instance-attribute
The path to the directory containing the add-storpool-repo
data files to install.
repotype: RepoType = REPO_TYPES[0]
class-attribute
instance-attribute
Which StorPool repository to configure.
verbose: bool = False
class-attribute
instance-attribute
Verbose operation; display diagnostic output.
Variant
Bases: NamedTuple
The information about a Linux distribution version (build variant).
Source code in python/sp_variant/defs.py
builder: Builder
instance-attribute
The data specific to the StorPool builder containers.
commands: Commands
instance-attribute
The OS commands to execute for particular purposes.
descr: str
instance-attribute
The human-readable description of the variant.
detect: Detect
instance-attribute
The ways to check whether we are running this variant.
family: str
instance-attribute
The OS "family" that this distribution belongs to.
file_ext: str
instance-attribute
The filename extension of the OS packages ("deb", "rpm", etc.).
initramfs_flavor: str
instance-attribute
The type of initramfs-generating tools.
min_sys_python: str
instance-attribute
The minimum Python version that we can depend on.
name: str
instance-attribute
The name of the variant, e.g. ALMA9
, UBUNTU2204
, etc.
package: dict[str, str]
instance-attribute
The names of the packages to be used for this variant.
parent: str
instance-attribute
The name of the variant that this one is based on.
repo: DebRepo | YumRepo
instance-attribute
The StorPool repository files to install.
supported: Supported
instance-attribute
The aspects of StorPool operation supported for this build variant.
systemd_lib: str
instance-attribute
The name of the directory to install systemd unit files to.
VariantDetectError
Bases: VariantError
An error that occurred during the detection of a variant.
VariantError
VariantFileError
Bases: VariantError
A filesystem-related error occurred.
VariantKeyError
Bases: VariantError
A variant with an unknown name was requested.
VariantRemoteError
Bases: VariantError
An error occurred while communicating with a remote host.
Source code in python/sp_variant/variant.py
hostname: str = hostname
instance-attribute
The name of the remote host that we could not communicate with.
msg: str = msg
instance-attribute
The description of the error that occurred.
__init__(hostname, msg)
detect_variant(cfg=_DEFAULT_CONFIG)
Detect the build variant for the current host.
Source code in python/sp_variant/variant.py
get_all_variants(cfg=_DEFAULT_CONFIG)
Return information about all the supported variants.
get_all_variants_in_order(cfg=_DEFAULT_CONFIG)
Return information about all supported variants in detect order.
get_by_alias(alias, cfg=_DEFAULT_CONFIG)
Return the variant with the specified name.
Source code in python/sp_variant/variant.py
get_variant(name, cfg=_DEFAULT_CONFIG)
Return the variant with the specified name.
Source code in python/sp_variant/variant.py
list_all_packages(var, patterns=None)
Parse the output of the "list installed packages" command.
Source code in python/sp_variant/variant.py
update_namedtuple(data, updates)
Create a new named tuple with some updated values.
Source code in python/sp_variant/vbuild.py
defs: some additional definitions and substructures
sp_variant.defs
Common definitions for the OS/distribution variant detection library.
Builder
Bases: NamedTuple
StorPool builder data.
Source code in python/sp_variant/defs.py
alias: str
instance-attribute
The builder name.
base_image: str
instance-attribute
The base Docker image that the builder is generated from.
branch: str
instance-attribute
The branch used by the sp-pkg tool to specify the variant.
kernel_package: str
instance-attribute
The base kernel OS package.
utf8_locale: str
instance-attribute
The name of the locale to use for clean UTF-8 output.
Commands
Bases: NamedTuple
Variant-specific commands, mainly related to the packaging system.
Source code in python/sp_variant/defs.py
package: CommandsPackage
instance-attribute
Commands related to installing packages from upstream repositories.
pkgfile: CommandsPkgFile
instance-attribute
Commands related to installing packages from locally-fetched files.
CommandsPackage
Bases: NamedTuple
Variant-specific commands related to OS packages.
Source code in python/sp_variant/defs.py
install: list[str]
instance-attribute
Install one or more packages from the upstream repositories.
list_all: list[str]
instance-attribute
List the currently installed packages.
purge: list[str]
instance-attribute
Remove a package and all its files, including configuration ones.
remove: list[str]
instance-attribute
Remove a package and all its files, possibly leaving configuration ones.
remove_impl: list[str]
instance-attribute
Remove a package using the low-level OS package manager.
update_db: list[str]
instance-attribute
Make the package manager fetch new data from the upstream repositories.
CommandsPkgFile
Bases: NamedTuple
Variant-specific commands related to OS package files.
Source code in python/sp_variant/defs.py
dep_query: list[str]
instance-attribute
List the packages that the one in the specified package file depends on.
install: list[str]
instance-attribute
Install a package from a locally-fetched file.
Config
dataclass
Runtime configuration for the sp-variant library functions.
Source code in python/sp_variant/defs.py
args: list[str] | None = None
class-attribute
instance-attribute
Additional arguments passed to the command.
command: str | None = None
class-attribute
instance-attribute
The main argument: a command to execute, a variant specification to show, etc.
noop: bool = False
class-attribute
instance-attribute
No-operation mode; display what would have been done.
repodir: pathlib.Path | None = None
class-attribute
instance-attribute
The path to the directory containing the add-storpool-repo
data files to install.
repotype: RepoType = REPO_TYPES[0]
class-attribute
instance-attribute
Which StorPool repository to configure.
verbose: bool = False
class-attribute
instance-attribute
Verbose operation; display diagnostic output.
DebRepo
Bases: NamedTuple
Debian package repository data.
Source code in python/sp_variant/defs.py
codename: str
instance-attribute
The distribution codename (e.g. "buster").
keyring: str
instance-attribute
The GnuPG keyring file to copy to /usr/share/keyrings/.
req_packages: list[str]
instance-attribute
OS packages that need to be installed before apt-get update
is run.
sources: str
instance-attribute
The APT sources list file to copy to /etc/apt/sources.list.d/.
vendor: str
instance-attribute
The distribution vendor ("debian", "ubuntu", etc.).
Detect
Bases: NamedTuple
Check whether this host is running this particular OS variant.
Source code in python/sp_variant/defs.py
filename: str
instance-attribute
The name of the file to read.
os_id: str
instance-attribute
The "ID" field in the /etc/os-release file.
os_version_regex: Pattern[str]
instance-attribute
The regular expression pattern for the "VERSION_ID" os-release field.
regex: Pattern[str]
instance-attribute
The regular expression pattern to look for in the file.
OSPackage
Bases: NamedTuple
The attributes of a currently-installed or known OS package.
Source code in python/sp_variant/defs.py
arch: str
instance-attribute
The system-dependent package architecture name.
name: str
instance-attribute
The package name.
status: str
instance-attribute
The system-dependent status of the package (installed, half-installed, removed, etc).
version: str
instance-attribute
The package version.
RepoType
Bases: NamedTuple
Attributes common to a StorPool package repository.
Source code in python/sp_variant/defs.py
extension: str
instance-attribute
The extension to be used in filenames for configurating the package manager.
name: str
instance-attribute
The name of the StorPool package repository.
url: str
instance-attribute
The base URL of the StorPool package repository.
Supported
Bases: NamedTuple
The aspects of the StorPool operation supported for this build variant.
Source code in python/sp_variant/defs.py
repo: bool
instance-attribute
Is there a StorPool third-party packages repository?
Variant
Bases: NamedTuple
The information about a Linux distribution version (build variant).
Source code in python/sp_variant/defs.py
builder: Builder
instance-attribute
The data specific to the StorPool builder containers.
commands: Commands
instance-attribute
The OS commands to execute for particular purposes.
descr: str
instance-attribute
The human-readable description of the variant.
detect: Detect
instance-attribute
The ways to check whether we are running this variant.
family: str
instance-attribute
The OS "family" that this distribution belongs to.
file_ext: str
instance-attribute
The filename extension of the OS packages ("deb", "rpm", etc.).
initramfs_flavor: str
instance-attribute
The type of initramfs-generating tools.
min_sys_python: str
instance-attribute
The minimum Python version that we can depend on.
name: str
instance-attribute
The name of the variant, e.g. ALMA9
, UBUNTU2204
, etc.
package: dict[str, str]
instance-attribute
The names of the packages to be used for this variant.
parent: str
instance-attribute
The name of the variant that this one is based on.
repo: DebRepo | YumRepo
instance-attribute
The StorPool repository files to install.
supported: Supported
instance-attribute
The aspects of StorPool operation supported for this build variant.
systemd_lib: str
instance-attribute
The name of the directory to install systemd unit files to.
VariantConfigError
Bases: VariantError
Invalid parameters passed to the variant routines.
VariantError
VariantUpdate
Bases: NamedTuple
The changes to be applied to the parent variant definition.
Source code in python/sp_variant/defs.py
descr: str
instance-attribute
The description of the new variant.
detect: Detect
instance-attribute
The ways to detect the new variant.
name: str
instance-attribute
The name of the new variant.
parent: str
instance-attribute
The variant that the new one is based on.
updates: dict[str, Any]
instance-attribute
The changes to be applied to the parent variant's structure.
YumRepo
Bases: NamedTuple
Yum/DNF package repository data.
Source code in python/sp_variant/defs.py
keyring: str
instance-attribute
The keyring file to copy to /etc/pki/rpm-gpg/.
yumdef: str
instance-attribute
The *.repo file to copy to /etc/yum.repos.d/.
jsonify(obj)
Return a more readable representation of an object.