From d575b1dd36cc5a9ad36896d47b2b9998a4b78385 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 17 Nov 2020 14:09:02 +0000
Subject: [PATCH] runtime: Don't issue warnings when unable to delete from
 runtime copy

If we can't delete a file because it doesn't exist, then ... job done?

In practice this happens because the runtime copy is merged-/usr, so
/lib and /usr/lib are in fact the same place.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 pressure-vessel/runtime.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c
index 3bccb914b..d1b5da6ef 100644
--- a/pressure-vessel/runtime.c
+++ b/pressure-vessel/runtime.c
@@ -2154,9 +2154,20 @@ pv_runtime_remove_overridden_libraries (PvRuntime *self,
 
           if (!glnx_unlinkat (iters[i].fd, name, 0, &local_error))
             {
-              g_warning ("Unable to delete %s/%s/%s: %s",
-                         self->mutable_sysroot, multiarch_libdirs[i],
-                         name, local_error->message);
+              if (g_error_matches (local_error, G_IO_ERROR,
+                                   G_IO_ERROR_NOT_FOUND))
+                {
+                  /* Ignore: probably we already deleted it from /lib,
+                   * now we are trying to delete it from /usr/lib, and
+                   * they are the same place. */
+                }
+              else
+                {
+                  g_warning ("Unable to delete %s/%s/%s: %s",
+                             self->mutable_sysroot, multiarch_libdirs[i],
+                             name, local_error->message);
+                }
+
               g_clear_error (&local_error);
             }
         }
-- 
GitLab