aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/fileutils.rb
diff options
context:
space:
mode:
authorJack Nagel2013-10-02 19:39:03 -0500
committerJack Nagel2013-10-02 19:41:05 -0500
commit02a0e4e2e08e66ccb28fdb84b45edd9612fdc2dd (patch)
tree2246b343290e975a846df4983f391c982600aebe /Library/Homebrew/extend/fileutils.rb
parent57560c03e64cb11a33287b3194b0c35cbea6e159 (diff)
downloadbrew-02a0e4e2e08e66ccb28fdb84b45edd9612fdc2dd.tar.bz2
Fix mktemp directory naming
Diffstat (limited to 'Library/Homebrew/extend/fileutils.rb')
-rw-r--r--Library/Homebrew/extend/fileutils.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index 6c2529c50..79a962fcb 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -6,6 +6,14 @@ module FileUtils extend self
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory.
def mktemp
+ # Prefer download_name if it is defined, for two reasons:
+ # - The name attribute may be nil for resources that represent primary
+ # formula downloads, in which case we want to use just the owner name.
+ # - For resources that have a name defined, we want to use "owner--name"
+ # instead of just "name"
+ prefix = download_name if respond_to?(:download_name)
+ prefix ||= name
+
# I used /tmp rather than `mktemp -td` because that generates a directory
# name with exotic characters like + in it, and these break badly written
# scripts that don't escape strings before trying to regexp them :(
@@ -14,7 +22,7 @@ module FileUtils extend self
# /tmp volume to the other volume. So we let the user override the tmp
# prefix if they need to.
tmp = ENV['HOMEBREW_TEMP'].chuzzle || '/tmp'
- tempd = with_system_path { `mktemp -d #{tmp}/#{name}-XXXX` }.chuzzle
+ tempd = with_system_path { `mktemp -d #{tmp}/#{prefix}-XXXX` }.chuzzle
raise "Failed to create sandbox" if tempd.nil?
prevd = pwd
cd tempd