OSTree.Sysroot¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
libostree will log to the journal various events, such as the /etc merge status, and transaction completion. |
Fields¶
- Inherited:
Class Details¶
- class OSTree.Sysroot(**kwargs)¶
- Bases:
- Abstract:
No
- classmethod get_deployment_origin_path(deployment_path)¶
- classmethod new(path)¶
- Parameters:
path (
Gio.File
orNone
) – Path to a system root directory, orNone
to use the current visible root file system- Returns:
An accessor object for an system root located at path
- Return type:
Create a new
OSTree.Sysroot
object for the sysroot at path. If path isNone
, the current visible root file system is used, equivalent toOSTree.Sysroot.new_default
().
- classmethod new_default()¶
- Returns:
An accessor for the current visible root / filesystem
- Return type:
- change_finalization(deployment)¶
- Parameters:
deployment (
OSTree.Deployment
) – Deployment which must be staged- Raises:
- Return type:
Given the target deployment (which must be the staged deployment) this API will toggle its “finalization locking” state. If it is currently locked, it will be unlocked (and hence queued to apply on shutdown).
New in version 2023.8.
- cleanup(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellable- Raises:
- Return type:
Delete any state that resulted from a partially completed transaction, such as incomplete deployments.
- cleanup_prune_repo(options, cancellable)¶
- Parameters:
options (
OSTree.RepoPruneOptions
) – Flags controlling pruningcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_objects_total:
Number of objects found
- out_objects_pruned:
Number of objects deleted
- out_pruned_object_size_total:
Storage size in bytes of objects deleted
- Return type:
(
bool
, out_objects_total:int
, out_objects_pruned:int
, out_pruned_object_size_total:int
)
Prune the system repository. This is a thin wrapper around
OSTree.Repo.prune_from_reachable
(); the primary addition is that this function automatically gathers all deployed commits into the reachable set.You generally want to at least set the
OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY
flag in options. A commit traversal depth of0
is assumed.Locking: exclusive
New in version 2018.6.
- deploy_tree(osname, revision, origin, provided_merge_deployment, override_kernel_argv, cancellable)¶
- Parameters:
revision (
str
) – Checksum to addorigin (
GLib.KeyFile
orNone
) – Origin to use for upgradesprovided_merge_deployment (
OSTree.Deployment
orNone
) – Use this deployment for merge pathoverride_kernel_argv ([
str
] orNone
) – Use these as kernel arguments; ifNone
, inherit options from provided_merge_deploymentcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_new_deployment:
The new deployment path
- Return type:
(
bool
, out_new_deployment:OSTree.Deployment
)
Older version of
OSTree.Sysroot.stage_tree_with_options
().New in version 2018.5.
- deploy_tree_with_options(osname, revision, origin, provided_merge_deployment, opts, cancellable)¶
- Parameters:
revision (
str
) – Checksum to addorigin (
GLib.KeyFile
orNone
) – Origin to use for upgradesprovided_merge_deployment (
OSTree.Deployment
orNone
) – Use this deployment for merge pathopts (
OSTree.SysrootDeployTreeOpts
orNone
) – Optionscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_new_deployment:
The new deployment path
- Return type:
(
bool
, out_new_deployment:OSTree.Deployment
)
Check out deployment tree with revision revision, performing a 3 way merge with provided_merge_deployment for configuration.
When booted into the sysroot, you should use the
OSTree.Sysroot.stage_tree
() API instead.New in version 2020.7.
- deployment_set_kargs(deployment, new_kargs, cancellable)¶
- Parameters:
deployment (
OSTree.Deployment
) – A deploymentnew_kargs ([
str
]) – Replace deployment’s kernel argumentscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Entirely replace the kernel arguments of deployment with the values in new_kargs.
- deployment_set_kargs_in_place(deployment, kargs_str, cancellable)¶
- Parameters:
deployment (
OSTree.Deployment
) – A deploymentkargs_str (
str
orNone
) – Replace deployment's kernel argumentscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Replace the kernel arguments of deployment with the values in kargs_str.
- deployment_set_mutable(deployment, is_mutable, cancellable)¶
- Parameters:
deployment (
OSTree.Deployment
) – A deploymentis_mutable (
bool
) – Whether or not deployment’s files can be changedcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
By default, deployment directories are not mutable. This function will allow making them temporarily mutable, for example to allow layering additional non-OSTree content.
- deployment_set_pinned(deployment, is_pinned)¶
- Parameters:
deployment (
OSTree.Deployment
) – A deploymentis_pinned (
bool
) – Whether or not deployment will be automatically GC’d
- Raises:
- Return type:
By default, deployments may be subject to garbage collection. Typical uses of libostree only retain at most 2 deployments. If is_pinned is
TRUE
, a metadata bit will be set causing libostree to avoid automatic GC of the deployment. However, this is really an “advisory” note; it’s still possible for e.g. older versions of libostree unaware of pinning to GC the deployment.This function does nothing and returns successfully if the deployment is already in the desired pinning state. It is an error to try to pin the staged deployment (as it’s not in the bootloader entries).
New in version 2018.3.
- deployment_unlock(deployment, unlocked_state, cancellable)¶
- Parameters:
deployment (
OSTree.Deployment
) – Deploymentunlocked_state (
OSTree.DeploymentUnlockedState
) – Transition to this unlocked statecancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Configure the target deployment deployment such that it is writable. There are multiple modes, essentially differing in whether or not any changes persist across reboot.
The
OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX
state is persistent across reboots.New in version 2016.4.
- ensure_initialized(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellable- Raises:
- Return type:
Ensure that self is set up as a valid rootfs, by creating /ostree/repo, among other things.
- get_booted_deployment()¶
- Returns:
The currently booted deployment, or
None
if none- Return type:
This function may only be called if the sysroot is loaded.
- get_deployment_directory(deployment)¶
- Parameters:
deployment (
OSTree.Deployment
) – A deployment- Returns:
Path to deployment root directory
- Return type:
- get_deployment_dirpath(deployment)¶
- Parameters:
deployment (
OSTree.Deployment
) – A deployment- Returns:
Path to deployment root directory, relative to sysroot
- Return type:
Note this function only returns a *relative* path - if you want to access, it, you must either use fd-relative api such as openat(), or concatenate it with the full
OSTree.Sysroot.get_path
().
- get_deployments()¶
- Returns:
Ordered list of deployments
- Return type:
- get_fd()¶
- Returns:
A file descriptor valid for the lifetime of self
- Return type:
Access a file descriptor that refers to the root directory of this sysroot.
OSTree.Sysroot.initialize
() (orOSTree.Sysroot.load
()) must have been invoked prior to calling this function.
- get_merge_deployment(osname)¶
- Parameters:
- Returns:
Configuration merge deployment
- Return type:
Find the deployment to use as a configuration merge source; this is the first one in the current deployment list which matches osname.
- get_repo(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellable- Raises:
- Returns:
True
on success,False
otherwise- out_repo:
Repository in sysroot self
- Return type:
(
bool
, out_repo:OSTree.Repo
)
Retrieve the OSTree repository in sysroot self. The repo is guaranteed to be open (see
OSTree.Repo.open
()).
- get_staged_deployment()¶
- Returns:
The currently staged deployment, or
None
if none- Return type:
New in version 2018.5.
- init_osname(osname, cancellable)¶
- Parameters:
osname (
str
) – Name group of operating system checkoutscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Initialize the directory structure for an “osname”, which is a group of operating system deployments, with a shared
/var
. One is required for generating a deployment.New in version 2016.4.
- initialize()¶
- Raises:
- Return type:
Subset of
OSTree.Sysroot.load
(); performs basic initialization. Notably, one can invokeostree_sysroot_get_fd()
after calling this function.It is not necessary to call this function if
OSTree.Sysroot.load
() is invoked.New in version 2020.1.
- initialize_with_mount_namespace(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) –- Raises:
- Return type:
Prepare the current process for modifying a booted sysroot, if applicable. This function subsumes the functionality of
ostree_sysroot_initialize
and may be invoked wherever that function is.If the sysroot does not appear to be booted, or where the current process is not uid 0, this function returns successfully.
Otherwise, if the process is in the same mount namespace as pid 1, create a new namespace.
If you invoke this function, it must be before
OSTree.Sysroot.load
(); it may be invoked before or afterOSTree.Sysroot.initialize
().New in version 2022.7.
- is_booted()¶
-
Can only be invoked after
ostree_sysroot_initialize()
.New in version 2020.1.
- load(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellable- Raises:
- Return type:
Load deployment list, bootversion, and subbootversion from the rootfs self.
- load_if_changed(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellable- Raises:
- Return type:
New in version 2016.4.
- lock()¶
- Raises:
- Return type:
Acquire an exclusive multi-process write lock for self. This call blocks until the lock has been acquired. The lock is not reentrant.
Release the lock with
OSTree.Sysroot.unlock
(). The lock will also be released if self is deallocated.
- lock_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellablecallback (
Gio.AsyncReadyCallback
orNone
) – Callback
An asynchronous version of
OSTree.Sysroot.lock
().
- lock_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – Result- Raises:
- Return type:
Call when
OSTree.Sysroot.lock_async
() is ready.
- origin_new_from_refspec(refspec)¶
- Parameters:
refspec (
str
) – A refspec- Returns:
A new config file which sets refspec as an origin
- Return type:
- prepare_cleanup(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Cancellable- Raises:
- Return type:
Like
OSTree.Sysroot.cleanup
() in that it cleans up incomplete deployments and old boot versions, but does NOT prune the repository.
- query_deployments_for(osname)¶
- Parameters:
- Returns:
- out_pending:
The pending deployment
- out_rollback:
The rollback deployment
- Return type:
(out_pending:
OSTree.Deployment
orNone
, out_rollback:OSTree.Deployment
orNone
)
Find the pending and rollback deployments for osname. Pass
None
for osname to use the booted deployment’s osname. By default, pending deployment is the first deployment in the order that matches osname, and rollback will be the next one after the booted deployment, or the deployment after the pending if we’re not looking at the booted deployment.New in version 2017.7.
- repo()¶
- Returns:
The OSTree repository in sysroot self.
- Return type:
This function is a variant of
OSTree.Sysroot.get_repo
() that cannot fail, and returns a cached repository. Can only be called afterOSTree.Sysroot.initialize
() orOSTree.Sysroot.load
() has been invoked successfully.New in version 2017.7.
- require_booted_deployment()¶
- Raises:
- Returns:
The currently booted deployment, or an error
- Return type:
Find the booted deployment, or return an error if not booted via OSTree.
New in version 2021.1.
- set_mount_namespace_in_use()¶
If this function is invoked, then libostree will assume that a private Linux mount namespace has been created by the process. The primary use case for this is to have e.g. /sysroot mounted read-only by default.
If this function has been called, then when a function which requires writable access is invoked, libostree will automatically remount as writable any mount points on which it operates. This currently is just
/sysroot
and/boot
.If you invoke this function, it must be before
OSTree.Sysroot.load
(); it may be invoked before or afterOSTree.Sysroot.initialize
().New in version 2020.1.
- simple_write_deployment(osname, new_deployment, merge_deployment, flags, cancellable)¶
- Parameters:
new_deployment (
OSTree.Deployment
) – Prepend this deployment to the listmerge_deployment (
OSTree.Deployment
orNone
) – Use this deployment for configuration mergeflags (
OSTree.SysrootSimpleWriteDeploymentFlags
) – Flags controlling behaviorcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Prepend new_deployment to the list of deployments, commit, and cleanup. By default, all other deployments for the given osname except the merge deployment and the booted deployment will be garbage collected.
If
OSTree.SysrootSimpleWriteDeploymentFlags.RETAIN
is specified, then all current deployments will be kept.If
OSTree.SysrootSimpleWriteDeploymentFlags.RETAIN_PENDING
is specified, then pending deployments will be kept.If
OSTree.SysrootSimpleWriteDeploymentFlags.RETAIN_ROLLBACK
is specified, then rollback deployments will be kept.If
OSTree.SysrootSimpleWriteDeploymentFlags.NOT_DEFAULT
is specified, then instead of prepending, the new deployment will be added right after the booted or merge deployment, instead of first.If
OSTree.SysrootSimpleWriteDeploymentFlags.NO_CLEAN
is specified, then no cleanup will be performed after adding the deployment. Make sure to callOSTree.Sysroot.cleanup
() sometime later, instead.
- stage_overlay_initrd(fd, cancellable)¶
- Parameters:
fd (
int
) – File descriptor to overlay initrdcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_checksum:
Overlay initrd checksum
- Return type:
Stage an overlay initrd to be used in an upcoming deployment. Returns a checksum which can be passed to
OSTree.Sysroot.deploy_tree_with_options
() orOSTree.Sysroot.stage_tree_with_options
() via theoverlay_initrds
array option.New in version 2020.7.
- stage_tree(osname, revision, origin, merge_deployment, override_kernel_argv, cancellable)¶
- Parameters:
revision (
str
) – Checksum to addorigin (
GLib.KeyFile
orNone
) – Origin to use for upgradesmerge_deployment (
OSTree.Deployment
orNone
) – Use this deployment for merge pathoverride_kernel_argv ([
str
] orNone
) – Use these as kernel arguments; ifNone
, inherit options from provided_merge_deploymentcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_new_deployment:
The new deployment path
- Return type:
(
bool
, out_new_deployment:OSTree.Deployment
)
Older version of
OSTree.Sysroot.stage_tree_with_options
().New in version 2018.5.
- stage_tree_with_options(osname, revision, origin, merge_deployment, opts, cancellable)¶
- Parameters:
revision (
str
) – Checksum to addorigin (
GLib.KeyFile
orNone
) – Origin to use for upgradesmerge_deployment (
OSTree.Deployment
orNone
) – Use this deployment for merge pathopts (
OSTree.SysrootDeployTreeOpts
) – Optionscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Returns:
- out_new_deployment:
The new deployment path
- Return type:
(
bool
, out_new_deployment:OSTree.Deployment
)
Like
OSTree.Sysroot.deploy_tree
(), but “finalization” only occurs at OS shutdown time.New in version 2020.7.
- try_lock()¶
- Raises:
- Returns:
- out_acquired:
Whether or not the lock has been acquired
- Return type:
Try to acquire an exclusive multi-process write lock for self. If another process holds the lock, this function will return immediately, setting out_acquired to
False
, and returningTrue
(and no error).Release the lock with
OSTree.Sysroot.unlock
(). The lock will also be released if self is deallocated.
- unload()¶
Release any resources such as file descriptors referring to the root directory of this sysroot. Normally, those resources are cleared by finalization, but in garbage collected languages that may not be predictable.
This undoes the effect of
ostree_sysroot_load()
.
- unlock()¶
Clear the lock previously acquired with
OSTree.Sysroot.lock
(). It is safe to call this function if the lock has not been previously acquired.
- update_post_copy(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) –- Raises:
- Return type:
Update a sysroot as needed after having copied it into place using file-level operations. This enables options like fs-verity on the required files that may have been lost during the copy.
New in version 2023.11.
- write_deployments(new_deployments, cancellable)¶
- Parameters:
new_deployments ([
OSTree.Deployment
]) – List of new deploymentscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Older version of
OSTree.Sysroot.write_deployments_with_options
(). This version will perform post-deployment cleanup by default.
- write_deployments_with_options(new_deployments, opts, cancellable)¶
- Parameters:
new_deployments ([
OSTree.Deployment
]) – List of new deploymentsopts (
OSTree.SysrootWriteDeploymentsOpts
) – Optionscancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Assuming new_deployments have already been deployed in place on disk via
OSTree.Sysroot.deploy_tree
(), atomically update bootloader configuration. By default, no post-transaction cleanup will be performed. You should invokeOSTree.Sysroot.cleanup
() at some point after the transaction, or specifydo_postclean
in opts. Skipping the post-transaction cleanup is useful if for example you want to control pruning of the repository.New in version 2017.4.
- write_origin_file(deployment, new_origin, cancellable)¶
- Parameters:
deployment (
OSTree.Deployment
) – Deploymentnew_origin (
GLib.KeyFile
orNone
) – Origin contentcancellable (
Gio.Cancellable
orNone
) – Cancellable
- Raises:
- Return type:
Immediately replace the origin file of the referenced deployment with the contents of new_origin. If new_origin is
None
, this function will write the current origin of deployment.
Signal Details¶
- OSTree.Sysroot.signals.journal_msg(sysroot, msg)¶
- Signal Name:
journal-msg
- Flags:
- Parameters:
sysroot (
OSTree.Sysroot
) – The object which received the signalmsg (
str
) – Human-readable string (should not contain newlines)
libostree will log to the journal various events, such as the /etc merge status, and transaction completion. Connect to this signal to also synchronously receive the text for those messages. This is intended to be used by command line tools which link to libostree as a library.
Currently, the structured data is only available via the systemd journal.
New in version 2017.10.