Add concept of "staged" deployment

Add API to write a deployment state to `/run/ostree/staged-deployment`,
along with a systemd service which runs at shutdown time.

This is a big change to the ostree model for hosts,
but it closes a longstanding set of bugs; many, many people have
hit the "losing changes in /etc" problem.  It also avoids
the other problem of racing with programs that modify `/etc`
such as LVM backups:
https://bugzilla.redhat.com/show_bug.cgi?id=1365297

We need this in particular to go to a full-on model for
automatically updated host systems where (like a dual-partition model)
everything is fully prepared and the reboot can be taken
asynchronously.

Closes: https://github.com/ostreedev/ostree/issues/545

Closes: #1503
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2018-04-12 14:55:12 +00:00
1 parent ff50495f67
commit eb506c759c
23 files changed
+747 -110

No files matched your search

+21
View File
@@ -61,6 +61,8 @@ struct OstreeSysroot {
int bootversion;
int subbootversion;
OstreeDeployment *booted_deployment;
OstreeDeployment *staged_deployment;
GVariant *staged_deployment_data;
struct timespec loaded_ts;
/* Only access through ostree_sysroot_[_get]repo() */
@@ -71,6 +73,7 @@ struct OstreeSysroot {
#define OSTREE_SYSROOT_LOCKFILE "ostree/lock"
/* We keep some transient state in /run */
#define _OSTREE_SYSROOT_RUNSTATE_STAGED "/run/ostree/staged-deployment"
#define _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_DIR "/run/ostree/deployment-state/"
#define _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_DEVELOPMENT "unlocked-development"
@@ -105,6 +108,22 @@ _ostree_sysroot_list_deployment_dirs_for_os (int deploydir_dfd,
GCancellable *cancellable,
GError **error);
void
_ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment,
char **override_kernel_argv);
gboolean
_ostree_sysroot_reload_staged (OstreeSysroot *self, GError **error);
gboolean
_ostree_sysroot_finalize_staged (OstreeSysroot *self,
GCancellable *cancellable,
GError **error);
OstreeDeployment *
_ostree_sysroot_deserialize_deployment_from_variant (GVariant *v,
GError **error);
char *
_ostree_sysroot_get_origin_relpath (GFile *path,
guint32 *out_device,
@@ -118,6 +137,8 @@ _ostree_sysroot_rmrf_deployment (OstreeSysroot *sysroot,
GCancellable *cancellable,
GError **error);
char * _ostree_sysroot_get_runstate_path (OstreeDeployment *deployment, const char *key);
char *_ostree_sysroot_join_lines (GPtrArray *lines);
gboolean _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,