Skip to content

Commit 1384037

Browse files
committed
Tar flags
This change makes the flags in the untar command conditional on whether the binary is actually gzipped. On Linux (unlike OS X), using the z flag causes a failure if the file isn't actually gzipped.
1 parent ec765d1 commit 1384037

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/java_buildpack/component/base_component.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def download_tar(version, uri, target_directory = @droplet.sandbox, name = @comp
121121
download(version, uri, name) do |file|
122122
with_timing "Expanding #{name} to #{target_directory.relative_path_from(@droplet.root)}" do
123123
FileUtils.mkdir_p target_directory
124-
shell "tar xzf #{file.path} -C #{target_directory} --strip 1 2>&1"
124+
shell "tar x#{gzipped?(file) ? 'x' : ''}f #{file.path} -C #{target_directory} --strip 1 2>&1"
125125
end
126126
end
127127
end
@@ -165,6 +165,12 @@ def with_timing(caption)
165165
puts "(#{(Time.now - start_time).duration})"
166166
end
167167

168+
private
169+
170+
def gzipped?(file)
171+
file.path.end_with? '.gz'
172+
end
173+
168174
end
169175

170176
end

0 commit comments

Comments
 (0)