Please review pull request #190: (#13680) Distinguish "Funtoo" from "Gentoo" Linux opened by (stschulte)

Description:

As the ticket owner Marc Richter states:

Funtoo Linux is a Fork of Gentoo Linux from the former creator of Gentoo
Linux, Daniel Robbins. The two derivates behave mostly the same, but
they are differing more and more over time. So the package manager
portage (and it's frontend emerge) for example are behaving a little
different already. Packages are named different, versions differ, and so
on. It would be great if one could differ between Funtoo and Gentoo in
his manifests to install different package versions on Funtoo/Gentoo or
package versions or deliver different configurations.

This patch now reads the contents of /etc/gentoo-release to
distinguish between the two. We already do this is in a similar way with
the /etc/redhat-release file to distinguish between CentOS, Scientific
Linux, RHEL, etc.

  • Opened: Sat Apr 07 21:25:52 UTC 2012
  • Based on: puppetlabs:1.6.x (96256a35bb6143cf0299c98462d4139a6f731e82)
  • Requested merge: stschulte:feature/1.6.x/13680 (0d5701fb1b090e68da448465223b009541be4ae5)

Diff follows:

diff --git a/lib/facter/architecture.rb b/lib/facter/architecture.rb
index a8ff9a3..f249b0b 100644
--- a/lib/facter/architecture.rb
+++ b/lib/facter/architecture.rb
@@ -5,8 +5,8 @@
 #
 # Resolution:
 #   On OpenBSD, Linux and Debian's kfreebsd, use the hardwaremodel fact.
-#   Gentoo and Debian call "x86_86" "amd64".
-#   Gentoo also calls "i386" "x86".
+#   Gentoo (and its fork Funtoo) and Debian call "x86_86" "amd64".
+#   Gentoo (and its fork Funtoo) also calls "i386" "x86".
 #
 # Caveats:
 #
@@ -18,14 +18,14 @@
       # most linuxen use "x86_64"
     when "x86_64"
       case Facter.value(:operatingsystem)
-      when "Debian", "Gentoo", "GNU/kFreeBSD", "Ubuntu"
+      when "Debian", "Gentoo", "Funtoo", "GNU/kFreeBSD", "Ubuntu"
         "amd64"
       else
         model
       end
     when /(i[3456]86|pentium)/
       case Facter.value(:operatingsystem)
-      when "Gentoo"
+      when "Gentoo", "Funtoo"
         "x86"
       else
         "i386"
diff --git a/lib/facter/operatingsystem.rb b/lib/facter/operatingsystem.rb
index be4243e..24656b7 100644
--- a/lib/facter/operatingsystem.rb
+++ b/lib/facter/operatingsystem.rb
@@ -31,7 +31,12 @@
     elsif FileTest.exists?("/etc/debian_version")
       "Debian"
     elsif FileTest.exists?("/etc/gentoo-release")
-      "Gentoo"
+      txt = File.read("/etc/gentoo-release")
+      if txt =~ /funtoo/i
+        "Funtoo"
+      else
+        "Gentoo"
+      end
     elsif FileTest.exists?("/etc/fedora-release")
       "Fedora"
     elsif FileTest.exists?("/etc/mandriva-release")
diff --git a/spec/unit/architecture_spec.rb b/spec/unit/architecture_spec.rb
index 5dadd84..81465e2 100755
--- a/spec/unit/architecture_spec.rb
+++ b/spec/unit/architecture_spec.rb
@@ -14,6 +14,7 @@
   os_archs = {
     ["Debian","x86_64"] => "amd64",
     ["Gentoo","x86_64"] => "amd64",
+    ["Funtoo","x86_64"] => "amd64",
     ["GNU/kFreeBSD","x86_64"] => "amd64",
     ["Ubuntu","x86_64"] => "amd64",
     ["Gentoo","i386"] => "x86",
@@ -21,6 +22,11 @@
     ["Gentoo","i586"] => "x86",
     ["Gentoo","i686"] => "x86",
     ["Gentoo","pentium"] => "x86",
+    ["Funtoo","i386"] => "x86",
+    ["Funtoo","i486"] => "x86",
+    ["Funtoo","i586"] => "x86",
+    ["Funtoo","i686"] => "x86",
+    ["Funtoo","pentium"] => "x86",
   }
   generic_archs = Hash.new
   generic_archs = {
@@ -30,7 +36,7 @@
     "i686" => "i386",
     "pentium" => "i386",
   }
-  
+
   os_archs.each do |pair, result|
     it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do
      Facter.fact(:operatingsystem).stubs(:value).returns(pair[0])
diff --git a/spec/unit/operatingsystem_spec.rb b/spec/unit/operatingsystem_spec.rb
index 89a18c4..0be27af 100755
--- a/spec/unit/operatingsystem_spec.rb
+++ b/spec/unit/operatingsystem_spec.rb
@@ -41,7 +41,6 @@
 
     {
       "Debian"      => "/etc/debian_version",
-      "Gentoo"      => "/etc/gentoo-release",
       "Fedora"      => "/etc/fedora-release",
       "Mandriva"    => "/etc/mandriva-release",
       "Mandrake"    => "/etc/mandrake-release",
@@ -75,6 +74,19 @@
 
     end
 
+    # Check distributions that rely on the contents of /etc/gentoo-release
+    {
+      'Gentoo' => 'Gentoo Base System release 2.1',
+      'Funtoo' => 'Funtoo Linux - baselayout 2.1.8'
+    }.each_pair do |operatingsystem, string|
+      it "should be #{operatingsystem} based on /etc/gentoo-release contents #{string}" do
+        FileTest.expects(:exists?).with("/etc/gentoo-release").returns true
+        File.expects(:read).with("/etc/gentoo-release").returns string
+
+        Facter.fact(:operatingsystem).value.should == operatingsystem
+      end
+    end
+
 
     # Check distributions that rely on the contents of /etc/redhat-release
     {

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to