diff options
author | Marc Jakobi <mrcjkb89@outlook.com> | 2024-08-05 16:48:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-05 11:48:22 -0300 |
commit | d300c11c6acba4390fdde9030a45b0a31e7501d1 (patch) | |
tree | 4b3ff2e8023995d4328ce57700ecc764d3b45884 | |
parent | 7f85bbc8fc0fd03fb1e4b01d64f334cd8d865828 (diff) | |
download | luarocks-d300c11c6acba4390fdde9030a45b0a31e7501d1.tar.gz luarocks-d300c11c6acba4390fdde9030a45b0a31e7501d1.tar.bz2 luarocks-d300c11c6acba4390fdde9030a45b0a31e7501d1.zip |
fix: use luarocks.lock in cwd for non-binary rocks too (#1693)
-rw-r--r-- | src/luarocks/build.lua | 17 | ||||
-rw-r--r-- | src/luarocks/cmd/build.lua | 8 | ||||
-rw-r--r-- | src/luarocks/cmd/install.lua | 5 | ||||
-rw-r--r-- | src/luarocks/cmd/make.lua | 9 |
4 files changed, 28 insertions, 11 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index c6b3388b..56e5ebd4 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -104,7 +104,7 @@ local function check_macosx_deployment_target(rockspec) | |||
104 | return true | 104 | return true |
105 | end | 105 | end |
106 | 106 | ||
107 | local function process_dependencies(rockspec, opts) | 107 | local function process_dependencies(rockspec, opts, cwd) |
108 | if not opts.build_only_deps then | 108 | if not opts.build_only_deps then |
109 | local ok, err, errcode = deps.check_external_deps(rockspec, "build") | 109 | local ok, err, errcode = deps.check_external_deps(rockspec, "build") |
110 | if err then | 110 | if err then |
@@ -116,6 +116,8 @@ local function process_dependencies(rockspec, opts) | |||
116 | return true | 116 | return true |
117 | end | 117 | end |
118 | 118 | ||
119 | local deplock_dir = fs.exists(dir.path(cwd, "luarocks.lock")) and cwd or nil | ||
120 | |||
119 | if not opts.build_only_deps then | 121 | if not opts.build_only_deps then |
120 | if next(rockspec.build_dependencies) then | 122 | if next(rockspec.build_dependencies) then |
121 | 123 | ||
@@ -136,7 +138,7 @@ local function process_dependencies(rockspec, opts) | |||
136 | path.use_tree(cfg.root_dir) | 138 | path.use_tree(cfg.root_dir) |
137 | end | 139 | end |
138 | 140 | ||
139 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify) | 141 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify, deplock_dir) |
140 | 142 | ||
141 | path.add_to_package_paths(cfg.root_dir) | 143 | path.add_to_package_paths(cfg.root_dir) |
142 | 144 | ||
@@ -155,7 +157,7 @@ local function process_dependencies(rockspec, opts) | |||
155 | end | 157 | end |
156 | end | 158 | end |
157 | 159 | ||
158 | return deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify) | 160 | return deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) |
159 | end | 161 | end |
160 | 162 | ||
161 | local function fetch_and_change_to_source_dir(rockspec, opts) | 163 | local function fetch_and_change_to_source_dir(rockspec, opts) |
@@ -381,12 +383,17 @@ local function write_rock_dir_files(rockspec, opts) | |||
381 | end | 383 | end |
382 | 384 | ||
383 | --- Build and install a rock given a rockspec. | 385 | --- Build and install a rock given a rockspec. |
386 | -- @param rockspec rockspec: the rockspec to build | ||
384 | -- @param opts table: build options table | 387 | -- @param opts table: build options table |
388 | -- @param cwd string or nil: The current working directory | ||
385 | -- @return (string, string) or (nil, string, [string]): Name and version of | 389 | -- @return (string, string) or (nil, string, [string]): Name and version of |
386 | -- installed rock if succeeded or nil and an error message followed by an error code. | 390 | -- installed rock if succeeded or nil and an error message followed by an error code. |
387 | function build.build_rockspec(rockspec, opts) | 391 | function build.build_rockspec(rockspec, opts, cwd) |
388 | assert(rockspec:type() == "rockspec") | 392 | assert(rockspec:type() == "rockspec") |
389 | assert(opts:type() == "build.opts") | 393 | assert(opts:type() == "build.opts") |
394 | assert(type(cwd) == "string" or type(cwd) == nil) | ||
395 | |||
396 | cwd = cwd or dir.path(".") | ||
390 | 397 | ||
391 | if not rockspec.build then | 398 | if not rockspec.build then |
392 | if rockspec:format_is_at_least("3.0") then | 399 | if rockspec:format_is_at_least("3.0") then |
@@ -413,7 +420,7 @@ function build.build_rockspec(rockspec, opts) | |||
413 | deplocks.init(rockspec.name, ".") | 420 | deplocks.init(rockspec.name, ".") |
414 | end | 421 | end |
415 | 422 | ||
416 | ok, err = process_dependencies(rockspec, opts) | 423 | ok, err = process_dependencies(rockspec, opts, cwd) |
417 | if not ok then return nil, err end | 424 | if not ok then return nil, err end |
418 | 425 | ||
419 | local name, version = rockspec.name, rockspec.version | 426 | local name, version = rockspec.name, rockspec.version |
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index 32680411..8049596f 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
@@ -5,6 +5,7 @@ local cmd_build = {} | |||
5 | 5 | ||
6 | local pack = require("luarocks.pack") | 6 | local pack = require("luarocks.pack") |
7 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
8 | local dir = require("luarocks.dir") | ||
8 | local util = require("luarocks.util") | 9 | local util = require("luarocks.util") |
9 | local fetch = require("luarocks.fetch") | 10 | local fetch = require("luarocks.fetch") |
10 | local fs = require("luarocks.fs") | 11 | local fs = require("luarocks.fs") |
@@ -52,6 +53,8 @@ local function build_rock(rock_filename, opts) | |||
52 | assert(type(rock_filename) == "string") | 53 | assert(type(rock_filename) == "string") |
53 | assert(opts:type() == "build.opts") | 54 | assert(opts:type() == "build.opts") |
54 | 55 | ||
56 | local cwd = fs.absolute_name(dir.path(".")) | ||
57 | |||
55 | local ok, err, errcode | 58 | local ok, err, errcode |
56 | 59 | ||
57 | local unpack_dir | 60 | local unpack_dir |
@@ -71,7 +74,7 @@ local function build_rock(rock_filename, opts) | |||
71 | return nil, err, errcode | 74 | return nil, err, errcode |
72 | end | 75 | end |
73 | 76 | ||
74 | ok, err, errcode = build.build_rockspec(rockspec, opts) | 77 | ok, err, errcode = build.build_rockspec(rockspec, opts, cwd) |
75 | 78 | ||
76 | fs.pop_dir() | 79 | fs.pop_dir() |
77 | return ok, err, errcode | 80 | return ok, err, errcode |
@@ -103,11 +106,12 @@ local function do_build(name, namespace, version, opts) | |||
103 | end | 106 | end |
104 | 107 | ||
105 | if url:match("%.rockspec$") then | 108 | if url:match("%.rockspec$") then |
109 | local cwd = fs.absolute_name(dir.path(".")) | ||
106 | local rockspec, err = fetch.load_rockspec(url, nil, opts.verify) | 110 | local rockspec, err = fetch.load_rockspec(url, nil, opts.verify) |
107 | if not rockspec then | 111 | if not rockspec then |
108 | return nil, err | 112 | return nil, err |
109 | end | 113 | end |
110 | return build.build_rockspec(rockspec, opts) | 114 | return build.build_rockspec(rockspec, opts, cwd) |
111 | end | 115 | end |
112 | 116 | ||
113 | if url:match("%.src%.rock$") then | 117 | if url:match("%.src%.rock$") then |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 05e31fe7..c3b5f811 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
@@ -177,7 +177,10 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
177 | return nil, "Failed loading rockspec for installed package: "..err, errcode | 177 | return nil, "Failed loading rockspec for installed package: "..err, errcode |
178 | end | 178 | end |
179 | 179 | ||
180 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, install_dir) | 180 | local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) |
181 | and "." | ||
182 | or install_dir | ||
183 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) | ||
181 | if err then return nil, err, errcode end | 184 | if err then return nil, err, errcode end |
182 | 185 | ||
183 | util.printout() | 186 | util.printout() |
diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index 0b3db27c..ffec8c5d 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua | |||
@@ -13,6 +13,8 @@ local pack = require("luarocks.pack") | |||
13 | local remove = require("luarocks.remove") | 13 | local remove = require("luarocks.remove") |
14 | local deps = require("luarocks.deps") | 14 | local deps = require("luarocks.deps") |
15 | local writer = require("luarocks.manif.writer") | 15 | local writer = require("luarocks.manif.writer") |
16 | local dir = require("luarocks.dir") | ||
17 | local fs = require("luarocks.fs") | ||
16 | 18 | ||
17 | function make.cmd_options(parser) | 19 | function make.cmd_options(parser) |
18 | parser:flag("--no-install", "Do not install the rock.") | 20 | parser:flag("--no-install", "Do not install the rock.") |
@@ -88,6 +90,7 @@ function make.command(args) | |||
88 | return nil, "Invalid argument: 'make' takes a rockspec as a parameter. "..util.see_help("make") | 90 | return nil, "Invalid argument: 'make' takes a rockspec as a parameter. "..util.see_help("make") |
89 | end | 91 | end |
90 | 92 | ||
93 | local cwd = fs.absolute_name(dir.path(".")) | ||
91 | local rockspec, err, errcode = fetch.load_rockspec(rockspec_filename) | 94 | local rockspec, err, errcode = fetch.load_rockspec(rockspec_filename) |
92 | if not rockspec then | 95 | if not rockspec then |
93 | return nil, err | 96 | return nil, err |
@@ -115,17 +118,17 @@ function make.command(args) | |||
115 | end | 118 | end |
116 | 119 | ||
117 | if args.no_install then | 120 | if args.no_install then |
118 | return build.build_rockspec(rockspec, opts) | 121 | return build.build_rockspec(rockspec, opts, cwd) |
119 | elseif args.pack_binary_rock then | 122 | elseif args.pack_binary_rock then |
120 | return pack.pack_binary_rock(name, namespace, rockspec.version, args.sign, function() | 123 | return pack.pack_binary_rock(name, namespace, rockspec.version, args.sign, function() |
121 | local name, version = build.build_rockspec(rockspec, opts) -- luacheck: ignore 431 | 124 | local name, version = build.build_rockspec(rockspec, opts, cwd) -- luacheck: ignore 431 |
122 | if name and args.no_doc then | 125 | if name and args.no_doc then |
123 | util.remove_doc_dir(name, version) | 126 | util.remove_doc_dir(name, version) |
124 | end | 127 | end |
125 | return name, version | 128 | return name, version |
126 | end) | 129 | end) |
127 | else | 130 | else |
128 | local ok, err = build.build_rockspec(rockspec, opts) | 131 | local ok, err = build.build_rockspec(rockspec, opts, cwd) |
129 | if not ok then return nil, err end | 132 | if not ok then return nil, err end |
130 | local name, version = ok, err -- luacheck: ignore 421 | 133 | local name, version = ok, err -- luacheck: ignore 421 |
131 | 134 | ||