Class: FPM::Cookery::SourceHandler::Curl

Inherits:
Template
  • Object
show all
Defined in:
lib/fpm/cookery/source_handler/curl.rb

Constant Summary collapse

NAME =
:curl
CHECKSUM =
true

Instance Attribute Summary

Attributes inherited from Template

#builddir, #cachedir, #has_checksum, #name, #options, #url

Instance Method Summary collapse

Methods inherited from Template

#checksum?, #initialize, #local_path, #source

Constructor Details

This class inherits a constructor from FPM::Cookery::SourceHandler::Template

Instance Method Details

#extractObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fpm/cookery/source_handler/curl.rb', line 23

def extract
  Dir.chdir(builddir) do
    case local_path.extname
    when '.bz2', '.gz', '.tgz'
      safesystem('tar', 'xf', local_path)
    when '.shar', '.bin'
      File.chmod(0755, local_path)
      safesystem(local_path)
    when '.zip'
      safesystem('unzip', '-d', local_path.basename('.zip'), local_path)
    end
    extracted_source
  end
end

#fetchObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/fpm/cookery/source_handler/curl.rb', line 12

def fetch
  if local_path.exist?
    Log.info "Using cached file #{local_path}"
  else
    Dir.chdir(cachedir) do
      curl(url, local_path) unless local_path.exist?
    end
  end
  local_path
end