forked from puppetlabs/puppetdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
146 lines (120 loc) · 4.82 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
require 'rake'
require 'erb'
require 'facter'
JAR_FILE = 'puppetdb.jar'
RAKE_ROOT = File.dirname(__FILE__)
# Load tasks and variables for packaging automation
begin
load File.join(RAKE_ROOT, 'ext', 'packaging', 'packaging.rake')
rescue LoadError
end
def ln_sf(src, dest)
if !File.exist?(dest)
sh "ln -sf #{src} #{dest}"
end
end
def cp_pr(src, dest, options={})
mandatory = {:preserve => true}
cp_r(src, dest, options.merge(mandatory))
end
def cp_p(src, dest, options={})
mandatory = {:preserve => true}
cp(src, dest, options.merge(mandatory))
end
# We want to use puppetdb's package:tar and its dependencies, because it
# contains all the special java snowflake magicks, so we have to clear the
# packaging repo's. We also want to use puppetdb's clean task, since it has so
# much more clean than the packaging repo knows about
['package:tar', 'clean'].each do |task|
Rake::Task[task].clear if Rake::Task.task_defined?(task)
end
# We establish variables used in the puppetdb tasks before hand
if (@build and @build.build_pe) || (ENV['PE_BUILD'] and ENV['PE_BUILD'].downcase == 'true')
@pe = TRUE
ENV['PATH'] = "/opt/puppet/bin:" + ENV['PATH']
else
@pe = FALSE
end
if @pe
@install_dir = "/opt/puppet/share/puppetdb"
@etc_dir = "/etc/puppetlabs/puppetdb"
@config_dir = "/etc/puppetlabs/puppetdb/conf.d"
@initscriptname = "/etc/init.d/pe-puppetdb"
@log_dir = "/var/log/pe-puppetdb"
@lib_dir = "/opt/puppet/share/puppetdb"
@name ="pe-puppetdb"
@sbin_dir = "/opt/puppet/sbin"
@pe_version = ENV['PE_VER'] || '3.0'
@java_bin = "/opt/puppet/bin/java"
else
@install_dir = "/usr/share/puppetdb"
@etc_dir = "/etc/puppetdb"
@config_dir = "/etc/puppetdb/conf.d"
@initscriptname = "/etc/init.d/puppetdb"
@log_dir = "/var/log/puppetdb"
@lib_dir = "/var/lib/puppetdb"
@link = "/usr/share/puppetdb"
@name = "puppetdb"
@sbin_dir = "/usr/sbin"
end
# We only need the ruby major, minor versions
@ruby_version = (ENV['RUBY_VER'] || Facter.value(:rubyversion))[0..2]
unless ['1.8','1.9'].include?(@ruby_version)
STDERR.puts "Warning: Existing rake commands are untested on #{@ruby_version} currently supported rubies include 1.8 or 1.9"
end
PATH = ENV['PATH']
DESTDIR= ENV['DESTDIR'] || ''
PE_SITELIBDIR = "/opt/puppet/lib/ruby/site_ruby/1.9.1"
@osfamily = (Facter.value(:osfamily) || "").downcase
case @osfamily
when /debian/
@plibdir = @pe ? PE_SITELIBDIR : '/usr/lib/ruby/vendor_ruby'
when /redhat/
@plibdir = @pe ? PE_SITELIBDIR : ( @ruby_version == '1.8' ? %x(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]').chomp : %x(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]').chomp )
when /suse/
@plibdir = @pe ? PE_SITELIBDIR : (%x(ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']").chomp)
when /openbsd/
@plibdir = @pe ? PE_SITELIBDIR : '/usr/local/lib/ruby/site_ruby/1.9.1'
end
@heap_dump_path = "#{@log_dir}/puppetdb-oom.hprof"
@default_java_args = "-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=#{@heap_dump_path} "
# All variables have been set, so we can load the puppetdb tasks
Dir[ File.join(RAKE_ROOT, 'tasks','*.rake') ].sort.each { |t| load t }
task :default => [ :package ]
task :allclean => [ :clobber ]
desc "Remove build artifacts (other than clojure (lein) builds)"
task :clean do
rm_rf FileList["ext/files", "pkg", "*.tar.gz"]
end
desc "Get rid of build artifacts including clojure (lein) builds"
task :clobber => [ :clean ] do
rm_rf FileList["target/puppetdb*jar"]
end
task :version do
puts @version
end
file "ext/files/config.ini" => [ :template, JAR_FILE ] do
end
namespace :test do
desc "Build packages for testing"
task :package do
# TODO: I'm not proud of this. The contents of the shell script(s) that
# we call here need to be reconciled with Moses' standardized packaging
# stuff, and a lot of the contents should probably be ported over to
# Ruby instead of just shipping the nasty scripts. However, this first step
# at least gives us 1) VCS for this stuff, and 2) the ability to run
# the two packaging builds in parallel.
sh "sh ./ext/test/build_packages.sh"
end
end
# The first package build tasks in puppetdb were rake deb and rake srpm (due to
# a cyclical dependency bug, the namespaced aliases to these tasks never worked
# actually worked). The packaging repo doesn't provide rake deb/srpm (they're
# namespaced as package:deb/srpm) and its just as well so we don't conflict
# here when we try to emulate the original behavior here backwards
# compatibility. These two tasks will force a reload of the packaging repo and
# then use it to do the same thing the original tasks did.
desc 'Build deb package'
task :deb => [ 'package:implode', 'package:bootstrap', 'package:deb' ]
desc 'Build a Source rpm for puppetdb'
task :srpm => [ 'package:implode', 'package:bootstrap', 'package:srpm' ]