diff options
| author | Jack Nagel | 2013-10-02 19:39:03 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-10-02 19:41:05 -0500 |
| commit | ed40bfe497760fb86905dd5915040f9755d21b7c (patch) | |
| tree | 877a84622d0f47120d08ed13a37b597f83c39eeb | |
| parent | c6274caa0b87d6c499bd2f5cf87ee91302a01e98 (diff) | |
| download | homebrew-ed40bfe497760fb86905dd5915040f9755d21b7c.tar.bz2 | |
Fix mktemp directory naming
| -rw-r--r-- | Library/Homebrew/extend/fileutils.rb | 10 |
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 |
