Skip to content

Commit 0819957

Browse files
Claude Devarennenebhale
authored andcommitted
download_tar improvements
A previous change to the download_tar method introduced a bug where the wrong decompression flag was applied to the tar command. This change fixes that bug, applying the appropriate gzip decompression flag. This change also adds support for bzip2 compressed tar files. [resolves #195]
1 parent 81f993c commit 0819957

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/java_buildpack/component/base_component.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def download_tar(version, uri, target_directory = @droplet.sandbox, name = @comp
122122
download(version, uri, name) do |file|
123123
with_timing "Expanding #{name} to #{target_directory.relative_path_from(@droplet.root)}" do
124124
FileUtils.mkdir_p target_directory
125-
shell "tar x#{gzipped?(file) ? 'x' : ''}f #{file.path} -C #{target_directory} --strip 1 2>&1"
125+
shell "tar x#{compression_flag(file)}f #{file.path} -C #{target_directory} --strip 1 2>&1"
126126
end
127127
end
128128
end
@@ -172,6 +172,20 @@ def gzipped?(file)
172172
file.path.end_with? '.gz'
173173
end
174174

175+
def bzipped?(file)
176+
file.path.end_with? '.bz2'
177+
end
178+
179+
def compression_flag(file)
180+
if gzipped?(file)
181+
'z'
182+
elsif bzipped?(file)
183+
'j'
184+
else
185+
''
186+
end
187+
end
188+
175189
end
176190

177191
end

0 commit comments

Comments
 (0)