From 2d4a87e4765756a0e6df024ccd52972590f2923d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 18 Dec 2024 13:20:18 -0300 Subject: fix: catch some unused variables Thanks to @euclidianAce's work at https://github.com/teal-language/tl/pull/869 --- src/luarocks/build/builtin.lua | 18 ++++++++++-------- src/luarocks/build/builtin.tl | 4 +++- src/luarocks/cmd/install.lua | 13 +++++++------ src/luarocks/cmd/install.tl | 17 +++++++++-------- src/luarocks/fetch.lua | 10 +++++++--- src/luarocks/fetch.tl | 10 +++++++--- 6 files changed, 43 insertions(+), 29 deletions(-) (limited to 'src') 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 function builtin.run(rockspec, no_install) local compile_object local compile_library - local compile_static_library + local build = rockspec.build local variables = rockspec.variables @@ -247,13 +247,15 @@ function builtin.run(rockspec, no_install) end return execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) end - compile_static_library = function(library, objects, _libraries, _libdirs, _name) - local ok = execute(variables.AR, "rc", library, _tl_table_unpack(objects)) - if ok then - ok = execute(variables.RANLIB, library) - end - return ok - end + + + + + + + + + end 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 function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, string local compile_object: function(string, string, {string}, {string}): boolean, string, string local compile_library: function(string, {string}, {string}, {string}, string): boolean, string, string - local compile_static_library: function(string, {string}, {string}, {string}, string): boolean, string, string + --local compile_static_library: function(string, {string}, {string}, {string}, string): boolean, string, string local build = rockspec.build as BuiltinBuild local variables = rockspec.variables @@ -247,6 +247,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, end return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, table.unpack(extras)) end + --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. compile_static_library = function(library: string, objects: {string}, _libraries: {string}, _libdirs: {string}, _name: string): boolean, string, string local ok = execute(variables.AR, "rc", library, table.unpack(objects)) if ok then @@ -254,6 +255,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, end return ok end + ]] end 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) if opts.deps_mode ~= "none" then ok, err, errcode = deps.check_external_deps(rockspec, "install") - if err then return nil, err, errcode end + if not ok then return nil, err, errcode end end if deps_mode ~= "none" then @@ -119,11 +119,11 @@ function install.install_binary_rock(rock_file, opts) "." or install_dir ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", deps_mode, opts.verify, deplock_dir) - if err then return nil, err, errcode end + if not ok then return nil, err, errcode end end ok, err = repo_writer.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode, namespace) - if err then return nil, err end + if not ok then return nil, err end util.remove_scheduled_function(rollback) rollback = util.schedule_function(function() @@ -131,7 +131,7 @@ function install.install_binary_rock(rock_file, opts) end) ok, err = repos.run_hook(rockspec, "post_install") - if err then return nil, err end + if not ok then return nil, err end util.announce_install(rockspec) util.remove_scheduled_function(rollback) @@ -157,7 +157,6 @@ function install.install_binary_rock_deps(rock_file, opts) local install_dir = path.install_dir(name, version) - local ok local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) if not oks then return nil, err, errcode end @@ -170,8 +169,10 @@ function install.install_binary_rock_deps(rock_file, opts) local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) and "." or install_dir + + local ok ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) - if err then return nil, err, errcode end + if not ok then return nil, err, errcode end util.printout() 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 if opts.deps_mode ~= "none" then ok, err, errcode = deps.check_external_deps(rockspec, "install") - if err then return nil, err, errcode end + if not ok then return nil, err, errcode end end if deps_mode ~= "none" then @@ -119,11 +119,11 @@ function install.install_binary_rock(rock_file: string, opts: IOpts): string, st and "." or install_dir ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", deps_mode, opts.verify, deplock_dir) - if err then return nil, err, errcode end + if not ok then return nil, err, errcode end end ok, err = repo_writer.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode, namespace) - if err then return nil, err end + if not ok then return nil, err end util.remove_scheduled_function(rollback) rollback = util.schedule_function(function() @@ -131,7 +131,7 @@ function install.install_binary_rock(rock_file: string, opts: IOpts): string, st end) ok, err = repos.run_hook(rockspec, "post_install") - if err then return nil, err end + if not ok then return nil, err end util.announce_install(rockspec) util.remove_scheduled_function(rollback) @@ -157,7 +157,6 @@ function install.install_binary_rock_deps(rock_file: string, opts: IOpts): strin local install_dir = path.install_dir(name, version) - local ok: boolean local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) if not oks then return nil, err, errcode end @@ -168,10 +167,12 @@ function install.install_binary_rock_deps(rock_file: string, opts: IOpts): strin end local deplock_dir = fs.exists(dir.path(".", "luarocks.lock")) - and "." - or install_dir + and "." + or install_dir + + local ok: boolean ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify, deplock_dir) - if err then return nil, err, errcode end + if not ok then return nil, err, errcode end util.printout() 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) return cachefile, nil, nil, true end - local lock, errlock + local lock if ok then - lock, errlock = fs.lock_access(cache_dir) + lock = fs.lock_access(cache_dir) end - if not (ok and lock) then + if not lock then cfg.local_cache = fs.make_temp_dir("local_cache") if not cfg.local_cache then return nil, "Failed creating temporary local_cache directory" @@ -78,6 +78,10 @@ function fetch.fetch_caching(url, mirroring) lock = fs.lock_access(cache_dir) end + if not lock then + return nil, "Failed locking cache directory" + end + local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) if not file then 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 return cachefile, nil, nil, true end - local lock, errlock: Lock, string + local lock: Lock if ok then - lock, errlock = fs.lock_access(cache_dir) + lock = fs.lock_access(cache_dir) end - if not (ok and lock) then + if not lock then cfg.local_cache = fs.make_temp_dir("local_cache") if not cfg.local_cache then return nil, "Failed creating temporary local_cache directory" @@ -78,6 +78,10 @@ function fetch.fetch_caching(url: string, mirroring?: string): string, string, s lock = fs.lock_access(cache_dir) end + if not lock then + return nil, "Failed locking cache directory" + end + local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) if not file then fs.unlock_access(lock) -- cgit v1.2.3-55-g6feb