[Libguestfs] [PATCH] inspect: use os-release for CoreOS

Pino Toscano ptoscano at redhat.com
Wed Mar 30 14:38:31 UTC 2016


Look for /lib/os-release in the /usr partition and try to use it, if
present, before using lsb-release later on.  This should not change the
final result of the inspection, while using the os-release detection
method also for CoreOS.
---
Nikos, since you added the support for CoreOS in libguestfs, can you
please check whether this change works for you as well?
Thanks in advance.


 src/inspect-fs-unix.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index 35181d6..dab4370 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -196,6 +196,8 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char *filename)
         distro = OS_DISTRO_ARCHLINUX;
       else if (VALUE_IS ("centos"))
         distro = OS_DISTRO_CENTOS;
+      else if (VALUE_IS ("coreos"))
+        distro = OS_DISTRO_COREOS;
       else if (VALUE_IS ("debian"))
         distro = OS_DISTRO_DEBIAN;
       else if (VALUE_IS ("fedora"))
@@ -1055,6 +1057,16 @@ guestfs_int_check_coreos_usr (guestfs_h *g, struct inspect_fs *fs)
 
   fs->type = OS_TYPE_LINUX;
   fs->distro = OS_DISTRO_COREOS;
+
+  if (guestfs_is_file_opts (g, "/lib/os-release",
+                            GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
+    r = parse_os_release (g, fs, "/lib/os-release");
+    if (r == -1)        /* error */
+      return -1;
+    if (r == 1)         /* ok - detected the release from this file */
+      goto skip_release_checks;
+  }
+
   if (guestfs_is_file_opts (g, "/share/coreos/lsb-release",
                             GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
     r = parse_lsb_release (g, fs, "/share/coreos/lsb-release");
@@ -1062,6 +1074,8 @@ guestfs_int_check_coreos_usr (guestfs_h *g, struct inspect_fs *fs)
       return -1;
   }
 
+ skip_release_checks:;
+
   /* Determine the architecture. */
   check_architecture (g, fs);
 
-- 
2.5.5




More information about the Libguestfs mailing list