Commit 234dacc2 authored by Daniel Helgenberger's avatar Daniel Helgenberger Committed by Ed Reel

Fixes #3205: only expand real archives (#3206)

Uses regex on File.basename(). Using File.extname() on some
files (ie, archive.tar.gz) can lead to unexpected behavior.
parent 0573e463
...@@ -444,22 +444,17 @@ def unpack (meta) ...@@ -444,22 +444,17 @@ def unpack (meta)
extract_dir = "#{meta[:filename]}.dir" extract_dir = "#{meta[:filename]}.dir"
target_dir = nil target_dir = nil
Dir.chdir CREW_BREW_DIR do Dir.chdir CREW_BREW_DIR do
puts "Unpacking archive, this may take awhile..."
Dir.mkdir("#{extract_dir}") unless Dir.exist?("#{extract_dir}") Dir.mkdir("#{extract_dir}") unless Dir.exist?("#{extract_dir}")
case File.extname meta[:filename] case File.basename meta[:filename]
when '.zip' when /\.zip$/i
if @opt_verbose then puts "Unpacking archive using 'unzip', this may take awhile..."
system "unzip", "-v", "-d", "#{extract_dir}", meta[:filename] _verbopt = @opt_verbose ? 'v' : 'qq'
else system "unzip", _verbopt, "-d", "#{extract_dir}", meta[:filename]
system "unzip", "-qq", "-d", "#{extract_dir}", meta[:filename] when /\.(tar(\.(gz|bz2|xz))?|tgz|tbz)$/i
end puts "Unpacking archive using 'tar', this may take awhile..."
else _verbopt = @opt_verbose ? 'v' : ''
if @opt_verbose then system "tar", "x#{_verbopt}f", meta[:filename], "-C", "#{extract_dir}"
system "tar", "xvf", meta[:filename], "-C", "#{extract_dir}" end
else
system "tar", "xf", meta[:filename], "-C", "#{extract_dir}"
end
end
if meta[:source] == true if meta[:source] == true
# Check the number of directories in the archive # Check the number of directories in the archive
entries = Dir["#{extract_dir}/*"] entries = Dir["#{extract_dir}/*"]
......
# Defines common constants used in different parts of crew # Defines common constants used in different parts of crew
CREW_VERSION = '1.2.1' CREW_VERSION = '1.2.2'
ARCH = `uname -m`.strip ARCH = `uname -m`.strip
ARCH_LIB = if ARCH == 'x86_64' then 'lib64' else 'lib' end ARCH_LIB = if ARCH == 'x86_64' then 'lib64' else 'lib' end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment