Merge pull request #1279 from MikeMcQuaid/use-tar-xz
Use BSD tar's libarchive LZMA support if available
This commit is contained in:
commit
527a62b64b
@ -61,6 +61,10 @@ class DependencyCollector
|
||||
parse_spec(spec, Array(tags))
|
||||
end
|
||||
|
||||
def self.tar_needs_xz_dependency?
|
||||
!new.xz_dep([]).nil?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_spec(spec, tags)
|
||||
@ -113,7 +117,7 @@ class DependencyCollector
|
||||
when :osxfuse then OsxfuseRequirement.new(tags)
|
||||
when :perl then PerlRequirement.new(tags)
|
||||
when :tuntap then TuntapRequirement.new(tags)
|
||||
when :ant then ant_dep(spec, tags)
|
||||
when :ant then ant_dep(tags)
|
||||
when :emacs then EmacsRequirement.new(tags)
|
||||
# Tiger's ld is too old to properly link some software
|
||||
when :ld64 then LD64Dependency.new if MacOS.version < :leopard
|
||||
@ -134,8 +138,12 @@ class DependencyCollector
|
||||
spec.new(tags)
|
||||
end
|
||||
|
||||
def ant_dep(spec, tags)
|
||||
Dependency.new(spec.to_s, tags)
|
||||
def ant_dep(tags)
|
||||
Dependency.new("ant", tags)
|
||||
end
|
||||
|
||||
def xz_dep(tags)
|
||||
Dependency.new("xz", tags)
|
||||
end
|
||||
|
||||
def resource_dep(spec, tags)
|
||||
@ -164,7 +172,7 @@ class DependencyCollector
|
||||
|
||||
def parse_url_spec(url, tags)
|
||||
case File.extname(url)
|
||||
when ".xz" then Dependency.new("xz", tags)
|
||||
when ".xz" then xz_dep(tags)
|
||||
when ".lha", ".lzh" then Dependency.new("lha", tags)
|
||||
when ".lz" then Dependency.new("lzip", tags)
|
||||
when ".rar" then Dependency.new("unrar", tags)
|
||||
|
@ -88,6 +88,10 @@ class DevelopmentTools
|
||||
@clang_version = @clang_build_version = nil
|
||||
@non_apple_gcc_version = {}
|
||||
end
|
||||
|
||||
def tar_supports_xz?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -222,7 +222,7 @@ end
|
||||
|
||||
class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
||||
def stage
|
||||
case cached_location.compression_type
|
||||
case type = cached_location.compression_type
|
||||
when :zip
|
||||
with_system_path { quiet_safe_system "unzip", "-qq", cached_location }
|
||||
chdir
|
||||
@ -230,19 +230,23 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
||||
with_system_path { buffered_write("gunzip") }
|
||||
when :bzip2_only
|
||||
with_system_path { buffered_write("bunzip2") }
|
||||
when :gzip, :bzip2, :compress, :tar
|
||||
when :gzip, :bzip2, :xz, :compress, :tar
|
||||
tar_flags = "x"
|
||||
# Older versions of tar require an explicit format flag
|
||||
if cached_location.compression_type == :gzip
|
||||
if type == :gzip
|
||||
tar_flags << "z"
|
||||
elsif cached_location.compression_type == :bzip2
|
||||
elsif type == :bzip2
|
||||
tar_flags << "j"
|
||||
elsif type == :xz
|
||||
tar_flags << "J"
|
||||
end
|
||||
tar_flags << "f"
|
||||
with_system_path { safe_system "tar", tar_flags, cached_location }
|
||||
chdir
|
||||
when :xz
|
||||
with_system_path { pipe_to_tar(xzpath) }
|
||||
with_system_path do
|
||||
if type == :xz && DependencyCollector.tar_needs_xz_dependency?
|
||||
pipe_to_tar(xzpath)
|
||||
else
|
||||
safe_system "tar", tar_flags, cached_location
|
||||
end
|
||||
end
|
||||
chdir
|
||||
when :lzip
|
||||
with_system_path { pipe_to_tar(lzippath) }
|
||||
|
@ -1,6 +1,11 @@
|
||||
class DependencyCollector
|
||||
def ant_dep(spec, tags)
|
||||
def ant_dep(tags)
|
||||
return if MacOS.version < :mavericks
|
||||
Dependency.new(spec.to_s, tags)
|
||||
Dependency.new("ant", tags)
|
||||
end
|
||||
|
||||
def xz_dep(tags)
|
||||
return if MacOS.version >= :lion
|
||||
Dependency.new("xz", tags)
|
||||
end
|
||||
end
|
||||
|
@ -76,5 +76,9 @@ class DevelopmentTools
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def tar_supports_xz?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -114,12 +114,6 @@ class DependencyCollectorTests < Homebrew::TestCase
|
||||
assert_nil @d.add(resource)
|
||||
end
|
||||
|
||||
def test_resource_dep_xz_url
|
||||
resource = Resource.new
|
||||
resource.url("http://example.com/foo.tar.xz")
|
||||
assert_equal Dependency.new("xz", [:build]), @d.add(resource)
|
||||
end
|
||||
|
||||
def test_resource_dep_lz_url
|
||||
resource = Resource.new
|
||||
resource.url("http://example.com/foo.lz")
|
||||
|
@ -14,6 +14,11 @@ class OSMacDependencyCollectorTests < Homebrew::TestCase
|
||||
DependencyCollector.clear_cache
|
||||
end
|
||||
|
||||
def test_tar_needs_xz_dependency
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.7"))
|
||||
refute DependencyCollector.tar_needs_xz_dependency?
|
||||
end
|
||||
|
||||
def test_ld64_dep_pre_leopard
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
|
||||
assert_equal LD64Dependency.new, @d.build(:ld64)
|
||||
@ -35,4 +40,18 @@ class OSMacDependencyCollectorTests < Homebrew::TestCase
|
||||
@d.add ant: :build
|
||||
assert_nil find_dependency("ant")
|
||||
end
|
||||
|
||||
def test_resource_dep_xz_url_pre_lion
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.6"))
|
||||
resource = Resource.new
|
||||
resource.url("http://example.com/foo.tar.xz")
|
||||
assert_equal Dependency.new("xz", [:build]), @d.add(resource)
|
||||
end
|
||||
|
||||
def test_resource_dep_xz_lion_or_newer
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.7"))
|
||||
resource = Resource.new
|
||||
resource.url("http://example.com/foo.tar.xz")
|
||||
assert_nil @d.add(resource)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user