Merge pull request #2049 from cgwalters/sysroot-refactor
sysroot: Reorganize sysroot load code a bit
This commit is contained in:
commit
62632511f1
|
|
@ -988,31 +988,12 @@ _ostree_sysroot_reload_staged (OstreeSysroot *self,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static gboolean
|
||||||
* ostree_sysroot_load_if_changed:
|
sysroot_load_from_bootloader_configs (OstreeSysroot *self,
|
||||||
* @self: #OstreeSysroot
|
GCancellable *cancellable,
|
||||||
* @out_changed: (out caller-allocates):
|
GError **error)
|
||||||
* @cancellable: Cancellable
|
|
||||||
* @error: Error
|
|
||||||
*
|
|
||||||
* Since: 2016.4
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
|
||||||
gboolean *out_changed,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
GLNX_AUTO_PREFIX_ERROR ("loading sysroot", error);
|
struct stat stbuf;
|
||||||
if (!ostree_sysroot_initialize (self, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Here we also lazily initialize the repository. We didn't do this
|
|
||||||
* previous to v2017.6, but we do now to support the error-free
|
|
||||||
* ostree_sysroot_repo() API.
|
|
||||||
*/
|
|
||||||
if (!ensure_repo (self, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
int bootversion = 0;
|
int bootversion = 0;
|
||||||
if (!read_current_bootversion (self, &bootversion, cancellable, error))
|
if (!read_current_bootversion (self, &bootversion, cancellable, error))
|
||||||
|
|
@ -1023,27 +1004,6 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
struct stat stbuf;
|
|
||||||
if (!glnx_fstatat (self->sysroot_fd, "ostree/deploy", &stbuf, 0, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (out_changed)
|
|
||||||
{
|
|
||||||
if (self->loaded_ts.tv_sec == stbuf.st_mtim.tv_sec &&
|
|
||||||
self->loaded_ts.tv_nsec == stbuf.st_mtim.tv_nsec)
|
|
||||||
{
|
|
||||||
*out_changed = FALSE;
|
|
||||||
/* Note early return */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_pointer (&self->deployments, g_ptr_array_unref);
|
|
||||||
g_clear_object (&self->booted_deployment);
|
|
||||||
g_clear_object (&self->staged_deployment);
|
|
||||||
self->bootversion = -1;
|
|
||||||
self->subbootversion = -1;
|
|
||||||
|
|
||||||
g_autoptr(GPtrArray) boot_loader_configs = NULL;
|
g_autoptr(GPtrArray) boot_loader_configs = NULL;
|
||||||
if (!_ostree_sysroot_read_boot_loader_configs (self, bootversion, &boot_loader_configs,
|
if (!_ostree_sysroot_read_boot_loader_configs (self, bootversion, &boot_loader_configs,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
|
|
@ -1121,8 +1081,60 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
||||||
|
|
||||||
self->bootversion = bootversion;
|
self->bootversion = bootversion;
|
||||||
self->subbootversion = subbootversion;
|
self->subbootversion = subbootversion;
|
||||||
self->deployments = deployments;
|
self->deployments = g_steal_pointer (&deployments);
|
||||||
deployments = NULL; /* Transfer ownership */
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_sysroot_load_if_changed:
|
||||||
|
* @self: #OstreeSysroot
|
||||||
|
* @out_changed: (out caller-allocates):
|
||||||
|
* @cancellable: Cancellable
|
||||||
|
* @error: Error
|
||||||
|
*
|
||||||
|
* Since: 2016.4
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
||||||
|
gboolean *out_changed,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GLNX_AUTO_PREFIX_ERROR ("loading sysroot", error);
|
||||||
|
|
||||||
|
if (!ostree_sysroot_initialize (self, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Here we also lazily initialize the repository. We didn't do this
|
||||||
|
* previous to v2017.6, but we do now to support the error-free
|
||||||
|
* ostree_sysroot_repo() API.
|
||||||
|
*/
|
||||||
|
if (!ensure_repo (self, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
struct stat stbuf;
|
||||||
|
if (!glnx_fstatat (self->sysroot_fd, "ostree/deploy", &stbuf, 0, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (self->loaded_ts.tv_sec == stbuf.st_mtim.tv_sec &&
|
||||||
|
self->loaded_ts.tv_nsec == stbuf.st_mtim.tv_nsec)
|
||||||
|
{
|
||||||
|
if (out_changed)
|
||||||
|
*out_changed = FALSE;
|
||||||
|
/* Note early return */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_pointer (&self->deployments, g_ptr_array_unref);
|
||||||
|
g_clear_object (&self->booted_deployment);
|
||||||
|
g_clear_object (&self->staged_deployment);
|
||||||
|
self->bootversion = -1;
|
||||||
|
self->subbootversion = -1;
|
||||||
|
|
||||||
|
if (!sysroot_load_from_bootloader_configs (self, cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
self->loaded_ts = stbuf.st_mtim;
|
self->loaded_ts = stbuf.st_mtim;
|
||||||
|
|
||||||
if (out_changed)
|
if (out_changed)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue