Merge pull request #2301 from cgwalters/api-require-booted
sysroot: Add _require_booted_deployment() API
This commit is contained in:
commit
407477f191
|
|
@ -533,6 +533,7 @@ ostree_sysroot_get_bootversion
|
||||||
ostree_sysroot_get_subbootversion
|
ostree_sysroot_get_subbootversion
|
||||||
ostree_sysroot_get_deployments
|
ostree_sysroot_get_deployments
|
||||||
ostree_sysroot_get_booted_deployment
|
ostree_sysroot_get_booted_deployment
|
||||||
|
ostree_sysroot_require_booted_deployment
|
||||||
ostree_sysroot_get_deployment_directory
|
ostree_sysroot_get_deployment_directory
|
||||||
ostree_sysroot_get_deployment_dirpath
|
ostree_sysroot_get_deployment_dirpath
|
||||||
ostree_sysroot_get_deployment_origin_path
|
ostree_sysroot_get_deployment_origin_path
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
LIBOSTREE_2021.1 {
|
LIBOSTREE_2021.1 {
|
||||||
global:
|
global:
|
||||||
ostree_commit_metadata_for_bootable;
|
ostree_commit_metadata_for_bootable;
|
||||||
|
ostree_sysroot_require_booted_deployment;
|
||||||
} LIBOSTREE_2020.8;
|
} LIBOSTREE_2020.8;
|
||||||
|
|
||||||
/* Stub section for the stable release *after* this development one; don't
|
/* Stub section for the stable release *after* this development one; don't
|
||||||
|
|
|
||||||
|
|
@ -3066,9 +3066,9 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self,
|
||||||
if (!_ostree_sysroot_ensure_writable (self, error))
|
if (!_ostree_sysroot_ensure_writable (self, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
OstreeDeployment *booted_deployment = ostree_sysroot_get_booted_deployment (self);
|
OstreeDeployment *booted_deployment = ostree_sysroot_require_booted_deployment (self, error);
|
||||||
if (booted_deployment == NULL)
|
if (booted_deployment == NULL)
|
||||||
return glnx_throw (error, "Cannot stage a deployment when not currently booted into an OSTree system");
|
return glnx_prefix_error (error, "Cannot stage deployment");
|
||||||
|
|
||||||
/* This is used by the testsuite to exercise the path unit, until it becomes the default
|
/* This is used by the testsuite to exercise the path unit, until it becomes the default
|
||||||
* (which is pending on the preset making it everywhere). */
|
* (which is pending on the preset making it everywhere). */
|
||||||
|
|
|
||||||
|
|
@ -1246,6 +1246,27 @@ ostree_sysroot_get_booted_deployment (OstreeSysroot *self)
|
||||||
return self->booted_deployment;
|
return self->booted_deployment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_sysroot_require_booted_deployment:
|
||||||
|
* @self: Sysroot
|
||||||
|
*
|
||||||
|
* Find the booted deployment, or return an error if not booted via OSTree.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (not nullable): The currently booted deployment, or an error
|
||||||
|
* Since: 2021.1
|
||||||
|
*/
|
||||||
|
OstreeDeployment *
|
||||||
|
ostree_sysroot_require_booted_deployment (OstreeSysroot *self, GError **error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (self->loadstate == OSTREE_SYSROOT_LOAD_STATE_LOADED, NULL);
|
||||||
|
|
||||||
|
if (!self->booted_deployment)
|
||||||
|
return glnx_null_throw (error, "Not currently booted into an OSTree system");
|
||||||
|
return self->booted_deployment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_sysroot_get_staged_deployment:
|
* ostree_sysroot_get_staged_deployment:
|
||||||
* @self: Sysroot
|
* @self: Sysroot
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,9 @@ GPtrArray *ostree_sysroot_get_deployments (OstreeSysroot *self);
|
||||||
_OSTREE_PUBLIC
|
_OSTREE_PUBLIC
|
||||||
OstreeDeployment *ostree_sysroot_get_booted_deployment (OstreeSysroot *self);
|
OstreeDeployment *ostree_sysroot_get_booted_deployment (OstreeSysroot *self);
|
||||||
_OSTREE_PUBLIC
|
_OSTREE_PUBLIC
|
||||||
|
OstreeDeployment *
|
||||||
|
ostree_sysroot_require_booted_deployment (OstreeSysroot *self, GError **error);
|
||||||
|
_OSTREE_PUBLIC
|
||||||
OstreeDeployment *ostree_sysroot_get_staged_deployment (OstreeSysroot *self);
|
OstreeDeployment *ostree_sysroot_get_staged_deployment (OstreeSysroot *self);
|
||||||
|
|
||||||
_OSTREE_PUBLIC
|
_OSTREE_PUBLIC
|
||||||
|
|
|
||||||
|
|
@ -75,13 +75,9 @@ ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *inv
|
||||||
|
|
||||||
if (opt_index == -1)
|
if (opt_index == -1)
|
||||||
{
|
{
|
||||||
target_deployment = ostree_sysroot_get_booted_deployment (sysroot);
|
target_deployment = ostree_sysroot_require_booted_deployment (sysroot, error);
|
||||||
if (target_deployment == NULL)
|
if (target_deployment == NULL)
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Not currently booted into an OSTree system");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
/* To match the below */
|
/* To match the below */
|
||||||
target_deployment = g_object_ref (target_deployment);
|
target_deployment = g_object_ref (target_deployment);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,13 +61,9 @@ ot_admin_builtin_unlock (int argc, char **argv, OstreeCommandInvocation *invocat
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
|
booted_deployment = ostree_sysroot_require_booted_deployment (sysroot, error);
|
||||||
if (!booted_deployment)
|
if (!booted_deployment)
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Not currently booted into an OSTree system");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_hotfix && opt_transient)
|
if (opt_hotfix && opt_transient)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ echo "ok layout"
|
||||||
if ${CMD_PREFIX} ostree admin deploy --stage --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
|
if ${CMD_PREFIX} ostree admin deploy --stage --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
|
||||||
fatal "staged when not booted"
|
fatal "staged when not booted"
|
||||||
fi
|
fi
|
||||||
assert_file_has_content_literal err.txt "Cannot stage a deployment when not currently booted into an OSTree system"
|
assert_file_has_content_literal err.txt "Cannot stage deployment: Not currently booted into an OSTree system"
|
||||||
echo "ok staging does not work when not booted"
|
echo "ok staging does not work when not booted"
|
||||||
|
|
||||||
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
|
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue