2011-12-07 22:59:34 +00:00
|
|
|
require 'fileutils'
|
|
|
|
|
|
|
|
Puppet::Type.type(:make_and_install).provide(:action) do
|
|
|
|
desc "Configure a program to install"
|
|
|
|
|
|
|
|
def create
|
2011-12-08 13:58:22 +00:00
|
|
|
system %{bash -c '#{path} cd #{@resource[:build_path]} ; make && make install'}
|
2012-05-09 16:56:25 +00:00
|
|
|
raise StandardError.new("Could not make and install") if $?.exitstatus != 0
|
2012-01-18 17:29:05 +00:00
|
|
|
|
|
|
|
FileUtils.rm_rf symlink_path
|
|
|
|
FileUtils.ln_sf(@resource[:install_path], symlink_path)
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
FileUtils.rm_rf @resource[:install_path]
|
|
|
|
FileUtils.rm_rf symlink_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def exists?
|
2012-05-07 18:30:35 +00:00
|
|
|
return true if unless?
|
|
|
|
|
|
|
|
File.directory?(@resource[:install_path]) && File.symlink?(symlink_path)
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2012-05-07 14:53:50 +00:00
|
|
|
def unless?
|
2012-05-09 16:56:25 +00:00
|
|
|
return nil if !@resource[:unless] || @resource[:unless].empty?
|
2012-05-07 14:53:50 +00:00
|
|
|
|
|
|
|
system %{bash -c '#{@resource[:unless]}'}
|
2012-05-09 16:56:25 +00:00
|
|
|
|
2012-05-07 14:53:50 +00:00
|
|
|
$?.exitstatus == 0
|
|
|
|
end
|
|
|
|
|
2011-12-07 22:59:34 +00:00
|
|
|
def symlink_path
|
|
|
|
File.join(File.dirname(@resource[:install_path]), @resource[:name])
|
|
|
|
end
|
2011-12-08 13:58:22 +00:00
|
|
|
|
|
|
|
def path
|
|
|
|
@resource[:path].empty? ? '' : "export PATH=#{@resource[:path]}:$PATH ; "
|
|
|
|
end
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|