aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2013-06-06 17:01:43 -0700
committerAdam Vandenberg2013-06-07 20:57:59 -0700
commitd5c331c0720f825737d43cd8d70ebe03d6ef8518 (patch)
tree3227ffea0a66e54fae036ee1970bcd7e731ec6d4 /Library
parent8507ba3da4977bca46dda69cbf3e1451f3bce09f (diff)
downloadbrew-d5c331c0720f825737d43cd8d70ebe03d6ef8518.tar.bz2
CurlDownloadStrategy no longer uses `?` in downloaded filenames
Strip `?` and trailing characters from URL extensions and basenames. This makes some install methods cleaner, and prevents staging of files with `?` in the name, as that is a weird character. Affects 2 formulae in core (though potentially externals will need to be fixed.)
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 87f8f85e1..e2ce122de 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -42,7 +42,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
super
if name.to_s.empty? || name == '__UNKNOWN__'
- @tarball_path = Pathname.new("#{HOMEBREW_CACHE}/#{File.basename(@url)}")
+ @tarball_path = Pathname.new("#{HOMEBREW_CACHE}/#{basename_without_params}")
else
@tarball_path = Pathname.new("#{HOMEBREW_CACHE}/#{name}-#{package.version}#{ext}")
end
@@ -118,7 +118,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
with_system_path { safe_system "#{xzpath} -dc \"#{@tarball_path}\" | tar xf -" }
chdir
when :pkg
- safe_system '/usr/sbin/pkgutil', '--expand', @tarball_path, File.basename(@url)
+ safe_system '/usr/sbin/pkgutil', '--expand', @tarball_path, basename_without_params
chdir
when :rar
raise "You must install unrar: brew install unrar" unless which "unrar"
@@ -134,7 +134,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
# behaviour, just open an issue at github
# We also do this for jar files, as they are in fact zip files, but
# we don't want to unzip them
- FileUtils.cp @tarball_path, File.basename(@url)
+ FileUtils.cp @tarball_path, basename_without_params
end
end
@@ -152,6 +152,11 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
end
end
+ def basename_without_params
+ # Strip any ?thing=wad out of .c?thing=wad style extensions
+ File.basename(@url)[/[^?]+/]
+ end
+
def ext
# GitHub uses odd URLs for zip files, so check for those
rx=%r[https?://(www\.)?github\.com/.*/(zip|tar)ball/]
@@ -162,7 +167,8 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
'.tgz'
end
else
- Pathname.new(@url).extname
+ # Strip any ?thing=wad out of .c?thing=wad style extensions
+ (Pathname.new(@url).extname)[/[^?]+/]
end
end
end
@@ -193,15 +199,15 @@ end
# Useful for installing jars.
class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
def stage
- FileUtils.cp @tarball_path, File.basename(@url)
+ FileUtils.cp @tarball_path, basename_without_params
end
end
# Normal strategy tries to untar as well
class GzipOnlyDownloadStrategy < CurlDownloadStrategy
def stage
- FileUtils.mv @tarball_path, File.basename(@url)
- with_system_path { safe_system 'gunzip', '-f', File.basename(@url) }
+ FileUtils.mv @tarball_path, basename
+ with_system_path { safe_system 'gunzip', '-f', basename_without_params }
end
end