Support patching using diffs on local filesystem
This commit is contained in:
parent
0a2cdea5fd
commit
fd5ed391be
@ -245,6 +245,7 @@ private
|
|||||||
|
|
||||||
def patch
|
def patch
|
||||||
return if patches.empty?
|
return if patches.empty?
|
||||||
|
|
||||||
ohai "Patching"
|
ohai "Patching"
|
||||||
if not patches.kind_of? Hash
|
if not patches.kind_of? Hash
|
||||||
# We assume -p0
|
# We assume -p0
|
||||||
@ -257,35 +258,37 @@ private
|
|||||||
n=0
|
n=0
|
||||||
patch_defns.each do |arg, urls|
|
patch_defns.each do |arg, urls|
|
||||||
urls.each do |url|
|
urls.each do |url|
|
||||||
dst='%03d-homebrew.patch' % n+=1
|
p = {:filename => '%03d-homebrew.patch' % n+=1, :compression => false}
|
||||||
compression = false
|
|
||||||
|
if url =~ %r[^\w+\://]
|
||||||
|
out_fn = p[:filename]
|
||||||
case url
|
case url
|
||||||
when /\.gz$/
|
when /\.gz$/
|
||||||
compression = :gzip
|
p[:compression] = :gzip
|
||||||
|
out_fn << '.gz'
|
||||||
when /\.bz2$/
|
when /\.bz2$/
|
||||||
compression = :bzip2
|
p[:compression] = :bzip2
|
||||||
|
out_fn << '.bz2'
|
||||||
end
|
end
|
||||||
patch_list << {
|
p[:curl_args] = [url, '-o', out_fn]
|
||||||
:curl_args => [url, '-o', dst],
|
else
|
||||||
:args => ["-#{arg}",'-i', dst],
|
# it's a file on the local filesystem
|
||||||
:filename => dst,
|
p[:filename] = url
|
||||||
:compression => compression
|
end
|
||||||
}
|
|
||||||
|
p[:args] = ["-#{arg}", '-i', p[:filename]]
|
||||||
|
|
||||||
|
patch_list << p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# downloading all at once is much more efficient, espeically for FTP
|
# downloading all at once is much more efficient, espeically for FTP
|
||||||
curl *(patch_list.collect { |p| p[:curl_args] }).flatten
|
curl *(patch_list.collect { |p| p[:curl_args] }).flatten
|
||||||
|
|
||||||
patch_list.each do |p|
|
patch_list.each do |p|
|
||||||
case p[:compression]
|
case p[:compression]
|
||||||
when :gzip
|
when :gzip then safe_system "gunzip", p[:filename]+'.gz'
|
||||||
# We rename with a .gz since gunzip -S '' deletes the file mysteriously
|
when :bzip2 then safe_system "bunzip2", p[:filename]+'.bz2'
|
||||||
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'}`
|
|
||||||
end
|
end
|
||||||
# -f means it doesn't prompt the user if there are errors, if just
|
# -f means it doesn't prompt the user if there are errors, if just
|
||||||
# exits with non-zero status
|
# exits with non-zero status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user