Common Build Operations#
Build process common methods.
- class relenv.build.common.Builder(root=None, recipies=None, build_default=<function build_default>, populate_env=<function populate_env>, force_download=False, arch='x86_64', version='')#
Utility that handles the build process.
- Parameters:
root (str) – The root of the working directories for this build
recipies – The instructions for the build steps
build_default (types.FunctionType) – The default build function, defaults to
build_default
populate_env (types.FunctionType) – The default function to populate the build environment, defaults to
populate_env
force_download (bool) – If True, forces downloading the archives even if they exist, defaults to False
arch (str) – The architecture being built
- add(name, build_func=None, wait_on=None, download=None)#
Add a step to the build process.
- Parameters:
name (str) – The name of the step
build_func (types.FunctionType, optional) – The function that builds this step, defaults to None
wait_on (list, optional) – Processes to wait on before running this step, defaults to None
download (dict, optional) – A dictionary of download information, defaults to None
- build(steps=None, cleanup=True)#
Build!
- Parameters:
steps (list, optional) – The steps to run, defaults to None
cleanup (bool, optional) – Whether to clean up or not, defaults to True
- check_prereqs()#
Check pre-requsists for build.
This method verifies all requrements for a successful build are satisfied.
- Returns:
Returns a list of string describing failed checks
- Return type:
list
- clean()#
Completely clean up the remnants of a relenv build.
- cleanup()#
Clean up the build directories.
- download_files(steps=None, force_download=False)#
Download all of the needed archives.
- Parameters:
steps (list, optional) – The steps to download archives for, defaults to None
- run(name, event, build_func, download)#
Run a build step.
- Parameters:
name (str) – The name of the step to run
event (
multiprocessing.Event
) – An event to track this process’ status and alert waiting stepsbuild_func (types.FunctionType) – The function to use to build this step
download (
Download
) – TheDownload
instance for this step
- Returns:
The output of the build function
- set_arch(arch)#
Set the architecture for the build.
- Parameters:
arch (str) – The arch to build
- class relenv.build.common.Builds#
Collection of builds.
- class relenv.build.common.Dirs(dirs, name, arch, version)#
A container for directories during build time.
- Parameters:
dirs (
relenv.common.WorkDirs
) – A collection of working directoriesname (str) – The name of this collection
arch (str) – The architecture being worked with
- to_dict()#
Get a dictionary representation of the directories in this collection.
- Returns:
A dictionary of all the directories
- Return type:
dict
- class relenv.build.common.Download(name, url, fallback_url=None, signature=None, destination='', version='', md5sum=None, checkfunc=None, checkurl=None)#
A utility that holds information about content to be downloaded.
- Parameters:
name (str) – The name of the download
url (str) – The url of the download
signature (str) – The signature of the download, defaults to None
destination (str) – The path to download the file to
version (str) – The version of the content to download
md5sum (str) – The md5 sum of the download
- exists()#
True when the artifact already exists on disk.
- Returns:
True when the artifact already exists on disk
- Return type:
bool
- fetch_file()#
Download the file.
- Returns:
The path to the downloaded content, and whether it was downloaded.
- Return type:
tuple(str, bool)
- fetch_signature(version)#
Download the file signature.
- Returns:
The path to the downloaded signature.
- Return type:
str
- static validate_md5sum(archive, md5sum)#
True when when the archive matches the md5 hash.
- Parameters:
archive (str) – The path to the archive to validate
md5sum (str) – The md5 sum to validate against
- Returns:
True if the sums matched, else False
- Return type:
bool
- static validate_signature(archive, signature)#
True when the archive’s signature is valid.
- Parameters:
archive (str) – The path to the archive to validate
signature (str) – The path to the signature to validate against
- Returns:
True if it validated properly, else False
- Return type:
bool
- relenv.build.common.all_dirs(root, recurse=True)#
Get all directories under and including the given root.
- Parameters:
root (str) – The root directory to traverse
recurse (bool, optional) – Whether to recursively search for directories, defaults to True
- Returns:
A list of directories found
- Return type:
list
- relenv.build.common.build_default(env, dirs, logfp)#
The default build function if none is given during the build process.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs
) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.build_openssl(env, dirs, logfp, fips=False)#
Build openssl.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs
) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.build_sqlite(env, dirs, logfp)#
Build sqlite.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs
) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.create_archive(tarfp, toarchive, globs, logfp=None)#
Create an archive.
- Parameters:
tarfp (file) – A pointer to the archive to be created
toarchive (str) – The path to the directory to archive
globs (list) – A list of filtering patterns to match against files to be added
logfp (file) – A pointer to the log file
- relenv.build.common.finalize(env, dirs, logfp)#
Run after we’ve fully built python.
This method enhances the newly created python with Relenv’s runtime hacks.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs
) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.find_sysconfigdata(pymodules)#
Find sysconfigdata directory for python installation.
- Parameters:
pymodules (str) – Path to python modules (e.g. lib/python3.10)
- Returns:
The name of the sysconig data module
- Return type:
str
- relenv.build.common.install_runtime(sitepackages)#
Install a base relenv runtime.
- relenv.build.common.install_sysdata(mod, destfile, buildroot, toolchain)#
Create a Relenv Python environment’s sysconfigdata.
Helper method used by the finalize build method to create a Relenv Python environment’s sysconfigdata.
- Parameters:
mod (
types.ModuleType
) – The module to operate ondestfile (str) – Path to the file to write the data to
buildroot (str) – Path to the root of the build
toolchain (str) – Path to the root of the toolchain
- relenv.build.common.patch_shebang(path, old, new)#
Replace a file’s shebang.
- Parameters:
path (str) – The path of the file to patch
old (str) – The old shebang, will only patch when this is found
name (str) – The new shebang to be written
- relenv.build.common.patch_shebangs(path, old, new)#
Traverse directory and patch shebangs.
- Parameters:
path (str) – The of the directory to traverse
old (str) – The old shebang, will only patch when this is found
name (str) – The new shebang to be written
- relenv.build.common.print_ui(events, processes, fails, flipstat=None)#
Prints the UI during the relenv building process.
- Parameters:
events (dict) – A dictionary of events that are updated during the build process
processes (dict) – A dictionary of build processes
fails (list) – A list of processes that have failed
flipstat (dict, optional) – A dictionary of process statuses, defaults to {}
- relenv.build.common.verify_checksum(file, checksum)#
Verify the checksum of a files.
- Parameters:
file (str) – The path to the file to check.
checksum (str) – The checksum to verify against
- Raises:
RelenvException – If the checksum verification failed
- Returns:
True if it succeeded, or False if the checksum was None
- Return type:
bool