From: Tobias Ulmer Date: Mon, 18 Nov 2013 13:25:10 +0000 (+0100) Subject: Move patch() into files plugin and convert to argv X-Git-Tag: e2factory-2.3.15rc1~378 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=fcd56a706c0f8e526b46d425477cceae48dcc2f5;p=e2factory.git Move patch() into files plugin and convert to argv Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index c900ce1..469fddc 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -1746,15 +1746,6 @@ function e2lib.mkdir_recursive(path, mode) return true end ---- call the patch command --- @param dir string: the directory name --- @param flags string: flags to pass to mkdir --- @return bool --- @return the last line ouf captured output -function e2lib.patch(args) - return e2lib.call_tool("patch", args) -end - --- Call a tool. -- @param tool Tool name as registered in the tools library (string). -- @param args Arguments as a string. Caller is responsible for safe escaping. diff --git a/plugins/files.lua b/plugins/files.lua index d307ede..3178c48 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -314,6 +314,14 @@ local function gen_unpack_command(physpath, virtpath, destdir) return tool, toolargv end +--- Call the patch command +-- @param argv Vector of arguments supplied to patch tool. +-- @return True on success, false on error. +-- @return Error object on failure. +local function patch_tool(argv) + return e2lib.call_tool_argv("patch", argv) +end + --- Prepare a files source. -- @param info The info table. -- @param sourcename The source name (string) @@ -392,9 +400,8 @@ function files.prepare_source(info, sourcename, sourceset, buildpath) if not path then return false, e:append(re) end - local args = string.format("-p '%s' -d '%s' -i '%s'", file.patch, - symlink, path) - rc, re = e2lib.patch(args) + local argv = { "-p", file.patch, "-d", symlink, "-i", path } + rc, re = patch_tool(argv) if not rc then e:append("applying patch: \"%s:%s\"", file.server, file.location) return false, e:cat(re)