Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add --nodeps flag. Closes #67.

  • Loading branch information...
commit 427969b562399683086e1b01596085a264932343 1 parent b3bcddf
@hishamhm hishamhm authored
View
34 src/luarocks/build.lua
@@ -111,9 +111,10 @@ end
-- @param minimal_mode boolean: true if there's no need to fetch,
-- unpack or change dir (this is used by "luarocks make"). Implies
-- need_to_fetch = false.
+-- @param no_deps boolean: true if dependency check needs to be skipped
-- @return boolean or (nil, string, [string]): True if succeeded or
-- nil and an error message followed by an error code.
-function build_rockspec(rockspec_file, need_to_fetch, minimal_mode)
+function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, no_deps)
assert(type(rockspec_file) == "string")
assert(type(need_to_fetch) == "boolean")
@@ -126,10 +127,15 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode)
return nil, "Rockspec error: build type not specified"
end
- local ok, err, errcode = deps.fulfill_dependencies(rockspec)
- if err then
- return nil, err, errcode
+ if no_deps then
+ util.printerr("Warning: skipping dependency checks.")
+ else
+ local ok, err, errcode = deps.fulfill_dependencies(rockspec)
+ if err then
+ return nil, err, errcode
+ end
end
+
ok, err, errcode = deps.check_external_deps(rockspec, "build")
if err then
return nil, err, errcode
@@ -267,7 +273,7 @@ end
-- false if the rockspec was obtained from inside a source rock.
-- @return boolean or (nil, string, [string]): True if build was successful,
-- or false and an error message and an optional error code.
-function build_rock(rock_file, need_to_fetch)
+function build_rock(rock_file, need_to_fetch, no_deps)
assert(type(rock_file) == "string")
assert(type(need_to_fetch) == "boolean")
@@ -277,24 +283,24 @@ function build_rock(rock_file, need_to_fetch)
end
local rockspec_file = path.rockspec_name_from_rock(rock_file)
fs.change_dir(unpack_dir)
- local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch)
+ local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch, false, no_deps)
fs.pop_dir()
return ok, err, errcode
end
-local function do_build(name, version)
+local function do_build(name, version, no_deps)
if name:match("%.rockspec$") then
- return build_rockspec(name, true)
+ return build_rockspec(name, true, false, no_deps)
elseif name:match("%.src%.rock$") then
- return build_rock(name, false)
+ return build_rock(name, false, no_deps)
elseif name:match("%.all%.rock$") then
local install = require("luarocks.install")
- return install.install_binary_rock(name)
+ return install.install_binary_rock(name, no_deps)
elseif name:match("%.rock$") then
- return build_rock(name, true)
+ return build_rock(name, true, no_deps)
elseif not name:match(dir.separator) then
local search = require("luarocks.search")
- return search.act_on_src_or_rockspec(run, name:lower(), version)
+ return search.act_on_src_or_rockspec(run, name:lower(), version, no_deps and "--nodeps")
end
return nil, "Don't know what to do with "..name
end
@@ -315,10 +321,10 @@ function run(...)
assert(type(version) == "string" or not version)
if flags["pack-binary-rock"] then
- return pack.pack_binary_rock(name, version, do_build, name, version)
+ return pack.pack_binary_rock(name, version, do_build, name, version, flags["nodeps"])
else
local ok, err = fs.check_command_permissions(flags)
if not ok then return nil, err end
- return do_build(name, version)
+ return do_build(name, version, flags["nodeps"])
end
end
View
19 src/luarocks/install.lua
@@ -23,9 +23,10 @@ or a filename of a locally available rock.
--- Install a binary rock.
-- @param rock_file string: local or remote filename of a rock.
+-- @param no_deps boolean: true if dependency check needs to be skipped
-- @return boolean or (nil, string, [string]): True if succeeded or
-- nil and an error message and an optional error code.
-function install_binary_rock(rock_file)
+function install_binary_rock(rock_file, no_deps)
assert(type(rock_file) == "string")
local name, version, arch = path.parse_name(rock_file)
@@ -53,8 +54,12 @@ function install_binary_rock(rock_file)
return nil, "Failed loading rockspec for installed package: "..err, errcode
end
- ok, err, errcode = deps.check_external_deps(rockspec, "install")
- if err then return nil, err, errcode end
+ if no_deps then
+ util.printerr("Warning: skipping dependency checks.")
+ else
+ ok, err, errcode = deps.check_external_deps(rockspec, "install")
+ if err then return nil, err, errcode end
+ end
-- For compatibility with .rock files built with LuaRocks 1
if not fs.exists(path.rock_manifest_file(name, version)) then
@@ -62,8 +67,10 @@ function install_binary_rock(rock_file)
if err then return nil, err end
end
- ok, err, errcode = deps.fulfill_dependencies(rockspec)
- if err then return nil, err, errcode end
+ if not no_deps then
+ ok, err, errcode = deps.fulfill_dependencies(rockspec)
+ if err then return nil, err, errcode end
+ end
local wrap_bin_scripts = true
if rockspec.deploy and rockspec.deploy.wrap_bin_scripts == false then
@@ -121,7 +128,7 @@ function run(...)
local build = require("luarocks.build")
return build.run(name, flags["local"] and "--local")
elseif name:match("%.rock$") then
- return install_binary_rock(name)
+ return install_binary_rock(name, flags["nodeps"])
else
local search = require("luarocks.search")
local results, err = search.find_suitable_rock(search.make_query(name:lower(), version))
View
2  src/luarocks/make.lua
@@ -62,7 +62,7 @@ function run(...)
if not rspec then
return nil, err
end
- return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true)
+ return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, flags["nodeps"])
else
local ok, err = fs.check_command_permissions(flags)
if not ok then return nil, err end
View
4 src/luarocks/search.lua
@@ -334,7 +334,7 @@ end
-- @param name string: A rock name
-- @param version string or nil: A version number may also be given.
-- @return The result of the action function, or nil and an error message.
-function act_on_src_or_rockspec(action, name, version)
+function act_on_src_or_rockspec(action, name, version, ...)
assert(type(action) == "function")
assert(type(name) == "string")
assert(type(version) == "string" or not version)
@@ -343,7 +343,7 @@ function act_on_src_or_rockspec(action, name, version)
query.arch = "src|rockspec"
local results, err = find_suitable_rock(query)
if type(results) == "string" then
- return action(results)
+ return action(results, ...)
elseif type(results) == "table" and next(results) then
util.printout("Multiple search results were returned.")
util.printout()
Please sign in to comment.
Something went wrong with that request. Please try again.