Sha256: 37c90cc80b3c51c660cf9c2e390daa705490db4a233cbbc1ef93bd070014b2df

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

module PoolParty    
  module Resources
        
    class Gempackage < Resource
      
      # When we call gempackage, we want the exec to run on the directory we suggest
      # we also only want it to run if there is NOT a local gem already installed with
      # the package details (version and name)
      # 
      # TODO: Add it so that it tries to pull the gem off the master fileserver first...
      def loaded(opts={}, parent=self)
        if download_url
          execute_if("$hostname", "master") do
            has_exec(:name => "download-#{name}", :cwd => Base.remote_storage_path, :command => "wget #{download_url} -O #{name}.gem", :ifnot => "test -f #{Base.remote_storage_path}/#{name}.gem")
          end
          has_file(:name => "#{Base.remote_storage_path}/#{name}.gem", :source => "#{Base.fileserver_base}/#{name}.gem")
          
          has_exec(opts.merge({:name => "#{name}", :cwd =>"#{Base.remote_storage_path}", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin"})) do
            command "gem install -y --no-ri --no-rdoc #{name}.gem"
            ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
            requires get_file("#{Base.remote_storage_path}/#{name}.gem")
          end
        else
          has_exec(opts.merge({:name => "#{name}", :cwd => "/tmp", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin"})) do
            command "gem install -y --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name} <<heredoc
            1
            heredoc"
            ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
          end
        end
      end
      def virtual_resource?
        true
      end
      def printable?
        true
      end
      def class_type_name
        "Exec"
      end
      
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
auser-poolparty-0.2.23 lib/poolparty/pool/resources/gem_package.rb
auser-poolparty-0.2.24 lib/poolparty/pool/resources/gem_package.rb
auser-poolparty-0.2.25 lib/poolparty/pool/resources/gem_package.rb
auser-poolparty-0.2.26 lib/poolparty/pool/resources/gem_package.rb