Add a notion of "physical" sysroot, use for remote writing
Using `${sysroot}` to mean the physical storage root: We don't want to write to
`${sysroot}/etc/ostree/remotes.d`, since nothing will read it, and really
`${sysroot}` should just have `/ostree` (ideally). Today the Anaconda rpmostree
code ends up writing there. Fix this by adding a notion of "physical" sysroot.
We determine whether the path is physical by checking for `/sysroot`, which
exists in deployment roots (and there shouldn't be a `${sysroot}/sysroot`).
In order to unit test this, I added a `--sysroot` argument to `remote add`.
However, doing this better would require reworking the command line parsing for
the `remote` argument to support specifying `--repo` or `--sysroot`, and I
didn't quite want to do that yet in this patch.
Closes: https://github.com/ostreedev/ostree/issues/892
Closes: #896
Approved by: jlebon
This commit is contained in:
1 parent
2414704609
commit
1eff3e8343
9 files changed
+81
-23
No files matched your search
@@ -135,6 +135,8 @@ ostree_sysroot_constructed (GObject *object)
|
||||
repo_path = g_file_resolve_relative_path (self->path, "ostree/repo");
|
||||
self->repo = ostree_repo_new_for_sysroot_path (repo_path, self->path);
|
||||
self->repo->is_system = TRUE;
|
||||
/* Hold a weak ref for the remote-add handling */
|
||||
g_weak_ref_init (&self->repo->sysroot, object);
|
||||
|
||||
G_OBJECT_CLASS (ostree_sysroot_parent_class)->constructed (object);
|
||||
}
|
||||
@@ -813,6 +815,26 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
/* Determine whether we're "physical" or not, the first time we initialize */
|
||||
if (!self->loaded)
|
||||
{
|
||||
/* If we have a booted deployment, the sysroot is / and we're definitely
|
||||
* not physical.
|
||||
*/
|
||||
if (self->booted_deployment)
|
||||
self->is_physical = FALSE; /* (the default, but explicit for clarity) */
|
||||
/* Otherwise - check for /sysroot which should only exist in a deployment,
|
||||
* not in ${sysroot} (a metavariable for the real physical root).
|
||||
*/
|
||||
else if (fstatat (self->sysroot_fd, "sysroot", &stbuf, 0) < 0)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
return glnx_throw_errno_prefix (error, "fstatat");
|
||||
self->is_physical = TRUE;
|
||||
}
|
||||
/* Otherwise, the default is FALSE */
|
||||
}
|
||||
|
||||
self->bootversion = bootversion;
|
||||
self->subbootversion = subbootversion;
|
||||
self->deployments = deployments;
|
||||
|
||||
Reference in new issue
Block a user