diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2024-12-18 13:20:18 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-12-18 13:20:18 -0300 |
commit | 31f0048d04178236bb9d4a838f718e8595237749 (patch) | |
tree | c7eab57a864c4b310cd7f2caff9e02cdff9bc2d8 | |
parent | aa4850fc2836b25c66738709336a3df07c9fc584 (diff) | |
download | luarocks-fix-unused-variables.tar.gz luarocks-fix-unused-variables.tar.bz2 luarocks-fix-unused-variables.zip |
fix: catch some unused variablesfix-unused-variables
Thanks to @euclidianAce's work at https://github.com/teal-language/tl/pull/869
-rw-r--r-- | src/luarocks/build/builtin.lua | 18 | ||||
-rw-r--r-- | src/luarocks/build/builtin.tl | 4 | ||||
-rw-r--r-- | src/luarocks/cmd/install.lua | 13 | ||||
-rw-r--r-- | src/luarocks/cmd/install.tl | 17 | ||||
-rw-r--r-- | src/luarocks/fetch.lua | 10 | ||||
-rw-r--r-- | src/luarocks/fetch.tl | 10 |
6 files changed, 43 insertions, 29 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 4e46db72..48b3c19d 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -134,7 +134,7 @@ end | |||
134 | function builtin.run(rockspec, no_install) | 134 | function builtin.run(rockspec, no_install) |
135 | local compile_object | 135 | local compile_object |
136 | local compile_library | 136 | local compile_library |
137 | local compile_static_library | 137 | |
138 | 138 | ||
139 | local build = rockspec.build | 139 | local build = rockspec.build |
140 | local variables = rockspec.variables | 140 | local variables = rockspec.variables |
@@ -247,13 +247,15 @@ function builtin.run(rockspec, no_install) | |||
247 | end | 247 | end |
248 | return execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) | 248 | return execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) |
249 | end | 249 | end |
250 | compile_static_library = function(library, objects, _libraries, _libdirs, _name) | 250 | |
251 | local ok = execute(variables.AR, "rc", library, _tl_table_unpack(objects)) | 251 | |
252 | if ok then | 252 | |
253 | ok = execute(variables.RANLIB, library) | 253 | |
254 | end | 254 | |
255 | return ok | 255 | |
256 | end | 256 | |
257 | |||
258 | |||
257 | end | 259 | end |
258 | 260 | ||
259 | local ok, err, errcode | 261 | local ok, err, errcode |
diff --git a/src/luarocks/build/builtin.tl b/src/luarocks/build/builtin.tl index b5a02f4c..c5529a74 100644 --- a/src/luarocks/build/builtin.tl +++ b/src/luarocks/build/builtin.tl | |||
@@ -134,7 +134,7 @@ end | |||
134 | function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, string | 134 | function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, string |
135 | local compile_object: function(string, string, {string}, {string}): boolean, string, string | 135 | local compile_object: function(string, string, {string}, {string}): boolean, string, string |
136 | local compile_library: function(string, {string}, {string}, {string}, string): boolean, string, string | 136 | local compile_library: function(string, {string}, {string}, {string}, string): boolean, string, string |
137 | local compile_static_library: function(string, {string}, {string}, {string}, string): boolean, string, string | 137 | --local compile_static_library: function(string, {string}, {string}, {string}, string): boolean, string, string |
138 | 138 | ||
139 | local build = rockspec.build as BuiltinBuild | 139 | local build = rockspec.build as BuiltinBuild |
140 | local variables = rockspec.variables | 140 | local variables = rockspec.variables |
@@ -247,6 +247,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, | |||
247 | end | 247 | end |
248 | return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, table.unpack(extras)) | 248 | return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, table.unpack(extras)) |
249 | end | 249 | end |
250 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | ||
250 | compile_static_library = function(library: string, objects: {string}, _libraries: {string}, _libdirs: {string}, _name: string): boolean, string, string | 251 | compile_static_library = function(library: string, objects: {string}, _libraries: {string}, _libdirs: {string}, _name: string): boolean, string, string |
251 | local ok = execute(variables.AR, "rc", library, table.unpack(objects)) | 252 | local ok = execute(variables.AR, "rc", library, table.unpack(objects)) |
252 | if ok then | 253 | if ok then |
@@ -254,6 +255,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, | |||
254 | end | 255 | end |
255 | return ok | 256 | return ok |
256 | end | 257 | end |
258 | ]] | ||
257 | end | 259 | end |
258 | 260 | ||
259 | local ok, err, errcode: boolean, string, string | 261 | local ok, err, errcode: boolean, string, string |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 28b1c888..3b5ea563 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
@@ -111,7 +111,7 @@ function install.install_binary_rock(rock_file, opts) | |||
111 | 111 | ||
112 | if opts.deps_mode ~= "none" then | 112 | if opts.deps_mode ~= "none" then |
113 | ok, err, errcode = deps.check_external_deps(rockspec, "install") | 113 | ok, err, errcode = deps.check_external_deps(rockspec, "install") |
114 | if err then return nil, err, errcode end | 114 | if not ok then return nil, err, errcode end |
115 | end | 115 | end |
116 | 116 | ||
117 | if deps_mode ~= "none" then | 117 | if deps_mode ~= "none" then |
@@ -119,11 +119,11 @@ function install.install_binary_rock(rock_file, opts) | |||
119 | "." or | 119 | "." or |
120 | install_dir | 120 | install_dir |
121 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", deps_mode, opts.verify, deplock_dir) | 121 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", deps_mode, opts.verify, deplock_dir) |
122 | if err then return nil, err, errcode end | 122 | if not ok then return nil, err, errcode end |
123 | end | 123 | end |
124 | 124 | ||
125 | ok, err = repo_writer.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode, namespace) | 125 | ok, err = repo_writer.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode, namespace) |
126 | if err then return nil, err end | 126 | if not ok then return nil, err end |
127 | 127 | ||
128 | util.remove_scheduled_function(rollback) | 128 | util.remove_scheduled_function(rollback) |
129 | rollback = util.schedule_function(function() | 129 | rollback = util.schedule_function(function() |
@@ -131,7 +131,7 @@ function install.install_binary_rock(rock_file, opts) | |||
131 | end) | 131 | end) |
132 | 132 | ||
133 | ok, err = repos.run_hook(rockspec, "post_install") | 133 | ok, err = repos.run_hook(rockspec, "post_install") |
134 | if err then return nil, err end | 134 | if not ok then return nil, err end |
135 | 135 | ||
136 | util.announce_install(rockspec) | 136 | util.announce_install(rockspec) |
137 | util.remove_scheduled_function(rollback) | 137 | util.remove_scheduled_function(rollback) |
@@ -157,7 +157,6 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
157 | 157 | ||
158 | local install_dir = path.install_dir(name, version) | 158 | local install_dir = path.install_dir(name, version) |
159 | 159 | ||
160 | local ok | ||
161 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | 160 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) |
162 | if not oks then return nil, err, errcode end | 161 | if not oks then return nil, err, errcode end |
163 | 162 | ||
@@ -170,8 +169,10 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
170 | local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) and | 169 | local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) and |
171 | "." or | 170 | "." or |
172 | install_dir | 171 | install_dir |
172 | |||
173 | local ok | ||
173 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) | 174 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) |
174 | if err then return nil, err, errcode end | 175 | if not ok then return nil, err, errcode end |
175 | 176 | ||
176 | util.printout() | 177 | util.printout() |
177 | util.printout("Successfully installed dependencies for " .. name .. " " .. version) | 178 | util.printout("Successfully installed dependencies for " .. name .. " " .. version) |
diff --git a/src/luarocks/cmd/install.tl b/src/luarocks/cmd/install.tl index 6c472768..95d42f8e 100644 --- a/src/luarocks/cmd/install.tl +++ b/src/luarocks/cmd/install.tl | |||
@@ -111,7 +111,7 @@ function install.install_binary_rock(rock_file: string, opts: IOpts): string, st | |||
111 | 111 | ||
112 | if opts.deps_mode ~= "none" then | 112 | if opts.deps_mode ~= "none" then |
113 | ok, err, errcode = deps.check_external_deps(rockspec, "install") | 113 | ok, err, errcode = deps.check_external_deps(rockspec, "install") |
114 | if err then return nil, err, errcode end | 114 | if not ok then return nil, err, errcode end |
115 | end | 115 | end |
116 | 116 | ||
117 | if deps_mode ~= "none" then | 117 | if deps_mode ~= "none" then |
@@ -119,11 +119,11 @@ function install.install_binary_rock(rock_file: string, opts: IOpts): string, st | |||
119 | and "." | 119 | and "." |
120 | or install_dir | 120 | or install_dir |
121 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", deps_mode, opts.verify, deplock_dir) | 121 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", deps_mode, opts.verify, deplock_dir) |
122 | if err then return nil, err, errcode end | 122 | if not ok then return nil, err, errcode end |
123 | end | 123 | end |
124 | 124 | ||
125 | ok, err = repo_writer.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode, namespace) | 125 | ok, err = repo_writer.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode, namespace) |
126 | if err then return nil, err end | 126 | if not ok then return nil, err end |
127 | 127 | ||
128 | util.remove_scheduled_function(rollback) | 128 | util.remove_scheduled_function(rollback) |
129 | rollback = util.schedule_function(function() | 129 | rollback = util.schedule_function(function() |
@@ -131,7 +131,7 @@ function install.install_binary_rock(rock_file: string, opts: IOpts): string, st | |||
131 | end) | 131 | end) |
132 | 132 | ||
133 | ok, err = repos.run_hook(rockspec, "post_install") | 133 | ok, err = repos.run_hook(rockspec, "post_install") |
134 | if err then return nil, err end | 134 | if not ok then return nil, err end |
135 | 135 | ||
136 | util.announce_install(rockspec) | 136 | util.announce_install(rockspec) |
137 | util.remove_scheduled_function(rollback) | 137 | util.remove_scheduled_function(rollback) |
@@ -157,7 +157,6 @@ function install.install_binary_rock_deps(rock_file: string, opts: IOpts): strin | |||
157 | 157 | ||
158 | local install_dir = path.install_dir(name, version) | 158 | local install_dir = path.install_dir(name, version) |
159 | 159 | ||
160 | local ok: boolean | ||
161 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | 160 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) |
162 | if not oks then return nil, err, errcode end | 161 | if not oks then return nil, err, errcode end |
163 | 162 | ||
@@ -168,10 +167,12 @@ function install.install_binary_rock_deps(rock_file: string, opts: IOpts): strin | |||
168 | end | 167 | end |
169 | 168 | ||
170 | local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) | 169 | local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) |
171 | and "." | 170 | and "." |
172 | or install_dir | 171 | or install_dir |
172 | |||
173 | local ok: boolean | ||
173 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) | 174 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) |
174 | if err then return nil, err, errcode end | 175 | if not ok then return nil, err, errcode end |
175 | 176 | ||
176 | util.printout() | 177 | util.printout() |
177 | util.printout("Successfully installed dependencies for " ..name.." "..version) | 178 | util.printout("Successfully installed dependencies for " ..name.." "..version) |
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index b563a7d8..be0cbcb7 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
@@ -60,12 +60,12 @@ function fetch.fetch_caching(url, mirroring) | |||
60 | return cachefile, nil, nil, true | 60 | return cachefile, nil, nil, true |
61 | end | 61 | end |
62 | 62 | ||
63 | local lock, errlock | 63 | local lock |
64 | if ok then | 64 | if ok then |
65 | lock, errlock = fs.lock_access(cache_dir) | 65 | lock = fs.lock_access(cache_dir) |
66 | end | 66 | end |
67 | 67 | ||
68 | if not (ok and lock) then | 68 | if not lock then |
69 | cfg.local_cache = fs.make_temp_dir("local_cache") | 69 | cfg.local_cache = fs.make_temp_dir("local_cache") |
70 | if not cfg.local_cache then | 70 | if not cfg.local_cache then |
71 | return nil, "Failed creating temporary local_cache directory" | 71 | return nil, "Failed creating temporary local_cache directory" |
@@ -78,6 +78,10 @@ function fetch.fetch_caching(url, mirroring) | |||
78 | lock = fs.lock_access(cache_dir) | 78 | lock = fs.lock_access(cache_dir) |
79 | end | 79 | end |
80 | 80 | ||
81 | if not lock then | ||
82 | return nil, "Failed locking cache directory" | ||
83 | end | ||
84 | |||
81 | local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) | 85 | local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) |
82 | if not file then | 86 | if not file then |
83 | fs.unlock_access(lock) | 87 | fs.unlock_access(lock) |
diff --git a/src/luarocks/fetch.tl b/src/luarocks/fetch.tl index 6859142f..2f81ac0c 100644 --- a/src/luarocks/fetch.tl +++ b/src/luarocks/fetch.tl | |||
@@ -60,12 +60,12 @@ function fetch.fetch_caching(url: string, mirroring?: string): string, string, s | |||
60 | return cachefile, nil, nil, true | 60 | return cachefile, nil, nil, true |
61 | end | 61 | end |
62 | 62 | ||
63 | local lock, errlock: Lock, string | 63 | local lock: Lock |
64 | if ok then | 64 | if ok then |
65 | lock, errlock = fs.lock_access(cache_dir) | 65 | lock = fs.lock_access(cache_dir) |
66 | end | 66 | end |
67 | 67 | ||
68 | if not (ok and lock) then | 68 | if not lock then |
69 | cfg.local_cache = fs.make_temp_dir("local_cache") | 69 | cfg.local_cache = fs.make_temp_dir("local_cache") |
70 | if not cfg.local_cache then | 70 | if not cfg.local_cache then |
71 | return nil, "Failed creating temporary local_cache directory" | 71 | return nil, "Failed creating temporary local_cache directory" |
@@ -78,6 +78,10 @@ function fetch.fetch_caching(url: string, mirroring?: string): string, string, s | |||
78 | lock = fs.lock_access(cache_dir) | 78 | lock = fs.lock_access(cache_dir) |
79 | end | 79 | end |
80 | 80 | ||
81 | if not lock then | ||
82 | return nil, "Failed locking cache directory" | ||
83 | end | ||
84 | |||
81 | local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) | 85 | local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) |
82 | if not file then | 86 | if not file then |
83 | fs.unlock_access(lock) | 87 | fs.unlock_access(lock) |