aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2011-08-26 14:30:27 -0500
committerJack Nagel2011-12-09 16:16:46 -0600
commitc729fb2d325b224c49750400fe8936d7cfe2d93b (patch)
tree1aedb6014ea63afe8afd5f9cb0be570c39fc7869 /Library
parentbd71558188e0e0821e62e28b196e5195bbf3bdc6 (diff)
downloadhomebrew-c729fb2d325b224c49750400fe8936d7cfe2d93b.tar.bz2
Add support for xz-compressed tarballs
Rationale: some software (e.g. GNU Coreutils, GnuTLS 3.x), have started distributing _only_ xz-compressed tarballs. There is no system XZ utility provided by OS X, but it is necessary so that we can continue to provide formulae for this software. If XZUtils isn't installed, we abort and prompt the user to `brew install xz`. The `xz` command itself doesn't do any untarring, so we write the decompressed archive to stdout and pipe it to tar.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb8
-rw-r--r--Library/Homebrew/extend/pathname.rb4
-rw-r--r--Library/Homebrew/test/test_bucket.rb2
3 files changed, 10 insertions, 4 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 58221c28f..625dbaf9a 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -76,8 +76,8 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
# Use more than 4 characters to not clash with magicbytes
magic_bytes = "____pkg"
else
- # get the first four bytes
- File.open(@tarball_path) { |f| magic_bytes = f.read(4) }
+ # get the first six bytes
+ File.open(@tarball_path) { |f| magic_bytes = f.read(6) }
end
# magic numbers stolen from /usr/share/file/magic/
@@ -89,6 +89,10 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
# TODO check if it's really a tar archive
safe_system '/usr/bin/tar', 'xf', @tarball_path
chdir
+ when /^\xFD7zXZ\x00/ # xz compressed
+ raise "You must install XZutils: brew install xz" unless system "/usr/bin/which -s xz"
+ safe_system "xz -dc #{@tarball_path} | /usr/bin/tar xf -"
+ chdir
when '____pkg'
safe_system '/usr/sbin/pkgutil', '--expand', @tarball_path, File.basename(@url)
chdir
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 65d34d450..018547ff8 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -62,9 +62,9 @@ class Pathname
return dst
end
- # extended to support the double extensions .tar.gz and .tar.bz2
+ # extended to support the double extensions .tar.gz, .tar.bz2, and .tar.xz
def extname
- /(\.tar\.(gz|bz2))$/.match to_s
+ /(\.tar\.(gz|bz2|xz))$/.match to_s
return $1 if $1
return File.extname(to_s)
end
diff --git a/Library/Homebrew/test/test_bucket.rb b/Library/Homebrew/test/test_bucket.rb
index 010c06761..f328dacca 100644
--- a/Library/Homebrew/test/test_bucket.rb
+++ b/Library/Homebrew/test/test_bucket.rb
@@ -32,8 +32,10 @@ class BeerTasting < Test::Unit::TestCase
assert_nothing_raised do
MockFormula.new 'test-0.1.tar.gz'
MockFormula.new 'test-0.1.tar.bz2'
+ MockFormula.new 'test-0.1.tar.xz'
MockFormula.new 'test-0.1.tgz'
MockFormula.new 'test-0.1.bgz'
+ MockFormula.new 'test-0.1.txz'
MockFormula.new 'test-0.1.zip'
end
end