forked from puppetlabs/facter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
112 lines (96 loc) · 2.65 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Rakefile for facter
$: << File.expand_path('lib')
$LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
require 'rubygems'
require 'rspec'
require 'rspec/core/rake_task'
begin
require 'rcov'
rescue LoadError
end
Dir['tasks/**/*.rake'].each { |t| load t }
require 'rake'
require 'rake/packagetask'
require 'rake/gempackagetask'
FILES = FileList[
'[A-Z]*',
'install.rb',
'bin/**/*',
'lib/**/*',
'conf/**/*',
'etc/**/*',
'spec/**/*'
]
def get_version
`git describe`.strip
end
# :build_environment and :tar are mostly borrowed from puppet-dashboard Rakefile
task :build_environment do
unless ENV['FORCE'] == '1'
modified = `git status --porcelain | sed -e '/^\?/d'`
if modified.split(/\n/).length != 0
puts <<-HERE
!! ERROR: Your git working directory is not clean. You must
!! remove or commit your changes before you can create a package:
#{`git status | grep '^#'`.chomp}
!! To override this check, set FORCE=1 -- e.g. `rake package:deb FORCE=1`
HERE
raise
end
end
end
desc "Create a release .tar.gz"
task :tar => :build_environment do
name = "facter"
rm_rf 'pkg/tar'
temp=`mktemp -d -t tmpXXXXXX`.strip!
version = get_version
base = "#{temp}/#{name}-#{version}/"
mkdir_p base
sh "git checkout-index -af --prefix=#{base}"
mkdir_p "pkg/tar"
sh "tar -C #{temp} -pczf #{temp}/#{name}-#{version}.tar.gz #{name}-#{version}"
mv "#{temp}/#{name}-#{version}.tar.gz", "pkg/tar"
rm_rf temp
puts "Tarball is pkg/tar/#{name}-#{version}.tar.gz"
end
spec = Gem::Specification.new do |spec|
spec.platform = Gem::Platform::RUBY
spec.name = 'facter'
spec.files = FILES.to_a
spec.executables = %w{facter}
spec.version = get_version.split('-')[0]
spec.summary = 'Facter, a system inventory tool'
spec.description = 'You can prove anything with facts!'
spec.author = 'Puppet Labs'
spec.email = '[email protected]'
spec.homepage = 'http://puppetlabs.com'
spec.rubyforge_project = 'facter'
spec.has_rdoc = true
spec.rdoc_options <<
'--title' << 'Facter - System Inventory Tool' <<
'--main' << 'README' <<
'--line-numbers'
end
Rake::GemPackageTask.new(spec) do |pkg|
end
task :package => :tar
task :default do
sh %{rake -T}
end
# Aliases for spec
task :test => [:spec]
task :tests => [:spec]
task :specs => [:spec]
RSpec::Core::RakeTask.new do |t|
t.pattern ='spec/{unit,integration}/**/*_spec.rb'
t.fail_on_error = true
end
RSpec::Core::RakeTask.new('spec:rcov') do |t|
t.pattern ='spec/{unit,integration}/**/*_spec.rb'
t.fail_on_error = true
if defined?(Rcov)
t.rcov = true
t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*']
end
end