Codebase list facter / 5e18273
Merge branch '2.0rc' into 2.0.x * 2.0rc: Use git describe in Rakefile to determine pkg ver (#14582) Fix noise in LSB facts Update CHANGELOG, conf/redhat/facter.spec for 1.6.9 Hailee Kenney 11 years ago
12 changed file(s) with 61 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
5656 9df78a1 (#9929) Add support for Mageia to operatingsystem.rb and operatingsystemrelease.rb
5757 51cb8e2 Cleaned up Arch Linux detection routine
5858
59 1.6.9rc1
59 1.6.9
6060 ===
6161 b398bd8 (#14334) Fix dmidecode based facts on DragonFly BSD
6262 6c46b2c (#14332) Correct stubbing on Ubuntu
1616 require 'rake/packagetask'
1717 require 'rake/gempackagetask'
1818
19 module Facter
20 FACTERVERSION = File.read('lib/facter.rb')[/FACTERVERSION *= *'(.*)'/,1] or fail "Couldn't find FACTERVERSION"
21 end
22
2319 FILES = FileList[
2420 '[A-Z]*',
2521 'install.rb',
3026 'spec/**/*'
3127 ]
3228
29 def get_version
30 `git describe`.strip
31 end
32
33 # :build_environment and :tar are mostly borrowed from puppet-dashboard Rakefile
34 task :build_environment do
35 unless ENV['FORCE'] == '1'
36 modified = `git status --porcelain | sed -e '/^\?/d'`
37 if modified.split(/\n/).length != 0
38 puts <<-HERE
39 !! ERROR: Your git working directory is not clean. You must
40 !! remove or commit your changes before you can create a package:
41
42 #{`git status | grep '^#'`.chomp}
43
44 !! To override this check, set FORCE=1 -- e.g. `rake package:deb FORCE=1`
45 HERE
46 raise
47 end
48 end
49 end
50
51 desc "Create a release .tar.gz"
52 task :tar => :build_environment do
53 name = "facter"
54 rm_rf 'pkg/tar'
55 temp=`mktemp -d -t tmpXXXXXX`.strip!
56 version = get_version
57 base = "#{temp}/#{name}-#{version}/"
58 mkdir_p base
59 sh "git checkout-index -af --prefix=#{base}"
60 mkdir_p "pkg/tar"
61 sh "tar -C #{temp} -pczf #{temp}/#{name}-#{version}.tar.gz #{name}-#{version}"
62 mv "#{temp}/#{name}-#{version}.tar.gz", "pkg/tar"
63 rm_rf temp
64 puts "Tarball is pkg/tar/#{name}-#{version}.tar.gz"
65 end
66
3367 spec = Gem::Specification.new do |spec|
3468 spec.platform = Gem::Platform::RUBY
3569 spec.name = 'facter'
3670 spec.files = FILES.to_a
3771 spec.executables = %w{facter}
38 spec.version = Facter::FACTERVERSION
72 spec.version = get_version.split('-')[0]
3973 spec.summary = 'Facter, a system inventory tool'
4074 spec.description = 'You can prove anything with facts!'
4175 spec.author = 'Puppet Labs'
4882 '--main' << 'README' <<
4983 '--line-numbers'
5084 end
51
52 Rake::PackageTask.new("facter", Facter::FACTERVERSION) do |pkg|
53 pkg.package_dir = 'pkg'
54 pkg.need_tar_gz = true
55 pkg.package_files = FILES.to_a
56 end
57
5885 Rake::GemPackageTask.new(spec) do |pkg|
5986 end
6087
1212 Facter.add(:lsbdistcodename) do
1313 confine :kernel => [ :linux, :"gnu/kfreebsd" ]
1414 setcode do
15 Facter::Util::Resolution.exec('lsb_release -c -s')
15 Facter::Util::Resolution.exec('lsb_release -c -s 2>/dev/null')
1616 end
1717 end
1212 Facter.add(:lsbdistdescription) do
1313 confine :kernel => [ :linux, :"gnu/kfreebsd" ]
1414 setcode do
15 if output = Facter::Util::Resolution.exec('lsb_release -d -s')
15 if output = Facter::Util::Resolution.exec('lsb_release -d -s 2>/dev/null')
1616 # the output may be quoted (at least it is on gentoo)
1717 output.sub(/^"(.*)"$/,'\1')
1818 end
1212 Facter.add(:lsbdistid) do
1313 confine :kernel => [ :linux, :"gnu/kfreebsd" ]
1414 setcode do
15 Facter::Util::Resolution.exec('lsb_release -i -s')
15 Facter::Util::Resolution.exec('lsb_release -i -s 2>/dev/null')
1616 end
1717 end
1212 Facter.add(:lsbdistrelease) do
1313 confine :kernel => [ :linux, :"gnu/kfreebsd" ]
1414 setcode do
15 Facter::Util::Resolution.exec('lsb_release -r -s')
15 Facter::Util::Resolution.exec('lsb_release -r -s 2>/dev/null')
1616 end
1717 end
1212 Facter.add(:lsbrelease) do
1313 confine :kernel => [ :linux, :"gnu/kfreebsd" ]
1414 setcode do
15 Facter::Util::Resolution.exec('lsb_release -v -s')
15 Facter::Util::Resolution.exec('lsb_release -v -s 2>/dev/null')
1616 end
1717 end
99 Facter.fact(:kernel).stubs(:value).returns kernel
1010 end
1111
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'
12 it "should return the codename through lsb_release -c -s 2>/dev/null" do
13 Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns 'n/a'
1414 Facter.fact(:lsbdistcodename).value.should == 'n/a'
1515 end
1616
1717 it "should return nil if lsb_release is not installed" do
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s').returns nil
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns nil
1919 Facter.fact(:lsbdistcodename).value.should be_nil
2020 end
2121 end
99 Facter.fact(:kernel).stubs(:value).returns kernel
1010 end
1111
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"'
12 it "should return the description through lsb_release -d -s 2>/dev/null" do
13 Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns '"Gentoo Base System release 2.1"'
1414 Facter.fact(:lsbdistdescription).value.should == 'Gentoo Base System release 2.1'
1515 end
1616
1717 it "should return nil if lsb_release is not installed" do
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s').returns nil
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns nil
1919 Facter.fact(:lsbdistdescription).value.should be_nil
2020 end
2121 end
99 Facter.fact(:kernel).stubs(:value).returns kernel
1010 end
1111
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'
12 it "should return the id through lsb_release -i -s 2>/dev/null" do
13 Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns 'Gentoo'
1414 Facter.fact(:lsbdistid).value.should == 'Gentoo'
1515 end
1616
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
17 it "should return nil if lsb_release is not installed 2>/dev/null" do
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns nil
1919 Facter.fact(:lsbdistid).value.should be_nil
2020 end
2121 end
99 Facter.fact(:kernel).stubs(:value).returns kernel
1010 end
1111
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'
12 it "should return the release through lsb_release -r -s 2>/dev/null" do
13 Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns '2.1'
1414 Facter.fact(:lsbdistrelease).value.should == '2.1'
1515 end
1616
1717 it "should return nil if lsb_release is not installed" do
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s').returns nil
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns nil
1919 Facter.fact(:lsbdistrelease).value.should be_nil
2020 end
2121 end
99 Facter.fact(:kernel).stubs(:value).returns kernel
1010 end
1111
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'
12 it "should return the release through lsb_release -v -s 2>/dev/null" do
13 Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns 'n/a'
1414 Facter.fact(:lsbrelease).value.should == 'n/a'
1515 end
1616
1717 it "should return nil if lsb_release is not installed" do
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s').returns nil
18 Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns nil
1919 Facter.fact(:lsbrelease).value.should be_nil
2020 end
2121 end