Blame SOURCES/0008-inspection-More-reliable-detection-of-Linux-split-us.patch

aba816
From e1b339688e5f8f2a14fe0c7e9d02ad68004e4655 Mon Sep 17 00:00:00 2001
aba816
From: "Richard W.M. Jones" <rjones@redhat.com>
aba816
Date: Thu, 15 Apr 2021 09:18:22 +0100
aba816
Subject: [PATCH] inspection: More reliable detection of Linux split /usr
aba816
 configurations
aba816
aba816
In RHEL 8+, /usr/etc no longer exists.  Since we were looking for this
aba816
directory in order to detect a separate /usr partition, those were no
aba816
longer detected, so the merging of /usr data into the root was not
aba816
being done.  The result was incomplete inspection data and failure of
aba816
virt-v2v.
aba816
aba816
All Linux systems since forever have had /usr/src but not /src, so
aba816
detect this instead.
aba816
aba816
Furthermore the merging code didn't work, because we expected that the
aba816
root filesystem had a distro assigned, but in this configuration we
aba816
may need to look for that information in /usr/lib/os-release (not on
aba816
the root filesystem).  This change makes the merging work even if we
aba816
have incomplete information about the root filesystem, so long as we
aba816
have an /etc/fstab entry pointing to the /usr mountpoint.
aba816
aba816
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1949683
aba816
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1930133
aba816
Fixes: commit 394d11be49121884295e61964ed47f5a8488c252
aba816
(cherry picked from commit 26427b9ecc64e7e5e53a1d577cef9dc080d08877)
aba816
---
aba816
 daemon/inspect.ml    | 33 +++++++++++++++------------------
aba816
 daemon/inspect_fs.ml |  6 +++---
aba816
 2 files changed, 18 insertions(+), 21 deletions(-)
aba816
aba816
diff --git a/daemon/inspect.ml b/daemon/inspect.ml
aba816
index 945a476f6..fb75b4a6c 100644
aba816
--- a/daemon/inspect.ml
aba816
+++ b/daemon/inspect.ml
aba816
@@ -182,11 +182,9 @@ and check_for_duplicated_bsd_root fses =
aba816
 and collect_linux_inspection_info fses =
aba816
   List.map (
aba816
     function
aba816
-    | { role = RoleRoot { distro = Some d } } as root ->
aba816
-       if d <> DISTRO_COREOS then
aba816
-         collect_linux_inspection_info_for fses root
aba816
-       else
aba816
-         root
aba816
+    | { role = RoleRoot { distro = Some DISTRO_COREOS } } as root -> root
aba816
+    | { role = RoleRoot _ } as root ->
aba816
+       collect_linux_inspection_info_for fses root
aba816
     | fs -> fs
aba816
   ) fses
aba816
 
aba816
@@ -196,29 +194,28 @@ and collect_linux_inspection_info fses =
aba816
  * or other ways to identify the OS).
aba816
  *)
aba816
 and collect_linux_inspection_info_for fses root =
aba816
-  let root_distro, root_fstab =
aba816
+  let root_fstab =
aba816
     match root with
aba816
-    | { role = RoleRoot { distro = Some d; fstab = f } } -> d, f
aba816
+    | { role = RoleRoot { fstab = f } } -> f
aba816
     | _ -> assert false in
aba816
 
aba816
   try
aba816
     let usr =
aba816
       List.find (
aba816
         function
aba816
-        | { role = RoleUsr { distro = d } }
aba816
-             when d = Some root_distro || d = None -> true
aba816
+        | { role = RoleUsr _; fs_location = usr_mp } ->
aba816
+           (* This checks that this usr is found in the fstab of
aba816
+            * the root filesystem.
aba816
+            *)
aba816
+           List.exists (
aba816
+             fun (mountable, _) ->
aba816
+               usr_mp.mountable = mountable
aba816
+           ) root_fstab
aba816
         | _ -> false
aba816
       ) fses in
aba816
 
aba816
-    let usr_mountable = usr.fs_location.mountable in
aba816
-
aba816
-    (* This checks that [usr] is found in the fstab of the root
aba816
-     * filesystem.  If not, [Not_found] is thrown.
aba816
-     *)
aba816
-    ignore (
aba816
-      List.find (fun (mountable, _) -> usr_mountable = mountable) root_fstab
aba816
-    );
aba816
-
aba816
+    eprintf "collect_linux_inspection_info_for: merging:\n%sinto:\n%s"
aba816
+      (string_of_fs usr) (string_of_fs root);
aba816
     merge usr root;
aba816
     root
aba816
   with
aba816
diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml
aba816
index 6e00c7083..02b5a0470 100644
aba816
--- a/daemon/inspect_fs.ml
aba816
+++ b/daemon/inspect_fs.ml
aba816
@@ -164,10 +164,10 @@ and check_filesystem mountable =
aba816
     ()
aba816
   )
aba816
   (* Linux /usr? *)
aba816
-  else if Is.is_dir "/etc" &&
aba816
-          Is.is_dir "/bin" &&
aba816
-          Is.is_dir "/share" &&
aba816
+  else if Is.is_dir "/bin" &&
aba816
           Is.is_dir "/local" &&
aba816
+          Is.is_dir "/share" &&
aba816
+          Is.is_dir "/src" &&
aba816
           not (Is.is_file "/etc/fstab") then (
aba816
     debug_matching "Linux /usr";
aba816
     role := `Usr;
aba816
-- 
aba816
2.31.1
aba816