Created
January 14, 2010 21:13
-
-
Save rcreasey/277515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| configure_options = {:with => %W(modules="mod_readme:mod_tls:mod_vroot" shared="mod_ldap"), | |
| :enable => %w(ctrls dso facl openssl), | |
| :disable => %w(ident), | |
| :other => %w(localstatedir=/var/run)} | |
| mod_vroot_tag = "#{node[:proftpd][:modules][:vroot][:name]}-#{node[:proftpd][:modules][:vroot][:version]}" | |
| source_package "proftpd" do | |
| version node[:proftpd][:version] | |
| location node[:proftpd][:mirror] | |
| filename node[:proftpd][:filename] | |
| prefix node[:proftpd][:path] | |
| configure configure_options | |
| post_extract do | |
| remote_file "/export/sources/#{mod_vroot_tag}" do | |
| source node[:proftpd][:modules][:vroot][:source] | |
| end | |
| execute "tar xzf /export/sources/#{mod_vroot_tag}.tar.gz" do | |
| cwd "/export/builds" | |
| end | |
| execute "mv mod_vroot /export/builds/proftpd-#{node[:proftpd][:version]}/contrib" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set_unless[:proftpd] = Mash.new | |
| set_unless[:proftpd][:version] = "1.3.2c" | |
| default[:proftpd][:mirror] = "ftp://ftp.proftpd.org/distrib/source" | |
| default[:proftpd][:path] = "/z/services/proftpd/#{proftpd.version}" | |
| default[:proftpd][:filename] = "proftpd-#{proftpd.version}.tar.gz" | |
| default[:proftpd][:modules] = Mash.new | |
| set_unless[:proftpd][:modules][:vroot] = {:name => 'proftpd-mod-vroot', :version => '0.8.5', :source => 'http://www.castaglia.org/proftpd/modules/proftpd-mod-vroot-0.8.5.tar.gz'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define :source_package do | |
| source_root = params[:source_root] || "/export/source" | |
| build_root = params[:build_root] || "/export/builds" | |
| build_directory = "#{build_root}/#{$1}" if params[:filename] =~ /(.*)\.(tar\.gz|tgz|tar\.bz2|tb2)/ | |
| [source_root, build_root].each do |r| | |
| directory r do | |
| mode 0755 | |
| action :create | |
| not_if { File.directory?( r ) } | |
| end | |
| end | |
| # extract command | |
| archiver_command = case params[:filename] | |
| when /(tar.gz)|(tgz)$/ | |
| 'tar xzf' | |
| when /(tar.bz2)|(tb2)$/ | |
| 'tar xjf' | |
| when /tar$/ | |
| 'tar xf' | |
| when /zip$/ | |
| 'unzip' | |
| else | |
| raise "Unknown source archive format: #{archive_name}" | |
| end | |
| commands = {:download => "wget -cq #{params[:location]}/#{params[:filename]}", | |
| :extract => "#{archiver_command} #{source_root}/#{params[:filename]}", | |
| :configure => "./configure --prefix=#{params[:prefix]} ", | |
| :compile => 'make', | |
| :install => 'make install'} | |
| # decide what to configure | |
| if params[:configure] | |
| if params[:configure][:with] | |
| params[:configure][:enable] = params[:configure][:enable].compact.reject {|s| s.empty?} | |
| commands[:configure] << params[:configure][:with].map {|o| "--with-#{o} "}.join(' ') | |
| end | |
| if params[:configure][:enable] | |
| params[:configure][:enable] = params[:configure][:enable].compact.reject {|s| s.empty?} | |
| commands[:configure] << params[:configure][:enable].map {|o| "--enable-#{o} " unless o.eql?('')}.join(' ') | |
| end | |
| if params[:configure][:disable] | |
| params[:configure][:disable] = params[:configure][:disable].compact.reject {|s| s.empty?} | |
| commands[:configure] << params[:configure][:disable].map {|o| "--disable-#{o} " unless o.eql?('')}.join(' ') | |
| end | |
| if params[:configure][:other] | |
| params[:configure][:other] = params[:configure][:other].compact.reject {|s| s.empty?} | |
| commands[:configure] << params[:configure][:other].map {|o| "--#{o} " unless o.eql?('')}.join(' ') | |
| end | |
| end | |
| # execute commands | |
| unless File.directory?( params[:prefix] ) | |
| instance_eval( ¶ms[:pre_download] ) if params[:pre_download] | |
| execute commands[:download] do | |
| cwd source_root | |
| not_if { File.exists?( "#{source_root}/#{params[:filename]}" ) } | |
| end | |
| instance_eval( ¶ms[:post_download] ) if params[:post_download] | |
| instance_eval( ¶ms[:pre_extract] ) if params[:pre_extract] | |
| execute commands[:extract] do | |
| cwd build_root | |
| end | |
| instance_eval( ¶ms[:post_extract] ) if params[:post_extract] | |
| instance_eval( ¶ms[:pre_configure] ) if params[:pre_configure] | |
| execute commands[:configure] do | |
| cwd build_directory | |
| end | |
| instance_eval( ¶ms[:post_configure] ) if params[:post_configure] | |
| instance_eval( ¶ms[:pre_compile] ) if params[:pre_compile] | |
| execute commands[:compile] do | |
| cwd build_directory | |
| end | |
| instance_eval( ¶ms[:post_compile] ) if params[:post_compile] | |
| instance_eval( ¶ms[:pre_install] ) if params[:pre_install] | |
| execute commands[:install] do | |
| cwd build_directory | |
| end | |
| instance_eval( ¶ms[:post_install] ) if params[:post_install] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment