Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- OSTree.break_hardlink(dfd, path, skip_xattrs, cancellable)¶
- Parameters:
dfd (
int
) – Directory fdpath (
str
) – Path relative to dfdskip_xattrs (
bool
) – Do not copy extended attributescancellable (
Gio.Cancellable
orNone
) –
- Raises:
- Return type:
In many cases using libostree, a program may need to “break” hardlinks by performing a copy. For example, in order to logically append to a file.
This function performs full copying, including e.g. extended attributes and permissions of both regular files and symbolic links.
If the file is not hardlinked, this function does nothing and returns successfully.
This function does not perform synchronization via
fsync()
orfdatasync()
; the idea is this will commonly be done as part of anostree_repo_commit_transaction()
, which itself takes care of synchronization.New in version 2017.15.
- OSTree.check_version(required_year, required_release)¶
- Parameters:
- Returns:
True
if current libostree has at least the requested version,False
otherwise- Return type:
New in version 2017.4.
- OSTree.checksum_b64_from_bytes(csum)¶
- Parameters:
csum (
bytes
) – An binary checksum of length 32- Returns:
Modified base64 encoding of csum
The “modified” term refers to the fact that instead of ‘/’, the ‘_’ character is used.
- Return type:
New in version 2016.8.
- OSTree.checksum_b64_to_bytes(checksum)¶
- Parameters:
checksum (
str
) – An ASCII checksum- Returns:
Binary version of checksum.
- Return type:
New in version 2016.8.
- OSTree.checksum_bytes_peek(bytes)¶
- Parameters:
bytes (
GLib.Variant
) –GLib.Variant
of type ay- Returns:
Binary checksum data in bytes; do not free. If bytes does not have the correct length, return
None
.- Return type:
- OSTree.checksum_bytes_peek_validate(bytes)¶
- Parameters:
bytes (
GLib.Variant
) –GLib.Variant
of type ay- Raises:
- Returns:
Binary checksum data
- Return type:
Like
OSTree.checksum_bytes_peek
(), but also throws error.
- OSTree.checksum_file(f, objtype, cancellable)¶
- Parameters:
f (
Gio.File
) – File pathobjtype (
OSTree.ObjectType
) – Object typecancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_csum:
Return location for binary checksum
- Return type:
Compute the OSTree checksum for a given file.
- OSTree.checksum_file_async(f, objtype, io_priority, cancellable, callback, *user_data)¶
- Parameters:
f (
Gio.File
) – File pathobjtype (
OSTree.ObjectType
) – Object typeio_priority (
int
) – Priority for operation, see %G_IO_PRIORITY_DEFAULTcancellable (
Gio.Cancellable
orNone
) – Cancellablecallback (
Gio.AsyncReadyCallback
orNone
) – Invoked when operation is complete
Asynchronously compute the OSTree checksum for a given file; complete with
OSTree.checksum_file_async_finish
().
- OSTree.checksum_file_async_finish(f, result)¶
- Parameters:
f (
Gio.File
) – File pathresult (
Gio.AsyncResult
) – Async result
- Raises:
- Returns:
- out_csum:
Return location for binary checksum
- Return type:
Finish computing the OSTree checksum for a given file; see
OSTree.checksum_file_async
().
- OSTree.checksum_file_at(dfd, path, stbuf, objtype, flags, out_checksum, cancellable)¶
- Parameters:
dfd (
int
) – Directory file descriptorpath (
str
) – Subpath stbuf (allow-none): Optional stat bufferobjtype (
OSTree.ObjectType
) – Object typeflags (
OSTree.ChecksumFlags
) – Flags out_checksum (out) (transfer full): Return location for hex checksumout_checksum (
str
) –cancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Compute the OSTree checksum for a given file. This is an fd-relative version of
OSTree.checksum_file
() which also takes flags and fills in a caller allocated buffer.New in version 2017.13.
- OSTree.checksum_file_from_input(file_info, xattrs, in_, objtype, cancellable)¶
- Parameters:
file_info (
Gio.FileInfo
) – File informationxattrs (
GLib.Variant
orNone
) – Optional extended attributesin (
Gio.InputStream
orNone
) – File content, should beNone
for symbolic linksobjtype (
OSTree.ObjectType
) – Object typecancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_csum:
Return location for binary checksum
- Return type:
Compute the OSTree checksum for a given input.
- OSTree.checksum_from_bytes(csum)¶
- OSTree.checksum_from_bytes_v(csum_v)¶
- Parameters:
csum_v (
GLib.Variant
) –GLib.Variant
of type ay- Returns:
String form of csum_bytes
- Return type:
- OSTree.checksum_inplace_to_bytes(checksum, buf)¶
- Parameters:
Convert checksum from a string to binary in-place, without allocating memory. Use this function in hot code paths.
- OSTree.checksum_to_bytes(checksum)¶
- OSTree.checksum_to_bytes_v(checksum)¶
- Parameters:
checksum (
str
) – An ASCII checksum- Returns:
New
GLib.Variant
of type ay with length 32- Return type:
- OSTree.cmp_checksum_bytes(a, b)¶
-
Compare two binary checksums, using memcmp().
- OSTree.collection_ref_dupv(refs)¶
- Parameters:
refs ([
OSTree.CollectionRef
]) –None
-terminated array ofOSTree.CollectionRefs
- Returns:
a newly allocated copy of refs
- Return type:
Copy an array of
OSTree.CollectionRefs
, including deep copies of all its elements. refs must beNone
-terminated; it may be empty, but must not beNone
.New in version 2018.6.
- OSTree.collection_ref_freev(refs)¶
- Parameters:
refs ([
OSTree.CollectionRef
]) – an array ofOSTree.CollectionRefs
Free the given array of refs, including freeing all its elements. refs must be
None
-terminated; it may be empty, but must not beNone
.New in version 2018.6.
- OSTree.commit_get_content_checksum(commit_variant)¶
- Parameters:
commit_variant (
GLib.Variant
) – A commit object- Returns:
A SHA-256 hex string, or
None
if commit_variant is not well-formed- Return type:
There are use cases where one wants a checksum just of the content of a commit. OSTree commits by default capture the current timestamp, and may have additional metadata, which means that re-committing identical content often results in a new checksum.
By comparing checksums of content, it’s possible to easily distinguish cases where nothing actually changed.
The content checksums is simply defined as
SHA256(root dirtree_checksum || root_dirmeta_checksum)
, i.e. the SHA-256 of the root “dirtree” object’s checksum concatenated with the root “dirmeta” checksum (both in binary form, not hexadecimal).New in version 2018.2.
- OSTree.commit_get_object_sizes(commit_variant)¶
- Parameters:
commit_variant (
GLib.Variant
) – variant of typeOSTree.ObjectType.COMMIT
- Raises:
- Returns:
- out_sizes_entries:
return location for an array of object size entries
- Return type:
(
bool
, out_sizes_entries: [OSTree.CommitSizesEntry
])
Reads a commit’s “ostree.sizes” metadata and returns an array of
OSTree.CommitSizesEntry
in out_sizes_entries. Each element represents an object in the commit. If the commit does not contain the “ostree.sizes” metadata, aGio.IOErrorEnum.NOT_FOUND
error will be returned.New in version 2020.1.
- OSTree.commit_get_parent(commit_variant)¶
- Parameters:
commit_variant (
GLib.Variant
) – Variant of typeOSTree.ObjectType.COMMIT
- Returns:
Checksum of the parent commit of commit_variant, or
None
if none- Return type:
- OSTree.commit_get_timestamp(commit_variant)¶
- Parameters:
commit_variant (
GLib.Variant
) – Commit object- Returns:
timestamp in seconds since the Unix epoch, UTC
- Return type:
New in version 2016.3.
- OSTree.commit_metadata_for_bootable(root, dict, cancellable)¶
- Parameters:
root (
Gio.File
) – Root filesystem to be committeddict (
GLib.VariantDict
) – Dictionary to updatecancellable (
Gio.Cancellable
orNone
) –
- Raises:
- Return type:
Update provided dict with standard metadata for bootable OSTree commits.
New in version 2021.1.
- OSTree.content_file_parse(compressed, content_path, trusted, cancellable)¶
- Parameters:
- Raises:
- Returns:
- out_input:
The raw file content stream
- out_file_info:
Normal metadata
- out_xattrs:
Extended attributes
- Return type:
(
bool
, out_input:Gio.InputStream
, out_file_info:Gio.FileInfo
, out_xattrs:GLib.Variant
)
A thin wrapper for
OSTree.content_stream_parse
(); this function converts an object content stream back into components.
- OSTree.content_file_parse_at(compressed, parent_dfd, path, trusted, cancellable)¶
- Parameters:
- Raises:
- Returns:
- out_input:
The raw file content stream
- out_file_info:
Normal metadata
- out_xattrs:
Extended attributes
- Return type:
(
bool
, out_input:Gio.InputStream
, out_file_info:Gio.FileInfo
, out_xattrs:GLib.Variant
)
A thin wrapper for
OSTree.content_stream_parse
(); this function converts an object content stream back into components.
- OSTree.content_stream_parse(compressed, input, input_length, trusted, cancellable)¶
- Parameters:
compressed (
bool
) – Whether or not the stream is zlib-compressedinput (
Gio.InputStream
) – Object content streaminput_length (
int
) – Length of streamtrusted (
bool
) – IfTrue
, assume the content has been validatedcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_input:
The raw file content stream
- out_file_info:
Normal metadata
- out_xattrs:
Extended attributes
- Return type:
(
bool
, out_input:Gio.InputStream
, out_file_info:Gio.FileInfo
, out_xattrs:GLib.Variant
)
The reverse of
OSTree.raw_file_to_content_stream
(); this function converts an object content stream back into components.
- OSTree.create_directory_metadata(dir_info, xattrs)¶
- Parameters:
dir_info (
Gio.FileInfo
) – aGio.FileInfo
containing directory informationxattrs (
GLib.Variant
orNone
) – Optional extended attributes
- Returns:
A new
GLib.Variant
containingOSTree.ObjectType.DIR_META
- Return type:
- OSTree.diff_dirs(flags, a, b, modified, removed, added, cancellable)¶
- Parameters:
flags (
OSTree.DiffFlags
) – Flagsb (
Gio.File
) – First directory pathmodified ([
OSTree.DiffItem
]) – Modified filesremoved ([
Gio.File
]) – Removed filesadded ([
Gio.File
]) – Added filescancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Compute the difference between directory a and b as 3 separate sets of
OSTree.DiffItem
in modified, removed, and added.
- OSTree.diff_dirs_with_options(flags, a, b, modified, removed, added, options, cancellable)¶
- Parameters:
flags (
OSTree.DiffFlags
) – Flagsb (
Gio.File
) – First directory pathmodified ([
OSTree.DiffItem
]) – Modified filesremoved ([
Gio.File
]) – Removed filesadded ([
Gio.File
]) – Added filesoptions (
OSTree.DiffDirsOptions
orNone
) – Optionscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Compute the difference between directory a and b as 3 separate sets of
OSTree.DiffItem
in modified, removed, and added.New in version 2017.4.
- OSTree.diff_print(a, b, modified, removed, added)¶
- Parameters:
a (
Gio.File
) – First directory pathb (
Gio.File
) – First directory pathmodified ([
OSTree.DiffItem
]) – Modified filesremoved ([
Gio.File
]) – Removed filesadded ([
Gio.File
]) – Added files
Print the contents of a diff to stdout.
- OSTree.fs_get_all_xattrs(fd, cancellable)¶
- Parameters:
fd (
int
) – File descriptorcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
A
GLib.Variant
of typea(ayay)
- Return type:
Retrieve all extended attributes in a canonical (sorted) order from the given file descriptor.
- OSTree.fs_get_all_xattrs_at(dfd, path, cancellable)¶
- Parameters:
dfd (
int
) – Directory file descriptorpath (
str
) – Filesystem pathcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
A
GLib.Variant
of typea(ayay)
- Return type:
Retrieve all extended attributes in a canonical (sorted) order from the given path, relative to the provided directory file descriptor. The target path will not be dereferenced. Currently on Linux, this API must be used currently to retrieve extended attributes for symbolic links because while
O_PATH
exists, it cannot be used withfgetxattr()
.
- OSTree.hash_object_name(a)¶
- Parameters:
a (
object
orNone
) – AGLib.Variant
containing a serialized object- Return type:
Use this function with
GLib.HashTable
andOSTree.object_name_serialize
().
- OSTree.kernel_args_cleanup(loc)¶
- Parameters:
loc (
object
orNone
) – Address of anOSTree.KernelArgs
pointer
Frees the
OSTree.KernelArgs
structure pointed by *locNew in version 2019.3.
- OSTree.metadata_variant_type(objtype)¶
- Parameters:
objtype (
OSTree.ObjectType
) –- Return type:
- OSTree.object_from_string(str)¶
- Parameters:
str (
str
) – An ASCII checksum- Returns:
- out_checksum:
Parsed checksum
- out_objtype:
Parsed object type
- Return type:
(out_checksum:
str
, out_objtype:OSTree.ObjectType
)
Reverse
OSTree.object_to_string
().
- OSTree.object_name_deserialize(variant)¶
- Parameters:
variant (
GLib.Variant
) – AGLib.Variant
of type (su)- Returns:
- out_checksum:
Pointer into string memory of variant with checksum
- out_objtype:
Return object type
- Return type:
(out_checksum:
str
, out_objtype:OSTree.ObjectType
)
Reverse
OSTree.object_name_serialize
(). Note that out_checksum is only valid for the lifetime of variant, and must not be freed.
- OSTree.object_name_serialize(checksum, objtype)¶
- Parameters:
checksum (
str
) – An ASCII checksumobjtype (
OSTree.ObjectType
) – An object type
- Returns:
A new floating
GLib.Variant
containing checksum string and objtype- Return type:
- OSTree.object_to_string(checksum, objtype)¶
- Parameters:
checksum (
str
) – An ASCII checksumobjtype (
OSTree.ObjectType
) – Object type
- Returns:
A string containing both checksum and a stringifed version of objtype
- Return type:
- OSTree.object_type_from_string(str)¶
- Parameters:
str (
str
) – A stringified version ofOSTree.ObjectType
- Return type:
The reverse of
OSTree.object_type_to_string
().
- OSTree.object_type_to_string(objtype)¶
- Parameters:
objtype (
OSTree.ObjectType
) – anOSTree.ObjectType
- Return type:
Serialize objtype to a string; this is used for file extensions.
- OSTree.parse_refspec(refspec)¶
- Parameters:
refspec (
str
) – A “refspec” string- Raises:
- Returns:
True
on successful parsing,False
otherwise- out_remote:
Return location for the remote name, or
None
if the refspec refs to a local ref- out_ref:
Return location for the ref name
- Return type:
Split a refspec like
gnome-ostree:gnome-ostree/buildmain
or justgnome-ostree/buildmain
into two parts. In the first case, out_remote will be set tognome-ostree
, and out_ref tognome-ostree/buildmain
. In the second case (a local ref), out_remote will beNone
, and out_ref will begnome-ostree/buildmain
. In both cases,True
will be returned.
- OSTree.raw_file_to_archive_z2_stream(input, file_info, xattrs, cancellable)¶
- Parameters:
input (
Gio.InputStream
) – File raw content streamfile_info (
Gio.FileInfo
) – A file infoxattrs (
GLib.Variant
orNone
) – Optional extended attributescancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_input:
Serialized object stream
- Return type:
(
bool
, out_input:Gio.InputStream
)
Convert from a “bare” file representation into an
OSTree.ObjectType.FILE
stream suitable for ostree pull.New in version 2016.6.
- OSTree.raw_file_to_archive_z2_stream_with_options(input, file_info, xattrs, options, cancellable)¶
- Parameters:
input (
Gio.InputStream
) – File raw content streamfile_info (
Gio.FileInfo
) – A file infoxattrs (
GLib.Variant
orNone
) – Optional extended attributesoptions (
GLib.Variant
orNone
) – AGLib.Variant
a{sv}
with an extensible set of flagscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_input:
Serialized object stream
- Return type:
(
bool
, out_input:Gio.InputStream
)
Like
OSTree.raw_file_to_archive_z2_stream
(), but supports an extensible set of flags. The following flags are currently defined:compression-level
(i
): Level of compression to use, 0–9, with 0 being the least compression, and <0 giving the default level (currently 6).
New in version 2017.3.
- OSTree.raw_file_to_content_stream(input, file_info, xattrs, cancellable)¶
- Parameters:
input (
Gio.InputStream
) – File raw content streamfile_info (
Gio.FileInfo
) – A file infoxattrs (
GLib.Variant
orNone
) – Optional extended attributescancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_input:
Serialized object stream
- out_length:
Length of stream
- Return type:
(
bool
, out_input:Gio.InputStream
, out_length:int
)
Convert from a “bare” file representation into an
OSTree.ObjectType.FILE
stream. This is a fundamental operation for writing data to anOSTree.Repo
.
- OSTree.repo_finder_resolve_all_async(finders, refs, parent_repo, cancellable, callback, *user_data)¶
- Parameters:
finders ([
OSTree.RepoFinder
]) – non-empty array ofOSTree.RepoFinders
refs ([
OSTree.CollectionRef
]) – non-empty array of collection–ref pairs to find remotes forparent_repo (
OSTree.Repo
) – the local repository which the refs are being resolved for, which provides configuration information and GPG keyscancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – asynchronous completion callback
A version of
OSTree.RepoFinder.resolve_async
() which queries one or more finders in parallel and combines the results.New in version 2018.6.
- OSTree.repo_finder_resolve_all_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) –Gio.AsyncResult
from the callback- Raises:
- Returns:
array of zero or more results
- Return type:
Get the results from a
OSTree.RepoFinder.resolve_all_async
() operation.New in version 2018.6.
- OSTree.repo_finder_result_freev(results)¶
- Parameters:
results ([
OSTree.RepoFinderResult
]) – anOSTree.RepoFinderResult
Free the given results array, freeing each element and the container.
New in version 2018.6.
- OSTree.sign_get_all()¶
- Returns:
an array of signing engines
- Return type:
Return an array with newly allocated instances of all available signing engines; they will not be initialized.
New in version 2020.2.
- OSTree.sign_get_by_name(name)¶
- Parameters:
name (
str
) – the name of desired signature engine- Raises:
- Returns:
New signing engine, or
None
if the engine is not known- Return type:
Create a new instance of a signing engine.
New in version 2020.2.
- OSTree.validate_checksum_string(sha256)¶
- Parameters:
sha256 (
str
) – SHA256 hex string- Raises:
- Returns:
- Return type:
Use this function to see if input strings are checksums.
- OSTree.validate_collection_id(collection_id)¶
- Parameters:
- Raises:
- Returns:
True
if collection_id is a valid collection ID,False
if it is invalid orNone
- Return type:
Check whether the given collection_id is valid. Return an error if it is invalid or
None
.Valid collection IDs are reverse DNS names:
They are composed of 1 or more elements separated by a period (
.
) character. All elements must contain at least one character.Each element must only contain the ASCII characters
[A-Z][a-z][0-9]_
and must not begin with a digit.They must contain at least one
.
(period) character (and thus at least two elements).They must not begin with a
.
(period) character.They must not exceed 255 characters in length.
(This makes their format identical to D-Bus interface names, for consistency.)
New in version 2018.6.
- OSTree.validate_remote_name(remote_name)¶
- Parameters:
remote_name (
str
) – A remote name- Raises:
- Returns:
True
if remote_name is a valid remote name- Return type:
New in version 2017.8.
- OSTree.validate_rev(rev)¶
- OSTree.validate_structureof_checksum_string(checksum)¶
- OSTree.validate_structureof_commit(commit)¶
- Parameters:
commit (
GLib.Variant
) – A commit object,OSTree.ObjectType.COMMIT
- Raises:
- Returns:
True
if commit is structurally valid- Return type:
Use this to validate the basic structure of commit, independent of any other objects it references.
- OSTree.validate_structureof_csum_v(checksum)¶
- Parameters:
checksum (
GLib.Variant
) – aGLib.Variant
of type “ay”- Raises:
- Returns:
True
if checksum is a valid binary SHA256 checksum- Return type:
- OSTree.validate_structureof_dirmeta(dirmeta)¶
- Parameters:
dirmeta (
GLib.Variant
) – A dirmeta object,OSTree.ObjectType.DIR_META
- Raises:
- Returns:
True
if dirmeta is structurally valid- Return type:
Use this to validate the basic structure of dirmeta.
- OSTree.validate_structureof_dirtree(dirtree)¶
- Parameters:
dirtree (
GLib.Variant
) – A dirtree object,OSTree.ObjectType.DIR_TREE
- Raises:
- Returns:
True
if dirtree is structurally valid- Return type:
Use this to validate the basic structure of dirtree, independent of any other objects it references.
- OSTree.validate_structureof_file_mode(mode)¶