summaryrefslogtreecommitdiffstats
path: root/perl
diff options
context:
space:
mode:
authorMatthew Booth <mbooth@redhat.com>2009-07-16 23:48:25 +0100
committerMatthew Booth <mbooth@redhat.com>2009-07-17 11:29:33 +0100
commit9e90b24c7d76489f93830377e3d7d3c37f36c30c (patch)
treed16cf0a6c997610cf92e9b3be77b46719eaa583e /perl
parent2ab233b3124f4dd3e7c686de110d9a97cc525c18 (diff)
downloadlibguestfs-9e90b24c7d76489f93830377e3d7d3c37f36c30c.tar.gz
libguestfs-9e90b24c7d76489f93830377e3d7d3c37f36c30c.tar.xz
libguestfs-9e90b24c7d76489f93830377e3d7d3c37f36c30c.zip
Differentiate 'distro' and 'distrofamily' in Sys::Guestfs::Lib
Change distro in the output formally known as virt-inspector to reflect the actual distro. Possible values are now: fedora, rhel, centos, scientific, debian. Add new distrofamily entry which is one of: redhat, debian. Currently all distros except 'debian' are in the redhat family. This allows you to, for example, select a RHEL/CentOS/Scientific Linux specific kernel for installation rather than assuming they're all the same. Note this also changes the behaviour of virt-inspector --query. It will now only return rhel=yes for RHEL.
Diffstat (limited to 'perl')
-rw-r--r--perl/lib/Sys/Guestfs/Lib.pm58
1 files changed, 46 insertions, 12 deletions
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 925c4945..df3bbe19 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -475,8 +475,13 @@ Filesystem content, if we could determine it. One of: "linux-grub",
=item osdistro
(For Linux root partitions only).
-Operating system distribution. One of: "fedora", "redhat",
-"debian".
+Operating system distribution. One of: "fedora", "rhel", "centos",
+"scientific", "debian".
+
+=item osdistrofamily
+
+(For Linux root partitions only)
+Operating system distribution family. One of: "redhat", "debian".
=item osversion
@@ -609,20 +614,47 @@ sub _check_linux_root
# Look into /etc to see if we recognise the operating system.
if ($g->is_file ("/etc/redhat-release")) {
+ $r->{osdistrofamily} = "redhat";
+
$_ = $g->cat ("/etc/redhat-release");
if (/Fedora release (\d+\.\d+)/) {
$r->{osdistro} = "fedora";
$r->{osversion} = "$1"
- } elsif (/(Red Hat Enterprise Linux|CentOS|Scientific Linux).*release (\d+).*Update (\d+)/) {
- $r->{osdistro} = "redhat";
- $r->{osversion} = "$2.$3";
- } elsif (/(Red Hat Enterprise Linux|CentOS|Scientific Linux).*release (\d+(?:\.(\d+))?)/) {
- $r->{osdistro} = "redhat";
- $r->{osversion} = "$2";
- } else {
- $r->{osdistro} = "redhat";
+ }
+
+ elsif (/(Red Hat Enterprise Linux|CentOS|Scientific Linux)/) {
+ my $distro = $1;
+
+ if($distro eq "Red Hat Enterprise Linux") {
+ $r->{osdistro} = "rhel";
+ }
+
+ elsif($distro eq "CentOS") {
+ $r->{osdistro} = "centos";
+ }
+
+ elsif($distro eq "Scientific Linux") {
+ $r->{osdistro} = "scientific";
+ }
+
+ # Shouldn't be possible
+ else { die };
+
+ if (/$distro.*release (\d+).*Update (\d+)/) {
+ $r->{osversion} = "$1.$2";
+ }
+
+ elsif (/$distro.*release (\d+(?:\.(?:\d+))?)/) {
+ $r->{osversion} = "$1";
+ }
+ }
+
+ else {
+ $r->{osdistro} = "redhat-based";
}
} elsif ($g->is_file ("/etc/debian_version")) {
+ $r->{osdistrofamily} = "debian";
+
$_ = $g->cat ("/etc/debian_version");
if (/(\d+\.\d+)/) {
$r->{osdistro} = "debian";
@@ -883,6 +915,8 @@ sub _get_os_version
$r->{os} = $r->{root}->{fsos} if exists $r->{root}->{fsos};
$r->{distro} = $r->{root}->{osdistro} if exists $r->{root}->{osdistro};
+ $r->{distrofamily} = $r->{root}->{osdistrofamily}
+ if exists $r->{root}->{osdistrofamily};
$r->{version} = $r->{root}->{osversion} if exists $r->{root}->{osversion};
}
@@ -1063,8 +1097,8 @@ sub _check_for_applications
my $osn = $os->{os};
if ($osn eq "linux") {
- my $distro = $os->{distro};
- if (defined $distro && ($distro eq "redhat" || $distro eq "fedora")) {
+ my $family = $os->{distrofamily};
+ if (defined $family && $family eq "redhat") {
my @lines = $g->command_lines
(["rpm",
"-q", "-a",