aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-05-07 19:12:38 -0300
committerHisham Muhammad <hisham@gobolinux.org>2012-05-07 19:12:38 -0300
commit427969b562399683086e1b01596085a264932343 (patch)
treeb1f526a63265f573377bacb3cec1128991b5d931 /src
parentb3bcddf8a5ebd671af37ced8a9abca7b62a43b76 (diff)
downloadluarocks-427969b562399683086e1b01596085a264932343.tar.gz
luarocks-427969b562399683086e1b01596085a264932343.tar.bz2
luarocks-427969b562399683086e1b01596085a264932343.zip
Add --nodeps flag. Closes #67.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/build.lua34
-rw-r--r--src/luarocks/install.lua19
-rw-r--r--src/luarocks/make.lua2
-rw-r--r--src/luarocks/search.lua4
4 files changed, 36 insertions, 23 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua
index 9a67f00b..42ae3fd7 100644
--- a/src/luarocks/build.lua
+++ b/src/luarocks/build.lua
@@ -111,9 +111,10 @@ end
111-- @param minimal_mode boolean: true if there's no need to fetch, 111-- @param minimal_mode boolean: true if there's no need to fetch,
112-- unpack or change dir (this is used by "luarocks make"). Implies 112-- unpack or change dir (this is used by "luarocks make"). Implies
113-- need_to_fetch = false. 113-- need_to_fetch = false.
114-- @param no_deps boolean: true if dependency check needs to be skipped
114-- @return boolean or (nil, string, [string]): True if succeeded or 115-- @return boolean or (nil, string, [string]): True if succeeded or
115-- nil and an error message followed by an error code. 116-- nil and an error message followed by an error code.
116function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) 117function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, no_deps)
117 assert(type(rockspec_file) == "string") 118 assert(type(rockspec_file) == "string")
118 assert(type(need_to_fetch) == "boolean") 119 assert(type(need_to_fetch) == "boolean")
119 120
@@ -126,10 +127,15 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode)
126 return nil, "Rockspec error: build type not specified" 127 return nil, "Rockspec error: build type not specified"
127 end 128 end
128 129
129 local ok, err, errcode = deps.fulfill_dependencies(rockspec) 130 if no_deps then
130 if err then 131 util.printerr("Warning: skipping dependency checks.")
131 return nil, err, errcode 132 else
133 local ok, err, errcode = deps.fulfill_dependencies(rockspec)
134 if err then
135 return nil, err, errcode
136 end
132 end 137 end
138
133 ok, err, errcode = deps.check_external_deps(rockspec, "build") 139 ok, err, errcode = deps.check_external_deps(rockspec, "build")
134 if err then 140 if err then
135 return nil, err, errcode 141 return nil, err, errcode
@@ -267,7 +273,7 @@ end
267-- false if the rockspec was obtained from inside a source rock. 273-- false if the rockspec was obtained from inside a source rock.
268-- @return boolean or (nil, string, [string]): True if build was successful, 274-- @return boolean or (nil, string, [string]): True if build was successful,
269-- or false and an error message and an optional error code. 275-- or false and an error message and an optional error code.
270function build_rock(rock_file, need_to_fetch) 276function build_rock(rock_file, need_to_fetch, no_deps)
271 assert(type(rock_file) == "string") 277 assert(type(rock_file) == "string")
272 assert(type(need_to_fetch) == "boolean") 278 assert(type(need_to_fetch) == "boolean")
273 279
@@ -277,24 +283,24 @@ function build_rock(rock_file, need_to_fetch)
277 end 283 end
278 local rockspec_file = path.rockspec_name_from_rock(rock_file) 284 local rockspec_file = path.rockspec_name_from_rock(rock_file)
279 fs.change_dir(unpack_dir) 285 fs.change_dir(unpack_dir)
280 local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch) 286 local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch, false, no_deps)
281 fs.pop_dir() 287 fs.pop_dir()
282 return ok, err, errcode 288 return ok, err, errcode
283end 289end
284 290
285local function do_build(name, version) 291local function do_build(name, version, no_deps)
286 if name:match("%.rockspec$") then 292 if name:match("%.rockspec$") then
287 return build_rockspec(name, true) 293 return build_rockspec(name, true, false, no_deps)
288 elseif name:match("%.src%.rock$") then 294 elseif name:match("%.src%.rock$") then
289 return build_rock(name, false) 295 return build_rock(name, false, no_deps)
290 elseif name:match("%.all%.rock$") then 296 elseif name:match("%.all%.rock$") then
291 local install = require("luarocks.install") 297 local install = require("luarocks.install")
292 return install.install_binary_rock(name) 298 return install.install_binary_rock(name, no_deps)
293 elseif name:match("%.rock$") then 299 elseif name:match("%.rock$") then
294 return build_rock(name, true) 300 return build_rock(name, true, no_deps)
295 elseif not name:match(dir.separator) then 301 elseif not name:match(dir.separator) then
296 local search = require("luarocks.search") 302 local search = require("luarocks.search")
297 return search.act_on_src_or_rockspec(run, name:lower(), version) 303 return search.act_on_src_or_rockspec(run, name:lower(), version, no_deps and "--nodeps")
298 end 304 end
299 return nil, "Don't know what to do with "..name 305 return nil, "Don't know what to do with "..name
300end 306end
@@ -315,10 +321,10 @@ function run(...)
315 assert(type(version) == "string" or not version) 321 assert(type(version) == "string" or not version)
316 322
317 if flags["pack-binary-rock"] then 323 if flags["pack-binary-rock"] then
318 return pack.pack_binary_rock(name, version, do_build, name, version) 324 return pack.pack_binary_rock(name, version, do_build, name, version, flags["nodeps"])
319 else 325 else
320 local ok, err = fs.check_command_permissions(flags) 326 local ok, err = fs.check_command_permissions(flags)
321 if not ok then return nil, err end 327 if not ok then return nil, err end
322 return do_build(name, version) 328 return do_build(name, version, flags["nodeps"])
323 end 329 end
324end 330end
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua
index 0ae163f8..0a779b86 100644
--- a/src/luarocks/install.lua
+++ b/src/luarocks/install.lua
@@ -23,9 +23,10 @@ or a filename of a locally available rock.
23 23
24--- Install a binary rock. 24--- Install a binary rock.
25-- @param rock_file string: local or remote filename of a rock. 25-- @param rock_file string: local or remote filename of a rock.
26-- @param no_deps boolean: true if dependency check needs to be skipped
26-- @return boolean or (nil, string, [string]): True if succeeded or 27-- @return boolean or (nil, string, [string]): True if succeeded or
27-- nil and an error message and an optional error code. 28-- nil and an error message and an optional error code.
28function install_binary_rock(rock_file) 29function install_binary_rock(rock_file, no_deps)
29 assert(type(rock_file) == "string") 30 assert(type(rock_file) == "string")
30 31
31 local name, version, arch = path.parse_name(rock_file) 32 local name, version, arch = path.parse_name(rock_file)
@@ -53,8 +54,12 @@ function install_binary_rock(rock_file)
53 return nil, "Failed loading rockspec for installed package: "..err, errcode 54 return nil, "Failed loading rockspec for installed package: "..err, errcode
54 end 55 end
55 56
56 ok, err, errcode = deps.check_external_deps(rockspec, "install") 57 if no_deps then
57 if err then return nil, err, errcode end 58 util.printerr("Warning: skipping dependency checks.")
59 else
60 ok, err, errcode = deps.check_external_deps(rockspec, "install")
61 if err then return nil, err, errcode end
62 end
58 63
59 -- For compatibility with .rock files built with LuaRocks 1 64 -- For compatibility with .rock files built with LuaRocks 1
60 if not fs.exists(path.rock_manifest_file(name, version)) then 65 if not fs.exists(path.rock_manifest_file(name, version)) then
@@ -62,8 +67,10 @@ function install_binary_rock(rock_file)
62 if err then return nil, err end 67 if err then return nil, err end
63 end 68 end
64 69
65 ok, err, errcode = deps.fulfill_dependencies(rockspec) 70 if not no_deps then
66 if err then return nil, err, errcode end 71 ok, err, errcode = deps.fulfill_dependencies(rockspec)
72 if err then return nil, err, errcode end
73 end
67 74
68 local wrap_bin_scripts = true 75 local wrap_bin_scripts = true
69 if rockspec.deploy and rockspec.deploy.wrap_bin_scripts == false then 76 if rockspec.deploy and rockspec.deploy.wrap_bin_scripts == false then
@@ -121,7 +128,7 @@ function run(...)
121 local build = require("luarocks.build") 128 local build = require("luarocks.build")
122 return build.run(name, flags["local"] and "--local") 129 return build.run(name, flags["local"] and "--local")
123 elseif name:match("%.rock$") then 130 elseif name:match("%.rock$") then
124 return install_binary_rock(name) 131 return install_binary_rock(name, flags["nodeps"])
125 else 132 else
126 local search = require("luarocks.search") 133 local search = require("luarocks.search")
127 local results, err = search.find_suitable_rock(search.make_query(name:lower(), version)) 134 local results, err = search.find_suitable_rock(search.make_query(name:lower(), version))
diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua
index fe8f7645..769db2f7 100644
--- a/src/luarocks/make.lua
+++ b/src/luarocks/make.lua
@@ -62,7 +62,7 @@ function run(...)
62 if not rspec then 62 if not rspec then
63 return nil, err 63 return nil, err
64 end 64 end
65 return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true) 65 return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, flags["nodeps"])
66 else 66 else
67 local ok, err = fs.check_command_permissions(flags) 67 local ok, err = fs.check_command_permissions(flags)
68 if not ok then return nil, err end 68 if not ok then return nil, err end
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua
index 9671d15b..5df2bd38 100644
--- a/src/luarocks/search.lua
+++ b/src/luarocks/search.lua
@@ -334,7 +334,7 @@ end
334-- @param name string: A rock name 334-- @param name string: A rock name
335-- @param version string or nil: A version number may also be given. 335-- @param version string or nil: A version number may also be given.
336-- @return The result of the action function, or nil and an error message. 336-- @return The result of the action function, or nil and an error message.
337function act_on_src_or_rockspec(action, name, version) 337function act_on_src_or_rockspec(action, name, version, ...)
338 assert(type(action) == "function") 338 assert(type(action) == "function")
339 assert(type(name) == "string") 339 assert(type(name) == "string")
340 assert(type(version) == "string" or not version) 340 assert(type(version) == "string" or not version)
@@ -343,7 +343,7 @@ function act_on_src_or_rockspec(action, name, version)
343 query.arch = "src|rockspec" 343 query.arch = "src|rockspec"
344 local results, err = find_suitable_rock(query) 344 local results, err = find_suitable_rock(query)
345 if type(results) == "string" then 345 if type(results) == "string" then
346 return action(results) 346 return action(results, ...)
347 elseif type(results) == "table" and next(results) then 347 elseif type(results) == "table" and next(results) then
348 util.printout("Multiple search results were returned.") 348 util.printout("Multiple search results were returned.")
349 util.printout() 349 util.printout()