Merge 1.6.x into master branch of Facter.
Daniel Pittman
12 years ago
0 | 1.6.9rc1 | |
1 | === | |
2 | b398bd8 (#14334) Fix dmidecode based facts on DragonFly BSD | |
3 | 6c46b2c (#14332) Correct stubbing on Ubuntu | |
4 | 753f3a4 Revert "(#12864) Windows: get primary DNS from registry" | |
5 | ac51593 Wrap dmidecode/pciutils in ifarch block | |
6 | fbaa8fe (#11511) Correct lsbrelease specfile filename | |
7 | 14eee2b (#12864) Windows: get primary DNS from registry | |
8 | 2842c96 Update rpm spec file | |
9 | 515fd65 (#11511) Split lsb facts into multiple files | |
10 | ||
0 | 11 | 1.6.8 |
1 | 12 | === |
2 | 13 | b86fe4c (#12831) Add rspec tests to have_which method in Resolution |
0 | 0 | %{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG["sitelibdir"]')} |
1 | ||
2 | %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5 | |
3 | %define has_ruby_noarch %has_ruby_abi | |
4 | 1 | |
5 | 2 | Summary: Ruby module for collecting simple facts about a host operating system |
6 | 3 | Name: facter |
7 | Version: 1.6.6 | |
8 | Release: 1%{?dist} | |
9 | #Release: 0.1rc1%{?dist} | |
4 | Version: 1.6.9 | |
5 | #Release: 1%{?dist} | |
6 | Release: 0.1rc1%{?dist} | |
10 | 7 | License: Apache 2.0 |
11 | 8 | Group: System Environment/Base |
12 | 9 | URL: http://www.puppetlabs.com/puppet/related-projects/%{name} |
13 | #Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz | |
14 | Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz | |
15 | #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz.asc | |
10 | Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz | |
11 | #Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz | |
12 | Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz.asc | |
13 | #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.asc | |
16 | 14 | |
17 | 15 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) |
18 | %if %has_ruby_noarch | |
19 | BuildArch: noarch | |
20 | %endif | |
21 | 16 | |
22 | Requires: ruby >= 1.8.1 | |
17 | Requires: ruby >= 1.8.5 | |
23 | 18 | Requires: which |
24 | # Note: dmidecode is only available on x86 and x86_64 so this package may need to move into being | |
25 | # arch specific if people are using ppc, arm, s390 etc | |
19 | # dmidecode and pciutils are not available on all arches | |
20 | %ifarch %ix86 x86_64 ia64 | |
26 | 21 | Requires: dmidecode |
27 | 22 | Requires: pciutils |
28 | %if %has_ruby_abi | |
23 | %endif | |
29 | 24 | Requires: ruby(abi) = 1.8 |
30 | %endif | |
31 | BuildRequires: ruby >= 1.8.1 | |
25 | BuildRequires: ruby >= 1.8.5 | |
32 | 26 | |
33 | 27 | %description |
34 | 28 | Ruby module for collecting simple facts about a host Operating |
36 | 30 | operating system. Additional facts can be added through simple Ruby scripts |
37 | 31 | |
38 | 32 | %prep |
39 | %setup -q -n %{name}-%{version} | |
40 | #%setup -q -n %{name}-%{version}rc1 | |
33 | #%setup -q -n %{name}-%{version} | |
34 | %setup -q -n %{name}-%{version}rc1 | |
41 | 35 | |
42 | 36 | %build |
43 | 37 | |
58 | 52 | |
59 | 53 | |
60 | 54 | %changelog |
55 | * Thu May 10 2012 Matthaus Litteken <matthaus@puppetlabs.com> - 1.6.9-0.1rc1 | |
56 | - Update for 1.6.9rc1 | |
57 | ||
58 | * Mon Apr 30 2012 Moses Mendoza <moses@puppetlabs.com> - 1.6.8-1 | |
59 | - Update for 1.6.8, spec for arch-specific build, req ruby 1.8.5 | |
60 | ||
61 | 61 | * Thu Feb 23 2012 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.6-1 |
62 | 62 | - Update for 1.6.6 |
63 | 63 |
0 | # Fact: lsb | |
1 | # | |
2 | # Purpose: Return Linux Standard Base information for the host. | |
3 | # | |
4 | # Resolution: | |
5 | # Uses the lsb_release system command and parses the output with a series of | |
6 | # regular expressions. | |
7 | # | |
8 | # Caveats: | |
9 | # Only works on Linux (and the kfreebsd derivative) systems. | |
10 | # Requires the lsb_release program, which may not be installed by default. | |
11 | # Also is as only as accurate as that program outputs. | |
12 | ||
13 | ## lsb.rb | |
14 | ## Facts related to Linux Standard Base (LSB) | |
15 | ||
16 | { "LSBRelease" => %r{^LSB Version:\t(.*)$}, | |
17 | "LSBDistId" => %r{^Distributor ID:\t(.*)$}, | |
18 | "LSBDistRelease" => %r{^Release:\t(.*)$}, | |
19 | "LSBDistDescription" => %r{^Description:\t(.*)$}, | |
20 | "LSBDistCodeName" => %r{^Codename:\t(.*)$} | |
21 | }.each do |fact, pattern| | |
22 | Facter.add(fact) do | |
23 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] | |
24 | setcode do | |
25 | unless defined?(lsbdata) and defined?(lsbtime) and (Time.now.to_i - lsbtime.to_i < 5) | |
26 | type = nil | |
27 | lsbtime = Time.now | |
28 | lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null') | |
29 | end | |
30 | ||
31 | if pattern.match(lsbdata) | |
32 | $1 | |
33 | else | |
34 | nil | |
35 | end | |
36 | end | |
37 | end | |
38 | end |
0 | # Fact: lsbdistcodename | |
1 | # | |
2 | # Purpose: Return Linux Standard Base information for the host. | |
3 | # | |
4 | # Resolution: | |
5 | # Uses the lsb_release system command | |
6 | # | |
7 | # Caveats: | |
8 | # Only works on Linux (and the kfreebsd derivative) systems. | |
9 | # Requires the lsb_release program, which may not be installed by default. | |
10 | # Also is as only as accurate as that program outputs. | |
11 | ||
12 | Facter.add(:lsbdistcodename) do | |
13 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] | |
14 | setcode do | |
15 | Facter::Util::Resolution.exec('lsb_release -c -s') | |
16 | end | |
17 | end |
0 | # Fact: lsbdistdescription | |
1 | # | |
2 | # Purpose: Return Linux Standard Base information for the host. | |
3 | # | |
4 | # Resolution: | |
5 | # Uses the lsb_release system command | |
6 | # | |
7 | # Caveats: | |
8 | # Only works on Linux (and the kfreebsd derivative) systems. | |
9 | # Requires the lsb_release program, which may not be installed by default. | |
10 | # Also is as only as accurate as that program outputs. | |
11 | ||
12 | Facter.add(:lsbdistdescription) do | |
13 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] | |
14 | setcode do | |
15 | if output = Facter::Util::Resolution.exec('lsb_release -d -s') | |
16 | # the output may be quoted (at least it is on gentoo) | |
17 | output.sub(/^"(.*)"$/,'\1') | |
18 | end | |
19 | end | |
20 | end |
0 | # Fact: lsbdistid | |
1 | # | |
2 | # Purpose: Return Linux Standard Base information for the host. | |
3 | # | |
4 | # Resolution: | |
5 | # Uses the lsb_release system command | |
6 | # | |
7 | # Caveats: | |
8 | # Only works on Linux (and the kfreebsd derivative) systems. | |
9 | # Requires the lsb_release program, which may not be installed by default. | |
10 | # Also is as only as accurate as that program outputs. | |
11 | ||
12 | Facter.add(:lsbdistid) do | |
13 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] | |
14 | setcode do | |
15 | Facter::Util::Resolution.exec('lsb_release -i -s') | |
16 | end | |
17 | end |
0 | # Fact: lsbdistrelease | |
1 | # | |
2 | # Purpose: Return Linux Standard Base information for the host. | |
3 | # | |
4 | # Resolution: | |
5 | # Uses the lsb_release system command | |
6 | # | |
7 | # Caveats: | |
8 | # Only works on Linux (and the kfreebsd derivative) systems. | |
9 | # Requires the lsb_release program, which may not be installed by default. | |
10 | # Also is as only as accurate as that program outputs. | |
11 | ||
12 | Facter.add(:lsbdistrelease) do | |
13 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] | |
14 | setcode do | |
15 | Facter::Util::Resolution.exec('lsb_release -r -s') | |
16 | end | |
17 | end |
0 | # Fact: lsbrelease | |
1 | # | |
2 | # Purpose: Return Linux Standard Base information for the host. | |
3 | # | |
4 | # Resolution: | |
5 | # Uses the lsb_release system command | |
6 | # | |
7 | # Caveats: | |
8 | # Only works on Linux (and the kfreebsd derivative) systems. | |
9 | # Requires the lsb_release program, which may not be installed by default. | |
10 | # Also is as only as accurate as that program outputs. | |
11 | ||
12 | Facter.add(:lsbrelease) do | |
13 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] | |
14 | setcode do | |
15 | Facter::Util::Resolution.exec('lsb_release -v -s') | |
16 | end | |
17 | end |
9 | 9 | # |
10 | 10 | # Caveats: |
11 | 11 | # |
12 | require 'facter/lsb' | |
13 | 12 | |
14 | 13 | Facter.add(:operatingsystem) do |
15 | 14 | confine :kernel => :sunos |
12 | 12 | return nil unless FileTest.exists?("/usr/local/sbin/dmidecode") |
13 | 13 | |
14 | 14 | output=%x{/usr/local/sbin/dmidecode 2>/dev/null} |
15 | when 'NetBSD' | |
15 | when 'NetBSD', 'DragonFly' | |
16 | 16 | return nil unless FileTest.exists?("/usr/pkg/sbin/dmidecode") |
17 | 17 | |
18 | 18 | output=%x{/usr/pkg/sbin/dmidecode 2>/dev/null} |
37 | 37 | if line =~ /#{key}/ and line =~ /\n\s+#{value} (.+)\n/ |
38 | 38 | result = $1.strip |
39 | 39 | Facter.add(facterkey) do |
40 | confine :kernel => [ :linux, :freebsd, :netbsd, :sunos, :"gnu/kfreebsd" ] | |
40 | confine :kernel => [ :linux, :freebsd, :netbsd, :sunos, :"gnu/kfreebsd", :dragonfly ] | |
41 | 41 | setcode do |
42 | 42 | result |
43 | 43 | end |
24 | 24 | include Comparable |
25 | 25 | include Enumerable |
26 | 26 | |
27 | FACTERVERSION = '1.6.8' | |
27 | FACTERVERSION = '1.6.9' | |
28 | 28 | # = Facter |
29 | 29 | # Functions as a hash of 'facts' you might care about about your |
30 | 30 | # system, such as mac address, IP address, Video card, etc. |
0 | #!/usr/bin/env rspec | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe "lsbdistcodename fact" do | |
5 | ||
6 | [ "Linux", "GNU/kFreeBSD"].each do |kernel| | |
7 | describe "on #{kernel}" do | |
8 | before :each do | |
9 | Facter.fact(:kernel).stubs(:value).returns kernel | |
10 | end | |
11 | ||
12 | it "should return the codename through lsb_release -c -s" do | |
13 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s').returns 'n/a' | |
14 | Facter.fact(:lsbdistcodename).value.should == 'n/a' | |
15 | end | |
16 | ||
17 | it "should return nil if lsb_release is not installed" do | |
18 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s').returns nil | |
19 | Facter.fact(:lsbdistcodename).value.should be_nil | |
20 | end | |
21 | end | |
22 | end | |
23 | ||
24 | end |
0 | #!/usr/bin/env rspec | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe "lsbdistdescription fact" do | |
5 | ||
6 | [ "Linux", "GNU/kFreeBSD"].each do |kernel| | |
7 | describe "on #{kernel}" do | |
8 | before :each do | |
9 | Facter.fact(:kernel).stubs(:value).returns kernel | |
10 | end | |
11 | ||
12 | it "should return the description through lsb_release -d -s" do | |
13 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s').returns '"Gentoo Base System release 2.1"' | |
14 | Facter.fact(:lsbdistdescription).value.should == 'Gentoo Base System release 2.1' | |
15 | end | |
16 | ||
17 | it "should return nil if lsb_release is not installed" do | |
18 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s').returns nil | |
19 | Facter.fact(:lsbdistdescription).value.should be_nil | |
20 | end | |
21 | end | |
22 | end | |
23 | ||
24 | end |
0 | #!/usr/bin/env rspec | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe "lsbdistid fact" do | |
5 | ||
6 | [ "Linux", "GNU/kFreeBSD"].each do |kernel| | |
7 | describe "on #{kernel}" do | |
8 | before :each do | |
9 | Facter.fact(:kernel).stubs(:value).returns kernel | |
10 | end | |
11 | ||
12 | it "should return the id through lsb_release -i -s" do | |
13 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s').returns 'Gentoo' | |
14 | Facter.fact(:lsbdistid).value.should == 'Gentoo' | |
15 | end | |
16 | ||
17 | it "should return nil if lsb_release is not installed" do | |
18 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s').returns nil | |
19 | Facter.fact(:lsbdistid).value.should be_nil | |
20 | end | |
21 | end | |
22 | end | |
23 | ||
24 | end |
0 | #!/usr/bin/env rspec | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe "lsbdistrelease fact" do | |
5 | ||
6 | [ "Linux", "GNU/kFreeBSD"].each do |kernel| | |
7 | describe "on #{kernel}" do | |
8 | before :each do | |
9 | Facter.fact(:kernel).stubs(:value).returns kernel | |
10 | end | |
11 | ||
12 | it "should return the release through lsb_release -r -s" do | |
13 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s').returns '2.1' | |
14 | Facter.fact(:lsbdistrelease).value.should == '2.1' | |
15 | end | |
16 | ||
17 | it "should return nil if lsb_release is not installed" do | |
18 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s').returns nil | |
19 | Facter.fact(:lsbdistrelease).value.should be_nil | |
20 | end | |
21 | end | |
22 | end | |
23 | ||
24 | end |
0 | #!/usr/bin/env rspec | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe "lsbrelease fact" do | |
5 | ||
6 | [ "Linux", "GNU/kFreeBSD"].each do |kernel| | |
7 | describe "on #{kernel}" do | |
8 | before :each do | |
9 | Facter.fact(:kernel).stubs(:value).returns kernel | |
10 | end | |
11 | ||
12 | it "should return the release through lsb_release -v -s" do | |
13 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s').returns 'n/a' | |
14 | Facter.fact(:lsbrelease).value.should == 'n/a' | |
15 | end | |
16 | ||
17 | it "should return nil if lsb_release is not installed" do | |
18 | Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s').returns nil | |
19 | Facter.fact(:lsbrelease).value.should be_nil | |
20 | end | |
21 | end | |
22 | end | |
23 | ||
24 | end |
36 | 36 | describe "on Linux" do |
37 | 37 | before :each do |
38 | 38 | Facter.fact(:kernel).stubs(:value).returns("Linux") |
39 | ||
40 | # Always stub lsbdistid by default, so tests work on Ubuntu | |
41 | Facter.stubs(:value).with(:lsbdistid).returns(nil) | |
39 | 42 | end |
40 | 43 | |
41 | 44 | { |
68 | 71 | it "on Ubuntu should use the lsbdistid fact" do |
69 | 72 | FileUtils.stubs(:exists?).with("/etc/debian_version").returns true |
70 | 73 | |
71 | Facter.fact(:lsbdistid).expects(:value).returns("Ubuntu") | |
74 | Facter.stubs(:value).with(:lsbdistid).returns("Ubuntu") | |
72 | 75 | Facter.fact(:operatingsystem).value.should == "Ubuntu" |
73 | 76 | end |
74 | 77 |