[Libguestfs] [PATCH] Detect Red Hat Desktop as 'rhel' distro (RHBZ#682979).

Richard W.M. Jones
Tue, 08 Mar 2011 08:12:58 -0000

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From c1a227a960066fb9552e0c225bc473be365b67b0 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones at redhat.com>
Date: Tue, 8 Mar 2011 08:10:19 +0000
Subject: [PATCH] Detect Red Hat Desktop as 'rhel' distro (RHBZ#682979).

/etc/redhat-release on Red Hat Desktop contains the following
string:
  Red Hat Desktop release 4 (Nahant Update 8)

Previously we matched against the string "Red Hat Enterprise Linux"
but since this does not contain that string, this distro wasn't being
detected correctly.

Note this also changes the obsolete Perl code, for the benefit of
virt-v2v.
---
 perl/lib/Sys/Guestfs/Lib.pm |    4 ++--
 src/inspect.c               |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 393eb8a..97d0e8e 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -524,12 +524,12 @@ sub _check_linux_root
             $r->{package_management} = "yum";
         }

-        elsif (/(Red Hat Enterprise Linux|CentOS|Scientific Linux)/) {
+        elsif (/(Red Hat|CentOS|Scientific Linux)/) {
             chomp; $r->{product_name} = $_;

             my $distro = $1;

-            if($distro eq "Red Hat Enterprise Linux") {
+            if($distro eq "Red Hat") {
                 $r->{osdistro} = "rhel";
             }

diff --git a/src/inspect.c b/src/inspect.c
index 4986cac..99097ee 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -106,11 +106,11 @@ compile_regexps (void)

   COMPILE (re_fedora, "Fedora release (\\d+)", 0);
   COMPILE (re_rhel_old,
-           "(?:Red Hat Enterprise Linux|CentOS|Scientific Linux).*release
(\\d+).*Update (\\d+)", 0);
+           "(?:Red Hat|CentOS|Scientific Linux).*release (\\d+).*Update
(\\d+)", 0);
   COMPILE (re_rhel,
-           "(?:Red Hat Enterprise Linux|CentOS|Scientific Linux).*release
(\\d+)\\.(\\d+)", 0);
+           "(?:Red Hat|CentOS|Scientific Linux).*release
(\\d+)\\.(\\d+)", 0);
   COMPILE (re_rhel_no_minor,
-           "(?:Red Hat Enterprise Linux|CentOS|Scientific Linux).*release
(\\d+)", 0);
+           "(?:Red Hat|CentOS|Scientific Linux).*release (\\d+)", 0);
   COMPILE (re_major_minor, "(\\d+)\\.(\\d+)", 0);
   COMPILE (re_aug_seq, "/\\d+$", 0);
   COMPILE (re_xdev, "^/dev/(?:h|s|v|xv)d([a-z]\\d*)$", 0);
--
1.7.4