diff options
| author | Max Howell | 2009-09-15 20:07:40 +0100 |
|---|---|---|
| committer | Max Howell | 2009-09-16 14:49:05 +0100 |
| commit | 7240098105fd150d0d28dcf06b79cbfea10d993d (patch) | |
| tree | 83f366f26fa5fd0f5e8d3ef67f839acf1ebc8626 /Library | |
| parent | cfb6505767f591a1580c7ed4ce75acdc00ad8491 (diff) | |
| download | homebrew-7240098105fd150d0d28dcf06b79cbfea10d993d.tar.bz2 | |
Support patching using diffs on local filesystem
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 192620798..a5a69b496 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -245,6 +245,7 @@ private def patch return if patches.empty? + ohai "Patching" if not patches.kind_of? Hash # We assume -p0 @@ -257,35 +258,37 @@ private n=0 patch_defns.each do |arg, urls| urls.each do |url| - dst='%03d-homebrew.patch' % n+=1 - compression = false - case url - when /\.gz$/ - compression = :gzip - when /\.bz2$/ - compression = :bzip2 + p = {:filename => '%03d-homebrew.patch' % n+=1, :compression => false} + + if url =~ %r[^\w+\://] + out_fn = p[:filename] + case url + when /\.gz$/ + p[:compression] = :gzip + out_fn << '.gz' + when /\.bz2$/ + p[:compression] = :bzip2 + out_fn << '.bz2' + end + p[:curl_args] = [url, '-o', out_fn] + else + # it's a file on the local filesystem + p[:filename] = url end - patch_list << { - :curl_args => [url, '-o', dst], - :args => ["-#{arg}",'-i', dst], - :filename => dst, - :compression => compression - } + + p[:args] = ["-#{arg}", '-i', p[:filename]] + + patch_list << p end end + # downloading all at once is much more efficient, espeically for FTP curl *(patch_list.collect { |p| p[:curl_args] }).flatten + patch_list.each do |p| case p[:compression] - when :gzip - # We rename with a .gz since gunzip -S '' deletes the file mysteriously - FileUtils.mv p[:filename], p[:filename] + '.gz' - `gunzip #{p[:filename] + '.gz'}` - when :bzip2 - # We rename with a .bz2 since bunzip2 can't guess the original filename - # without it - FileUtils.mv p[:filename], p[:filename] + '.bz2' - `bunzip2 #{p[:filename] + '.bz2'}` + when :gzip then safe_system "gunzip", p[:filename]+'.gz' + when :bzip2 then safe_system "bunzip2", p[:filename]+'.bz2' end # -f means it doesn't prompt the user if there are errors, if just # exits with non-zero status |
