Skip to content

Commit

Permalink
add support for .tar.xz files
Browse files Browse the repository at this point in the history
  • Loading branch information
James FitzGibbon committed Sep 6, 2013
1 parent 0ffb466 commit 62ec360
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/omnibus/fetchers/net_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def extract_cmd
"7z.exe x #{project_file} -o#{source_dir} -r -y"
elsif project_file.end_with?(".zip")
"unzip #{project_file} -d #{source_dir}"
elsif project_file.end_with?(".xz") || project_file.end_with?(".txz")
"xz -dc #{project_file} | ( cd #{source_dir} && tar -xf - )"
else
#if we don't recognize the extension, simply copy over the file
Proc.new do
Expand Down
25 changes: 25 additions & 0 deletions spec/fetchers/net_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,29 @@
net_fetcher = Omnibus::NetFetcher.new software_mock
net_fetcher.extract_cmd.should == 'unzip file.zip -d /tmp/out'
end
it "should download and uncompress .tar.xz files" do
software_mock = stub 'software'
software_mock.stub :project_file => 'file.tar.xz',
:name => 'file',
:source => '/tmp/out',
:checksum => 'abc123',
:source_uri => 'http://example.com/file.tar.xz',
:source_dir => '/tmp/out',
:project_dir => '/tmp/project'
net_fetcher = Omnibus::NetFetcher.new software_mock
net_fetcher.extract_cmd.should == 'xz -dc file.tar.xz | ( cd /tmp/out && tar -xf - )'
end
it "should download and uncompress .txz files" do
software_mock = stub 'software'
software_mock.stub :project_file => 'file.txz',
:name => 'file',
:source => '/tmp/out',
:checksum => 'abc123',
:source_uri => 'http://example.com/file.txz',
:source_dir => '/tmp/out',
:project_dir => '/tmp/project'
net_fetcher = Omnibus::NetFetcher.new software_mock
net_fetcher.extract_cmd.should == 'xz -dc file.txz | ( cd /tmp/out && tar -xf - )'
end
end

0 comments on commit 62ec360

Please sign in to comment.