[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 3a39dd8353b6308cf49522990104cc63e55d7cda

Todd Zullinger tmz at pobox.com
Fri Jan 29 17:22:15 UTC 2010


The following commit has been merged in the upstream branch:
commit bee55c4ab1746ea78de8defaff29663d7ab15604
Author: Todd Zullinger <tmz at pobox.com>
Date:   Mon Mar 9 02:09:12 2009 -0400

    Consolidate operatingsystemrelease for CentOS, Fedora, oel, ovs, and RedHat
    
    These operating systems all use a similar format for the release file.

diff --git a/lib/facter/operatingsystemrelease.rb b/lib/facter/operatingsystemrelease.rb
index 25a226d..2f76817 100644
--- a/lib/facter/operatingsystemrelease.rb
+++ b/lib/facter/operatingsystemrelease.rb
@@ -1,21 +1,17 @@
 Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => :fedora
+    confine :operatingsystem => %w{CentOS Fedora oel ovs RedHat}
     setcode do
-        File::open("/etc/fedora-release", "r") do |f|
-            line = f.readline.chomp
-            if line =~ /\(Rawhide\)$/
-                "Rawhide"
-            elsif line =~ /release (\d+)/
-                $1
-            end
+        case Facter.value(:operatingsystem)
+        when "CentOS", "RedHat"
+            releasefile = "/etc/redhat-release"
+        when "Fedora"
+            releasefile = "/etc/fedora-release"
+        when "oel"
+            releasefile = "/etc/enterprise-release"
+        when "ovs"
+            releasefile = "/etc/ovs-release"
         end
-    end
-end
-
-Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => %w{RedHat}
-    setcode do
-        File::open("/etc/redhat-release", "r") do |f|
+        File::open(releasefile, "r") do |f|
             line = f.readline.chomp
             if line =~ /\(Rawhide\)$/
                 "Rawhide"
@@ -27,42 +23,6 @@ Facter.add(:operatingsystemrelease) do
 end
 
 Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => :oel
-    setcode do
-        File::open("/etc/enterprise-release", "r") do |f|
-            line = f.readline.chomp
-            if line =~ /release (\d+)/
-                $1
-            end
-        end
-    end
-end
-
-Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => :ovs
-    setcode do
-        File::open("/etc/ovs-release", "r") do |f|
-            line = f.readline.chomp
-            if line =~ /release (\d+)/
-                $1
-            end
-        end
-    end
-end
-
-Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => %w{CentOS}
-    setcode do
-        centos_release = Facter::Util::Resolution.exec("sed -r -e 's/CentOS release //' -e 's/ \((Branch|Final)\)//' /etc/redhat-release")
-        if centos_release =~ /5/
-            release = Facter::Util::Resolution.exec('rpm -q --qf \'%{VERSION}.%{RELEASE}\' centos-release | cut -d. -f1,2')
-        else
-            release = centos_release
-        end
-    end
-end
-
-Facter.add(:operatingsystemrelease) do
     confine :operatingsystem => %w{Debian}
     setcode do
         release = Facter::Util::Resolution.exec('cat /etc/debian_version')

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list