Skip to content

Commit d67b00c

Browse files
author
Przemysław Niekraś
committed
Allow optional extraction of archive in net_fetcher
1 parent ac881b7 commit d67b00c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ Here is an example:
151151
name "ruby"
152152
default_version "1.9.2-p290"
153153
source url: "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}.tar.gz",
154-
md5: "604da71839a6ae02b5b5b5e1b792d5eb"
154+
md5: "604da71839a6ae02b5b5b5e1b792d5eb",
155+
extract: false
155156

156157
dependency "zlib"
157158
dependency "ncurses"

lib/omnibus/fetchers/net_fetcher.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ def fetch_required?
4444
!(File.exist?(downloaded_file) && digest(downloaded_file, digest_type) == checksum)
4545
end
4646

47+
#
48+
# A extract is required if the downloaded_file is an archive and
49+
# source[:extract] is set to true if provided. Default: true
50+
#
51+
# @return [true, false]
52+
#
53+
def extract_required?
54+
return false unless downloaded_file.end_with?(*ALL_EXTENSIONS)
55+
!source.key?(:extract) ? true : source[:extract]
56+
end
4757
#
4858
# The version identifier for this remote location. This is computed using
4959
# the name of the software, the version of the software, and the checksum.
@@ -182,11 +192,15 @@ def download
182192
# is copied over as a raw file.
183193
#
184194
def deploy
185-
if downloaded_file.end_with?(*ALL_EXTENSIONS)
195+
if downloaded_file.end_with?(*ALL_EXTENSIONS) && extract_required?
186196
log.info(log_key) { "Extracting `#{safe_downloaded_file}' to `#{safe_project_dir}'" }
187197
extract
188198
else
189-
log.info(log_key) { "`#{safe_downloaded_file}' is not an archive - copying to `#{safe_project_dir}'" }
199+
if extract_required?
200+
log.info(log_key) { "`#{safe_downloaded_file}' has extraction disabled - copying to `#{safe_project_dir}'" }
201+
else
202+
log.info(log_key) { "`#{safe_downloaded_file}' is not an archive - copying to `#{safe_project_dir}'" }
203+
end
190204

191205
if File.directory?(downloaded_file)
192206
# If the file itself was a directory, copy the whole thing over. This

0 commit comments

Comments
 (0)