diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-09-05 00:15:17 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-09-05 00:15:17 -0300 |
commit | a1ec2d939bf10e6429f46b8b74c95927dcc3a6dc (patch) | |
tree | 9cfe1b2dcd26d23130964a9f176aa2b4d919fbbf | |
parent | 785c3366f946dbb7235c46adf83aa5e7de85a3ab (diff) | |
download | luarocks-a1ec2d939bf10e6429f46b8b74c95927dcc3a6dc.tar.gz luarocks-a1ec2d939bf10e6429f46b8b74c95927dcc3a6dc.tar.bz2 luarocks-a1ec2d939bf10e6429f46b8b74c95927dcc3a6dc.zip |
Add support for working on future extensions of the rockspec format; start with support for disabling the bin/ wrappers.
-rw-r--r-- | src/luarocks/build.lua | 2 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 6 | ||||
-rw-r--r-- | src/luarocks/install.lua | 7 | ||||
-rw-r--r-- | src/luarocks/rep.lua | 18 | ||||
-rw-r--r-- | src/luarocks/type_check.lua | 17 |
5 files changed, 46 insertions, 4 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index dec61999..69f46fcc 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -225,7 +225,7 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) | |||
225 | ok, err = manif.make_rock_manifest(name, version) | 225 | ok, err = manif.make_rock_manifest(name, version) |
226 | if err then return nil, err end | 226 | if err then return nil, err end |
227 | 227 | ||
228 | ok, err = rep.deploy_files(name, version) | 228 | ok, err = rep.deploy_files(name, version, rep.should_wrap_bin_scripts(rockspec)) |
229 | if err then return nil, err end | 229 | if err then return nil, err end |
230 | 230 | ||
231 | util.remove_scheduled_function(rollback) | 231 | util.remove_scheduled_function(rollback) |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 02793c5a..dfb28e99 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -79,6 +79,12 @@ function run_command(...) | |||
79 | end | 79 | end |
80 | end | 80 | end |
81 | command = command:gsub("-", "_") | 81 | command = command:gsub("-", "_") |
82 | |||
83 | if flags["extensions"] then | ||
84 | cfg.use_extensions = true | ||
85 | local type_check = require("luarocks.type_check") | ||
86 | type_check.load_extensions() | ||
87 | end | ||
82 | 88 | ||
83 | if cfg.local_by_default then | 89 | if cfg.local_by_default then |
84 | flags["local"] = true | 90 | flags["local"] = true |
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index e99b4ce0..c42542c9 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -65,7 +65,12 @@ function install_binary_rock(rock_file) | |||
65 | ok, err, errcode = deps.fulfill_dependencies(rockspec) | 65 | ok, err, errcode = deps.fulfill_dependencies(rockspec) |
66 | if err then return nil, err, errcode end | 66 | if err then return nil, err, errcode end |
67 | 67 | ||
68 | ok, err = rep.deploy_files(name, version) | 68 | local wrap_bin_scripts = true |
69 | if rockspec.deploy and rockspec.deploy.wrap_bin_scripts == false then | ||
70 | wrap_bin_scripts = false | ||
71 | end | ||
72 | |||
73 | ok, err = rep.deploy_files(name, version, rep.should_wrap_bin_scripts(rockspec)) | ||
69 | if err then return nil, err end | 74 | if err then return nil, err end |
70 | 75 | ||
71 | util.remove_scheduled_function(rollback) | 76 | util.remove_scheduled_function(rollback) |
diff --git a/src/luarocks/rep.lua b/src/luarocks/rep.lua index f8f1f694..5bb5fed5 100644 --- a/src/luarocks/rep.lua +++ b/src/luarocks/rep.lua | |||
@@ -194,9 +194,22 @@ local function resolve_conflict(target, deploy_dir, name, version) | |||
194 | end | 194 | end |
195 | end | 195 | end |
196 | 196 | ||
197 | function deploy_files(name, version) | 197 | function should_wrap_bin_scripts(rockspec) |
198 | assert(type(rockspec) == "table") | ||
199 | |||
200 | if cfg.wrap_bin_scripts ~= nil then | ||
201 | return cfg.wrap_bin_scripts | ||
202 | end | ||
203 | if rockspec.deploy and rockspec.deploy.wrap_bin_scripts == false then | ||
204 | return false | ||
205 | end | ||
206 | return true | ||
207 | end | ||
208 | |||
209 | function deploy_files(name, version, wrap_bin_scripts) | ||
198 | assert(type(name) == "string") | 210 | assert(type(name) == "string") |
199 | assert(type(version) == "string") | 211 | assert(type(version) == "string") |
212 | assert(type(wrap_bin_scripts) == "boolean") | ||
200 | 213 | ||
201 | local function deploy_file_tree(file_tree, source_dir, deploy_dir, move_fn) | 214 | local function deploy_file_tree(file_tree, source_dir, deploy_dir, move_fn) |
202 | if not move_fn then | 215 | if not move_fn then |
@@ -230,7 +243,8 @@ function deploy_files(name, version) | |||
230 | 243 | ||
231 | local ok, err = true | 244 | local ok, err = true |
232 | if rock_manifest.bin then | 245 | if rock_manifest.bin then |
233 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir(name, version), cfg.deploy_bin_dir, install_binary) | 246 | local move_bin_fn = wrap_bin_scripts and install_binary or fs.copy_binary |
247 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir(name, version), cfg.deploy_bin_dir, move_bin_fn) | ||
234 | end | 248 | end |
235 | if ok and rock_manifest.lua then | 249 | if ok and rock_manifest.lua then |
236 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir(name, version), cfg.deploy_lua_dir) | 250 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir(name, version), cfg.deploy_lua_dir) |
diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua index 0e4a73af..4c554809 100644 --- a/src/luarocks/type_check.lua +++ b/src/luarocks/type_check.lua | |||
@@ -4,6 +4,8 @@ | |||
4 | -- loaded by LuaRocks. | 4 | -- loaded by LuaRocks. |
5 | module("luarocks.type_check", package.seeall) | 5 | module("luarocks.type_check", package.seeall) |
6 | 6 | ||
7 | local cfg = require("luarocks.cfg") | ||
8 | |||
7 | rockspec_format = "1.0" | 9 | rockspec_format = "1.0" |
8 | 10 | ||
9 | rockspec_types = { | 11 | rockspec_types = { |
@@ -72,6 +74,17 @@ rockspec_types = { | |||
72 | } | 74 | } |
73 | } | 75 | } |
74 | 76 | ||
77 | function load_extensions() | ||
78 | rockspec_format = "1.1" | ||
79 | rockspec_types.deploy = { | ||
80 | wrap_bin_scripts = true, | ||
81 | } | ||
82 | end | ||
83 | |||
84 | if cfg.use_extensions then | ||
85 | load_extensions() | ||
86 | end | ||
87 | |||
75 | rockspec_types.build.platforms.ANY = rockspec_types.build | 88 | rockspec_types.build.platforms.ANY = rockspec_types.build |
76 | rockspec_types.dependencies.platforms.ANY = rockspec_types.dependencies | 89 | rockspec_types.dependencies.platforms.ANY = rockspec_types.dependencies |
77 | rockspec_types.external_dependencies.platforms.ANY = rockspec_types.external_dependencies | 90 | rockspec_types.external_dependencies.platforms.ANY = rockspec_types.external_dependencies |
@@ -218,6 +231,10 @@ end | |||
218 | -- succeeded, or nil and an error message if it failed. | 231 | -- succeeded, or nil and an error message if it failed. |
219 | function type_check_rockspec(rockspec) | 232 | function type_check_rockspec(rockspec) |
220 | assert(type(rockspec) == "table") | 233 | assert(type(rockspec) == "table") |
234 | if rockspec.rockspec_format then | ||
235 | -- relies on global state | ||
236 | load_extensions() | ||
237 | end | ||
221 | return type_check_table(rockspec, rockspec_types, "") | 238 | return type_check_table(rockspec, rockspec_types, "") |
222 | end | 239 | end |
223 | 240 | ||