Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Fixes BZ 824312, back to native tar if not on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianofranz committed May 30, 2012
1 parent b77e6c9 commit c73a664
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions express/lib/rhc/targz.rb
Expand Up @@ -4,26 +4,36 @@
require 'archive/tar/minitar'
include Archive::Tar

TAR_BIN = 'tar'
TAR_BIN = '/usr/bin/gnutar' if File.executable?('/usr/bin/gnutar')

module RHC

module TarGz

def self.contains(filename, search)

return false if ! (File.file? filename and File.basename(filename).downcase =~ /.\.tar\.gz$/i)
search = /#{search.to_s}/ if ! search.is_a?(Regexp)

contains = false
begin
RHC::Vendor::Zlib::GzipReader.open(filename) do |gz|
Minitar::Reader.open gz do |tar|
tar.each_entry do |entry|
if entry.full_name =~ search
contains = true
if RHC::Helpers.windows? then
search = /#{search.to_s}/ if ! search.is_a?(Regexp)
begin
RHC::Vendor::Zlib::GzipReader.open(filename) do |gz|
Minitar::Reader.open gz do |tar|
tar.each_entry do |entry|
if entry.full_name =~ search
contains = true
end
end
end
end
rescue RHC::Vendor::Zlib::GzipFile::Error
return false
end
rescue RHC::Vendor::Zlib::GzipFile::Error
return false
else
`#{TAR_BIN} --wildcards -tf #{filename} '#{search.to_s}'`
contains = $?.exitstatus == 0
end
contains
end
Expand Down

0 comments on commit c73a664

Please sign in to comment.