diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-07-17 18:14:18 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-07-17 18:14:18 -0300 |
| commit | c0d6ec090bcfbdc3895809fd914b3724e2742782 (patch) | |
| tree | e476871ac478e28a8b90852839128343314d2abc /src | |
| parent | 0b4543697adf8de2fab1d33d5993746de1ab7708 (diff) | |
| download | luarocks-c0d6ec090bcfbdc3895809fd914b3724e2742782.tar.gz luarocks-c0d6ec090bcfbdc3895809fd914b3724e2742782.tar.bz2 luarocks-c0d6ec090bcfbdc3895809fd914b3724e2742782.zip | |
Fix: make sure that --keep flag forwards correctly from 'install' to 'build'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/install.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 32 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index e1b44203..c181d612 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
| @@ -134,7 +134,7 @@ function run(...) | |||
| 134 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 134 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
| 135 | util.printout("Using "..name.."... switching to 'build' mode") | 135 | util.printout("Using "..name.."... switching to 'build' mode") |
| 136 | local build = require("luarocks.build") | 136 | local build = require("luarocks.build") |
| 137 | return build.run(name, deps.get_deps_mode(flags), flags["local"] and "--local") | 137 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode")) |
| 138 | elseif name:match("%.rock$") then | 138 | elseif name:match("%.rock$") then |
| 139 | ok, err = install_binary_rock(name, deps.get_deps_mode(flags)) | 139 | ok, err = install_binary_rock(name, deps.get_deps_mode(flags)) |
| 140 | if not ok then return nil, err end | 140 | if not ok then return nil, err end |
| @@ -152,7 +152,7 @@ function run(...) | |||
| 152 | elseif type(results) == "string" then | 152 | elseif type(results) == "string" then |
| 153 | local url = results | 153 | local url = results |
| 154 | util.printout("Installing "..url.."...") | 154 | util.printout("Installing "..url.."...") |
| 155 | return run(url) | 155 | return run(url, util.forward_flags(flags)) |
| 156 | else | 156 | else |
| 157 | util.printout() | 157 | util.printout() |
| 158 | util.printerr("Could not determine which rock to install.") | 158 | util.printerr("Could not determine which rock to install.") |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index b2428f62..ba20acfa 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -85,6 +85,38 @@ function parse_flags(...) | |||
| 85 | return flags, unpack(args) | 85 | return flags, unpack(args) |
| 86 | end | 86 | end |
| 87 | 87 | ||
| 88 | --- Build a sequence of flags for forwarding from one command to | ||
| 89 | -- another (for example, from "install" to "build"). | ||
| 90 | -- @param flags table: A table of parsed flags | ||
| 91 | -- @param ... string...: A variable number of flags to be checked | ||
| 92 | -- in the flags table. If no flags are passed as varargs, the | ||
| 93 | -- entire flags table is forwarded. | ||
| 94 | -- @return string... A variable number of strings | ||
| 95 | function forward_flags(flags, ...) | ||
| 96 | assert(type(flags) == "table") | ||
| 97 | local out = {} | ||
| 98 | local filter = select('#', ...) | ||
| 99 | local function add_flag(flagname) | ||
| 100 | if flags[flagname] then | ||
| 101 | if flags[flagname] == true then | ||
| 102 | table.insert(out, "--"..flagname) | ||
| 103 | else | ||
| 104 | table.insert(out, "--"..flagname.."="..flags[flagname]) | ||
| 105 | end | ||
| 106 | end | ||
| 107 | end | ||
| 108 | if filter > 0 then | ||
| 109 | for i = 1, filter do | ||
| 110 | add_flag(select(i, ...)) | ||
| 111 | end | ||
| 112 | else | ||
| 113 | for flagname, _ in pairs(flags) do | ||
| 114 | add_flag(flagname) | ||
| 115 | end | ||
| 116 | end | ||
| 117 | return unpack(out) | ||
| 118 | end | ||
| 119 | |||
| 88 | --- Merges contents of src on top of dst's contents. | 120 | --- Merges contents of src on top of dst's contents. |
| 89 | -- @param dst Destination table, which will receive src's contents. | 121 | -- @param dst Destination table, which will receive src's contents. |
| 90 | -- @param src Table which provides new contents to dst. | 122 | -- @param src Table which provides new contents to dst. |
