Skip to content

Commit a20d6ba

Browse files
author
Przemysław Niekraś
committed
Allow optional extraction of archive in net_fetcher
Signed-off-by: Przemysław Niekraś <[email protected]>
1 parent ac881b7 commit a20d6ba

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-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: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ 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
57+
4758
#
4859
# The version identifier for this remote location. This is computed using
4960
# the name of the software, the version of the software, and the checksum.
@@ -182,11 +193,15 @@ def download
182193
# is copied over as a raw file.
183194
#
184195
def deploy
185-
if downloaded_file.end_with?(*ALL_EXTENSIONS)
196+
if downloaded_file.end_with?(*ALL_EXTENSIONS) && extract_required?
186197
log.info(log_key) { "Extracting `#{safe_downloaded_file}' to `#{safe_project_dir}'" }
187198
extract
188199
else
189-
log.info(log_key) { "`#{safe_downloaded_file}' is not an archive - copying to `#{safe_project_dir}'" }
200+
if extract_required?
201+
log.info(log_key) { "`#{safe_downloaded_file}' has extraction disabled - copying to `#{safe_project_dir}'" }
202+
else
203+
log.info(log_key) { "`#{safe_downloaded_file}' is not an archive - copying to `#{safe_project_dir}'" }
204+
end
190205

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

0 commit comments

Comments
 (0)