aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/tools/patch.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua
index 44d00ef8..f1a14578 100644
--- a/src/luarocks/tools/patch.lua
+++ b/src/luarocks/tools/patch.lua
@@ -84,6 +84,13 @@ local function file_copy(src, dest)
84 return true 84 return true
85end 85end
86 86
87local function overwrite_file(filename)
88 local fh = io.open(filename, "w+")
89 if not fh then return false end
90 fh:close()
91 return true
92end
93
87local function string_as_file(s) 94local function string_as_file(s)
88 return { 95 return {
89 at = 0, 96 at = 0,
@@ -565,7 +572,12 @@ function patch.apply_patch(the_patch, strip)
565 local all_ok = true 572 local all_ok = true
566 local total = #the_patch.source 573 local total = #the_patch.source
567 for fileno, filename in ipairs(the_patch.source) do 574 for fileno, filename in ipairs(the_patch.source) do
568 filename = strip_dirs(filename, strip) 575 if filename == "/dev/null" then
576 filename = strip_dirs(the_patch.target[fileno], strip)
577 assert(overwrite_file(filename))
578 else
579 filename = strip_dirs(filename, strip)
580 end
569 local continue 581 local continue
570 local f2patch = filename 582 local f2patch = filename
571 if not exists(f2patch) then 583 if not exists(f2patch) then