Insert item x in list a, and keep it sorted assuming a is sorted.
Parameters: |
|
---|---|
Returns: | index where the item was inserted |
Return type: | int |
If x is already in a, insert it to the left of the leftmost x. Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched.
This is a modified version of bisect.insort_left that can use a function for the compare, and returns the index position where it was inserted.
Bases: ConfigParser.SafeConfigParser
lorax-composer configuration
Parameters: |
|
---|
Convert the changelog to a string
Parameters: | changelog (tuple) – A list of time, author, string tuples. |
---|---|
Returns: | The most recent changelog text or “” |
Return type: | str |
This returns only the most recent changelog entry.
Convert time since epoch to a string
Parameters: | t (int) – Seconds since epoch |
---|---|
Returns: | Time string |
Return type: | str |
Delete a source from a repo file
Parameters: | source_glob (str) – A glob of the repo sources to search |
---|---|
Returns: | None |
Raises : | ProjectsError if there was a problem |
A repo file may have multiple sources in it, delete only the selected source. If it is the last one in the file, delete the file.
WARNING: This will delete ANY source, the caller needs to ensure that a system source_name isn’t passed to it.
Return the epoch:version-release.arch for the dep
Parameters: | dep (dict) – dependency dict |
---|---|
Returns: | epoch:version-release.arch |
Return type: | str |
Estimate the installed size of a package list
Parameters: |
|
---|---|
Returns: | The estimated size of installed packages |
Return type: | int |
Estimating actual requirements is difficult without the actual file sizes, which yum doesn’t provide access to. So use the file count and block size to estimate a minimum size for each package.
Filter a list of yum package objects with a version glob
Parameters: |
|
---|
pkgs should be a list of all the versions of the same package. Return the latest package that matches the ‘version’ glob.
Return a list of sources from a directory of yum repositories
Parameters: | source_glob (str) – A glob to use to match the source files, including full path |
---|---|
Returns: | A list of the source ids in all of the matching files |
Return type: | list of str |
Return a list of the source ids in a file
Parameters: | source_path (str) – Full path and filename of the source (yum repo) file |
---|---|
Returns: | A list of source id strings |
Return type: | list of str |
Return details about a module, including dependencies
Parameters: |
|
---|---|
Returns: | List of dicts with module details and dependencies. |
Return type: | list of dicts |
Return a list of modules
Parameters: |
|
---|---|
Returns: | List of module information and total count |
Return type: | tuple of a list of dicts and an Int |
Modules don’t exist in RHEL7 so this only returns projects and sets the type to “rpm”
Extract the name from a YumAvailablePackageSqlite object
Parameters: | proj (dict) – Project details |
---|---|
Returns: | A dict with name, and group_type |
Return type: | dict |
group_type is hard-coded to “rpm”
Return the dependencies for a list of projects
Parameters: |
|
---|---|
Returns: | NEVRA’s of the project and its dependencies |
Return type: | list of dicts |
Raises : | ProjectsError if there was a problem installing something |
Return the dependencies and installed size for a list of projects
Parameters: |
|
---|---|
Returns: | installed size and a list of NEVRA’s of the project and its dependencies |
Return type: | tuple of (int, list of dicts) |
Raises : | ProjectsError if there was a problem installing something |
Return details about specific projects
Parameters: |
|
---|---|
Returns: | List of project info dicts with yaps_to_project as well as epoch, version, release, etc. |
Return type: | list of dicts |
Return a list of projects
Parameters: | yb (YumBase) – yum base object |
---|---|
Returns: | List of project info dicts with name, summary, description, homepage, upstream_vcs |
Return type: | list of dicts |
Return a Weldr Source dict created from the YumRepository
Parameters: |
|
---|---|
Returns: | A dict with Weldr Source fields filled in |
Return type: | dict |
Example:
{
"check_gpg": true,
"check_ssl": true,
"gpgkey_url": [
"file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-28-x86_64"
],
"name": "fedora",
"proxy": "http://proxy.brianlane.com:8123",
"system": true
"type": "yum-metalink",
"url": "https://mirrors.fedoraproject.org/metalink?repo=fedora-28&arch=x86_64"
}
Return an add_enable_repo kwargs dict created from a source dict
Parameters: | source (dict) – A Weldr source dict |
---|---|
Returns: | A yum YumRepository object |
Return type: | yum.yumRepo.YumRepository |
The dict it suitable for passing to yum’s add_enable_repo function after popping off baseurl and mirrorlist.
Example:
{
"gpgcheck": True,
"sslverify": True,
"gpgkey": ["file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-28-x86_64"],
"id": "fedora",
"proxy": "http://proxy.brianlane.com:8123",
"baseurl": "https://mirrors.fedoraproject.org/metalink?repo=fedora-28&arch=x86_64",
"metalink": None,
"mirrorlist": None
}
Extract the info from a TransactionMember object
Parameters: | tm (TransactionMember) – A Yum transaction object |
---|---|
Returns: | A dict with name, epoch, version, release, arch |
Return type: | dict |
Extract the build details from a hawkey.Package object
Parameters: | yaps (YumAvailablePackageSqlite) – Yum object with package details |
---|---|
Returns: | A dict with the build details, epoch, release, arch, build_time, changelog, ... |
Return type: | dict |
metadata entries are hard-coded to {}
Note that this only returns the build dict, it does not include the name, description, etc.
Extract the details from a YumAvailablePackageSqlite object
Parameters: | yaps (YumAvailablePackageSqlite) – Yum object with package details |
---|---|
Returns: | A dict with the name, summary, description, and url. |
Return type: | dict |
upstream_vcs is hard-coded to UPSTREAM_VCS
Extract the details from a YumAvailablePackageSqlite object
Parameters: | yaps (YumAvailablePackageSqlite) – Yum object with package details |
---|---|
Returns: | A dict with the project details, as well as epoch, release, arch, build_time, changelog, ... |
Return type: | dict |
metadata entries are hard-coded to {}
Return a string representation of a repo dict suitable for writing to a .repo file
Parameters: | repo (dict) – Yum Repository represented as a dict |
---|---|
Returns: | A string |
Return type: | str |
The YumRepo.dump() function does not produce a string that can be used as a yum .repo file. So do this manually with only the attributes we care about.
Bases: pylorax.base.DataHolder
Bases: dict
A Recipe of package and modules
This is a subclass of dict that enforces the constructor arguments and adds a .filename property to return the recipe’s filename, and a .toml() function to return the recipe as a TOML string.
semver recipe version number bump
Parameters: | old_version (str) – An optional old version number |
---|---|
Returns: | The new version number or None |
Return type: | str |
Raises : | ValueError |
If neither have a version, 0.0.1 is returned If there is no old version the new version is checked and returned If there is no new version, but there is a old one, bump its patch level If the old and new versions are the same, bump the patch level If they are different, check and return the new version
Return the Recipe’s filename
Replaces spaces in the name with ‘-‘ and appends .toml
Commit a recipe to a branch
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Commit all *.toml files from a directory, if they aren’t already in git.
Parameters: |
|
---|---|
Returns: | None |
Raises : | Can raise errors from Ggit or RecipeFileError |
Files with Toml or RecipeFileErrors will be skipped, and the remainder will be tried.
Commit a recipe file to a branch
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit or RecipeFileError |
Delete a file from a branch.
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Delete a recipe from a branch.
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Return the differences between two lists of dicts.
Parameters: |
|
---|---|
Returns: | List of diff dicts with old/new entries |
Return type: | list(dict) |
Find the tag that matches the commit_id
Parameters: |
|
---|---|
Returns: | The tag or None if there isn’t one |
Return type: | str or None |
There should be only 1 tag pointing to a commit, but there may not be a tag at all.
The tag will look like: ‘refs/tags/<branch>/<filename>/r<revision>’
Find the dict matching the name in a list and return it.
Parameters: |
|
---|---|
Returns: | First dict with matching name, or None |
Return type: | dict or None |
Return the details about a specific commit.
Parameters: |
|
---|---|
Returns: | Details about the commit |
Return type: | CommitDetails |
Raises : | CommitTimeValError or Ggit exceptions |
Return the revision number from a tag
Parameters: | tag (str) – The tag to exract the revision from |
---|---|
Returns: | The integer revision or None |
Return type: | int or None |
The revision is the part after the r in ‘branch/filename/rXXX’
Get the branch’s HEAD Commit Object
Parameters: |
|
---|---|
Returns: | Branch’s head commit |
Return type: | Git.Commit |
Raises : | Can raise errors from Ggit |
Check to see if a tag points to a specific commit.
Parameters: |
|
---|---|
Returns: | True if the tag points to the commit, False otherwise |
Return type: | bool |
Check to see if the commit is different from its parents
Parameters: |
|
---|---|
Retuns : | True if filename in the commit is different from its parents |
Return type: | bool |
Return a sorted list of the files on the branch HEAD
Parameters: |
|
---|---|
Returns: | A sorted list of the filenames |
Return type: | list(str) |
Raises : | Can raise errors from Ggit |
Return a sorted list of the files on a commit
Parameters: |
|
---|---|
Returns: | A sorted list of the filenames |
Return type: | list(str) |
Raises : | Can raise errors from Ggit |
List the commit history of a file on a branch.
Parameters: |
|
---|---|
Returns: | A list of commit details |
Return type: | list(CommitDetails) |
Raises : | Can raise errors from Ggit |
Open an existing repo, or create a new one
Parameters: | path (string) – path to recipe directory |
---|---|
Returns: | A repository object |
Return type: | Git.Repository |
Raises : | Can raise errors from Ggit |
A bare git repo will be created in the git directory of the specified path. If a repo already exists it will be opened and returned instead of creating a new one.
Prepare for a commit
Parameters: |
|
---|---|
Returns: | (Tree, Sig, Ref) |
Return type: | tuple |
Raises : | Can raise errors from Ggit |
Return the contents of a file on a specific branch or commit.
Parameters: |
|
---|---|
Returns: | The commit id, and the contents of the commit |
Return type: | tuple(str, str) |
Raises : | Can raise errors from Ggit |
If no commit is passed the master:filename is returned, otherwise it will be commit:filename
Return the raw content of the blob specified by the spec
Parameters: |
|
---|---|
Returns: | Contents of the commit |
Return type: | str |
Raises : | Can raise errors from Ggit |
eg. To read the README file from master the spec is “master:README”
Read a recipe commit and its id from git
Parameters: |
|
---|---|
Returns: | The commit id, and a Recipe object |
Return type: | tuple(str, Recipe) |
Raises : | Can raise errors from Ggit |
If no commit is passed the master:filename is returned, otherwise it will be commit:filename
Read a recipe commit from git and return a Recipe object
Parameters: |
|
---|---|
Returns: | A Recipe object |
Return type: | Recipe |
Raises : | Can raise errors from Ggit |
If no commit is passed the master:filename is returned, otherwise it will be commit:filename
Diff two versions of a recipe
Parameters: |
|
---|---|
Returns: | A list of diff dict entries with old/new |
Return type: | list(dict) |
Return the toml filename for a recipe
Replaces spaces with ‘-‘ and appends ‘.toml’
Create a Recipe object from a plain dict.
Parameters: | recipe_dict (dict) – A plain dict of the recipe |
---|---|
Returns: | A Recipe object |
Return type: | Recipe |
Raises : | RecipeError |
Return a recipe file as a Recipe object
Parameters: | recipe_path (str) – Path to the recipe fila |
---|---|
Returns: | A Recipe object |
Return type: | Recipe |
Create a Recipe object from a toml string.
Parameters: | recipe_str (str) – The Recipe TOML string |
---|---|
Returns: | A Recipe object |
Return type: | Recipe |
Raises : | TomlError |
Return True if the filename exists on the branch
Parameters: |
|
---|---|
Returns: | True if the filename exists on the HEAD of the branch, False otherwise. |
Return type: | bool |
Revert the contents of a file to that of a previous commit
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Revert the contents of a recipe to that of a previous commit
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Tag a file’s most recent commit
Parameters: |
|
---|---|
Returns: | Tag id or None if it failed. |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
This uses git tags, of the form refs/tags/<branch>/<filename>/r<revision> Only the most recent recipe commit can be tagged to prevent out of order tagging. Revisions start at 1 and increment for each new commit that is tagged. If the commit has already been tagged it will return false.
Tag a file’s most recent commit
Parameters: |
|
---|---|
Returns: | Tag id or None if it failed. |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Uses tag_file_commit()
Make a new commit to a repository’s branch
Parameters: |
|
---|---|
Returns: | OId of the new commit |
Return type: | Git.OId |
Raises : | Can raise errors from Ggit |
Delete the recipe from the workspace
Parameters: |
|
---|---|
Returns: | None |
Raises : | IO related errors |
Create the workspace’s path from a Repository and branch
Parameters: |
|
---|---|
Returns: | The path to the branch’s workspace directory |
Return type: | str |
Read a Recipe from the branch’s workspace
Parameters: |
|
---|---|
Returns: | The workspace copy of the recipe, or None if it doesn’t exist |
Return type: | Recipe or None |
Raises : | RecipeFileError |
Bases: object
Hold the YumBase object and a Lock to control access to it.
self.yb is a property that returns the YumBase object, but it may change from one call to the next if the upstream repositories have changed.
Check for repo updates (using expiration time) and return the lock
If the repository has been updated, tear down the old YumBase and create a new one. This is the only way to force yum to use the new metadata.
Force a check for repo updates and return the lock
If the repository has been updated, tear down the old YumBase and create a new one. This is the only way to force yum to use the new metadata.
Use this method sparingly, it removes the repodata and downloads a new copy every time.