aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Shulgin <izarizar@mail.ru>2017-10-04 10:52:22 -0700
committerHisham Muhammad <hisham@gobolinux.org>2017-10-04 14:52:22 -0300
commit18ed68c91646c20ae9bc21d0fe378898caf3c506 (patch)
tree702b22d18f7de273521d9588ca2bbb1eff3b3409
parent815cf73c266e371fe2eaa81787572564736e2b02 (diff)
downloadluarocks-18ed68c91646c20ae9bc21d0fe378898caf3c506.tar.gz
luarocks-18ed68c91646c20ae9bc21d0fe378898caf3c506.tar.bz2
luarocks-18ed68c91646c20ae9bc21d0fe378898caf3c506.zip
Patches now can create a new files from /dev/null (#692)
-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