diff --git a/README.md b/README.md index a42ad3525..4990ac9c0 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,8 @@ Here is an example: name "ruby" default_version "1.9.2-p290" source url: "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}.tar.gz", - md5: "604da71839a6ae02b5b5b5e1b792d5eb" + md5: "604da71839a6ae02b5b5b5e1b792d5eb", + extract: false dependency "zlib" dependency "ncurses" diff --git a/lib/omnibus/fetchers/net_fetcher.rb b/lib/omnibus/fetchers/net_fetcher.rb index 6f9cee62a..164e3fdbb 100644 --- a/lib/omnibus/fetchers/net_fetcher.rb +++ b/lib/omnibus/fetchers/net_fetcher.rb @@ -44,6 +44,17 @@ def fetch_required? !(File.exist?(downloaded_file) && digest(downloaded_file, digest_type) == checksum) end + # + # A extract is required if the downloaded_file is an archive and + # source[:extract] is set to true if provided. Default: true + # + # @return [true, false] + # + def extract_required? + return false unless downloaded_file.end_with?(*ALL_EXTENSIONS) + !source.key?(:extract) ? true : source[:extract] + end + # # The version identifier for this remote location. This is computed using # the name of the software, the version of the software, and the checksum. @@ -182,11 +193,15 @@ def download # is copied over as a raw file. # def deploy - if downloaded_file.end_with?(*ALL_EXTENSIONS) + if downloaded_file.end_with?(*ALL_EXTENSIONS) && extract_required? log.info(log_key) { "Extracting `#{safe_downloaded_file}' to `#{safe_project_dir}'" } extract else - log.info(log_key) { "`#{safe_downloaded_file}' is not an archive - copying to `#{safe_project_dir}'" } + if extract_required? + log.info(log_key) { "`#{safe_downloaded_file}' has extraction disabled - copying to `#{safe_project_dir}'" } + else + log.info(log_key) { "`#{safe_downloaded_file}' is not an archive - copying to `#{safe_project_dir}'" } + end if File.directory?(downloaded_file) # If the file itself was a directory, copy the whole thing over. This