summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-sysroot-deploy.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2021-06-09 09:44:09 -0400
committerColin Walters <walters@verbum.org>2021-06-10 07:33:17 -0400
commitedf7477ee9e2c1d238aae35b1a0414e478870837 (patch)
treed31e5226e914b1498a6b0bc637a95c7dba62c6bc /src/libostree/ostree-sysroot-deploy.c
parent3d66db2baea6a4124eae5ae4a4bdd7441b3e81ed (diff)
downloadostree-edf7477ee9e2c1d238aae35b1a0414e478870837.tar.gz
deploy: Warn if we find content in the deployment's /var
This will be ignored, so let's make it very clear people are doing something wrong. Motivated by a bug in a build pipeline that injected `/var/lib/rpm` into an ostree commit which ended up crashing rpm-ostree because it was an empty db which it wasn't expecting. It *also* turns out rpm-ostree is incorrectly dumping content in the deployment `/var` today, which is another bug.
Diffstat (limited to 'src/libostree/ostree-sysroot-deploy.c')
-rw-r--r--src/libostree/ostree-sysroot-deploy.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 32748a62..840775d4 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -2632,6 +2632,39 @@ _ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment,
}
}
+// Perform some basic static analysis and emit warnings for things
+// that are likely to fail later. This function only returns
+// a hard error if something unexpected (e.g. I/O error) occurs.
+static gboolean
+lint_deployment_fs (OstreeSysroot *self,
+ OstreeDeployment *deployment,
+ int deployment_dfd,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ glnx_autofd int dest_dfd = -1;
+ gboolean exists;
+
+ if (!ot_dfd_iter_init_allow_noent (deployment_dfd, "var", &dfd_iter, &exists, error))
+ return FALSE;
+ while (exists)
+ {
+ struct dirent *dent;
+
+ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
+ return FALSE;
+ if (dent == NULL)
+ break;
+
+ fprintf (stderr, "note: Deploying commit %s which contains content in /var/%s that will be ignored.\n",
+ ostree_deployment_get_csum (deployment),
+ dent->d_name);
+ }
+
+ return TRUE;
+}
+
/* The first part of writing a deployment. This primarily means doing the
* hardlink farm checkout, but we also compute some initial state.
*/
@@ -2680,6 +2713,9 @@ sysroot_initialize_deployment (OstreeSysroot *self,
cancellable, error))
return FALSE;
+ if (!lint_deployment_fs (self, new_deployment, deployment_dfd, cancellable, error))
+ return FALSE;
+
ot_transfer_out_value (out_new_deployment, &new_deployment);
return TRUE;
}