2011-12-07 22:59:34 +00:00
|
|
|
Puppet::Type.type(:configure).provide(:action) do
|
|
|
|
desc "Configure a program to install"
|
|
|
|
|
|
|
|
def create
|
2012-06-14 02:01:05 +00:00
|
|
|
system %{bash -c "cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o }
|
|
|
|
p $?
|
2012-05-09 16:56:25 +00:00
|
|
|
raise StandardError.new("Could not configure") if $?.exitstatus != 0
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
File.unlink config_status
|
|
|
|
end
|
|
|
|
|
|
|
|
def exists?
|
2012-05-07 18:30:35 +00:00
|
|
|
return true if unless?
|
|
|
|
|
|
|
|
File.file?(config_status)
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
2012-06-14 02:01:05 +00:00
|
|
|
|
2011-12-07 22:59:34 +00:00
|
|
|
private
|
|
|
|
def config_status
|
2012-01-18 17:29:05 +00:00
|
|
|
File.join(@resource[:build_path], @resource[:config_status])
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
|
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 path
|
2012-06-14 02:01:05 +00:00
|
|
|
@resource[:path].empty? ? '' : "PATH=#{@resource[:path]}:$PATH "
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|