diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-08-27 17:01:20 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
| commit | deb9cadc7012262eb0eaf4cb58b654b62106d6de (patch) | |
| tree | f8172b4d596fb0199492471f793f42322f5e8031 /src | |
| parent | 86092dbfd41c3b0cb173bc932aefb8e0473742dc (diff) | |
| download | luarocks-deb9cadc7012262eb0eaf4cb58b654b62106d6de.tar.gz luarocks-deb9cadc7012262eb0eaf4cb58b654b62106d6de.tar.bz2 luarocks-deb9cadc7012262eb0eaf4cb58b654b62106d6de.zip | |
Teal: fixed all warnings
Also addressed/removed all `--!` comments except for the ones that should stay.
Diffstat (limited to 'src')
77 files changed, 464 insertions, 369 deletions
diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua index 862a08a8..d6572dae 100644 --- a/src/luarocks/admin/cmd/add.lua +++ b/src/luarocks/admin/cmd/add.lua | |||
| @@ -73,7 +73,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do | |||
| 73 | return nil, "No files found" | 73 | return nil, "No files found" |
| 74 | end | 74 | end |
| 75 | 75 | ||
| 76 | local ok, err = fs.change_dir(local_cache) | 76 | ok, err = fs.change_dir(local_cache) |
| 77 | if not ok then return nil, err end | 77 | if not ok then return nil, err end |
| 78 | 78 | ||
| 79 | util.printout("Updating manifest...") | 79 | util.printout("Updating manifest...") |
diff --git a/src/luarocks/admin/cmd/add.tl b/src/luarocks/admin/cmd/add.tl index e544be96..56be7044 100644 --- a/src/luarocks/admin/cmd/add.tl +++ b/src/luarocks/admin/cmd/add.tl | |||
| @@ -73,7 +73,7 @@ local function add_files_to_server(refresh: boolean, rockfiles: {string}, server | |||
| 73 | return nil, "No files found" | 73 | return nil, "No files found" |
| 74 | end | 74 | end |
| 75 | 75 | ||
| 76 | local ok, err = fs.change_dir(local_cache) | 76 | ok, err = fs.change_dir(local_cache) |
| 77 | if not ok then return nil, err end | 77 | if not ok then return nil, err end |
| 78 | 78 | ||
| 79 | util.printout("Updating manifest...") | 79 | util.printout("Updating manifest...") |
| @@ -125,7 +125,7 @@ local function add_files_to_server(refresh: boolean, rockfiles: {string}, server | |||
| 125 | return fs.execute(cmd) | 125 | return fs.execute(cmd) |
| 126 | end | 126 | end |
| 127 | 127 | ||
| 128 | function add.command(args: Args): boolean, string, string --! | 128 | function add.command(args: Args): boolean, string, string |
| 129 | local server, server_table, err = cache.get_upload_server(args.add_server or args.server) | 129 | local server, server_table, err = cache.get_upload_server(args.add_server or args.server) |
| 130 | if not server then return nil, err end | 130 | if not server then return nil, err end |
| 131 | return add_files_to_server(not args.no_refresh, args.rocks, server, server_table, args.index) | 131 | return add_files_to_server(not args.no_refresh, args.rocks, server, server_table, args.index) |
diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua index 08e90bbc..35b7a3e9 100644 --- a/src/luarocks/admin/cmd/refresh_cache.lua +++ b/src/luarocks/admin/cmd/refresh_cache.lua | |||
| @@ -24,8 +24,9 @@ function refresh_cache.command(args) | |||
| 24 | if not server then return nil, err end | 24 | if not server then return nil, err end |
| 25 | local download_url = cache.get_server_urls(server, upload_server) | 25 | local download_url = cache.get_server_urls(server, upload_server) |
| 26 | 26 | ||
| 27 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) | 27 | local local_cache |
| 28 | if not ok then | 28 | local_cache, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) |
| 29 | if not local_cache then | ||
| 29 | return nil, err | 30 | return nil, err |
| 30 | else | 31 | else |
| 31 | return true | 32 | return true |
diff --git a/src/luarocks/admin/cmd/refresh_cache.tl b/src/luarocks/admin/cmd/refresh_cache.tl index 07480159..b0be9984 100644 --- a/src/luarocks/admin/cmd/refresh_cache.tl +++ b/src/luarocks/admin/cmd/refresh_cache.tl | |||
| @@ -24,8 +24,9 @@ function refresh_cache.command(args: Args): boolean, string | |||
| 24 | if not server then return nil, err end | 24 | if not server then return nil, err end |
| 25 | local download_url = cache.get_server_urls(server, upload_server) | 25 | local download_url = cache.get_server_urls(server, upload_server) |
| 26 | 26 | ||
| 27 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) | 27 | local local_cache: string |
| 28 | if not ok then | 28 | local_cache, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) |
| 29 | if not local_cache then | ||
| 29 | return nil, err | 30 | return nil, err |
| 30 | else | 31 | else |
| 31 | return true | 32 | return true |
diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.lua index eee761fa..bef6ea0d 100644 --- a/src/luarocks/admin/cmd/remove.lua +++ b/src/luarocks/admin/cmd/remove.lua | |||
| @@ -30,11 +30,11 @@ end | |||
| 30 | 30 | ||
| 31 | local function remove_files_from_server(refresh, rockfiles, server, upload_server) | 31 | local function remove_files_from_server(refresh, rockfiles, server, upload_server) |
| 32 | 32 | ||
| 33 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 33 | local download_url, _login_url = cache.get_server_urls(server, upload_server) |
| 34 | local at = fs.current_dir() | 34 | local at = fs.current_dir() |
| 35 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 35 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
| 36 | 36 | ||
| 37 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) | 37 | local local_cache, protocol, server_path, user, _password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
| 38 | if not local_cache then | 38 | if not local_cache then |
| 39 | return nil, protocol | 39 | return nil, protocol |
| 40 | end | 40 | end |
| @@ -58,7 +58,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
| 58 | return nil, "No files removed." | 58 | return nil, "No files removed." |
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | local ok, err = fs.change_dir(local_cache) | 61 | ok, err = fs.change_dir(local_cache) |
| 62 | if not ok then return nil, err end | 62 | if not ok then return nil, err end |
| 63 | 63 | ||
| 64 | util.printout("Updating manifest...") | 64 | util.printout("Updating manifest...") |
diff --git a/src/luarocks/admin/cmd/remove.tl b/src/luarocks/admin/cmd/remove.tl index 64b96ef2..0b1aa65b 100644 --- a/src/luarocks/admin/cmd/remove.tl +++ b/src/luarocks/admin/cmd/remove.tl | |||
| @@ -30,11 +30,11 @@ end | |||
| 30 | 30 | ||
| 31 | local function remove_files_from_server(refresh: boolean, rockfiles: {string}, server: string, upload_server: {string: string}): boolean, string | 31 | local function remove_files_from_server(refresh: boolean, rockfiles: {string}, server: string, upload_server: {string: string}): boolean, string |
| 32 | 32 | ||
| 33 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 33 | local download_url, _login_url = cache.get_server_urls(server, upload_server) |
| 34 | local at = fs.current_dir() | 34 | local at = fs.current_dir() |
| 35 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 35 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
| 36 | 36 | ||
| 37 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) | 37 | local local_cache, protocol, server_path, user, _password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
| 38 | if not local_cache then | 38 | if not local_cache then |
| 39 | return nil, protocol | 39 | return nil, protocol |
| 40 | end | 40 | end |
| @@ -58,7 +58,7 @@ local function remove_files_from_server(refresh: boolean, rockfiles: {string}, s | |||
| 58 | return nil, "No files removed." | 58 | return nil, "No files removed." |
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | local ok, err = fs.change_dir(local_cache) | 61 | ok, err = fs.change_dir(local_cache) |
| 62 | if not ok then return nil, err end | 62 | if not ok then return nil, err end |
| 63 | 63 | ||
| 64 | util.printout("Updating manifest...") | 64 | util.printout("Updating manifest...") |
| @@ -89,7 +89,7 @@ end | |||
| 89 | function admin_remove.command(args: Args): boolean, string | 89 | function admin_remove.command(args: Args): boolean, string |
| 90 | local server, server_table, err = cache.get_upload_server(args.server) | 90 | local server, server_table, err = cache.get_upload_server(args.server) |
| 91 | if not server then return nil, err end | 91 | if not server then return nil, err end |
| 92 | return remove_files_from_server(not args.no_refresh, args.rocks, server, server_table) --! | 92 | return remove_files_from_server(not args.no_refresh, args.rocks, server, server_table) |
| 93 | end | 93 | end |
| 94 | 94 | ||
| 95 | 95 | ||
diff --git a/src/luarocks/admin/index.lua b/src/luarocks/admin/index.lua index e2e2deff..c058697e 100644 --- a/src/luarocks/admin/index.lua +++ b/src/luarocks/admin/index.lua | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local io = _tl_compat and _tl_compat.io or io; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local package = _tl_compat and _tl_compat.package or package; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table | 1 | local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local io = _tl_compat and _tl_compat.io or io; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table |
| 2 | 2 | ||
| 3 | local index = {} | 3 | local index = {} |
| 4 | 4 | ||
| @@ -115,7 +115,7 @@ function index.format_external_dependencies(rockspec) | |||
| 115 | end | 115 | end |
| 116 | if plats then | 116 | if plats then |
| 117 | for plat, entries in util.sortedpairs(plats) do | 117 | for plat, entries in util.sortedpairs(plats) do |
| 118 | for name, desc in util.sortedpairs(entries) do | 118 | for name, _desc in util.sortedpairs(entries) do |
| 119 | if not listed_set[name] then | 119 | if not listed_set[name] then |
| 120 | table.insert(deplist, name:lower() .. " (on " .. plat .. ")") | 120 | table.insert(deplist, name:lower() .. " (on " .. plat .. ")") |
| 121 | end | 121 | end |
| @@ -136,7 +136,7 @@ function index.make_index(repo) | |||
| 136 | local out = io.open(dir.path(repo, "index.html"), "w") | 136 | local out = io.open(dir.path(repo, "index.html"), "w") |
| 137 | 137 | ||
| 138 | out:write(index_header) | 138 | out:write(index_header) |
| 139 | for package, version_list in util.sortedpairs(manifest.repository) do | 139 | for pkg, version_list in util.sortedpairs(manifest.repository) do |
| 140 | local latest_rockspec = nil | 140 | local latest_rockspec = nil |
| 141 | local output = index_package_begin | 141 | local output = index_package_begin |
| 142 | for version, data in util.sortedpairs(version_list, vers.compare_versions) do | 142 | for version, data in util.sortedpairs(version_list, vers.compare_versions) do |
| @@ -146,10 +146,10 @@ function index.make_index(repo) | |||
| 146 | for _, item in ipairs(data) do | 146 | for _, item in ipairs(data) do |
| 147 | local file | 147 | local file |
| 148 | if item.arch == 'rockspec' then | 148 | if item.arch == 'rockspec' then |
| 149 | file = ("%s-%s.rockspec"):format(package, version) | 149 | file = ("%s-%s.rockspec"):format(pkg, version) |
| 150 | if not latest_rockspec then latest_rockspec = file end | 150 | if not latest_rockspec then latest_rockspec = file end |
| 151 | else | 151 | else |
| 152 | file = ("%s-%s.%s.rock"):format(package, version, item.arch) | 152 | file = ("%s-%s.%s.rock"):format(pkg, version, item.arch) |
| 153 | end | 153 | end |
| 154 | table.insert(versions, '<a href="' .. file .. '">' .. item.arch .. '</a>') | 154 | table.insert(versions, '<a href="' .. file .. '">' .. item.arch .. '</a>') |
| 155 | end | 155 | end |
| @@ -160,7 +160,7 @@ function index.make_index(repo) | |||
| 160 | local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec)) | 160 | local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec)) |
| 161 | local descript = rockspec.description or {} | 161 | local descript = rockspec.description or {} |
| 162 | local vars = { | 162 | local vars = { |
| 163 | anchor = package, | 163 | anchor = pkg, |
| 164 | package = rockspec.package, | 164 | package = rockspec.package, |
| 165 | original = rockspec.source.url, | 165 | original = rockspec.source.url, |
| 166 | summary = descript.summary or "", | 166 | summary = descript.summary or "", |
| @@ -173,8 +173,8 @@ function index.make_index(repo) | |||
| 173 | vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"' .. ext_url_target .. '>%1</a>') | 173 | vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"' .. ext_url_target .. '>%1</a>') |
| 174 | output = output:gsub("$(%w+)", vars) | 174 | output = output:gsub("$(%w+)", vars) |
| 175 | else | 175 | else |
| 176 | output = output:gsub("$anchor", package) | 176 | output = output:gsub("$anchor", pkg) |
| 177 | output = output:gsub("$package", package) | 177 | output = output:gsub("$package", pkg) |
| 178 | output = output:gsub("$(%w+)", "") | 178 | output = output:gsub("$(%w+)", "") |
| 179 | end | 179 | end |
| 180 | out:write(output) | 180 | out:write(output) |
diff --git a/src/luarocks/admin/index.tl b/src/luarocks/admin/index.tl index 2cd47baf..c498932e 100644 --- a/src/luarocks/admin/index.tl +++ b/src/luarocks/admin/index.tl | |||
| @@ -115,7 +115,7 @@ function index.format_external_dependencies(rockspec: Rockspec): string | |||
| 115 | end | 115 | end |
| 116 | if plats then | 116 | if plats then |
| 117 | for plat, entries in util.sortedpairs(plats) do | 117 | for plat, entries in util.sortedpairs(plats) do |
| 118 | for name, desc in util.sortedpairs(entries) do | 118 | for name, _desc in util.sortedpairs(entries) do |
| 119 | if not listed_set[name] then | 119 | if not listed_set[name] then |
| 120 | table.insert(deplist, name:lower() .. " (on "..plat..")") | 120 | table.insert(deplist, name:lower() .. " (on "..plat..")") |
| 121 | end | 121 | end |
| @@ -136,7 +136,7 @@ function index.make_index(repo: string): boolean, string | |||
| 136 | local out = io.open(dir.path(repo, "index.html"), "w") | 136 | local out = io.open(dir.path(repo, "index.html"), "w") |
| 137 | 137 | ||
| 138 | out:write(index_header) | 138 | out:write(index_header) |
| 139 | for package, version_list in util.sortedpairs(manifest.repository) do | 139 | for pkg, version_list in util.sortedpairs(manifest.repository) do |
| 140 | local latest_rockspec: string = nil | 140 | local latest_rockspec: string = nil |
| 141 | local output = index_package_begin | 141 | local output = index_package_begin |
| 142 | for version, data in util.sortedpairs(version_list, vers.compare_versions) do | 142 | for version, data in util.sortedpairs(version_list, vers.compare_versions) do |
| @@ -146,10 +146,10 @@ function index.make_index(repo: string): boolean, string | |||
| 146 | for _, item in ipairs(data) do | 146 | for _, item in ipairs(data) do |
| 147 | local file: string | 147 | local file: string |
| 148 | if item.arch == 'rockspec' then | 148 | if item.arch == 'rockspec' then |
| 149 | file = ("%s-%s.rockspec"):format(package, version) | 149 | file = ("%s-%s.rockspec"):format(pkg, version) |
| 150 | if not latest_rockspec then latest_rockspec = file end | 150 | if not latest_rockspec then latest_rockspec = file end |
| 151 | else | 151 | else |
| 152 | file = ("%s-%s.%s.rock"):format(package, version, item.arch) | 152 | file = ("%s-%s.%s.rock"):format(pkg, version, item.arch) |
| 153 | end | 153 | end |
| 154 | table.insert(versions, '<a href="'..file..'">'..item.arch..'</a>') | 154 | table.insert(versions, '<a href="'..file..'">'..item.arch..'</a>') |
| 155 | end | 155 | end |
| @@ -160,7 +160,7 @@ function index.make_index(repo: string): boolean, string | |||
| 160 | local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec)) as Rockspec | 160 | local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec)) as Rockspec |
| 161 | local descript = rockspec.description or {} | 161 | local descript = rockspec.description or {} |
| 162 | local vars = { | 162 | local vars = { |
| 163 | anchor = package, | 163 | anchor = pkg, |
| 164 | package = rockspec.package, | 164 | package = rockspec.package, |
| 165 | original = rockspec.source.url, | 165 | original = rockspec.source.url, |
| 166 | summary = descript.summary or "", | 166 | summary = descript.summary or "", |
| @@ -173,8 +173,8 @@ function index.make_index(repo: string): boolean, string | |||
| 173 | vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"'..ext_url_target..'>%1</a>') | 173 | vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"'..ext_url_target..'>%1</a>') |
| 174 | output = output:gsub("$(%w+)", vars) | 174 | output = output:gsub("$(%w+)", vars) |
| 175 | else | 175 | else |
| 176 | output = output:gsub("$anchor", package) | 176 | output = output:gsub("$anchor", pkg) |
| 177 | output = output:gsub("$package", package) | 177 | output = output:gsub("$package", pkg) |
| 178 | output = output:gsub("$(%w+)", "") | 178 | output = output:gsub("$(%w+)", "") |
| 179 | end | 179 | end |
| 180 | out:write(output) | 180 | out:write(output) |
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 63082077..6b2d227f 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -69,7 +69,7 @@ do | |||
| 69 | for patch, patchdata in util.sortedpairs(rockspec.build.patches) do | 69 | for patch, patchdata in util.sortedpairs(rockspec.build.patches) do |
| 70 | util.printout("Applying patch " .. patch .. "...") | 70 | util.printout("Applying patch " .. patch .. "...") |
| 71 | local create_delete = rockspec:format_is_at_least("3.0") | 71 | local create_delete = rockspec:format_is_at_least("3.0") |
| 72 | local ok, err = fs.apply_patch(tostring(patch), patchdata, create_delete) | 72 | local ok, _err = fs.apply_patch(tostring(patch), patchdata, create_delete) |
| 73 | if not ok then | 73 | if not ok then |
| 74 | return nil, "Failed applying patch " .. patch | 74 | return nil, "Failed applying patch " .. patch |
| 75 | end | 75 | end |
| @@ -110,7 +110,7 @@ end | |||
| 110 | local function process_dependencies(rockspec, opts, cwd) | 110 | local function process_dependencies(rockspec, opts, cwd) |
| 111 | if not opts.build_only_deps then | 111 | if not opts.build_only_deps then |
| 112 | local ok, err, errcode = deps.check_external_deps(rockspec, "build") | 112 | local ok, err, errcode = deps.check_external_deps(rockspec, "build") |
| 113 | if err then | 113 | if not ok then |
| 114 | return nil, err, errcode | 114 | return nil, err, errcode |
| 115 | end | 115 | end |
| 116 | end | 116 | end |
| @@ -141,7 +141,7 @@ local function process_dependencies(rockspec, opts, cwd) | |||
| 141 | path.use_tree(cfg.root_dir) | 141 | path.use_tree(cfg.root_dir) |
| 142 | end | 142 | end |
| 143 | 143 | ||
| 144 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify, deplock_dir) | 144 | local _ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify, deplock_dir) |
| 145 | 145 | ||
| 146 | path.add_to_package_paths(cfg.root_dir) | 146 | path.add_to_package_paths(cfg.root_dir) |
| 147 | 147 | ||
| @@ -229,7 +229,7 @@ local function run_build_driver(rockspec, no_install) | |||
| 229 | if cfg.accepted_build_types and not fun.contains(cfg.accepted_build_types, btype) then | 229 | if cfg.accepted_build_types and not fun.contains(cfg.accepted_build_types, btype) then |
| 230 | return nil, "This rockspec uses the '" .. btype .. "' build type, which is blocked by the 'accepted_build_types' setting in your LuaRocks configuration." | 230 | return nil, "This rockspec uses the '" .. btype .. "' build type, which is blocked by the 'accepted_build_types' setting in your LuaRocks configuration." |
| 231 | end | 231 | end |
| 232 | local pok, driver_str = pcall(require, "luarocks.build." .. btype) | 232 | local _pok, driver_str = pcall(require, "luarocks.build." .. btype) |
| 233 | if not (type(driver_str) == "table") then | 233 | if not (type(driver_str) == "table") then |
| 234 | return nil, "Failed initializing build back-end for build type '" .. btype .. "': " .. driver_str | 234 | return nil, "Failed initializing build back-end for build type '" .. btype .. "': " .. driver_str |
| 235 | else | 235 | else |
| @@ -412,7 +412,7 @@ function build.build_rockspec(rockspec, opts, cwd) | |||
| 412 | return name, version | 412 | return name, version |
| 413 | end | 413 | end |
| 414 | 414 | ||
| 415 | local dirs, err | 415 | local dirs |
| 416 | local rollback | 416 | local rollback |
| 417 | if not opts.no_install then | 417 | if not opts.no_install then |
| 418 | if repos.is_installed(name, version) then | 418 | if repos.is_installed(name, version) then |
diff --git a/src/luarocks/build.tl b/src/luarocks/build.tl index 7fbe021f..9250e1dd 100644 --- a/src/luarocks/build.tl +++ b/src/luarocks/build.tl | |||
| @@ -69,7 +69,7 @@ do | |||
| 69 | for patch, patchdata in util.sortedpairs(rockspec.build.patches) do | 69 | for patch, patchdata in util.sortedpairs(rockspec.build.patches) do |
| 70 | util.printout("Applying patch "..patch.."...") | 70 | util.printout("Applying patch "..patch.."...") |
| 71 | local create_delete = rockspec:format_is_at_least("3.0") | 71 | local create_delete = rockspec:format_is_at_least("3.0") |
| 72 | local ok, err = fs.apply_patch(tostring(patch), patchdata, create_delete) | 72 | local ok, _err = fs.apply_patch(tostring(patch), patchdata, create_delete) |
| 73 | if not ok then | 73 | if not ok then |
| 74 | return nil, "Failed applying patch "..patch | 74 | return nil, "Failed applying patch "..patch |
| 75 | end | 75 | end |
| @@ -110,7 +110,7 @@ end | |||
| 110 | local function process_dependencies(rockspec: Rockspec, opts: BOpts, cwd: string): boolean, string, string | 110 | local function process_dependencies(rockspec: Rockspec, opts: BOpts, cwd: string): boolean, string, string |
| 111 | if not opts.build_only_deps then | 111 | if not opts.build_only_deps then |
| 112 | local ok, err, errcode = deps.check_external_deps(rockspec, "build") | 112 | local ok, err, errcode = deps.check_external_deps(rockspec, "build") |
| 113 | if err then | 113 | if not ok then |
| 114 | return nil, err, errcode | 114 | return nil, err, errcode |
| 115 | end | 115 | end |
| 116 | end | 116 | end |
| @@ -141,7 +141,7 @@ local function process_dependencies(rockspec: Rockspec, opts: BOpts, cwd: string | |||
| 141 | path.use_tree(cfg.root_dir as Tree) | 141 | path.use_tree(cfg.root_dir as Tree) |
| 142 | end | 142 | end |
| 143 | 143 | ||
| 144 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify, deplock_dir) | 144 | local _ok, err, errcode = deps.fulfill_dependencies(rockspec, "build_dependencies", "all", opts.verify, deplock_dir) |
| 145 | 145 | ||
| 146 | path.add_to_package_paths(cfg.root_dir) | 146 | path.add_to_package_paths(cfg.root_dir) |
| 147 | 147 | ||
| @@ -229,7 +229,7 @@ local function run_build_driver(rockspec: Rockspec, no_install: boolean): boolea | |||
| 229 | if cfg.accepted_build_types and not fun.contains(cfg.accepted_build_types, btype) then | 229 | if cfg.accepted_build_types and not fun.contains(cfg.accepted_build_types, btype) then |
| 230 | return nil, "This rockspec uses the '"..btype.."' build type, which is blocked by the 'accepted_build_types' setting in your LuaRocks configuration." | 230 | return nil, "This rockspec uses the '"..btype.."' build type, which is blocked by the 'accepted_build_types' setting in your LuaRocks configuration." |
| 231 | end | 231 | end |
| 232 | local pok, driver_str = pcall(require, "luarocks.build." .. btype) as (boolean, Builder | string) | 232 | local _pok, driver_str = pcall(require, "luarocks.build." .. btype) as (boolean, Builder | string) |
| 233 | if not driver_str is Builder then | 233 | if not driver_str is Builder then |
| 234 | return nil, "Failed initializing build back-end for build type '"..btype.."': "..driver_str | 234 | return nil, "Failed initializing build back-end for build type '"..btype.."': "..driver_str |
| 235 | else | 235 | else |
| @@ -412,7 +412,7 @@ function build.build_rockspec(rockspec: Rockspec, opts: BOpts, cwd: string): str | |||
| 412 | return name, version | 412 | return name, version |
| 413 | end | 413 | end |
| 414 | 414 | ||
| 415 | local dirs, err: InstallDirs, string | 415 | local dirs: InstallDirs |
| 416 | local rollback: util.Fn | 416 | local rollback: util.Fn |
| 417 | if not opts.no_install then | 417 | if not opts.no_install then |
| 418 | if repos.is_installed(name, version) then | 418 | if repos.is_installed(name, version) then |
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 24434fef..14812865 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
| @@ -247,7 +247,7 @@ 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 | compile_static_library = function(library, objects, _libraries, _libdirs, _name) |
| 251 | local ok = execute(variables.AR, "rc", library, _tl_table_unpack(objects)) | 251 | local ok = execute(variables.AR, "rc", library, _tl_table_unpack(objects)) |
| 252 | if ok then | 252 | if ok then |
| 253 | ok = execute(variables.RANLIB, library) | 253 | ok = execute(variables.RANLIB, library) |
| @@ -256,7 +256,7 @@ function builtin.run(rockspec, no_install) | |||
| 256 | end | 256 | end |
| 257 | end | 257 | end |
| 258 | 258 | ||
| 259 | local ok, err | 259 | local ok, err, errcode |
| 260 | local lua_modules = {} | 260 | local lua_modules = {} |
| 261 | local lib_modules = {} | 261 | local lib_modules = {} |
| 262 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 262 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
| @@ -306,13 +306,13 @@ function builtin.run(rockspec, no_install) | |||
| 306 | end | 306 | end |
| 307 | if type(info) == "table" then | 307 | if type(info) == "table" then |
| 308 | if not checked_lua_h then | 308 | if not checked_lua_h then |
| 309 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) | 309 | ok, err, errcode = deps.check_lua_incdir(rockspec.variables) |
| 310 | if not ok then | 310 | if not ok then |
| 311 | return nil, err, errcode | 311 | return nil, err, errcode |
| 312 | end | 312 | end |
| 313 | 313 | ||
| 314 | if cfg.link_lua_explicitly then | 314 | if cfg.link_lua_explicitly then |
| 315 | local ok, err, errcode = deps.check_lua_libdir(rockspec.variables) | 315 | ok, err, errcode = deps.check_lua_libdir(rockspec.variables) |
| 316 | if not ok then | 316 | if not ok then |
| 317 | return nil, err, errcode | 317 | return nil, err, errcode |
| 318 | end | 318 | end |
diff --git a/src/luarocks/build/builtin.tl b/src/luarocks/build/builtin.tl index 51d75900..b5a02f4c 100644 --- a/src/luarocks/build/builtin.tl +++ b/src/luarocks/build/builtin.tl | |||
| @@ -247,7 +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 | compile_static_library = function(library: string, objects: {string}, libraries: {string}, libdirs: {string}, name: string): boolean, string, string -- luacheck: ignore 211 | 250 | 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)) | 251 | local ok = execute(variables.AR, "rc", library, table.unpack(objects)) |
| 252 | if ok then | 252 | if ok then |
| 253 | ok = execute(variables.RANLIB, library) | 253 | ok = execute(variables.RANLIB, library) |
| @@ -256,7 +256,7 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, | |||
| 256 | end | 256 | end |
| 257 | end | 257 | end |
| 258 | 258 | ||
| 259 | local ok, err: boolean, string | 259 | local ok, err, errcode: boolean, string, string |
| 260 | local lua_modules = {} | 260 | local lua_modules = {} |
| 261 | local lib_modules = {} | 261 | local lib_modules = {} |
| 262 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 262 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
| @@ -306,13 +306,13 @@ function builtin.run(rockspec: Rockspec, no_install: boolean): boolean, string, | |||
| 306 | end | 306 | end |
| 307 | if info is Module then | 307 | if info is Module then |
| 308 | if not checked_lua_h then | 308 | if not checked_lua_h then |
| 309 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) | 309 | ok, err, errcode = deps.check_lua_incdir(rockspec.variables) |
| 310 | if not ok then | 310 | if not ok then |
| 311 | return nil, err, errcode | 311 | return nil, err, errcode |
| 312 | end | 312 | end |
| 313 | 313 | ||
| 314 | if cfg.link_lua_explicitly then | 314 | if cfg.link_lua_explicitly then |
| 315 | local ok, err, errcode = deps.check_lua_libdir(rockspec.variables) | 315 | ok, err, errcode = deps.check_lua_libdir(rockspec.variables) |
| 316 | if not ok then | 316 | if not ok then |
| 317 | return nil, err, errcode | 317 | return nil, err, errcode |
| 318 | end | 318 | end |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index e9c81a0f..90cf996b 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -385,45 +385,45 @@ local function use_to_fix_location(key, what) | |||
| 385 | return buf | 385 | return buf |
| 386 | end | 386 | end |
| 387 | 387 | ||
| 388 | local function get_config_text(cfg) | 388 | local function get_config_text(conf) |
| 389 | local deps = require("luarocks.deps") | 389 | local deps = require("luarocks.deps") |
| 390 | 390 | ||
| 391 | local libdir_ok = deps.check_lua_libdir(cfg.variables) | 391 | local libdir_ok = deps.check_lua_libdir(conf.variables) |
| 392 | local incdir_ok = deps.check_lua_incdir(cfg.variables) | 392 | local incdir_ok = deps.check_lua_incdir(conf.variables) |
| 393 | local lua_ok = cfg.variables.LUA and fs.exists(cfg.variables.LUA) | 393 | local lua_ok = conf.variables.LUA and fs.exists(conf.variables.LUA) |
| 394 | 394 | ||
| 395 | local buf = "Configuration:\n" | 395 | local buf = "Configuration:\n" |
| 396 | buf = buf .. " Lua:\n" | 396 | buf = buf .. " Lua:\n" |
| 397 | buf = buf .. " Version : " .. cfg.lua_version .. "\n" | 397 | buf = buf .. " Version : " .. conf.lua_version .. "\n" |
| 398 | if cfg.luajit_version then | 398 | if conf.luajit_version then |
| 399 | buf = buf .. " LuaJIT : " .. cfg.luajit_version .. "\n" | 399 | buf = buf .. " LuaJIT : " .. conf.luajit_version .. "\n" |
| 400 | end | 400 | end |
| 401 | buf = buf .. " LUA : " .. show_status(cfg.variables.LUA, lua_ok, "interpreter not found") .. "\n" | 401 | buf = buf .. " LUA : " .. show_status(conf.variables.LUA, lua_ok, "interpreter not found") .. "\n" |
| 402 | if not lua_ok then | 402 | if not lua_ok then |
| 403 | buf = buf .. use_to_fix_location("variables.LUA", lua_example) | 403 | buf = buf .. use_to_fix_location("variables.LUA", lua_example) |
| 404 | end | 404 | end |
| 405 | buf = buf .. " LUA_INCDIR : " .. show_status(cfg.variables.LUA_INCDIR, incdir_ok, "lua.h not found") .. "\n" | 405 | buf = buf .. " LUA_INCDIR : " .. show_status(conf.variables.LUA_INCDIR, incdir_ok, "lua.h not found") .. "\n" |
| 406 | if lua_ok and not incdir_ok then | 406 | if lua_ok and not incdir_ok then |
| 407 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") | 407 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") |
| 408 | end | 408 | end |
| 409 | buf = buf .. " LUA_LIBDIR : " .. show_status(cfg.variables.LUA_LIBDIR, libdir_ok, "Lua library itself not found") .. "\n" | 409 | buf = buf .. " LUA_LIBDIR : " .. show_status(conf.variables.LUA_LIBDIR, libdir_ok, "Lua library itself not found") .. "\n" |
| 410 | if lua_ok and not libdir_ok then | 410 | if lua_ok and not libdir_ok then |
| 411 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") | 411 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") |
| 412 | end | 412 | end |
| 413 | 413 | ||
| 414 | buf = buf .. "\n Configuration files:\n" | 414 | buf = buf .. "\n Configuration files:\n" |
| 415 | local conf = cfg.config_files | 415 | local files = conf.config_files |
| 416 | buf = buf .. " System : " .. show_status(fs.absolute_name(conf.system.file), conf.system.found) .. "\n" | 416 | buf = buf .. " System : " .. show_status(fs.absolute_name(files.system.file), files.system.found) .. "\n" |
| 417 | if conf.user.file then | 417 | if files.user.file then |
| 418 | buf = buf .. " User : " .. show_status(fs.absolute_name(conf.user.file), conf.user.found) .. "\n" | 418 | buf = buf .. " User : " .. show_status(fs.absolute_name(files.user.file), files.user.found) .. "\n" |
| 419 | else | 419 | else |
| 420 | buf = buf .. " User : disabled in this LuaRocks installation.\n" | 420 | buf = buf .. " User : disabled in this LuaRocks installation.\n" |
| 421 | end | 421 | end |
| 422 | if conf.project then | 422 | if files.project then |
| 423 | buf = buf .. " Project : " .. show_status(fs.absolute_name(conf.project.file), conf.project.found) .. "\n" | 423 | buf = buf .. " Project : " .. show_status(fs.absolute_name(files.project.file), files.project.found) .. "\n" |
| 424 | end | 424 | end |
| 425 | buf = buf .. "\n Rocks trees in use: \n" | 425 | buf = buf .. "\n Rocks trees in use: \n" |
| 426 | for _, tree in ipairs(cfg.rocks_trees) do | 426 | for _, tree in ipairs(conf.rocks_trees) do |
| 427 | if type(tree) == "string" then | 427 | if type(tree) == "string" then |
| 428 | buf = buf .. " " .. fs.absolute_name(tree) | 428 | buf = buf .. " " .. fs.absolute_name(tree) |
| 429 | else | 429 | else |
| @@ -604,14 +604,14 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 604 | end | 604 | end |
| 605 | end | 605 | end |
| 606 | for i = last, 1, -1 do | 606 | for i = last, 1, -1 do |
| 607 | local arg = args[i] | 607 | local arg_i = args[i] |
| 608 | if arg:match("^[^-][^=]*=") then | 608 | if arg_i:match("^[^-][^=]*=") then |
| 609 | local var, val = arg:match("^([A-Z_][A-Z0-9_]*)=(.*)") | 609 | local var, val = arg_i:match("^([A-Z_][A-Z0-9_]*)=(.*)") |
| 610 | if val then | 610 | if val then |
| 611 | cmdline_vars[var] = val | 611 | cmdline_vars[var] = val |
| 612 | table.remove(args, i) | 612 | table.remove(args, i) |
| 613 | else | 613 | else |
| 614 | die("Invalid assignment: " .. arg) | 614 | die("Invalid assignment: " .. arg_i) |
| 615 | end | 615 | end |
| 616 | end | 616 | end |
| 617 | end | 617 | end |
| @@ -718,7 +718,8 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 718 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") | 718 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") |
| 719 | end | 719 | end |
| 720 | 720 | ||
| 721 | local ok, err = process_tree_args(args, cfg.project_dir) | 721 | local ok |
| 722 | ok, err = process_tree_args(args, cfg.project_dir) | ||
| 722 | if not ok then | 723 | if not ok then |
| 723 | die(err) | 724 | die(err) |
| 724 | end | 725 | end |
| @@ -769,7 +770,7 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 769 | 770 | ||
| 770 | local lock | 771 | local lock |
| 771 | if cmd_mod.needs_lock and cmd_mod.needs_lock(args) then | 772 | if cmd_mod.needs_lock and cmd_mod.needs_lock(args) then |
| 772 | local ok, err = fs.check_command_permissions(args) | 773 | ok, err = fs.check_command_permissions(args) |
| 773 | if not ok then | 774 | if not ok then |
| 774 | die(err, cmd.errorcodes.PERMISSIONDENIED) | 775 | die(err, cmd.errorcodes.PERMISSIONDENIED) |
| 775 | end | 776 | end |
| @@ -788,7 +789,9 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 788 | end | 789 | end |
| 789 | end | 790 | end |
| 790 | 791 | ||
| 791 | local call_ok, ok, err, exitcode = xpcall(function() | 792 | local call_ok |
| 793 | local exitcode | ||
| 794 | call_ok, ok, err, exitcode = xpcall(function() | ||
| 792 | return cmd_mod.command(args) | 795 | return cmd_mod.command(args) |
| 793 | end, error_handler) | 796 | end, error_handler) |
| 794 | 797 | ||
diff --git a/src/luarocks/cmd.tl b/src/luarocks/cmd.tl index a3d2970f..6645e583 100644 --- a/src/luarocks/cmd.tl +++ b/src/luarocks/cmd.tl | |||
| @@ -168,7 +168,7 @@ local function process_server_args(args: Args): boolean, string | |||
| 168 | server[j] = dir.path(mirror, "dev") | 168 | server[j] = dir.path(mirror, "dev") |
| 169 | end | 169 | end |
| 170 | end | 170 | end |
| 171 | end | 171 | end |
| 172 | end | 172 | end |
| 173 | 173 | ||
| 174 | if args.only_server then | 174 | if args.only_server then |
| @@ -206,7 +206,7 @@ end | |||
| 206 | -- @param message string: The error message. | 206 | -- @param message string: The error message. |
| 207 | -- @param exitcode number: the exitcode to use | 207 | -- @param exitcode number: the exitcode to use |
| 208 | local function die(message: string, exitcode?: integer) | 208 | local function die(message: string, exitcode?: integer) |
| 209 | assert(type(message) == "string", "bad error, expected string, got: " .. type(message)) --! | 209 | assert(type(message) == "string", "bad error, expected string, got: " .. type(message)) |
| 210 | assert(exitcode == nil or type(exitcode) == "number", "bad error, expected number, got: " .. type(exitcode) .. " - " .. tostring(exitcode)) | 210 | assert(exitcode == nil or type(exitcode) == "number", "bad error, expected number, got: " .. type(exitcode) .. " - " .. tostring(exitcode)) |
| 211 | util.printerr("\nError: "..message) | 211 | util.printerr("\nError: "..message) |
| 212 | 212 | ||
| @@ -385,45 +385,45 @@ local function use_to_fix_location(key: string, what?: string): string | |||
| 385 | return buf | 385 | return buf |
| 386 | end | 386 | end |
| 387 | 387 | ||
| 388 | local function get_config_text(cfg: Config): string -- luacheck: ignore 431 | 388 | local function get_config_text(conf: Config): string |
| 389 | local deps = require("luarocks.deps") | 389 | local deps = require("luarocks.deps") |
| 390 | 390 | ||
| 391 | local libdir_ok = deps.check_lua_libdir(cfg.variables) | 391 | local libdir_ok = deps.check_lua_libdir(conf.variables) |
| 392 | local incdir_ok = deps.check_lua_incdir(cfg.variables) | 392 | local incdir_ok = deps.check_lua_incdir(conf.variables) |
| 393 | local lua_ok = cfg.variables.LUA and fs.exists(cfg.variables.LUA) | 393 | local lua_ok = conf.variables.LUA and fs.exists(conf.variables.LUA) |
| 394 | 394 | ||
| 395 | local buf = "Configuration:\n" | 395 | local buf = "Configuration:\n" |
| 396 | buf = buf.." Lua:\n" | 396 | buf = buf.." Lua:\n" |
| 397 | buf = buf.." Version : "..cfg.lua_version.."\n" | 397 | buf = buf.." Version : "..conf.lua_version.."\n" |
| 398 | if cfg.luajit_version then | 398 | if conf.luajit_version then |
| 399 | buf = buf.." LuaJIT : "..cfg.luajit_version.."\n" | 399 | buf = buf.." LuaJIT : "..conf.luajit_version.."\n" |
| 400 | end | 400 | end |
| 401 | buf = buf.." LUA : "..show_status(cfg.variables.LUA, lua_ok, "interpreter not found").."\n" | 401 | buf = buf.." LUA : "..show_status(conf.variables.LUA, lua_ok, "interpreter not found").."\n" |
| 402 | if not lua_ok then | 402 | if not lua_ok then |
| 403 | buf = buf .. use_to_fix_location("variables.LUA", lua_example) | 403 | buf = buf .. use_to_fix_location("variables.LUA", lua_example) |
| 404 | end | 404 | end |
| 405 | buf = buf.." LUA_INCDIR : "..show_status(cfg.variables.LUA_INCDIR, incdir_ok, "lua.h not found").."\n" | 405 | buf = buf.." LUA_INCDIR : "..show_status(conf.variables.LUA_INCDIR, incdir_ok, "lua.h not found").."\n" |
| 406 | if lua_ok and not incdir_ok then | 406 | if lua_ok and not incdir_ok then |
| 407 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") | 407 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") |
| 408 | end | 408 | end |
| 409 | buf = buf.." LUA_LIBDIR : "..show_status(cfg.variables.LUA_LIBDIR, libdir_ok, "Lua library itself not found").."\n" | 409 | buf = buf.." LUA_LIBDIR : "..show_status(conf.variables.LUA_LIBDIR, libdir_ok, "Lua library itself not found").."\n" |
| 410 | if lua_ok and not libdir_ok then | 410 | if lua_ok and not libdir_ok then |
| 411 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") | 411 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") |
| 412 | end | 412 | end |
| 413 | 413 | ||
| 414 | buf = buf.."\n Configuration files:\n" | 414 | buf = buf.."\n Configuration files:\n" |
| 415 | local conf = cfg.config_files | 415 | local files = conf.config_files |
| 416 | buf = buf.." System : "..show_status(fs.absolute_name(conf.system.file), conf.system.found).."\n" | 416 | buf = buf.." System : "..show_status(fs.absolute_name(files.system.file), files.system.found).."\n" |
| 417 | if conf.user.file then | 417 | if files.user.file then |
| 418 | buf = buf.." User : "..show_status(fs.absolute_name(conf.user.file), conf.user.found).."\n" | 418 | buf = buf.." User : "..show_status(fs.absolute_name(files.user.file), files.user.found).."\n" |
| 419 | else | 419 | else |
| 420 | buf = buf.." User : disabled in this LuaRocks installation.\n" | 420 | buf = buf.." User : disabled in this LuaRocks installation.\n" |
| 421 | end | 421 | end |
| 422 | if conf.project then | 422 | if files.project then |
| 423 | buf = buf.." Project : "..show_status(fs.absolute_name(conf.project.file), conf.project.found).."\n" | 423 | buf = buf.." Project : "..show_status(fs.absolute_name(files.project.file), files.project.found).."\n" |
| 424 | end | 424 | end |
| 425 | buf = buf.."\n Rocks trees in use: \n" | 425 | buf = buf.."\n Rocks trees in use: \n" |
| 426 | for _, tree in ipairs(cfg.rocks_trees) do | 426 | for _, tree in ipairs(conf.rocks_trees) do |
| 427 | if tree is string then | 427 | if tree is string then |
| 428 | buf = buf.." "..fs.absolute_name(tree) | 428 | buf = buf.." "..fs.absolute_name(tree) |
| 429 | else | 429 | else |
| @@ -604,14 +604,14 @@ function cmd.run_command(description: string, commands: {string: string}, extern | |||
| 604 | end | 604 | end |
| 605 | end | 605 | end |
| 606 | for i = last, 1, -1 do | 606 | for i = last, 1, -1 do |
| 607 | local arg = args[i] | 607 | local arg_i = args[i] |
| 608 | if arg:match("^[^-][^=]*=") then | 608 | if arg_i:match("^[^-][^=]*=") then |
| 609 | local var, val = arg:match("^([A-Z_][A-Z0-9_]*)=(.*)") | 609 | local var, val = arg_i:match("^([A-Z_][A-Z0-9_]*)=(.*)") |
| 610 | if val then | 610 | if val then |
| 611 | cmdline_vars[var] = val | 611 | cmdline_vars[var] = val |
| 612 | table.remove(args, i) | 612 | table.remove(args, i) |
| 613 | else | 613 | else |
| 614 | die("Invalid assignment: "..arg) | 614 | die("Invalid assignment: "..arg_i) |
| 615 | end | 615 | end |
| 616 | end | 616 | end |
| 617 | end | 617 | end |
| @@ -718,7 +718,8 @@ function cmd.run_command(description: string, commands: {string: string}, extern | |||
| 718 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") | 718 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") |
| 719 | end | 719 | end |
| 720 | 720 | ||
| 721 | local ok, err = process_tree_args(args, cfg.project_dir) | 721 | local ok: boolean |
| 722 | ok, err = process_tree_args(args, cfg.project_dir) | ||
| 722 | if not ok then | 723 | if not ok then |
| 723 | die(err) | 724 | die(err) |
| 724 | end | 725 | end |
| @@ -769,7 +770,7 @@ function cmd.run_command(description: string, commands: {string: string}, extern | |||
| 769 | 770 | ||
| 770 | local lock: fs.Lock | 771 | local lock: fs.Lock |
| 771 | if cmd_mod.needs_lock and cmd_mod.needs_lock(args) then | 772 | if cmd_mod.needs_lock and cmd_mod.needs_lock(args) then |
| 772 | local ok, err = fs.check_command_permissions(args) | 773 | ok, err = fs.check_command_permissions(args) |
| 773 | if not ok then | 774 | if not ok then |
| 774 | die(err, cmd.errorcodes.PERMISSIONDENIED) | 775 | die(err, cmd.errorcodes.PERMISSIONDENIED) |
| 775 | end | 776 | end |
| @@ -788,7 +789,9 @@ function cmd.run_command(description: string, commands: {string: string}, extern | |||
| 788 | end | 789 | end |
| 789 | end | 790 | end |
| 790 | 791 | ||
| 791 | local call_ok, ok, err, exitcode = xpcall(function(): boolean, string, integer | 792 | local call_ok: boolean |
| 793 | local exitcode: integer | ||
| 794 | call_ok, ok, err, exitcode = xpcall(function(): boolean, string, integer | ||
| 792 | return cmd_mod.command(args) | 795 | return cmd_mod.command(args) |
| 793 | end, error_handler) | 796 | end, error_handler) |
| 794 | 797 | ||
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index fb894c20..ee87d134 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
| @@ -25,8 +25,6 @@ local repos = require("luarocks.repos") | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | |||
| 29 | |||
| 30 | function cmd_build.add_to_parser(parser) | 28 | function cmd_build.add_to_parser(parser) |
| 31 | local cmd = parser:command("build", "Build and install a rock, compiling its C parts if any.\n" .. | 29 | local cmd = parser:command("build", "Build and install a rock, compiling its C parts if any.\n" .. |
| 32 | "If the sources contain a luarocks.lock file, uses it as an authoritative source for " .. | 30 | "If the sources contain a luarocks.lock file, uses it as an authoritative source for " .. |
| @@ -90,7 +88,6 @@ local function build_rock(rock_filename, opts) | |||
| 90 | end | 88 | end |
| 91 | 89 | ||
| 92 | local function do_build(name, namespace, version, opts) | 90 | local function do_build(name, namespace, version, opts) |
| 93 | |||
| 94 | local url, err | 91 | local url, err |
| 95 | if name:match("%.rockspec$") or name:match("%.rock$") then | 92 | if name:match("%.rockspec$") or name:match("%.rock$") then |
| 96 | url = name | 93 | url = name |
| @@ -112,7 +109,8 @@ local function do_build(name, namespace, version, opts) | |||
| 112 | 109 | ||
| 113 | if url:match("%.rockspec$") then | 110 | if url:match("%.rockspec$") then |
| 114 | local cwd = fs.absolute_name(dir.path(".")) | 111 | local cwd = fs.absolute_name(dir.path(".")) |
| 115 | local rockspec, err = fetch.load_rockspec(url, nil, opts.verify) | 112 | local rockspec |
| 113 | rockspec, err = fetch.load_rockspec(url, nil, opts.verify) | ||
| 116 | if not rockspec then | 114 | if not rockspec then |
| 117 | return nil, err | 115 | return nil, err |
| 118 | end | 116 | end |
| @@ -123,7 +121,8 @@ local function do_build(name, namespace, version, opts) | |||
| 123 | opts.need_to_fetch = false | 121 | opts.need_to_fetch = false |
| 124 | end | 122 | end |
| 125 | 123 | ||
| 126 | local ok, err, errcode = build_rock(url, opts) | 124 | local ok, errcode |
| 125 | ok, err, errcode = build_rock(url, opts) | ||
| 127 | if not ok then | 126 | if not ok then |
| 128 | return nil, err, errcode | 127 | return nil, err, errcode |
| 129 | end | 128 | end |
diff --git a/src/luarocks/cmd/build.tl b/src/luarocks/cmd/build.tl index c8d6a579..31e9bee9 100644 --- a/src/luarocks/cmd/build.tl +++ b/src/luarocks/cmd/build.tl | |||
| @@ -22,9 +22,7 @@ local repos = require("luarocks.repos") | |||
| 22 | local type Parser = require("luarocks.vendor.argparse").Parser | 22 | local type Parser = require("luarocks.vendor.argparse").Parser |
| 23 | 23 | ||
| 24 | local type Args = require("luarocks.core.types.args").Args | 24 | local type Args = require("luarocks.core.types.args").Args |
| 25 | |||
| 26 | local type BOpts = require("luarocks.core.types.bopts").BOpts | 25 | local type BOpts = require("luarocks.core.types.bopts").BOpts |
| 27 | |||
| 28 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | 26 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec |
| 29 | 27 | ||
| 30 | function cmd_build.add_to_parser(parser: Parser) | 28 | function cmd_build.add_to_parser(parser: Parser) |
| @@ -90,7 +88,6 @@ local function build_rock(rock_filename: string, opts: BOpts): boolean, string, | |||
| 90 | end | 88 | end |
| 91 | 89 | ||
| 92 | local function do_build(name: string, namespace: string, version: string, opts: BOpts): string, string, string | 90 | local function do_build(name: string, namespace: string, version: string, opts: BOpts): string, string, string |
| 93 | |||
| 94 | local url, err: string, string | 91 | local url, err: string, string |
| 95 | if name:match("%.rockspec$") or name:match("%.rock$") then | 92 | if name:match("%.rockspec$") or name:match("%.rock$") then |
| 96 | url = name | 93 | url = name |
| @@ -112,7 +109,8 @@ local function do_build(name: string, namespace: string, version: string, opts: | |||
| 112 | 109 | ||
| 113 | if url:match("%.rockspec$") then | 110 | if url:match("%.rockspec$") then |
| 114 | local cwd = fs.absolute_name(dir.path(".")) | 111 | local cwd = fs.absolute_name(dir.path(".")) |
| 115 | local rockspec, err = fetch.load_rockspec(url, nil, opts.verify) | 112 | local rockspec: Rockspec |
| 113 | rockspec, err = fetch.load_rockspec(url, nil, opts.verify) | ||
| 116 | if not rockspec then | 114 | if not rockspec then |
| 117 | return nil, err | 115 | return nil, err |
| 118 | end | 116 | end |
| @@ -123,7 +121,8 @@ local function do_build(name: string, namespace: string, version: string, opts: | |||
| 123 | opts.need_to_fetch = false | 121 | opts.need_to_fetch = false |
| 124 | end | 122 | end |
| 125 | 123 | ||
| 126 | local ok, err, errcode = build_rock(url, opts) | 124 | local ok, errcode: boolean, string |
| 125 | ok, err, errcode = build_rock(url, opts) | ||
| 127 | if not ok then | 126 | if not ok then |
| 128 | return nil, err, errcode | 127 | return nil, err, errcode |
| 129 | end | 128 | end |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index b0b04913..71a09a92 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
| @@ -197,7 +197,8 @@ local function write_entries(keys, scope, do_unset) | |||
| 197 | end) | 197 | end) |
| 198 | end | 198 | end |
| 199 | 199 | ||
| 200 | local ok, err = fs.make_dir(dir.dir_name(file_name)) | 200 | local ok |
| 201 | ok, err = fs.make_dir(dir.dir_name(file_name)) | ||
| 201 | if not ok then | 202 | if not ok then |
| 202 | return nil, err | 203 | return nil, err |
| 203 | end | 204 | end |
| @@ -373,13 +374,13 @@ function config_cmd.command(args) | |||
| 373 | 374 | ||
| 374 | if ok then | 375 | if ok then |
| 375 | if args.key == "variables.LUA_INCDIR" then | 376 | if args.key == "variables.LUA_INCDIR" then |
| 376 | local ok = report_on_lua_incdir_config(args.value) | 377 | local found = report_on_lua_incdir_config(args.value) |
| 377 | if not ok then | 378 | if not found then |
| 378 | warn_bad_c_config() | 379 | warn_bad_c_config() |
| 379 | end | 380 | end |
| 380 | elseif args.key == "variables.LUA_LIBDIR" then | 381 | elseif args.key == "variables.LUA_LIBDIR" then |
| 381 | local ok = report_on_lua_libdir_config(args.value) | 382 | local found = report_on_lua_libdir_config(args.value) |
| 382 | if not ok then | 383 | if not found then |
| 383 | warn_bad_c_config() | 384 | warn_bad_c_config() |
| 384 | end | 385 | end |
| 385 | end | 386 | end |
diff --git a/src/luarocks/cmd/config.tl b/src/luarocks/cmd/config.tl index 53e3be5e..cdda3fb9 100644 --- a/src/luarocks/cmd/config.tl +++ b/src/luarocks/cmd/config.tl | |||
| @@ -150,7 +150,7 @@ end | |||
| 150 | 150 | ||
| 151 | local function infer_type(var: string): string | 151 | local function infer_type(var: string): string |
| 152 | local typ: string | 152 | local typ: string |
| 153 | traverse_varstring(var, cfg as PersistableTable, function(t: PersistableTable, k: string): boolean, string --! | 153 | traverse_varstring(var, cfg as PersistableTable, function(t: PersistableTable, k: string): boolean, string |
| 154 | if t[k] then | 154 | if t[k] then |
| 155 | typ = type(t[k]) | 155 | typ = type(t[k]) |
| 156 | end | 156 | end |
| @@ -197,7 +197,8 @@ local function write_entries(keys: {string: string}, scope: string, do_unset: bo | |||
| 197 | end) | 197 | end) |
| 198 | end | 198 | end |
| 199 | 199 | ||
| 200 | local ok, err = fs.make_dir(dir.dir_name(file_name)) | 200 | local ok: boolean |
| 201 | ok, err = fs.make_dir(dir.dir_name(file_name)) | ||
| 201 | if not ok then | 202 | if not ok then |
| 202 | return nil, err | 203 | return nil, err |
| 203 | end | 204 | end |
| @@ -373,13 +374,13 @@ function config_cmd.command(args: Args): boolean, string | |||
| 373 | 374 | ||
| 374 | if ok then | 375 | if ok then |
| 375 | if args.key == "variables.LUA_INCDIR" then | 376 | if args.key == "variables.LUA_INCDIR" then |
| 376 | local ok = report_on_lua_incdir_config(args.value) | 377 | local found = report_on_lua_incdir_config(args.value) |
| 377 | if not ok then | 378 | if not found then |
| 378 | warn_bad_c_config() | 379 | warn_bad_c_config() |
| 379 | end | 380 | end |
| 380 | elseif args.key == "variables.LUA_LIBDIR" then | 381 | elseif args.key == "variables.LUA_LIBDIR" then |
| 381 | local ok = report_on_lua_libdir_config(args.value) | 382 | local found = report_on_lua_libdir_config(args.value) |
| 382 | if not ok then | 383 | if not found then |
| 383 | warn_bad_c_config() | 384 | warn_bad_c_config() |
| 384 | end | 385 | end |
| 385 | end | 386 | end |
diff --git a/src/luarocks/cmd/doc.lua b/src/luarocks/cmd/doc.lua index 1389d80c..87ac24ca 100644 --- a/src/luarocks/cmd/doc.lua +++ b/src/luarocks/cmd/doc.lua | |||
| @@ -17,6 +17,7 @@ local download = require("luarocks.download") | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | |||
| 20 | function doc.add_to_parser(parser) | 21 | function doc.add_to_parser(parser) |
| 21 | local cmd = parser:command("doc", "Show documentation for an installed rock.\n\n" .. | 22 | local cmd = parser:command("doc", "Show documentation for an installed rock.\n\n" .. |
| 22 | "Without any flags, tries to load the documentation using a series of heuristics.\n" .. | 23 | "Without any flags, tries to load the documentation using a series of heuristics.\n" .. |
| @@ -45,17 +46,26 @@ local function show_homepage(homepage, name, namespace, version) | |||
| 45 | end | 46 | end |
| 46 | 47 | ||
| 47 | local function try_to_open_homepage(name, namespace, version) | 48 | local function try_to_open_homepage(name, namespace, version) |
| 48 | local temp_dir, err = fs.make_temp_dir("doc-" .. name .. "-" .. (version or "")) | 49 | local temp_dir, err |
| 50 | temp_dir, err = fs.make_temp_dir("doc-" .. name .. "-" .. (version or "")) | ||
| 49 | if not temp_dir then | 51 | if not temp_dir then |
| 50 | return nil, "Failed creating temporary directory: " .. err | 52 | return nil, "Failed creating temporary directory: " .. err |
| 51 | end | 53 | end |
| 54 | |||
| 52 | util.schedule_function(fs.delete, temp_dir) | 55 | util.schedule_function(fs.delete, temp_dir) |
| 53 | local ok, err = fs.change_dir(temp_dir) | 56 | |
| 57 | local ok | ||
| 58 | ok, err = fs.change_dir(temp_dir) | ||
| 54 | if not ok then return nil, err end | 59 | if not ok then return nil, err end |
| 55 | local filename, err = download.download_file("rockspec", name, namespace, version) | 60 | |
| 61 | local filename | ||
| 62 | filename, err = download.download_file("rockspec", name, namespace, version) | ||
| 56 | if not filename then return nil, err end | 63 | if not filename then return nil, err end |
| 57 | local rockspec, err = fetch.load_local_rockspec(filename) | 64 | |
| 65 | local rockspec | ||
| 66 | rockspec, err = fetch.load_local_rockspec(filename) | ||
| 58 | if not rockspec then return nil, err end | 67 | if not rockspec then return nil, err end |
| 68 | |||
| 59 | fs.pop_dir() | 69 | fs.pop_dir() |
| 60 | local descript = rockspec.description or {} | 70 | local descript = rockspec.description or {} |
| 61 | return show_homepage(descript.homepage, name, namespace, version) | 71 | return show_homepage(descript.homepage, name, namespace, version) |
diff --git a/src/luarocks/cmd/doc.tl b/src/luarocks/cmd/doc.tl index 37eb2518..9e7bee2a 100644 --- a/src/luarocks/cmd/doc.tl +++ b/src/luarocks/cmd/doc.tl | |||
| @@ -16,6 +16,7 @@ local download = require("luarocks.download") | |||
| 16 | local type Parser = require("luarocks.vendor.argparse").Parser | 16 | local type Parser = require("luarocks.vendor.argparse").Parser |
| 17 | 17 | ||
| 18 | local type Args = require("luarocks.core.types.args").Args | 18 | local type Args = require("luarocks.core.types.args").Args |
| 19 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | ||
| 19 | 20 | ||
| 20 | function doc.add_to_parser(parser: Parser) | 21 | function doc.add_to_parser(parser: Parser) |
| 21 | local cmd = parser:command("doc", "Show documentation for an installed rock.\n\n".. | 22 | local cmd = parser:command("doc", "Show documentation for an installed rock.\n\n".. |
| @@ -45,17 +46,26 @@ local function show_homepage(homepage: string, name: string, namespace: string, | |||
| 45 | end | 46 | end |
| 46 | 47 | ||
| 47 | local function try_to_open_homepage(name: string, namespace: string, version: string): boolean, string | 48 | local function try_to_open_homepage(name: string, namespace: string, version: string): boolean, string |
| 48 | local temp_dir, err = fs.make_temp_dir("doc-"..name.."-"..(version or "")) | 49 | local temp_dir, err: string, string |
| 50 | temp_dir, err = fs.make_temp_dir("doc-"..name.."-"..(version or "")) | ||
| 49 | if not temp_dir then | 51 | if not temp_dir then |
| 50 | return nil, "Failed creating temporary directory: "..err | 52 | return nil, "Failed creating temporary directory: "..err |
| 51 | end | 53 | end |
| 54 | |||
| 52 | util.schedule_function(fs.delete, temp_dir) | 55 | util.schedule_function(fs.delete, temp_dir) |
| 53 | local ok, err = fs.change_dir(temp_dir) | 56 | |
| 57 | local ok: boolean | ||
| 58 | ok, err = fs.change_dir(temp_dir) | ||
| 54 | if not ok then return nil, err end | 59 | if not ok then return nil, err end |
| 55 | local filename, err = download.download_file("rockspec", name, namespace, version) | 60 | |
| 61 | local filename: string | ||
| 62 | filename, err = download.download_file("rockspec", name, namespace, version) | ||
| 56 | if not filename then return nil, err end | 63 | if not filename then return nil, err end |
| 57 | local rockspec, err = fetch.load_local_rockspec(filename) | 64 | |
| 65 | local rockspec: Rockspec | ||
| 66 | rockspec, err = fetch.load_local_rockspec(filename) | ||
| 58 | if not rockspec then return nil, err end | 67 | if not rockspec then return nil, err end |
| 68 | |||
| 59 | fs.pop_dir() | 69 | fs.pop_dir() |
| 60 | local descript = rockspec.description or {} | 70 | local descript = rockspec.description or {} |
| 61 | return show_homepage(descript.homepage, name, namespace, version) | 71 | return show_homepage(descript.homepage, name, namespace, version) |
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index 9b124974..a152b885 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
| @@ -154,7 +154,7 @@ function init.command(args) | |||
| 154 | if not has_rockspec then | 154 | if not has_rockspec then |
| 155 | args.version = args.version or "dev" | 155 | args.version = args.version or "dev" |
| 156 | args.location = pwd | 156 | args.location = pwd |
| 157 | local ok, err = write_rockspec.command(args) | 157 | ok, err = write_rockspec.command(args) |
| 158 | if not ok then | 158 | if not ok then |
| 159 | util.printerr(err) | 159 | util.printerr(err) |
| 160 | end | 160 | end |
| @@ -185,7 +185,8 @@ function init.command(args) | |||
| 185 | fs.delete(fs.absolute_name(config_file)) | 185 | fs.delete(fs.absolute_name(config_file)) |
| 186 | end | 186 | end |
| 187 | 187 | ||
| 188 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | 188 | local config_tbl |
| 189 | config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | ||
| 189 | if config_tbl then | 190 | if config_tbl then |
| 190 | local varnames = { | 191 | local varnames = { |
| 191 | "LUA_DIR", | 192 | "LUA_DIR", |
| @@ -200,7 +201,7 @@ function init.command(args) | |||
| 200 | (config_tbl.variables)[varname] = cfg.variables[varname] | 201 | (config_tbl.variables)[varname] = cfg.variables[varname] |
| 201 | end | 202 | end |
| 202 | end | 203 | end |
| 203 | local ok, err = persist.save_from_table(config_file, config_tbl) | 204 | ok, err = persist.save_from_table(config_file, config_tbl) |
| 204 | if ok then | 205 | if ok then |
| 205 | util.printout("Wrote " .. config_file) | 206 | util.printout("Wrote " .. config_file) |
| 206 | else | 207 | else |
diff --git a/src/luarocks/cmd/init.tl b/src/luarocks/cmd/init.tl index fcd49422..313c6df9 100644 --- a/src/luarocks/cmd/init.tl +++ b/src/luarocks/cmd/init.tl | |||
| @@ -154,7 +154,7 @@ function init.command(args: Args): boolean, string | |||
| 154 | if not has_rockspec then | 154 | if not has_rockspec then |
| 155 | args.version = args.version or "dev" | 155 | args.version = args.version or "dev" |
| 156 | args.location = pwd | 156 | args.location = pwd |
| 157 | local ok, err = write_rockspec.command(args) | 157 | ok, err = write_rockspec.command(args) |
| 158 | if not ok then | 158 | if not ok then |
| 159 | util.printerr(err) | 159 | util.printerr(err) |
| 160 | end | 160 | end |
| @@ -185,7 +185,8 @@ function init.command(args: Args): boolean, string | |||
| 185 | fs.delete(fs.absolute_name(config_file)) | 185 | fs.delete(fs.absolute_name(config_file)) |
| 186 | end | 186 | end |
| 187 | 187 | ||
| 188 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | 188 | local config_tbl: PersistableTable |
| 189 | config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | ||
| 189 | if config_tbl then | 190 | if config_tbl then |
| 190 | local varnames = { | 191 | local varnames = { |
| 191 | "LUA_DIR", | 192 | "LUA_DIR", |
| @@ -200,7 +201,7 @@ function init.command(args: Args): boolean, string | |||
| 200 | (config_tbl.variables as PersistableTable)[varname] = cfg.variables[varname] | 201 | (config_tbl.variables as PersistableTable)[varname] = cfg.variables[varname] |
| 201 | end | 202 | end |
| 202 | end | 203 | end |
| 203 | local ok, err = persist.save_from_table(config_file, config_tbl) | 204 | ok, err = persist.save_from_table(config_file, config_tbl) |
| 204 | if ok then | 205 | if ok then |
| 205 | util.printout("Wrote " .. config_file) | 206 | util.printout("Wrote " .. config_file) |
| 206 | else | 207 | else |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index e582f6e1..28b1c888 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
| @@ -23,7 +23,6 @@ local cfg = require("luarocks.core.cfg") | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | |||
| 27 | function install.add_to_parser(parser) | 26 | function install.add_to_parser(parser) |
| 28 | local cmd = parser:command("install", "Install a rock.", util.see_also()) | 27 | local cmd = parser:command("install", "Install a rock.", util.see_also()) |
| 29 | 28 | ||
| @@ -97,11 +96,15 @@ function install.install_binary_rock(rock_file, opts) | |||
| 97 | fs.delete(install_dir) | 96 | fs.delete(install_dir) |
| 98 | fs.remove_dir_if_empty(path.versions_dir(name)) | 97 | fs.remove_dir_if_empty(path.versions_dir(name)) |
| 99 | end) | 98 | end) |
| 100 | local ok | ||
| 101 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | ||
| 102 | if not oks then return nil, err, errcode end | ||
| 103 | 99 | ||
| 104 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | 100 | local ok, err, errcode |
| 101 | |||
| 102 | local filename | ||
| 103 | filename, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | ||
| 104 | if not filename then return nil, err, errcode end | ||
| 105 | |||
| 106 | local rockspec | ||
| 107 | rockspec, err, errcode = fetch.load_rockspec(path.rockspec_file(name, version)) | ||
| 105 | if err then | 108 | if err then |
| 106 | return nil, "Failed loading rockspec for installed package: " .. err, errcode | 109 | return nil, "Failed loading rockspec for installed package: " .. err, errcode |
| 107 | end | 110 | end |
| @@ -158,7 +161,8 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
| 158 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | 161 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) |
| 159 | if not oks then return nil, err, errcode end | 162 | if not oks then return nil, err, errcode end |
| 160 | 163 | ||
| 161 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | 164 | local rockspec |
| 165 | rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | ||
| 162 | if err then | 166 | if err then |
| 163 | return nil, "Failed loading rockspec for installed package: " .. err, errcode | 167 | return nil, "Failed loading rockspec for installed package: " .. err, errcode |
| 164 | end | 168 | end |
diff --git a/src/luarocks/cmd/install.tl b/src/luarocks/cmd/install.tl index 943afdba..6c472768 100644 --- a/src/luarocks/cmd/install.tl +++ b/src/luarocks/cmd/install.tl | |||
| @@ -20,9 +20,8 @@ local cfg = require("luarocks.core.cfg") | |||
| 20 | local type Parser = require("luarocks.vendor.argparse").Parser | 20 | local type Parser = require("luarocks.vendor.argparse").Parser |
| 21 | 21 | ||
| 22 | local type Args = require("luarocks.core.types.args").Args | 22 | local type Args = require("luarocks.core.types.args").Args |
| 23 | |||
| 24 | |||
| 25 | local type IOpts = require("luarocks.core.types.installs").IOpts | 23 | local type IOpts = require("luarocks.core.types.installs").IOpts |
| 24 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | ||
| 26 | 25 | ||
| 27 | function install.add_to_parser(parser: Parser) | 26 | function install.add_to_parser(parser: Parser) |
| 28 | local cmd = parser:command("install", "Install a rock.", util.see_also()) -- luacheck: ignore 431 | 27 | local cmd = parser:command("install", "Install a rock.", util.see_also()) -- luacheck: ignore 431 |
| @@ -97,13 +96,17 @@ function install.install_binary_rock(rock_file: string, opts: IOpts): string, st | |||
| 97 | fs.delete(install_dir) | 96 | fs.delete(install_dir) |
| 98 | fs.remove_dir_if_empty(path.versions_dir(name)) | 97 | fs.remove_dir_if_empty(path.versions_dir(name)) |
| 99 | end) | 98 | end) |
| 100 | local ok: boolean | ||
| 101 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | ||
| 102 | if not oks then return nil, err, errcode end | ||
| 103 | 99 | ||
| 104 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | 100 | local ok, err, errcode: boolean, string, string |
| 101 | |||
| 102 | local filename: string | ||
| 103 | filename, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | ||
| 104 | if not filename then return nil, err, errcode end | ||
| 105 | |||
| 106 | local rockspec: Rockspec | ||
| 107 | rockspec, err, errcode = fetch.load_rockspec(path.rockspec_file(name, version)) | ||
| 105 | if err then | 108 | if err then |
| 106 | return nil, "Failed loading rockspec for installed package: "..err, errcode | 109 | return nil, "Failed loading rockspec for installed package: " .. err, errcode |
| 107 | end | 110 | end |
| 108 | 111 | ||
| 109 | if opts.deps_mode ~= "none" then | 112 | if opts.deps_mode ~= "none" then |
| @@ -158,7 +161,8 @@ function install.install_binary_rock_deps(rock_file: string, opts: IOpts): strin | |||
| 158 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | 161 | local oks, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) |
| 159 | if not oks then return nil, err, errcode end | 162 | if not oks then return nil, err, errcode end |
| 160 | 163 | ||
| 161 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | 164 | local rockspec: Rockspec |
| 165 | rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | ||
| 162 | if err then | 166 | if err then |
| 163 | return nil, "Failed loading rockspec for installed package: "..err, errcode | 167 | return nil, "Failed loading rockspec for installed package: "..err, errcode |
| 164 | end | 168 | end |
diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index e8a52906..161ec0ac 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua | |||
| @@ -99,7 +99,7 @@ function make.command(args) | |||
| 99 | end | 99 | end |
| 100 | 100 | ||
| 101 | local cwd = fs.absolute_name(dir.path(".")) | 101 | local cwd = fs.absolute_name(dir.path(".")) |
| 102 | local rockspec, err, errcode = fetch.load_rockspec(rockspec_filename) | 102 | local rockspec, err = fetch.load_rockspec(rockspec_filename) |
| 103 | if not rockspec then | 103 | if not rockspec then |
| 104 | return nil, err | 104 | return nil, err |
| 105 | end | 105 | end |
| @@ -141,9 +141,9 @@ function make.command(args) | |||
| 141 | return name, version | 141 | return name, version |
| 142 | end) | 142 | end) |
| 143 | else | 143 | else |
| 144 | local ok, err = build.build_rockspec(rockspec, opts, cwd) | 144 | name, err = build.build_rockspec(rockspec, opts, cwd) |
| 145 | if not ok then return nil, err end | 145 | if not name then return nil, err end |
| 146 | name, version = ok, err | 146 | version = err |
| 147 | 147 | ||
| 148 | if opts.build_only_deps then | 148 | if opts.build_only_deps then |
| 149 | util.printout("Stopping after installing dependencies for " .. name .. " " .. version) | 149 | util.printout("Stopping after installing dependencies for " .. name .. " " .. version) |
| @@ -156,7 +156,8 @@ function make.command(args) | |||
| 156 | end | 156 | end |
| 157 | 157 | ||
| 158 | if (not args.keep) and not cfg.keep_other_versions then | 158 | if (not args.keep) and not cfg.keep_other_versions then |
| 159 | local ok, err, warn = remove.remove_other_versions(name, version, args.force, args.force_fast) | 159 | local ok, warn |
| 160 | ok, err, warn = remove.remove_other_versions(name, version, args.force, args.force_fast) | ||
| 160 | if not ok then | 161 | if not ok then |
| 161 | return nil, err | 162 | return nil, err |
| 162 | elseif warn then | 163 | elseif warn then |
diff --git a/src/luarocks/cmd/make.tl b/src/luarocks/cmd/make.tl index 13b1d66b..fc467b31 100644 --- a/src/luarocks/cmd/make.tl +++ b/src/luarocks/cmd/make.tl | |||
| @@ -99,7 +99,7 @@ function make.command(args: Args): boolean, string | |||
| 99 | end | 99 | end |
| 100 | 100 | ||
| 101 | local cwd = fs.absolute_name(dir.path(".")) | 101 | local cwd = fs.absolute_name(dir.path(".")) |
| 102 | local rockspec, err, errcode = fetch.load_rockspec(rockspec_filename) | 102 | local rockspec, err = fetch.load_rockspec(rockspec_filename) |
| 103 | if not rockspec then | 103 | if not rockspec then |
| 104 | return nil, err | 104 | return nil, err |
| 105 | end | 105 | end |
| @@ -141,9 +141,9 @@ function make.command(args: Args): boolean, string | |||
| 141 | return name, version | 141 | return name, version |
| 142 | end) | 142 | end) |
| 143 | else | 143 | else |
| 144 | local ok, err = build.build_rockspec(rockspec, opts, cwd) | 144 | name, err = build.build_rockspec(rockspec, opts, cwd) |
| 145 | if not ok then return nil, err end | 145 | if not name then return nil, err end |
| 146 | name, version = ok, err -- luacheck: ignore 421 | 146 | version = err |
| 147 | 147 | ||
| 148 | if opts.build_only_deps then | 148 | if opts.build_only_deps then |
| 149 | util.printout("Stopping after installing dependencies for " ..name.." "..version) | 149 | util.printout("Stopping after installing dependencies for " ..name.." "..version) |
| @@ -156,7 +156,8 @@ function make.command(args: Args): boolean, string | |||
| 156 | end | 156 | end |
| 157 | 157 | ||
| 158 | if (not args.keep) and not cfg.keep_other_versions then | 158 | if (not args.keep) and not cfg.keep_other_versions then |
| 159 | local ok, err, warn = remove.remove_other_versions(name, version, args.force, args.force_fast) | 159 | local ok, warn: boolean, string |
| 160 | ok, err, warn = remove.remove_other_versions(name, version, args.force, args.force_fast) | ||
| 160 | if not ok then | 161 | if not ok then |
| 161 | return nil, err | 162 | return nil, err |
| 162 | elseif warn then | 163 | elseif warn then |
diff --git a/src/luarocks/cmd/new_version.lua b/src/luarocks/cmd/new_version.lua index ea70a874..2d8d2365 100644 --- a/src/luarocks/cmd/new_version.lua +++ b/src/luarocks/cmd/new_version.lua | |||
| @@ -78,6 +78,7 @@ end | |||
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | |||
| 81 | local function check_url_and_update_md5(out_rs, invalid_is_error) | 82 | local function check_url_and_update_md5(out_rs, invalid_is_error) |
| 82 | local file, temp_dir = fetch.fetch_url_at_temp_dir(out_rs.source.url, "luarocks-new-version-" .. out_rs.package) | 83 | local file, temp_dir = fetch.fetch_url_at_temp_dir(out_rs.source.url, "luarocks-new-version-" .. out_rs.package) |
| 83 | if not file then | 84 | if not file then |
| @@ -85,7 +86,7 @@ local function check_url_and_update_md5(out_rs, invalid_is_error) | |||
| 85 | return nil, "invalid URL - " .. temp_dir | 86 | return nil, "invalid URL - " .. temp_dir |
| 86 | end | 87 | end |
| 87 | util.warning("invalid URL - " .. temp_dir) | 88 | util.warning("invalid URL - " .. temp_dir) |
| 88 | return true, false | 89 | return true, nil, false |
| 89 | end | 90 | end |
| 90 | do | 91 | do |
| 91 | local inferred_dir, found_dir = fetch.find_base_dir(file, temp_dir, out_rs.source.url, out_rs.source.dir) | 92 | local inferred_dir, found_dir = fetch.find_base_dir(file, temp_dir, out_rs.source.url, out_rs.source.dir) |
| @@ -106,15 +107,16 @@ local function check_url_and_update_md5(out_rs, invalid_is_error) | |||
| 106 | end | 107 | end |
| 107 | local old_md5 = out_rs.source.md5 | 108 | local old_md5 = out_rs.source.md5 |
| 108 | out_rs.source.md5 = new_md5 | 109 | out_rs.source.md5 = new_md5 |
| 109 | return true, new_md5 ~= old_md5 | 110 | return true, nil, new_md5 ~= old_md5 |
| 110 | else | 111 | else |
| 111 | util.printout("File successfully downloaded.") | 112 | util.printout("File successfully downloaded.") |
| 112 | return true, false | 113 | return true, nil, false |
| 113 | end | 114 | end |
| 114 | end | 115 | end |
| 115 | end | 116 | end |
| 116 | 117 | ||
| 117 | local function update_source_section(out_rs, url, tag, old_ver, new_ver) | 118 | local function update_source_section(out_rs, url, tag, old_ver, new_ver) |
| 119 | local ok, err, md5_changed | ||
| 118 | if tag then | 120 | if tag then |
| 119 | out_rs.source.tag = tag | 121 | out_rs.source.tag = tag |
| 120 | end | 122 | end |
| @@ -123,7 +125,7 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver) | |||
| 123 | return check_url_and_update_md5(out_rs) | 125 | return check_url_and_update_md5(out_rs) |
| 124 | end | 126 | end |
| 125 | if new_ver == old_ver then | 127 | if new_ver == old_ver then |
| 126 | return true | 128 | return true, nil, false |
| 127 | end | 129 | end |
| 128 | if out_rs.source.dir then | 130 | if out_rs.source.dir then |
| 129 | try_replace(out_rs.source, "dir", old_ver, new_ver) | 131 | try_replace(out_rs.source, "dir", old_ver, new_ver) |
| @@ -134,24 +136,25 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver) | |||
| 134 | 136 | ||
| 135 | local old_url = out_rs.source.url | 137 | local old_url = out_rs.source.url |
| 136 | if try_replace(out_rs.source, "url", old_ver, new_ver) then | 138 | if try_replace(out_rs.source, "url", old_ver, new_ver) then |
| 137 | local ok, md5_changed = check_url_and_update_md5(out_rs, true) | 139 | ok, err, md5_changed = check_url_and_update_md5(out_rs, true) |
| 138 | if ok then | 140 | if ok then |
| 139 | return ok, md5_changed | 141 | return ok, nil, md5_changed |
| 140 | end | 142 | end |
| 141 | out_rs.source.url = old_url | 143 | out_rs.source.url = old_url |
| 142 | end | 144 | end |
| 143 | if tag or try_replace(out_rs.source, "tag", old_ver, new_ver) then | 145 | if tag or try_replace(out_rs.source, "tag", old_ver, new_ver) then |
| 144 | return true | 146 | return true, nil, false |
| 145 | end | 147 | end |
| 146 | 148 | ||
| 147 | local ok, md5_changed = check_url_and_update_md5(out_rs) | 149 | |
| 150 | ok, err, md5_changed = check_url_and_update_md5(out_rs) | ||
| 148 | if not ok then | 151 | if not ok then |
| 149 | return nil, md5_changed | 152 | return nil, err |
| 150 | end | 153 | end |
| 151 | if md5_changed then | 154 | if md5_changed then |
| 152 | util.warning("URL is the same, but MD5 has changed. Old rockspec is broken.") | 155 | util.warning("URL is the same, but MD5 has changed. Old rockspec is broken.") |
| 153 | end | 156 | end |
| 154 | return true | 157 | return true, nil, true |
| 155 | end | 158 | end |
| 156 | 159 | ||
| 157 | function new_version.command(args) | 160 | function new_version.command(args) |
| @@ -176,7 +179,8 @@ function new_version.command(args) | |||
| 176 | end | 179 | end |
| 177 | end | 180 | end |
| 178 | 181 | ||
| 179 | local valid_rs, err = fetch.load_rockspec(filename) | 182 | local valid_rs |
| 183 | valid_rs, err = fetch.load_rockspec(filename) | ||
| 180 | if not valid_rs then | 184 | if not valid_rs then |
| 181 | return nil, err | 185 | return nil, err |
| 182 | end | 186 | end |
| @@ -206,11 +210,13 @@ function new_version.command(args) | |||
| 206 | end | 210 | end |
| 207 | local new_rockver = new_ver:gsub("-", "") | 211 | local new_rockver = new_ver:gsub("-", "") |
| 208 | 212 | ||
| 209 | local out_rs, err = persist.load_into_table(filename), string | 213 | local out_rs |
| 214 | out_rs, err = persist.load_into_table(filename) | ||
| 210 | local out_name = out_rs.package:lower() | 215 | local out_name = out_rs.package:lower() |
| 211 | out_rs.version = new_rockver .. "-" .. tostring(new_rev) | 216 | out_rs.version = new_rockver .. "-" .. tostring(new_rev) |
| 212 | 217 | ||
| 213 | local ok, err = update_source_section(out_rs, args.new_url, args.tag, old_ver, new_ver) | 218 | local ok |
| 219 | ok, err = update_source_section(out_rs, args.new_url, args.tag, old_ver, new_ver) | ||
| 214 | if not ok then return nil, err end | 220 | if not ok then return nil, err end |
| 215 | 221 | ||
| 216 | if out_rs.build and out_rs.build.type == "module" then | 222 | if out_rs.build and out_rs.build.type == "module" then |
| @@ -226,7 +232,8 @@ function new_version.command(args) | |||
| 226 | 232 | ||
| 227 | util.printout("Wrote " .. out_filename) | 233 | util.printout("Wrote " .. out_filename) |
| 228 | 234 | ||
| 229 | local valid_out_rs, err = fetch.load_local_rockspec(out_filename) | 235 | local valid_out_rs |
| 236 | valid_out_rs, err = fetch.load_local_rockspec(out_filename) | ||
| 230 | if not valid_out_rs then | 237 | if not valid_out_rs then |
| 231 | return nil, "Failed loading generated rockspec: " .. err | 238 | return nil, "Failed loading generated rockspec: " .. err |
| 232 | end | 239 | end |
diff --git a/src/luarocks/cmd/new_version.tl b/src/luarocks/cmd/new_version.tl index d5da0e86..d929376b 100644 --- a/src/luarocks/cmd/new_version.tl +++ b/src/luarocks/cmd/new_version.tl | |||
| @@ -76,16 +76,17 @@ end | |||
| 76 | 76 | ||
| 77 | -- Try to download source file using URL from a rockspec. | 77 | -- Try to download source file using URL from a rockspec. |
| 78 | -- If it specified MD5, update it. | 78 | -- If it specified MD5, update it. |
| 79 | -- @return (true, false) if MD5 was not specified or it stayed same, | 79 | -- @return true if no errors ocurred |
| 80 | -- (true, true) if MD5 changed, (nil, string) on error. | 80 | -- @return an error message in case of errors |
| 81 | local function check_url_and_update_md5(out_rs: Rockspec, invalid_is_error?: boolean): boolean, string | boolean --! | 81 | -- @return if no errors, a true boolean if the MD5 changed. |
| 82 | local function check_url_and_update_md5(out_rs: Rockspec, invalid_is_error?: boolean): boolean, string, boolean | ||
| 82 | local file, temp_dir = fetch.fetch_url_at_temp_dir(out_rs.source.url, "luarocks-new-version-"..out_rs.package) | 83 | local file, temp_dir = fetch.fetch_url_at_temp_dir(out_rs.source.url, "luarocks-new-version-"..out_rs.package) |
| 83 | if not file then | 84 | if not file then |
| 84 | if invalid_is_error then | 85 | if invalid_is_error then |
| 85 | return nil, "invalid URL - "..temp_dir | 86 | return nil, "invalid URL - "..temp_dir |
| 86 | end | 87 | end |
| 87 | util.warning("invalid URL - "..temp_dir) | 88 | util.warning("invalid URL - "..temp_dir) |
| 88 | return true, false | 89 | return true, nil, false |
| 89 | end | 90 | end |
| 90 | do | 91 | do |
| 91 | local inferred_dir, found_dir = fetch.find_base_dir(file, temp_dir, out_rs.source.url, out_rs.source.dir) | 92 | local inferred_dir, found_dir = fetch.find_base_dir(file, temp_dir, out_rs.source.url, out_rs.source.dir) |
| @@ -106,15 +107,16 @@ local function check_url_and_update_md5(out_rs: Rockspec, invalid_is_error?: boo | |||
| 106 | end | 107 | end |
| 107 | local old_md5 = out_rs.source.md5 | 108 | local old_md5 = out_rs.source.md5 |
| 108 | out_rs.source.md5 = new_md5 | 109 | out_rs.source.md5 = new_md5 |
| 109 | return true, new_md5 ~= old_md5 | 110 | return true, nil, new_md5 ~= old_md5 |
| 110 | else | 111 | else |
| 111 | util.printout("File successfully downloaded.") | 112 | util.printout("File successfully downloaded.") |
| 112 | return true, false | 113 | return true, nil, false |
| 113 | end | 114 | end |
| 114 | end | 115 | end |
| 115 | end | 116 | end |
| 116 | 117 | ||
| 117 | local function update_source_section(out_rs: Rockspec, url: string, tag: string, old_ver: string, new_ver: string): boolean, string | boolean | 118 | local function update_source_section(out_rs: Rockspec, url: string, tag: string, old_ver: string, new_ver: string): boolean, string, boolean |
| 119 | local ok, err, md5_changed: boolean, string, boolean | ||
| 118 | if tag then | 120 | if tag then |
| 119 | out_rs.source.tag = tag | 121 | out_rs.source.tag = tag |
| 120 | end | 122 | end |
| @@ -123,7 +125,7 @@ local function update_source_section(out_rs: Rockspec, url: string, tag: string, | |||
| 123 | return check_url_and_update_md5(out_rs) | 125 | return check_url_and_update_md5(out_rs) |
| 124 | end | 126 | end |
| 125 | if new_ver == old_ver then | 127 | if new_ver == old_ver then |
| 126 | return true | 128 | return true, nil, false |
| 127 | end | 129 | end |
| 128 | if out_rs.source.dir then | 130 | if out_rs.source.dir then |
| 129 | try_replace(out_rs.source as {string: string}, "dir", old_ver, new_ver) | 131 | try_replace(out_rs.source as {string: string}, "dir", old_ver, new_ver) |
| @@ -134,24 +136,25 @@ local function update_source_section(out_rs: Rockspec, url: string, tag: string, | |||
| 134 | 136 | ||
| 135 | local old_url = out_rs.source.url | 137 | local old_url = out_rs.source.url |
| 136 | if try_replace(out_rs.source as {string: string}, "url", old_ver, new_ver) then | 138 | if try_replace(out_rs.source as {string: string}, "url", old_ver, new_ver) then |
| 137 | local ok, md5_changed = check_url_and_update_md5(out_rs, true) | 139 | ok, err, md5_changed = check_url_and_update_md5(out_rs, true) |
| 138 | if ok then | 140 | if ok then |
| 139 | return ok, md5_changed | 141 | return ok, nil, md5_changed |
| 140 | end | 142 | end |
| 141 | out_rs.source.url = old_url | 143 | out_rs.source.url = old_url |
| 142 | end | 144 | end |
| 143 | if tag or try_replace(out_rs.source as {string: string}, "tag", old_ver, new_ver) then | 145 | if tag or try_replace(out_rs.source as {string: string}, "tag", old_ver, new_ver) then |
| 144 | return true | 146 | return true, nil, false |
| 145 | end | 147 | end |
| 148 | |||
| 146 | -- Couldn't replace anything significant, use the old URL. | 149 | -- Couldn't replace anything significant, use the old URL. |
| 147 | local ok, md5_changed = check_url_and_update_md5(out_rs) | 150 | ok, err, md5_changed = check_url_and_update_md5(out_rs) |
| 148 | if not ok then | 151 | if not ok then |
| 149 | return nil, md5_changed | 152 | return nil, err |
| 150 | end | 153 | end |
| 151 | if md5_changed then | 154 | if md5_changed then |
| 152 | util.warning("URL is the same, but MD5 has changed. Old rockspec is broken.") | 155 | util.warning("URL is the same, but MD5 has changed. Old rockspec is broken.") |
| 153 | end | 156 | end |
| 154 | return true | 157 | return true, nil, true |
| 155 | end | 158 | end |
| 156 | 159 | ||
| 157 | function new_version.command(args: Args): boolean, string | boolean | 160 | function new_version.command(args: Args): boolean, string | boolean |
| @@ -176,7 +179,8 @@ function new_version.command(args: Args): boolean, string | boolean | |||
| 176 | end | 179 | end |
| 177 | end | 180 | end |
| 178 | 181 | ||
| 179 | local valid_rs, err = fetch.load_rockspec(filename) | 182 | local valid_rs: Rockspec |
| 183 | valid_rs, err = fetch.load_rockspec(filename) | ||
| 180 | if not valid_rs then | 184 | if not valid_rs then |
| 181 | return nil, err | 185 | return nil, err |
| 182 | end | 186 | end |
| @@ -206,11 +210,13 @@ function new_version.command(args: Args): boolean, string | boolean | |||
| 206 | end | 210 | end |
| 207 | local new_rockver = new_ver:gsub("-", "") | 211 | local new_rockver = new_ver:gsub("-", "") |
| 208 | 212 | ||
| 209 | local out_rs, err = persist.load_into_table(filename) as Rockspec, string | 213 | local out_rs: Rockspec |
| 214 | out_rs, err = persist.load_into_table(filename) as (Rockspec, string) | ||
| 210 | local out_name = out_rs.package:lower() | 215 | local out_name = out_rs.package:lower() |
| 211 | out_rs.version = new_rockver.."-"..tostring(new_rev) | 216 | out_rs.version = new_rockver.."-"..tostring(new_rev) |
| 212 | 217 | ||
| 213 | local ok, err = update_source_section(out_rs, args.new_url, args.tag, old_ver, new_ver) | 218 | local ok: boolean |
| 219 | ok, err = update_source_section(out_rs, args.new_url, args.tag, old_ver, new_ver) | ||
| 214 | if not ok then return nil, err end | 220 | if not ok then return nil, err end |
| 215 | 221 | ||
| 216 | if out_rs.build and out_rs.build.type == "module" then | 222 | if out_rs.build and out_rs.build.type == "module" then |
| @@ -226,7 +232,8 @@ function new_version.command(args: Args): boolean, string | boolean | |||
| 226 | 232 | ||
| 227 | util.printout("Wrote "..out_filename) | 233 | util.printout("Wrote "..out_filename) |
| 228 | 234 | ||
| 229 | local valid_out_rs, err = fetch.load_local_rockspec(out_filename) | 235 | local valid_out_rs: Rockspec |
| 236 | valid_out_rs, err = fetch.load_local_rockspec(out_filename) | ||
| 230 | if not valid_out_rs then | 237 | if not valid_out_rs then |
| 231 | return nil, "Failed loading generated rockspec: "..err | 238 | return nil, "Failed loading generated rockspec: "..err |
| 232 | end | 239 | end |
diff --git a/src/luarocks/cmd/purge.lua b/src/luarocks/cmd/purge.lua index b7d28f82..f84a15f2 100644 --- a/src/luarocks/cmd/purge.lua +++ b/src/luarocks/cmd/purge.lua | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local package = _tl_compat and _tl_compat.package or package | 1 | |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | local purge = {} | 4 | local purge = {} |
| @@ -51,11 +51,11 @@ function purge.command(args) | |||
| 51 | sort = vers.compare_versions | 51 | sort = vers.compare_versions |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | for package, versions in util.sortedpairs(results) do | 54 | for pkg, versions in util.sortedpairs(results) do |
| 55 | for version, _ in util.sortedpairs(versions, sort) do | 55 | for version, _ in util.sortedpairs(versions, sort) do |
| 56 | if args.old_versions then | 56 | if args.old_versions then |
| 57 | util.printout("Keeping " .. package .. " " .. version .. "...") | 57 | util.printout("Keeping " .. pkg .. " " .. version .. "...") |
| 58 | local ok, err, warn = remove.remove_other_versions(package, version, args.force, args.force_fast) | 58 | local ok, err, warn = remove.remove_other_versions(pkg, version, args.force, args.force_fast) |
| 59 | if not ok then | 59 | if not ok then |
| 60 | util.printerr(err) | 60 | util.printerr(err) |
| 61 | elseif warn then | 61 | elseif warn then |
| @@ -63,8 +63,8 @@ function purge.command(args) | |||
| 63 | end | 63 | end |
| 64 | break | 64 | break |
| 65 | else | 65 | else |
| 66 | util.printout("Removing " .. package .. " " .. version .. "...") | 66 | util.printout("Removing " .. pkg .. " " .. version .. "...") |
| 67 | local ok, err = repo_writer.delete_version(package, version, "none", true) | 67 | local ok, err = repo_writer.delete_version(pkg, version, "none", true) |
| 68 | if not ok then | 68 | if not ok then |
| 69 | util.printerr(err) | 69 | util.printerr(err) |
| 70 | end | 70 | end |
diff --git a/src/luarocks/cmd/purge.tl b/src/luarocks/cmd/purge.tl index 9d8eacc1..2801f357 100644 --- a/src/luarocks/cmd/purge.tl +++ b/src/luarocks/cmd/purge.tl | |||
| @@ -51,11 +51,11 @@ function purge.command(args: Args): boolean, string | |||
| 51 | sort = vers.compare_versions | 51 | sort = vers.compare_versions |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | for package, versions in util.sortedpairs(results) do | 54 | for pkg, versions in util.sortedpairs(results) do |
| 55 | for version, _ in util.sortedpairs(versions, sort) do | 55 | for version, _ in util.sortedpairs(versions, sort) do |
| 56 | if args.old_versions then | 56 | if args.old_versions then |
| 57 | util.printout("Keeping "..package.." "..version.."...") | 57 | util.printout("Keeping "..pkg.." "..version.."...") |
| 58 | local ok, err, warn = remove.remove_other_versions(package, version, args.force, args.force_fast) | 58 | local ok, err, warn = remove.remove_other_versions(pkg, version, args.force, args.force_fast) |
| 59 | if not ok then | 59 | if not ok then |
| 60 | util.printerr(err) | 60 | util.printerr(err) |
| 61 | elseif warn then | 61 | elseif warn then |
| @@ -63,8 +63,8 @@ function purge.command(args: Args): boolean, string | |||
| 63 | end | 63 | end |
| 64 | break | 64 | break |
| 65 | else | 65 | else |
| 66 | util.printout("Removing "..package.." "..version.."...") | 66 | util.printout("Removing "..pkg.." "..version.."...") |
| 67 | local ok, err = repo_writer.delete_version(package, version, "none", true) | 67 | local ok, err = repo_writer.delete_version(pkg, version, "none", true) |
| 68 | if not ok then | 68 | if not ok then |
| 69 | util.printerr(err) | 69 | util.printerr(err) |
| 70 | end | 70 | end |
diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index 7f9ca9c6..5022e288 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua | |||
| @@ -307,8 +307,10 @@ function show.command(args) | |||
| 307 | if not rockspec then return nil, err end | 307 | if not rockspec then return nil, err end |
| 308 | 308 | ||
| 309 | local descript = rockspec.description or {} | 309 | local descript = rockspec.description or {} |
| 310 | local manifest, err = manif.load_manifest(repo_url) | 310 | |
| 311 | if not manifest then return nil, err end | 311 | local manifest, manifest_err = manif.load_manifest(repo_url) |
| 312 | if not manifest then return nil, manifest_err end | ||
| 313 | |||
| 312 | local minfo = manifest.repository[name][version][1] | 314 | local minfo = manifest.repository[name][version][1] |
| 313 | 315 | ||
| 314 | if args.rock_tree then util.printout(tree) | 316 | if args.rock_tree then util.printout(tree) |
diff --git a/src/luarocks/cmd/show.tl b/src/luarocks/cmd/show.tl index 6063179a..56d70277 100644 --- a/src/luarocks/cmd/show.tl +++ b/src/luarocks/cmd/show.tl | |||
| @@ -307,8 +307,10 @@ function show.command(args: Args): boolean, string | |||
| 307 | if not rockspec then return nil,err end | 307 | if not rockspec then return nil,err end |
| 308 | 308 | ||
| 309 | local descript = rockspec.description or {} | 309 | local descript = rockspec.description or {} |
| 310 | local manifest, err = manif.load_manifest(repo_url) | 310 | |
| 311 | if not manifest then return nil,err end | 311 | local manifest, manifest_err = manif.load_manifest(repo_url) |
| 312 | if not manifest then return nil, manifest_err end | ||
| 313 | |||
| 312 | local minfo = manifest.repository[name][version][1] | 314 | local minfo = manifest.repository[name][version][1] |
| 313 | 315 | ||
| 314 | if args.rock_tree then util.printout(tree) | 316 | if args.rock_tree then util.printout(tree) |
diff --git a/src/luarocks/cmd/test.tl b/src/luarocks/cmd/test.tl index b1189d47..a258e4a3 100644 --- a/src/luarocks/cmd/test.tl +++ b/src/luarocks/cmd/test.tl | |||
| @@ -35,7 +35,7 @@ to separate LuaRocks arguments from test suite arguments.]], | |||
| 35 | :argname("<type>") | 35 | :argname("<type>") |
| 36 | end | 36 | end |
| 37 | 37 | ||
| 38 | function cmd_test.command(args: Args): boolean, string, string --! | 38 | function cmd_test.command(args: Args): boolean, string, string |
| 39 | if args.rockspec and args.rockspec:match("rockspec$") then | 39 | if args.rockspec and args.rockspec:match("rockspec$") then |
| 40 | return test.run_test_suite(args.rockspec, args.test_type, args.args, args.prepare) | 40 | return test.run_test_suite(args.rockspec, args.test_type, args.args, args.prepare) |
| 41 | end | 41 | end |
diff --git a/src/luarocks/cmd/unpack.lua b/src/luarocks/cmd/unpack.lua index 5a1ae799..aa136c32 100644 --- a/src/luarocks/cmd/unpack.lua +++ b/src/luarocks/cmd/unpack.lua | |||
| @@ -47,7 +47,8 @@ local function unpack_rockspec(rockspec_file, dir_name) | |||
| 47 | if not rockspec then | 47 | if not rockspec then |
| 48 | return nil, "Failed loading rockspec " .. rockspec_file .. ": " .. err | 48 | return nil, "Failed loading rockspec " .. rockspec_file .. ": " .. err |
| 49 | end | 49 | end |
| 50 | local ok, err = fs.change_dir(dir_name) | 50 | local ok |
| 51 | ok, err = fs.change_dir(dir_name) | ||
| 51 | if not ok then return nil, err end | 52 | if not ok then return nil, err end |
| 52 | local filename, sources_dir = fetch.fetch_sources(rockspec, true, ".") | 53 | local filename, sources_dir = fetch.fetch_sources(rockspec, true, ".") |
| 53 | if not filename then | 54 | if not filename then |
| @@ -78,10 +79,13 @@ local function unpack_rock(rock_file, dir_name, kind) | |||
| 78 | ok, err = fs.change_dir(dir_name) | 79 | ok, err = fs.change_dir(dir_name) |
| 79 | if not ok then return nil, err end | 80 | if not ok then return nil, err end |
| 80 | local rockspec_file = dir_name .. ".rockspec" | 81 | local rockspec_file = dir_name .. ".rockspec" |
| 81 | local rockspec, err = fetch.load_rockspec(rockspec_file) | 82 | |
| 83 | local rockspec | ||
| 84 | rockspec, err = fetch.load_rockspec(rockspec_file) | ||
| 82 | if not rockspec then | 85 | if not rockspec then |
| 83 | return nil, "Failed loading rockspec " .. rockspec_file .. ": " .. err | 86 | return nil, "Failed loading rockspec " .. rockspec_file .. ": " .. err |
| 84 | end | 87 | end |
| 88 | |||
| 85 | if kind == "src" then | 89 | if kind == "src" then |
| 86 | if rockspec.source.file then | 90 | if rockspec.source.file then |
| 87 | ok, err = fs.unpack_archive(rockspec.source.file) | 91 | ok, err = fs.unpack_archive(rockspec.source.file) |
diff --git a/src/luarocks/cmd/unpack.tl b/src/luarocks/cmd/unpack.tl index 0e168785..6d05ecde 100644 --- a/src/luarocks/cmd/unpack.tl +++ b/src/luarocks/cmd/unpack.tl | |||
| @@ -47,7 +47,8 @@ local function unpack_rockspec(rockspec_file: string, dir_name: string): Rockspe | |||
| 47 | if not rockspec then | 47 | if not rockspec then |
| 48 | return nil, "Failed loading rockspec "..rockspec_file..": "..err | 48 | return nil, "Failed loading rockspec "..rockspec_file..": "..err |
| 49 | end | 49 | end |
| 50 | local ok, err = fs.change_dir(dir_name) | 50 | local ok: boolean |
| 51 | ok, err = fs.change_dir(dir_name) | ||
| 51 | if not ok then return nil, err end | 52 | if not ok then return nil, err end |
| 52 | local filename, sources_dir = fetch.fetch_sources(rockspec, true, ".") | 53 | local filename, sources_dir = fetch.fetch_sources(rockspec, true, ".") |
| 53 | if not filename then | 54 | if not filename then |
| @@ -78,10 +79,13 @@ local function unpack_rock(rock_file: string, dir_name: string, kind: string): R | |||
| 78 | ok, err = fs.change_dir(dir_name) | 79 | ok, err = fs.change_dir(dir_name) |
| 79 | if not ok then return nil, err end | 80 | if not ok then return nil, err end |
| 80 | local rockspec_file = dir_name..".rockspec" | 81 | local rockspec_file = dir_name..".rockspec" |
| 81 | local rockspec, err = fetch.load_rockspec(rockspec_file) | 82 | |
| 83 | local rockspec: Rockspec | ||
| 84 | rockspec, err = fetch.load_rockspec(rockspec_file) | ||
| 82 | if not rockspec then | 85 | if not rockspec then |
| 83 | return nil, "Failed loading rockspec "..rockspec_file..": "..err | 86 | return nil, "Failed loading rockspec "..rockspec_file..": "..err |
| 84 | end | 87 | end |
| 88 | |||
| 85 | if kind == "src" then | 89 | if kind == "src" then |
| 86 | if rockspec.source.file then | 90 | if rockspec.source.file then |
| 87 | ok, err = fs.unpack_archive(rockspec.source.file) | 91 | ok, err = fs.unpack_archive(rockspec.source.file) |
diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua index 70a1f9b9..cc65de0b 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.lua | |||
| @@ -24,6 +24,7 @@ local Api = require("luarocks.upload.api") | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | |||
| 27 | function upload.add_to_parser(parser) | 28 | function upload.add_to_parser(parser) |
| 28 | local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) " .. | 29 | local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) " .. |
| 29 | "and upload it and the rockspec to the public rocks repository.", util.see_also()): | 30 | "and upload it and the rockspec to the public rocks repository.", util.see_also()): |
| @@ -60,13 +61,16 @@ function upload.command(args) | |||
| 60 | api.debug = true | 61 | api.debug = true |
| 61 | end | 62 | end |
| 62 | 63 | ||
| 63 | local rockspec, err, errcode = fetch.load_rockspec(args.rockspec) | 64 | local rockspec |
| 65 | local errcode | ||
| 66 | rockspec, err, errcode = fetch.load_rockspec(args.rockspec) | ||
| 64 | if err then | 67 | if err then |
| 65 | return nil, err, errcode | 68 | return nil, err, errcode |
| 66 | end | 69 | end |
| 67 | 70 | ||
| 68 | util.printout("Sending " .. tostring(args.rockspec) .. " ...") | 71 | util.printout("Sending " .. tostring(args.rockspec) .. " ...") |
| 69 | local res, err = api:method("check_rockspec", { | 72 | local res |
| 73 | res, err = api:method("check_rockspec", { | ||
| 70 | package = rockspec.package, | 74 | package = rockspec.package, |
| 71 | version = rockspec.version, | 75 | version = rockspec.version, |
| 72 | }) | 76 | }) |
diff --git a/src/luarocks/cmd/upload.tl b/src/luarocks/cmd/upload.tl index df544d13..a222a50c 100644 --- a/src/luarocks/cmd/upload.tl +++ b/src/luarocks/cmd/upload.tl | |||
| @@ -23,6 +23,7 @@ local type Response = upload.Response | |||
| 23 | local type Parser = require("luarocks.vendor.argparse").Parser | 23 | local type Parser = require("luarocks.vendor.argparse").Parser |
| 24 | 24 | ||
| 25 | local type Args = require("luarocks.core.types.args").Args | 25 | local type Args = require("luarocks.core.types.args").Args |
| 26 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | ||
| 26 | 27 | ||
| 27 | function upload.add_to_parser(parser: Parser) | 28 | function upload.add_to_parser(parser: Parser) |
| 28 | local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) ".. | 29 | local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) ".. |
| @@ -60,13 +61,16 @@ function upload.command(args: Args): boolean, string, string | |||
| 60 | api.debug = true | 61 | api.debug = true |
| 61 | end | 62 | end |
| 62 | 63 | ||
| 63 | local rockspec, err, errcode = fetch.load_rockspec(args.rockspec) | 64 | local rockspec: Rockspec |
| 65 | local errcode: string | ||
| 66 | rockspec, err, errcode = fetch.load_rockspec(args.rockspec) | ||
| 64 | if err then | 67 | if err then |
| 65 | return nil, err, errcode | 68 | return nil, err, errcode |
| 66 | end | 69 | end |
| 67 | 70 | ||
| 68 | util.printout("Sending " .. tostring(args.rockspec) .. " ...") | 71 | util.printout("Sending " .. tostring(args.rockspec) .. " ...") |
| 69 | local res, err = api:method("check_rockspec", { | 72 | local res: Response |
| 73 | res, err = api:method("check_rockspec", { | ||
| 70 | package = rockspec.package, | 74 | package = rockspec.package, |
| 71 | version = rockspec.version | 75 | version = rockspec.version |
| 72 | }) as (Response, string) | 76 | }) as (Response, string) |
diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua index 156339b8..b84c2803 100644 --- a/src/luarocks/cmd/write_rockspec.lua +++ b/src/luarocks/cmd/write_rockspec.lua | |||
| @@ -386,7 +386,8 @@ function write_rockspec.command(args) | |||
| 386 | end | 386 | end |
| 387 | end | 387 | end |
| 388 | 388 | ||
| 389 | local ok, err = fs.change_dir(local_dir) | 389 | local ok |
| 390 | ok, err = fs.change_dir(local_dir) | ||
| 390 | if not ok then return nil, "Failed reaching files from project - error entering directory " .. local_dir end | 391 | if not ok then return nil, "Failed reaching files from project - error entering directory " .. local_dir end |
| 391 | 392 | ||
| 392 | if not (args.summary and args.detailed) then | 393 | if not (args.summary and args.detailed) then |
diff --git a/src/luarocks/cmd/write_rockspec.tl b/src/luarocks/cmd/write_rockspec.tl index 6ece30da..7354a683 100644 --- a/src/luarocks/cmd/write_rockspec.tl +++ b/src/luarocks/cmd/write_rockspec.tl | |||
| @@ -386,7 +386,8 @@ function write_rockspec.command(args: Args): boolean, string | |||
| 386 | end | 386 | end |
| 387 | end | 387 | end |
| 388 | 388 | ||
| 389 | local ok, err = fs.change_dir(local_dir) | 389 | local ok: boolean |
| 390 | ok, err = fs.change_dir(local_dir) | ||
| 390 | if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end | 391 | if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end |
| 391 | 392 | ||
| 392 | if not (args.summary and args.detailed) then | 393 | if not (args.summary and args.detailed) then |
diff --git a/src/luarocks/core/types/args.d.tl b/src/luarocks/core/types/args.d.tl index d2aca6fc..510855dd 100644 --- a/src/luarocks/core/types/args.d.tl +++ b/src/luarocks/core/types/args.d.tl | |||
| @@ -3,18 +3,18 @@ local record args | |||
| 3 | tree: string | 3 | tree: string |
| 4 | global: boolean | 4 | global: boolean |
| 5 | deps_mode: string | 5 | deps_mode: string |
| 6 | ["local"]: boolean --! | 6 | ["local"]: boolean |
| 7 | project_tree: string | 7 | project_tree: string |
| 8 | server: string | 8 | server: string |
| 9 | dev: boolean | 9 | dev: boolean |
| 10 | only_server: string --! | 10 | only_server: string |
| 11 | verbose: string | 11 | verbose: string |
| 12 | lua_version: string | 12 | lua_version: string |
| 13 | lua_dir: string | 13 | lua_dir: string |
| 14 | no_project: boolean | 14 | no_project: boolean |
| 15 | input: {string} | 15 | input: {string} |
| 16 | nodeps: boolean | 16 | nodeps: boolean |
| 17 | timeout: number --! | 17 | timeout: number |
| 18 | command: string | 18 | command: string |
| 19 | key: string | 19 | key: string |
| 20 | value: string | 20 | value: string |
| @@ -26,8 +26,8 @@ local record args | |||
| 26 | pack_binary_rock: boolean | 26 | pack_binary_rock: boolean |
| 27 | only_deps: boolean | 27 | only_deps: boolean |
| 28 | branch: string | 28 | branch: string |
| 29 | verify: boolean --! | 29 | verify: boolean |
| 30 | check_lua_versions: boolean --! | 30 | check_lua_versions: boolean |
| 31 | pin: boolean | 31 | pin: boolean |
| 32 | no_install: boolean | 32 | no_install: boolean |
| 33 | sign: boolean | 33 | sign: boolean |
| @@ -48,7 +48,7 @@ local record args | |||
| 48 | json: boolean | 48 | json: boolean |
| 49 | home: boolean | 49 | home: boolean |
| 50 | porcelain: boolean | 50 | porcelain: boolean |
| 51 | list: boolean --! | 51 | list: boolean |
| 52 | name: string | 52 | name: string |
| 53 | all: boolean | 53 | all: boolean |
| 54 | source: string | 54 | source: string |
| @@ -109,4 +109,4 @@ local record args | |||
| 109 | end | 109 | end |
| 110 | end | 110 | end |
| 111 | 111 | ||
| 112 | return args \ No newline at end of file | 112 | return args |
diff --git a/src/luarocks/download.lua b/src/luarocks/download.lua index 068ade96..b82cbe41 100644 --- a/src/luarocks/download.lua +++ b/src/luarocks/download.lua | |||
| @@ -34,13 +34,13 @@ function download.download_all(arch, name, namespace, version) | |||
| 34 | local has_result = false | 34 | local has_result = false |
| 35 | local all_ok = true | 35 | local all_ok = true |
| 36 | local any_err = "" | 36 | local any_err = "" |
| 37 | for name, result in pairs(results) do | 37 | for rname, result in pairs(results) do |
| 38 | for version, items in pairs(result) do | 38 | for rversion, items in pairs(result) do |
| 39 | for _, item in ipairs(items) do | 39 | for _, item in ipairs(items) do |
| 40 | 40 | ||
| 41 | if item.arch ~= "installed" then | 41 | if item.arch ~= "installed" then |
| 42 | has_result = true | 42 | has_result = true |
| 43 | local filename = path.make_url(item.repo, name, version, item.arch) | 43 | local filename = path.make_url(item.repo, rname, rversion, item.arch) |
| 44 | local ok, err = get_file(filename) | 44 | local ok, err = get_file(filename) |
| 45 | if not ok then | 45 | if not ok then |
| 46 | all_ok = false | 46 | all_ok = false |
diff --git a/src/luarocks/download.tl b/src/luarocks/download.tl index f993da0f..9a7076f7 100644 --- a/src/luarocks/download.tl +++ b/src/luarocks/download.tl | |||
| @@ -34,13 +34,13 @@ function download.download_all(arch: string, name: string, namespace: string, ve | |||
| 34 | local has_result = false | 34 | local has_result = false |
| 35 | local all_ok = true | 35 | local all_ok = true |
| 36 | local any_err = "" | 36 | local any_err = "" |
| 37 | for name, result in pairs(results) do -- luacheck: ignore 422 | 37 | for rname, result in pairs(results) do -- luacheck: ignore 422 |
| 38 | for version, items in pairs(result) do -- luacheck: ignore 422 | 38 | for rversion, items in pairs(result) do -- luacheck: ignore 422 |
| 39 | for _, item in ipairs(items) do | 39 | for _, item in ipairs(items) do |
| 40 | -- Ignore provided rocks. | 40 | -- Ignore provided rocks. |
| 41 | if item.arch ~= "installed" then | 41 | if item.arch ~= "installed" then |
| 42 | has_result = true | 42 | has_result = true |
| 43 | local filename = path.make_url(item.repo, name, version, item.arch) | 43 | local filename = path.make_url(item.repo, rname, rversion, item.arch) |
| 44 | local ok, err = get_file(filename) | 44 | local ok, err = get_file(filename) |
| 45 | if not ok then | 45 | if not ok then |
| 46 | all_ok = false | 46 | all_ok = false |
| @@ -54,11 +54,11 @@ function download.download_all(arch: string, name: string, namespace: string, ve | |||
| 54 | if has_result then | 54 | if has_result then |
| 55 | return all_ok, any_err | 55 | return all_ok, any_err |
| 56 | end | 56 | end |
| 57 | 57 | ||
| 58 | local rock = util.format_rock_name(name, namespace, version) | 58 | local rock = util.format_rock_name(name, namespace, version) |
| 59 | return nil, "Could not find a result named "..rock..(search_err and ": "..search_err or ".") | 59 | return nil, "Could not find a result named "..rock..(search_err and ": "..search_err or ".") |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | function download.download_file(arch: string, name: string, namespace?: string, version?: string, check_lua_versions?: boolean): string, string | 62 | function download.download_file(arch: string, name: string, namespace?: string, version?: string, check_lua_versions?: boolean): string, string |
| 63 | local query = queries.new(name, namespace, version, false, arch) | 63 | local query = queries.new(name, namespace, version, false, arch) |
| 64 | local search_err: string | 64 | local search_err: string |
| @@ -68,7 +68,7 @@ function download.download_file(arch: string, name: string, namespace?: string, | |||
| 68 | if url then | 68 | if url then |
| 69 | return get_file(url) | 69 | return get_file(url) |
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | local rock = util.format_rock_name(name, namespace, version) | 72 | local rock = util.format_rock_name(name, namespace, version) |
| 73 | return nil, "Could not find a result named "..rock..(search_err and ": "..search_err or ".") | 73 | return nil, "Could not find a result named "..rock..(search_err and ": "..search_err or ".") |
| 74 | end | 74 | end |
diff --git a/src/luarocks/fetch.tl b/src/luarocks/fetch.tl index 222b2194..6859142f 100644 --- a/src/luarocks/fetch.tl +++ b/src/luarocks/fetch.tl | |||
| @@ -196,7 +196,7 @@ function fetch.fetch_url(url: string, filename?: string, cache?: boolean, mirror | |||
| 196 | if not name then | 196 | if not name then |
| 197 | return nil, "Failed downloading "..url..(err and " - "..err or ""), err_code | 197 | return nil, "Failed downloading "..url..(err and " - "..err or ""), err_code |
| 198 | end | 198 | end |
| 199 | return name, nil, nil, from_cache --! string or boolean | 199 | return name, nil, nil, from_cache |
| 200 | else | 200 | else |
| 201 | return nil, "Unsupported protocol "..protocol | 201 | return nil, "Unsupported protocol "..protocol |
| 202 | end | 202 | end |
diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua index 6aabfb31..d890c04c 100644 --- a/src/luarocks/fetch/cvs.lua +++ b/src/luarocks/fetch/cvs.lua | |||
| @@ -16,7 +16,7 @@ local util = require("luarocks.util") | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | function cvs.get_sources(rockspec, extract, dest_dir) | 19 | function cvs.get_sources(rockspec, _extract, dest_dir) |
| 20 | local cvs_cmd = rockspec.variables.CVS | 20 | local cvs_cmd = rockspec.variables.CVS |
| 21 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") | 21 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") |
| 22 | if not ok then | 22 | if not ok then |
diff --git a/src/luarocks/fetch/cvs.tl b/src/luarocks/fetch/cvs.tl index c8fc5e3d..6d2264ee 100644 --- a/src/luarocks/fetch/cvs.tl +++ b/src/luarocks/fetch/cvs.tl | |||
| @@ -16,7 +16,7 @@ local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | |||
| 16 | -- @return (string, string) or (nil, string): The absolute pathname of | 16 | -- @return (string, string) or (nil, string): The absolute pathname of |
| 17 | -- the fetched source tarball and the temporary directory created to | 17 | -- the fetched source tarball and the temporary directory created to |
| 18 | -- store it; or nil and an error message. | 18 | -- store it; or nil and an error message. |
| 19 | function cvs.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string --? extract not needed | 19 | function cvs.get_sources(rockspec: Rockspec, _extract: boolean, dest_dir?: string): string, string --? extract not needed |
| 20 | local cvs_cmd = rockspec.variables.CVS | 20 | local cvs_cmd = rockspec.variables.CVS |
| 21 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") | 21 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") |
| 22 | if not ok then | 22 | if not ok then |
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index b32dfb1b..4242c342 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
| @@ -86,7 +86,7 @@ end | |||
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | function git.get_sources(rockspec, extract, dest_dir, depth) | 89 | function git.get_sources(rockspec, _extract, dest_dir, depth) |
| 90 | 90 | ||
| 91 | local git_cmd = rockspec.variables.GIT | 91 | local git_cmd = rockspec.variables.GIT |
| 92 | local name_version = rockspec.name .. "-" .. rockspec.version | 92 | local name_version = rockspec.name .. "-" .. rockspec.version |
diff --git a/src/luarocks/fetch/git.tl b/src/luarocks/fetch/git.tl index 6d281a33..2ad5b2b1 100644 --- a/src/luarocks/fetch/git.tl +++ b/src/luarocks/fetch/git.tl | |||
| @@ -86,7 +86,7 @@ end | |||
| 86 | -- @return (string, string) or (nil, string): The absolute pathname of | 86 | -- @return (string, string) or (nil, string): The absolute pathname of |
| 87 | -- the fetched source tarball and the temporary directory created to | 87 | -- the fetched source tarball and the temporary directory created to |
| 88 | -- store it; or nil and an error message. | 88 | -- store it; or nil and an error message. |
| 89 | function git.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string, depth?: string): string, string | 89 | function git.get_sources(rockspec: Rockspec, _extract: boolean, dest_dir?: string, depth?: string): string, string |
| 90 | 90 | ||
| 91 | local git_cmd = rockspec.variables.GIT | 91 | local git_cmd = rockspec.variables.GIT |
| 92 | local name_version = rockspec.name .. "-" .. rockspec.version | 92 | local name_version = rockspec.name .. "-" .. rockspec.version |
diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index 5265920f..6fe0812b 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua | |||
| @@ -16,7 +16,7 @@ local util = require("luarocks.util") | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | function hg.get_sources(rockspec, extract, dest_dir) | 19 | function hg.get_sources(rockspec, _extract, dest_dir) |
| 20 | 20 | ||
| 21 | local hg_cmd = rockspec.variables.HG | 21 | local hg_cmd = rockspec.variables.HG |
| 22 | local ok_available, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") | 22 | local ok_available, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") |
diff --git a/src/luarocks/fetch/hg.tl b/src/luarocks/fetch/hg.tl index 3f94cee1..e34f9145 100644 --- a/src/luarocks/fetch/hg.tl +++ b/src/luarocks/fetch/hg.tl | |||
| @@ -16,7 +16,7 @@ local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | |||
| 16 | -- @return (string, string) or (nil, string): The absolute pathname of | 16 | -- @return (string, string) or (nil, string): The absolute pathname of |
| 17 | -- the fetched source tarball and the temporary directory created to | 17 | -- the fetched source tarball and the temporary directory created to |
| 18 | -- store it; or nil and an error message. | 18 | -- store it; or nil and an error message. |
| 19 | function hg.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string | 19 | function hg.get_sources(rockspec: Rockspec, _extract: boolean, dest_dir?: string): string, string |
| 20 | 20 | ||
| 21 | local hg_cmd = rockspec.variables.HG | 21 | local hg_cmd = rockspec.variables.HG |
| 22 | local ok_available, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") | 22 | local ok_available, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") |
diff --git a/src/luarocks/fetch/sscm.lua b/src/luarocks/fetch/sscm.lua index f635c02f..20478c72 100644 --- a/src/luarocks/fetch/sscm.lua +++ b/src/luarocks/fetch/sscm.lua | |||
| @@ -15,7 +15,7 @@ local dir = require("luarocks.dir") | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | function sscm.get_sources(rockspec, extract, dest_dir) | 18 | function sscm.get_sources(rockspec, _extract, _dest_dir) |
| 19 | 19 | ||
| 20 | local sscm_cmd = rockspec.variables.SSCM | 20 | local sscm_cmd = rockspec.variables.SSCM |
| 21 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) | 21 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) |
diff --git a/src/luarocks/fetch/sscm.tl b/src/luarocks/fetch/sscm.tl index 7c850a4b..45255bcb 100644 --- a/src/luarocks/fetch/sscm.tl +++ b/src/luarocks/fetch/sscm.tl | |||
| @@ -15,7 +15,7 @@ local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | |||
| 15 | -- @return (string, string) or (nil, string): The absolute pathname of | 15 | -- @return (string, string) or (nil, string): The absolute pathname of |
| 16 | -- the fetched source tarball and the temporary directory created to | 16 | -- the fetched source tarball and the temporary directory created to |
| 17 | -- store it; or nil and an error message. | 17 | -- store it; or nil and an error message. |
| 18 | function sscm.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string | 18 | function sscm.get_sources(rockspec: Rockspec, _extract: boolean, _dest_dir?: string): string, string |
| 19 | 19 | ||
| 20 | local sscm_cmd = rockspec.variables.SSCM | 20 | local sscm_cmd = rockspec.variables.SSCM |
| 21 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) | 21 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) |
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua index cd467cef..e265684c 100644 --- a/src/luarocks/fetch/svn.lua +++ b/src/luarocks/fetch/svn.lua | |||
| @@ -16,7 +16,7 @@ local util = require("luarocks.util") | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | function svn.get_sources(rockspec, extract, dest_dir) | 19 | function svn.get_sources(rockspec, _extract, dest_dir) |
| 20 | 20 | ||
| 21 | local svn_cmd = rockspec.variables.SVN | 21 | local svn_cmd = rockspec.variables.SVN |
| 22 | local ok, err_msg = fs.is_tool_available(svn_cmd, "Subversion") | 22 | local ok, err_msg = fs.is_tool_available(svn_cmd, "Subversion") |
diff --git a/src/luarocks/fetch/svn.tl b/src/luarocks/fetch/svn.tl index 4d738d74..741b0141 100644 --- a/src/luarocks/fetch/svn.tl +++ b/src/luarocks/fetch/svn.tl | |||
| @@ -16,7 +16,7 @@ local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | |||
| 16 | -- @return (string, string) or (nil, string): The absolute pathname of | 16 | -- @return (string, string) or (nil, string): The absolute pathname of |
| 17 | -- the fetched source tarball and the temporary directory created to | 17 | -- the fetched source tarball and the temporary directory created to |
| 18 | -- store it; or nil and an error message. | 18 | -- store it; or nil and an error message. |
| 19 | function svn.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string | 19 | function svn.get_sources(rockspec: Rockspec, _extract: boolean, dest_dir?: string): string, string |
| 20 | 20 | ||
| 21 | local svn_cmd = rockspec.variables.SVN | 21 | local svn_cmd = rockspec.variables.SVN |
| 22 | local ok, err_msg = fs.is_tool_available(svn_cmd, "Subversion") | 22 | local ok, err_msg = fs.is_tool_available(svn_cmd, "Subversion") |
diff --git a/src/luarocks/fs.d.tl b/src/luarocks/fs.d.tl index 3d145bab..580f7c3f 100644 --- a/src/luarocks/fs.d.tl +++ b/src/luarocks/fs.d.tl | |||
| @@ -43,7 +43,7 @@ local record fs | |||
| 43 | record Lock | 43 | record Lock |
| 44 | free: function() | 44 | free: function() |
| 45 | end | 45 | end |
| 46 | lock_access: function(string, ?boolean): Lock, string --! | 46 | lock_access: function(string, ?boolean): Lock, string |
| 47 | unlock_access: function(Lock) | 47 | unlock_access: function(Lock) |
| 48 | copy: function(string, string, ?string): boolean, string | 48 | copy: function(string, string, ?string): boolean, string |
| 49 | unpack_archive: function(string): boolean, string | 49 | unpack_archive: function(string): boolean, string |
diff --git a/src/luarocks/manif.tl b/src/luarocks/manif.tl index 23ed081b..6a62a73f 100644 --- a/src/luarocks/manif.tl +++ b/src/luarocks/manif.tl | |||
| @@ -142,7 +142,7 @@ function manif.load_manifest(repo_url: string, lua_version?: string, versioned_o | |||
| 142 | pathname = nozip | 142 | pathname = nozip |
| 143 | end | 143 | end |
| 144 | local manifest, err, errcode = core.manifest_loader(pathname, repo_url, lua_version) | 144 | local manifest, err, errcode = core.manifest_loader(pathname, repo_url, lua_version) |
| 145 | if not manifest and err is string then --! | 145 | if not manifest and err is string then |
| 146 | return nil, err, errcode | 146 | return nil, err, errcode |
| 147 | end | 147 | end |
| 148 | 148 | ||
diff --git a/src/luarocks/manif/writer.lua b/src/luarocks/manif/writer.lua index 04becbac..7d78c2ea 100644 --- a/src/luarocks/manif/writer.lua +++ b/src/luarocks/manif/writer.lua | |||
| @@ -134,7 +134,7 @@ end | |||
| 134 | local function sort_package_matching_table(tbl) | 134 | local function sort_package_matching_table(tbl) |
| 135 | 135 | ||
| 136 | if next(tbl) then | 136 | if next(tbl) then |
| 137 | for item, pkgs in pairs(tbl) do | 137 | for _item, pkgs in pairs(tbl) do |
| 138 | if #pkgs > 1 then | 138 | if #pkgs > 1 then |
| 139 | table.sort(pkgs, sort_pkgs) | 139 | table.sort(pkgs, sort_pkgs) |
| 140 | 140 | ||
| @@ -261,17 +261,17 @@ function writer.make_rock_manifest(name, version) | |||
| 261 | local walk = tree | 261 | local walk = tree |
| 262 | local last | 262 | local last |
| 263 | local last_name | 263 | local last_name |
| 264 | local next | 264 | local nxt |
| 265 | for filename in file:gmatch("[^\\/]+") do | 265 | for filename in file:gmatch("[^\\/]+") do |
| 266 | next = walk[filename] | 266 | nxt = walk[filename] |
| 267 | if not next then | 267 | if not nxt then |
| 268 | next = {} | 268 | nxt = {} |
| 269 | walk[filename] = next | 269 | walk[filename] = nxt |
| 270 | end | 270 | end |
| 271 | last = walk | 271 | last = walk |
| 272 | last_name = filename | 272 | last_name = filename |
| 273 | assert(type(next) == "table") | 273 | assert(type(nxt) == "table") |
| 274 | walk = next | 274 | walk = nxt |
| 275 | end | 275 | end |
| 276 | if fs.is_file(full_path) then | 276 | if fs.is_file(full_path) then |
| 277 | 277 | ||
| @@ -303,8 +303,8 @@ function writer.make_namespace_file(name, version, namespace) | |||
| 303 | if not fd then | 303 | if not fd then |
| 304 | return nil, err | 304 | return nil, err |
| 305 | end | 305 | end |
| 306 | local ok, err = fd:write(namespace) | 306 | fd, err = fd:write(namespace) |
| 307 | if not ok then | 307 | if not fd then |
| 308 | return nil, err | 308 | return nil, err |
| 309 | end | 309 | end |
| 310 | fd:close() | 310 | fd:close() |
| @@ -416,7 +416,7 @@ function writer.remove_from_manifest(name, version, repo, deps_mode) | |||
| 416 | 416 | ||
| 417 | if deps_mode == "none" then deps_mode = cfg.deps_mode end | 417 | if deps_mode == "none" then deps_mode = cfg.deps_mode end |
| 418 | 418 | ||
| 419 | local manifest, err = manif.load_manifest(rocks_dir) | 419 | local manifest, _err = manif.load_manifest(rocks_dir) |
| 420 | if not manifest then | 420 | if not manifest then |
| 421 | util.printerr("No existing manifest. Attempting to rebuild...") | 421 | util.printerr("No existing manifest. Attempting to rebuild...") |
| 422 | 422 | ||
diff --git a/src/luarocks/manif/writer.tl b/src/luarocks/manif/writer.tl index b333c36f..7b30f5c2 100644 --- a/src/luarocks/manif/writer.tl +++ b/src/luarocks/manif/writer.tl | |||
| @@ -134,7 +134,7 @@ end | |||
| 134 | local function sort_package_matching_table(tbl: {string: {string}}) | 134 | local function sort_package_matching_table(tbl: {string: {string}}) |
| 135 | 135 | ||
| 136 | if next(tbl) then | 136 | if next(tbl) then |
| 137 | for item, pkgs in pairs(tbl) do | 137 | for _item, pkgs in pairs(tbl) do |
| 138 | if #pkgs > 1 then | 138 | if #pkgs > 1 then |
| 139 | table.sort(pkgs, sort_pkgs) | 139 | table.sort(pkgs, sort_pkgs) |
| 140 | -- Remove duplicates from the sorted array. | 140 | -- Remove duplicates from the sorted array. |
| @@ -261,17 +261,17 @@ function writer.make_rock_manifest(name: string, version: string): boolean, stri | |||
| 261 | local walk = tree | 261 | local walk = tree |
| 262 | local last: {string : Entry} | 262 | local last: {string : Entry} |
| 263 | local last_name: string | 263 | local last_name: string |
| 264 | local next: Entry | 264 | local nxt: Entry |
| 265 | for filename in file:gmatch("[^\\/]+") do | 265 | for filename in file:gmatch("[^\\/]+") do |
| 266 | next = walk[filename] | 266 | nxt = walk[filename] |
| 267 | if not next then | 267 | if not nxt then |
| 268 | next = {} | 268 | nxt = {} |
| 269 | walk[filename] = next | 269 | walk[filename] = nxt |
| 270 | end | 270 | end |
| 271 | last = walk | 271 | last = walk |
| 272 | last_name = filename | 272 | last_name = filename |
| 273 | assert(next is {string: Entry}) | 273 | assert(nxt is {string: Entry}) |
| 274 | walk = next | 274 | walk = nxt |
| 275 | end | 275 | end |
| 276 | if fs.is_file(full_path) then | 276 | if fs.is_file(full_path) then |
| 277 | 277 | ||
| @@ -303,8 +303,8 @@ function writer.make_namespace_file(name: string, version: string, namespace?: s | |||
| 303 | if not fd then | 303 | if not fd then |
| 304 | return nil, err | 304 | return nil, err |
| 305 | end | 305 | end |
| 306 | local ok, err = fd:write(namespace) | 306 | fd, err = fd:write(namespace) |
| 307 | if not ok then | 307 | if not fd then |
| 308 | return nil, err | 308 | return nil, err |
| 309 | end | 309 | end |
| 310 | fd:close() | 310 | fd:close() |
| @@ -370,7 +370,7 @@ end | |||
| 370 | -- "none" for using the default dependency mode from the configuration. | 370 | -- "none" for using the default dependency mode from the configuration. |
| 371 | -- @return boolean or (nil, string): True if manifest was updated successfully, | 371 | -- @return boolean or (nil, string): True if manifest was updated successfully, |
| 372 | -- or nil and an error message. | 372 | -- or nil and an error message. |
| 373 | function writer.add_to_manifest(name: string, version: string, repo: string, deps_mode: string): boolean, string | 373 | function writer.add_to_manifest(name: string, version: string, repo: string, deps_mode: string): boolean, string |
| 374 | assert(not name:match("/")) | 374 | assert(not name:match("/")) |
| 375 | local rocks_dir = path.rocks_dir(repo or cfg.root_dir) | 375 | local rocks_dir = path.rocks_dir(repo or cfg.root_dir) |
| 376 | 376 | ||
| @@ -388,7 +388,7 @@ function writer.add_to_manifest(name: string, version: string, repo: string, dep | |||
| 388 | local results: {string : {string : {Result}}} = {[name] = {[version] = {{arch = "installed", repo = rocks_dir}}}} | 388 | local results: {string : {string : {Result}}} = {[name] = {[version] = {{arch = "installed", repo = rocks_dir}}}} |
| 389 | 389 | ||
| 390 | local ok: boolean | 390 | local ok: boolean |
| 391 | ok, err = store_results(results, manifest) --! | 391 | ok, err = store_results(results, manifest) |
| 392 | if not ok then return nil, err end | 392 | if not ok then return nil, err end |
| 393 | 393 | ||
| 394 | update_dependencies(manifest, deps_mode) | 394 | update_dependencies(manifest, deps_mode) |
| @@ -416,7 +416,7 @@ function writer.remove_from_manifest(name: string, version: string, repo: string | |||
| 416 | 416 | ||
| 417 | if deps_mode == "none" then deps_mode = cfg.deps_mode end | 417 | if deps_mode == "none" then deps_mode = cfg.deps_mode end |
| 418 | 418 | ||
| 419 | local manifest, err = manif.load_manifest(rocks_dir) | 419 | local manifest, _err = manif.load_manifest(rocks_dir) |
| 420 | if not manifest then | 420 | if not manifest then |
| 421 | util.printerr("No existing manifest. Attempting to rebuild...") | 421 | util.printerr("No existing manifest. Attempting to rebuild...") |
| 422 | -- Manifest built by `writer.make_manifest` should already | 422 | -- Manifest built by `writer.make_manifest` should already |
| @@ -436,7 +436,7 @@ function writer.remove_from_manifest(name: string, version: string, repo: string | |||
| 436 | return writer.make_manifest(rocks_dir, deps_mode) | 436 | return writer.make_manifest(rocks_dir, deps_mode) |
| 437 | end | 437 | end |
| 438 | 438 | ||
| 439 | remove_package_items(manifest.modules, name, version, version_entry.modules) --! | 439 | remove_package_items(manifest.modules, name, version, version_entry.modules) |
| 440 | remove_package_items(manifest.commands, name, version, version_entry.commands) | 440 | remove_package_items(manifest.commands, name, version, version_entry.commands) |
| 441 | 441 | ||
| 442 | package_entry[version] = nil | 442 | package_entry[version] = nil |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 8a4df1a0..2596ca11 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
| @@ -111,18 +111,19 @@ function pack.pack_installed_rock(query, tree) | |||
| 111 | local temp_dir = fs.make_temp_dir("pack") | 111 | local temp_dir = fs.make_temp_dir("pack") |
| 112 | fs.copy_contents(prefix, temp_dir) | 112 | fs.copy_contents(prefix, temp_dir) |
| 113 | 113 | ||
| 114 | local ok | ||
| 114 | local is_binary = false | 115 | local is_binary = false |
| 115 | if rock_manifest.lib then | 116 | if rock_manifest.lib then |
| 116 | local ok, err = copy_back_files(name, version, (rock_manifest.lib), path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec") | 117 | ok, err = copy_back_files(name, version, (rock_manifest.lib), path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec") |
| 117 | if not ok then return nil, "Failed copying back files: " .. err end | 118 | if not ok then return nil, "Failed copying back files: " .. err end |
| 118 | is_binary = true | 119 | is_binary = true |
| 119 | end | 120 | end |
| 120 | if rock_manifest.lua then | 121 | if rock_manifest.lua then |
| 121 | local ok, err = copy_back_files(name, version, (rock_manifest.lua), path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") | 122 | ok, err = copy_back_files(name, version, (rock_manifest.lua), path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") |
| 122 | if not ok then return nil, "Failed copying back files: " .. err end | 123 | if not ok then return nil, "Failed copying back files: " .. err end |
| 123 | end | 124 | end |
| 124 | 125 | ||
| 125 | local ok, err = fs.change_dir(temp_dir) | 126 | ok, err = fs.change_dir(temp_dir) |
| 126 | if not ok then return nil, err end | 127 | if not ok then return nil, err end |
| 127 | if not is_binary and not repos.has_binaries(name, version) then | 128 | if not is_binary and not repos.has_binaries(name, version) then |
| 128 | rock_file = rock_file:gsub("%." .. cfg.arch:gsub("%-", "%%-") .. "%.", ".all.") | 129 | rock_file = rock_file:gsub("%." .. cfg.arch:gsub("%-", "%%-") .. "%.", ".all.") |
| @@ -172,16 +173,22 @@ function pack.pack_binary_rock(name, namespace, version, sign, cmd) | |||
| 172 | util.schedule_function(fs.delete, temp_dir) | 173 | util.schedule_function(fs.delete, temp_dir) |
| 173 | 174 | ||
| 174 | path.use_tree(temp_dir) | 175 | path.use_tree(temp_dir) |
| 175 | local ok, err = cmd() | 176 | |
| 176 | if not ok then | 177 | local ret |
| 178 | ret, err = cmd() | ||
| 179 | if not ret then | ||
| 177 | return nil, err | 180 | return nil, err |
| 178 | end | 181 | end |
| 182 | |||
| 179 | local rname, rversion = path.parse_name(name) | 183 | local rname, rversion = path.parse_name(name) |
| 180 | if not rname then | 184 | if not rname then |
| 181 | rname, rversion = name, version | 185 | rname, rversion = name, version |
| 182 | end | 186 | end |
| 183 | local query = queries.new(rname, namespace, rversion) | 187 | local query = queries.new(rname, namespace, rversion) |
| 184 | local file, err = pack.pack_installed_rock(query, temp_dir) | 188 | |
| 189 | local file | ||
| 190 | file, err = pack.pack_installed_rock(query, temp_dir) | ||
| 191 | |||
| 185 | return pack.report_and_sign_local_file(file, err, sign) | 192 | return pack.report_and_sign_local_file(file, err, sign) |
| 186 | end | 193 | end |
| 187 | 194 | ||
diff --git a/src/luarocks/pack.tl b/src/luarocks/pack.tl index 8bb284f7..d23595a9 100644 --- a/src/luarocks/pack.tl +++ b/src/luarocks/pack.tl | |||
| @@ -111,18 +111,19 @@ function pack.pack_installed_rock(query: Query, tree: string | Tree): string, st | |||
| 111 | local temp_dir = fs.make_temp_dir("pack") | 111 | local temp_dir = fs.make_temp_dir("pack") |
| 112 | fs.copy_contents(prefix, temp_dir) | 112 | fs.copy_contents(prefix, temp_dir) |
| 113 | 113 | ||
| 114 | local ok: boolean | ||
| 114 | local is_binary = false | 115 | local is_binary = false |
| 115 | if rock_manifest.lib then | 116 | if rock_manifest.lib then |
| 116 | local ok, err = copy_back_files(name, version, (rock_manifest.lib as {string: Entry}), path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec") | 117 | ok, err = copy_back_files(name, version, (rock_manifest.lib as {string: Entry}), path.deploy_lib_dir(repo), dir.path(temp_dir, "lib"), "exec") |
| 117 | if not ok then return nil, "Failed copying back files: " .. err end | 118 | if not ok then return nil, "Failed copying back files: " .. err end |
| 118 | is_binary = true | 119 | is_binary = true |
| 119 | end | 120 | end |
| 120 | if rock_manifest.lua then | 121 | if rock_manifest.lua then |
| 121 | local ok, err = copy_back_files(name, version, (rock_manifest.lua as {string: Entry}), path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") | 122 | ok, err = copy_back_files(name, version, (rock_manifest.lua as {string: Entry}), path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") |
| 122 | if not ok then return nil, "Failed copying back files: " .. err end | 123 | if not ok then return nil, "Failed copying back files: " .. err end |
| 123 | end | 124 | end |
| 124 | 125 | ||
| 125 | local ok, err = fs.change_dir(temp_dir) | 126 | ok, err = fs.change_dir(temp_dir) |
| 126 | if not ok then return nil, err end | 127 | if not ok then return nil, err end |
| 127 | if not is_binary and not repos.has_binaries(name, version) then | 128 | if not is_binary and not repos.has_binaries(name, version) then |
| 128 | rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.") | 129 | rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.") |
| @@ -172,16 +173,22 @@ function pack.pack_binary_rock(name: string, namespace: string, version: string, | |||
| 172 | util.schedule_function(fs.delete, temp_dir) | 173 | util.schedule_function(fs.delete, temp_dir) |
| 173 | 174 | ||
| 174 | path.use_tree(temp_dir) | 175 | path.use_tree(temp_dir) |
| 175 | local ok, err = cmd() | 176 | |
| 176 | if not ok then | 177 | local ret: string |
| 178 | ret, err = cmd() | ||
| 179 | if not ret then | ||
| 177 | return nil, err | 180 | return nil, err |
| 178 | end | 181 | end |
| 182 | |||
| 179 | local rname, rversion = path.parse_name(name) | 183 | local rname, rversion = path.parse_name(name) |
| 180 | if not rname then | 184 | if not rname then |
| 181 | rname, rversion = name, version | 185 | rname, rversion = name, version |
| 182 | end | 186 | end |
| 183 | local query = queries.new(rname, namespace, rversion) | 187 | local query = queries.new(rname, namespace, rversion) |
| 184 | local file, err = pack.pack_installed_rock(query, temp_dir) | 188 | |
| 189 | local file: string | ||
| 190 | file, err = pack.pack_installed_rock(query, temp_dir) | ||
| 191 | |||
| 185 | return pack.report_and_sign_local_file(file, err, sign) | 192 | return pack.report_and_sign_local_file(file, err, sign) |
| 186 | end | 193 | end |
| 187 | 194 | ||
diff --git a/src/luarocks/queries.lua b/src/luarocks/queries.lua index 34b6d687..917ca2f4 100644 --- a/src/luarocks/queries.lua +++ b/src/luarocks/queries.lua | |||
| @@ -11,7 +11,6 @@ local query = require("luarocks.core.types.query") | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | |||
| 15 | local query_mt = {} | 14 | local query_mt = {} |
| 16 | 15 | ||
| 17 | query_mt.__index = query.Query | 16 | query_mt.__index = query.Query |
diff --git a/src/luarocks/queries.tl b/src/luarocks/queries.tl index 303d9250..ed421a97 100644 --- a/src/luarocks/queries.tl +++ b/src/luarocks/queries.tl | |||
| @@ -9,7 +9,6 @@ local cfg = require("luarocks.core.cfg") | |||
| 9 | local query = require("luarocks.core.types.query") | 9 | local query = require("luarocks.core.types.query") |
| 10 | local type Query = query.Query | 10 | local type Query = query.Query |
| 11 | 11 | ||
| 12 | local type Version = require("luarocks.core.types.version").Version | ||
| 13 | local type Constraint = require("luarocks.core.types.version").Constraint | 12 | local type Constraint = require("luarocks.core.types.version").Constraint |
| 14 | 13 | ||
| 15 | local query_mt: metatable<Query> = {} | 14 | local query_mt: metatable<Query> = {} |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index 72d3a1d8..ef19eac2 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua | |||
| @@ -36,7 +36,7 @@ local function check_dependents(name, versions, deps_mode) | |||
| 36 | local_rocks[name] = nil | 36 | local_rocks[name] = nil |
| 37 | for rock_name, rock_versions in pairs(local_rocks) do | 37 | for rock_name, rock_versions in pairs(local_rocks) do |
| 38 | for rock_version, _ in pairs(rock_versions) do | 38 | for rock_version, _ in pairs(rock_versions) do |
| 39 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(rock_name, rock_version)) | 39 | local rockspec = fetch.load_rockspec(path.rockspec_file(rock_name, rock_version)) |
| 40 | if rockspec then | 40 | if rockspec then |
| 41 | local _, missing = deps.match_deps(rockspec.dependencies.queries, rockspec.rocks_provided, deps_mode, skip_set) | 41 | local _, missing = deps.match_deps(rockspec.dependencies.queries, rockspec.rocks_provided, deps_mode, skip_set) |
| 42 | if missing[name] then | 42 | if missing[name] then |
| @@ -127,8 +127,13 @@ function remove.remove_other_versions(name, version, force, fast) | |||
| 127 | if not fast then | 127 | if not fast then |
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) | 130 | local rock_manifest, err = manif.load_rock_manifest(name, version) |
| 131 | local ok, err = repos.check_everything_is_installed(name, version, rock_manifest, cfg.root_dir, false) | 131 | if not rock_manifest then |
| 132 | return nil, err | ||
| 133 | end | ||
| 134 | |||
| 135 | local ok | ||
| 136 | ok, err = repos.check_everything_is_installed(name, version, rock_manifest, cfg.root_dir, false) | ||
| 132 | if not ok then | 137 | if not ok then |
| 133 | return nil, err | 138 | return nil, err |
| 134 | end | 139 | end |
diff --git a/src/luarocks/remove.tl b/src/luarocks/remove.tl index 11d270a9..21fdd51b 100644 --- a/src/luarocks/remove.tl +++ b/src/luarocks/remove.tl | |||
| @@ -36,7 +36,7 @@ local function check_dependents(name: string, versions: {string: {Result}}, deps | |||
| 36 | local_rocks[name] = nil | 36 | local_rocks[name] = nil |
| 37 | for rock_name, rock_versions in pairs(local_rocks) do | 37 | for rock_name, rock_versions in pairs(local_rocks) do |
| 38 | for rock_version, _ in pairs(rock_versions) do | 38 | for rock_version, _ in pairs(rock_versions) do |
| 39 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(rock_name, rock_version)) | 39 | local rockspec = fetch.load_rockspec(path.rockspec_file(rock_name, rock_version)) |
| 40 | if rockspec then | 40 | if rockspec then |
| 41 | local _, missing = deps.match_deps(rockspec.dependencies.queries, rockspec.rocks_provided, deps_mode, skip_set) | 41 | local _, missing = deps.match_deps(rockspec.dependencies.queries, rockspec.rocks_provided, deps_mode, skip_set) |
| 42 | if missing[name] then | 42 | if missing[name] then |
| @@ -127,8 +127,13 @@ function remove.remove_other_versions(name: string, version: string, force: bool | |||
| 127 | if not fast then | 127 | if not fast then |
| 128 | -- since we're not using --keep, this means that all files of the rock being installed | 128 | -- since we're not using --keep, this means that all files of the rock being installed |
| 129 | -- should be available as non-versioned variants. Double-check that: | 129 | -- should be available as non-versioned variants. Double-check that: |
| 130 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) | 130 | local rock_manifest, err = manif.load_rock_manifest(name, version) |
| 131 | local ok, err = repos.check_everything_is_installed(name, version, rock_manifest, cfg.root_dir, false) | 131 | if not rock_manifest then |
| 132 | return nil, err | ||
| 133 | end | ||
| 134 | |||
| 135 | local ok: boolean | ||
| 136 | ok, err = repos.check_everything_is_installed(name, version, rock_manifest, cfg.root_dir, false) | ||
| 132 | if not ok then | 137 | if not ok then |
| 133 | return nil, err | 138 | return nil, err |
| 134 | end | 139 | end |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 956825e4..c4c5f28f 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
| @@ -160,7 +160,7 @@ function repos.has_binaries(name, version) | |||
| 160 | end | 160 | end |
| 161 | local bin = entries["bin"] | 161 | local bin = entries["bin"] |
| 162 | if type(bin) == "table" then | 162 | if type(bin) == "table" then |
| 163 | for bin_name, md5 in pairs(bin) do | 163 | for bin_name, _md5 in pairs(bin) do |
| 164 | 164 | ||
| 165 | if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, bin_name)) then | 165 | if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, bin_name)) then |
| 166 | return true | 166 | return true |
| @@ -222,7 +222,7 @@ local function find_suffixed(file, suffix) | |||
| 222 | end | 222 | end |
| 223 | 223 | ||
| 224 | local function check_suffix(filename, suffix) | 224 | local function check_suffix(filename, suffix) |
| 225 | local suffixed_filename, err = find_suffixed(filename, suffix) | 225 | local suffixed_filename, _err = find_suffixed(filename, suffix) |
| 226 | if not suffixed_filename then | 226 | if not suffixed_filename then |
| 227 | return "" | 227 | return "" |
| 228 | end | 228 | end |
| @@ -308,7 +308,8 @@ local function prepare_op_install() | |||
| 308 | return nil, err | 308 | return nil, err |
| 309 | end | 309 | end |
| 310 | 310 | ||
| 311 | local backup, err = backup_existing(op.backup, op.dst) | 311 | local backup |
| 312 | backup, err = backup_existing(op.backup, op.dst) | ||
| 312 | if err then | 313 | if err then |
| 313 | return nil, err | 314 | return nil, err |
| 314 | end | 315 | end |
| @@ -559,8 +560,12 @@ local function double_check_all(double_checks, repo) | |||
| 559 | local errs = {} | 560 | local errs = {} |
| 560 | for next_name, versions in pairs(double_checks) do | 561 | for next_name, versions in pairs(double_checks) do |
| 561 | for next_version in pairs(versions) do | 562 | for next_version in pairs(versions) do |
| 562 | local rock_manifest, load_err = manif.load_rock_manifest(next_name, next_version) | 563 | local rock_manifest |
| 563 | local ok, err = repos.check_everything_is_installed(next_name, next_version, rock_manifest, repo, true) | 564 | local ok, err |
| 565 | rock_manifest, err = manif.load_rock_manifest(next_name, next_version) | ||
| 566 | if rock_manifest then | ||
| 567 | ok, err = repos.check_everything_is_installed(next_name, next_version, rock_manifest, repo, true) | ||
| 568 | end | ||
| 564 | if not ok then | 569 | if not ok then |
| 565 | table.insert(errs, err) | 570 | table.insert(errs, err) |
| 566 | end | 571 | end |
| @@ -582,7 +587,7 @@ end | |||
| 582 | 587 | ||
| 583 | 588 | ||
| 584 | 589 | ||
| 585 | function repos.delete_local_version(name, version, deps_mode, quick) | 590 | function repos.delete_local_version(name, version, _deps_mode, quick) |
| 586 | assert(not name:match("/")) | 591 | assert(not name:match("/")) |
| 587 | 592 | ||
| 588 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) | 593 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) |
| @@ -602,7 +607,7 @@ function repos.delete_local_version(name, version, deps_mode, quick) | |||
| 602 | if rock_manifest.bin then | 607 | if rock_manifest.bin then |
| 603 | repos.recurse_rock_manifest_entry(rock_manifest.bin, function(file_path) | 608 | repos.recurse_rock_manifest_entry(rock_manifest.bin, function(file_path) |
| 604 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) | 609 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) |
| 605 | local mode, cur_name, cur_version, item_name = check_spot_if_available(name, version, "bin", file_path) | 610 | local mode, _cur_name, _cur_version, item_name = check_spot_if_available(name, version, "bin", file_path) |
| 606 | if mode == "v" then | 611 | if mode == "v" then |
| 607 | table.insert(deletes, { name = paths.v, suffix = cfg.wrapper_suffix }) | 612 | table.insert(deletes, { name = paths.v, suffix = cfg.wrapper_suffix }) |
| 608 | else | 613 | else |
| @@ -622,7 +627,7 @@ function repos.delete_local_version(name, version, deps_mode, quick) | |||
| 622 | if rock_manifest.lua then | 627 | if rock_manifest.lua then |
| 623 | repos.recurse_rock_manifest_entry(rock_manifest.lua, function(file_path) | 628 | repos.recurse_rock_manifest_entry(rock_manifest.lua, function(file_path) |
| 624 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) | 629 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) |
| 625 | local mode, cur_name, cur_version, item_name = check_spot_if_available(name, version, "lua", file_path) | 630 | local mode, _cur_name, _cur_version, item_name = check_spot_if_available(name, version, "lua", file_path) |
| 626 | if mode == "v" then | 631 | if mode == "v" then |
| 627 | table.insert(deletes, { name = paths.v }) | 632 | table.insert(deletes, { name = paths.v }) |
| 628 | else | 633 | else |
| @@ -644,7 +649,7 @@ function repos.delete_local_version(name, version, deps_mode, quick) | |||
| 644 | if rock_manifest.lib then | 649 | if rock_manifest.lib then |
| 645 | repos.recurse_rock_manifest_entry(rock_manifest.lib, function(file_path) | 650 | repos.recurse_rock_manifest_entry(rock_manifest.lib, function(file_path) |
| 646 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) | 651 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) |
| 647 | local mode, cur_name, cur_version, item_name = check_spot_if_available(name, version, "lib", file_path) | 652 | local mode, _cur_name, _cur_version, item_name = check_spot_if_available(name, version, "lib", file_path) |
| 648 | if mode == "v" then | 653 | if mode == "v" then |
| 649 | table.insert(deletes, { name = paths.v }) | 654 | table.insert(deletes, { name = paths.v }) |
| 650 | else | 655 | else |
diff --git a/src/luarocks/repos.tl b/src/luarocks/repos.tl index 29645112..93c85d9a 100644 --- a/src/luarocks/repos.tl +++ b/src/luarocks/repos.tl | |||
| @@ -160,7 +160,7 @@ function repos.has_binaries(name: string, version: string): boolean | |||
| 160 | end | 160 | end |
| 161 | local bin = entries["bin"] | 161 | local bin = entries["bin"] |
| 162 | if bin is {string:Entry} then | 162 | if bin is {string:Entry} then |
| 163 | for bin_name, md5 in pairs(bin) do | 163 | for bin_name, _md5 in pairs(bin) do |
| 164 | -- TODO verify that it is the same file. If it isn't, find the actual command. | 164 | -- TODO verify that it is the same file. If it isn't, find the actual command. |
| 165 | if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, bin_name)) then | 165 | if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, bin_name)) then |
| 166 | return true | 166 | return true |
| @@ -222,7 +222,7 @@ local function find_suffixed(file: string, suffix: string): string, string | |||
| 222 | end | 222 | end |
| 223 | 223 | ||
| 224 | local function check_suffix(filename: string, suffix: string): string | 224 | local function check_suffix(filename: string, suffix: string): string |
| 225 | local suffixed_filename, err = find_suffixed(filename, suffix) | 225 | local suffixed_filename, _err = find_suffixed(filename, suffix) |
| 226 | if not suffixed_filename then | 226 | if not suffixed_filename then |
| 227 | return "" | 227 | return "" |
| 228 | end | 228 | end |
| @@ -308,7 +308,8 @@ local function prepare_op_install(): function(Op): (boolean, string), function() | |||
| 308 | return nil, err | 308 | return nil, err |
| 309 | end | 309 | end |
| 310 | 310 | ||
| 311 | local backup, err = backup_existing(op.backup, op.dst) | 311 | local backup: string |
| 312 | backup, err = backup_existing(op.backup, op.dst) | ||
| 312 | if err then | 313 | if err then |
| 313 | return nil, err | 314 | return nil, err |
| 314 | end | 315 | end |
| @@ -559,8 +560,12 @@ local function double_check_all(double_checks: {string: {string: boolean}}, repo | |||
| 559 | local errs: {string} = {} | 560 | local errs: {string} = {} |
| 560 | for next_name, versions in pairs(double_checks) do | 561 | for next_name, versions in pairs(double_checks) do |
| 561 | for next_version in pairs(versions) do | 562 | for next_version in pairs(versions) do |
| 562 | local rock_manifest, load_err = manif.load_rock_manifest(next_name, next_version) | 563 | local rock_manifest: {string: Entry} |
| 563 | local ok, err = repos.check_everything_is_installed(next_name, next_version, rock_manifest, repo, true) | 564 | local ok, err: boolean, string |
| 565 | rock_manifest, err = manif.load_rock_manifest(next_name, next_version) | ||
| 566 | if rock_manifest then | ||
| 567 | ok, err = repos.check_everything_is_installed(next_name, next_version, rock_manifest, repo, true) | ||
| 568 | end | ||
| 564 | if not ok then | 569 | if not ok then |
| 565 | table.insert(errs, err) | 570 | table.insert(errs, err) |
| 566 | end | 571 | end |
| @@ -582,7 +587,7 @@ end | |||
| 582 | -- of another version that provides the same module that | 587 | -- of another version that provides the same module that |
| 583 | -- was deleted. This is used during 'purge', as every module | 588 | -- was deleted. This is used during 'purge', as every module |
| 584 | -- will be eventually deleted. | 589 | -- will be eventually deleted. |
| 585 | function repos.delete_local_version(name: string, version: string, deps_mode: string, quick: boolean): boolean, string, string | 590 | function repos.delete_local_version(name: string, version: string, _deps_mode: string, quick: boolean): boolean, string, string |
| 586 | assert(not name:match("/")) | 591 | assert(not name:match("/")) |
| 587 | 592 | ||
| 588 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) | 593 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) |
| @@ -602,7 +607,7 @@ function repos.delete_local_version(name: string, version: string, deps_mode: st | |||
| 602 | if rock_manifest.bin then | 607 | if rock_manifest.bin then |
| 603 | repos.recurse_rock_manifest_entry(rock_manifest.bin, function(file_path: string): boolean, string | 608 | repos.recurse_rock_manifest_entry(rock_manifest.bin, function(file_path: string): boolean, string |
| 604 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) | 609 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) |
| 605 | local mode, cur_name, cur_version, item_name = check_spot_if_available(name, version, "bin", file_path) | 610 | local mode, _cur_name, _cur_version, item_name = check_spot_if_available(name, version, "bin", file_path) |
| 606 | if mode == "v" then | 611 | if mode == "v" then |
| 607 | table.insert(deletes, { name = paths.v, suffix = cfg.wrapper_suffix }) | 612 | table.insert(deletes, { name = paths.v, suffix = cfg.wrapper_suffix }) |
| 608 | else | 613 | else |
| @@ -622,7 +627,7 @@ function repos.delete_local_version(name: string, version: string, deps_mode: st | |||
| 622 | if rock_manifest.lua then | 627 | if rock_manifest.lua then |
| 623 | repos.recurse_rock_manifest_entry(rock_manifest.lua, function(file_path: string): boolean, string | 628 | repos.recurse_rock_manifest_entry(rock_manifest.lua, function(file_path: string): boolean, string |
| 624 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) | 629 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) |
| 625 | local mode, cur_name, cur_version, item_name = check_spot_if_available(name, version, "lua", file_path) | 630 | local mode, _cur_name, _cur_version, item_name = check_spot_if_available(name, version, "lua", file_path) |
| 626 | if mode == "v" then | 631 | if mode == "v" then |
| 627 | table.insert(deletes, { name = paths.v }) | 632 | table.insert(deletes, { name = paths.v }) |
| 628 | else | 633 | else |
| @@ -644,7 +649,7 @@ function repos.delete_local_version(name: string, version: string, deps_mode: st | |||
| 644 | if rock_manifest.lib then | 649 | if rock_manifest.lib then |
| 645 | repos.recurse_rock_manifest_entry(rock_manifest.lib, function(file_path: string): boolean, string | 650 | repos.recurse_rock_manifest_entry(rock_manifest.lib, function(file_path: string): boolean, string |
| 646 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) | 651 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) |
| 647 | local mode, cur_name, cur_version, item_name = check_spot_if_available(name, version, "lib", file_path) | 652 | local mode, _cur_name, _cur_version, item_name = check_spot_if_available(name, version, "lib", file_path) |
| 648 | if mode == "v" then | 653 | if mode == "v" then |
| 649 | table.insert(deletes, { name = paths.v }) | 654 | table.insert(deletes, { name = paths.v }) |
| 650 | else | 655 | else |
diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index c41469fd..c82e4856 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua | |||
| @@ -107,7 +107,7 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
| 107 | 107 | ||
| 108 | do | 108 | do |
| 109 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") | 109 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") |
| 110 | rockspec.format_is_at_least = function(self, version) | 110 | rockspec.format_is_at_least = function(_self, version) |
| 111 | return parsed_format >= vers.parse_version(version) | 111 | return parsed_format >= vers.parse_version(version) |
| 112 | end | 112 | end |
| 113 | end | 113 | end |
diff --git a/src/luarocks/rockspecs.tl b/src/luarocks/rockspecs.tl index 15a28de0..a34c0dbf 100644 --- a/src/luarocks/rockspecs.tl +++ b/src/luarocks/rockspecs.tl | |||
| @@ -107,12 +107,12 @@ function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, gl | |||
| 107 | -- @return boolean: true if rockspec format matches version or is newer, false otherwise. | 107 | -- @return boolean: true if rockspec format matches version or is newer, false otherwise. |
| 108 | do | 108 | do |
| 109 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") | 109 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") |
| 110 | rockspec.format_is_at_least = function(self: Rockspec, version: string): boolean | 110 | rockspec.format_is_at_least = function(_self: Rockspec, version: string): boolean |
| 111 | return parsed_format >= vers.parse_version(version) | 111 | return parsed_format >= vers.parse_version(version) |
| 112 | end | 112 | end |
| 113 | end | 113 | end |
| 114 | 114 | ||
| 115 | platform_overrides(rockspec.build as {any : any}) --! | 115 | platform_overrides(rockspec.build as {any : any}) |
| 116 | platform_overrides(rockspec.dependencies as {any : any}) | 116 | platform_overrides(rockspec.dependencies as {any : any}) |
| 117 | platform_overrides(rockspec.build_dependencies as {any : any}) | 117 | platform_overrides(rockspec.build_dependencies as {any : any}) |
| 118 | platform_overrides(rockspec.test_dependencies as {any : any}) | 118 | platform_overrides(rockspec.test_dependencies as {any : any}) |
diff --git a/src/luarocks/test/busted.lua b/src/luarocks/test/busted.lua index bc00b33a..aa47349b 100644 --- a/src/luarocks/test/busted.lua +++ b/src/luarocks/test/busted.lua | |||
| @@ -7,7 +7,6 @@ local deps = require("luarocks.deps") | |||
| 7 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
| 8 | local dir = require("luarocks.dir") | 8 | local dir = require("luarocks.dir") |
| 9 | local queries = require("luarocks.queries") | 9 | local queries = require("luarocks.queries") |
| 10 | local install = require("luarocks.cmd.install") | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | 12 | ||
diff --git a/src/luarocks/test/busted.tl b/src/luarocks/test/busted.tl index 832a81b7..878319c7 100644 --- a/src/luarocks/test/busted.tl +++ b/src/luarocks/test/busted.tl | |||
| @@ -7,7 +7,6 @@ local deps = require("luarocks.deps") | |||
| 7 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
| 8 | local dir = require("luarocks.dir") | 8 | local dir = require("luarocks.dir") |
| 9 | local queries = require("luarocks.queries") | 9 | local queries = require("luarocks.queries") |
| 10 | local install = require("luarocks.cmd.install") | ||
| 11 | 10 | ||
| 12 | local type Test = require("luarocks.core.types.rockspec").Test | 11 | local type Test = require("luarocks.core.types.rockspec").Test |
| 13 | 12 | ||
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 5c21eaf0..4bf27e31 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
| @@ -53,7 +53,7 @@ end | |||
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | local debugmode = false | 55 | local debugmode = false |
| 56 | local function debug(_) end | 56 | local function dbg(_) end |
| 57 | local function info(_) end | 57 | local function info(_) end |
| 58 | local function warning(s) io.stderr:write(s .. '\n') end | 58 | local function warning(s) io.stderr:write(s .. '\n') end |
| 59 | 59 | ||
| @@ -79,14 +79,6 @@ local function table_copy(t) | |||
| 79 | return t2 | 79 | return t2 |
| 80 | end | 80 | end |
| 81 | 81 | ||
| 82 | local function exists(filename) | ||
| 83 | local fh = io.open(filename) | ||
| 84 | local result = fh ~= nil | ||
| 85 | if fh then fh:close() end | ||
| 86 | return result | ||
| 87 | end | ||
| 88 | local function isfile() return true end | ||
| 89 | |||
| 90 | local function string_as_file(s) | 82 | local function string_as_file(s) |
| 91 | return { | 83 | return { |
| 92 | at = 0, | 84 | at = 0, |
| @@ -279,7 +271,7 @@ function patch.read_patch(filename, data) | |||
| 279 | elseif startswith(line, "--- ") then | 271 | elseif startswith(line, "--- ") then |
| 280 | state = 'filenames' | 272 | state = 'filenames' |
| 281 | if debugmode and #files.source > 0 then | 273 | if debugmode and #files.source > 0 then |
| 282 | debug(string.format("- %2d hunks for %s", #files.hunks[nextfileno], | 274 | dbg(string.format("- %2d hunks for %s", #files.hunks[nextfileno], |
| 283 | files.source[nextfileno])) | 275 | files.source[nextfileno])) |
| 284 | end | 276 | end |
| 285 | end | 277 | end |
| @@ -393,7 +385,7 @@ function patch.read_patch(filename, data) | |||
| 393 | else | 385 | else |
| 394 | 386 | ||
| 395 | if debugmode and #files.source > 0 then | 387 | if debugmode and #files.source > 0 then |
| 396 | debug(string.format("- %2d hunks for %s", #files.hunks[nextfileno], | 388 | dbg(string.format("- %2d hunks for %s", #files.hunks[nextfileno], |
| 397 | files.source[nextfileno])) | 389 | files.source[nextfileno])) |
| 398 | end | 390 | end |
| 399 | end | 391 | end |
| @@ -512,7 +504,7 @@ local function patch_hunks(srcname, tgtname, hunks) | |||
| 512 | local srclineno = 1 | 504 | local srclineno = 1 |
| 513 | local lineends = { ['\n'] = 0, ['\r\n'] = 0, ['\r'] = 0 } | 505 | local lineends = { ['\n'] = 0, ['\r\n'] = 0, ['\r'] = 0 } |
| 514 | for hno, h in ipairs(hunks) do | 506 | for hno, h in ipairs(hunks) do |
| 515 | debug(string.format("processing hunk %d for file %s", hno, tgtname)) | 507 | dbg(string.format("processing hunk %d for file %s", hno, tgtname)) |
| 516 | 508 | ||
| 517 | while srclineno < h.startsrc do | 509 | while srclineno < h.startsrc do |
| 518 | local line = src_readline() | 510 | local line = src_readline() |
| @@ -596,17 +588,16 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) | |||
| 596 | end | 588 | end |
| 597 | source = strip_dirs(source, strip) | 589 | source = strip_dirs(source, strip) |
| 598 | local f2patch = source | 590 | local f2patch = source |
| 599 | if not exists(f2patch) then | 591 | if not fs.exists(f2patch) then |
| 600 | f2patch = strip_dirs(target, strip) | 592 | f2patch = strip_dirs(target, strip) |
| 601 | f2patch = fs.absolute_name(f2patch) | 593 | f2patch = fs.absolute_name(f2patch) |
| 602 | if not exists(f2patch) then | 594 | if not fs.exists(f2patch) then |
| 603 | warning(string.format("source/target file does not exist\n--- %s\n+++ %s", | 595 | warning(string.format("source/target file does not exist\n--- %s\n+++ %s", |
| 604 | source, f2patch)) | 596 | source, f2patch)) |
| 605 | return false | 597 | return false |
| 606 | end | 598 | end |
| 607 | end | 599 | end |
| 608 | 600 | if not fs.is_file(f2patch) then | |
| 609 | if not isfile() then | ||
| 610 | warning(string.format("not a file - %s", f2patch)) | 601 | warning(string.format("not a file - %s", f2patch)) |
| 611 | return false | 602 | return false |
| 612 | end | 603 | end |
| @@ -658,7 +649,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) | |||
| 658 | if endlstrip(line) == hunkfind[hunklineno] then | 649 | if endlstrip(line) == hunkfind[hunklineno] then |
| 659 | hunklineno = hunklineno + 1 | 650 | hunklineno = hunklineno + 1 |
| 660 | else | 651 | else |
| 661 | debug(string.format("hunk no.%d doesn't match source file %s", | 652 | dbg(string.format("hunk no.%d doesn't match source file %s", |
| 662 | hunkno, source)) | 653 | hunkno, source)) |
| 663 | 654 | ||
| 664 | hunkno = hunkno + 1 | 655 | hunkno = hunkno + 1 |
| @@ -672,7 +663,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) | |||
| 672 | end | 663 | end |
| 673 | 664 | ||
| 674 | if lineno == hunk.startsrc + #hunkfind - 1 then | 665 | if lineno == hunk.startsrc + #hunkfind - 1 then |
| 675 | debug(string.format("file %s hunk no.%d -- is ready to be patched", | 666 | dbg(string.format("file %s hunk no.%d -- is ready to be patched", |
| 676 | source, hunkno)) | 667 | source, hunkno)) |
| 677 | hunkno = hunkno + 1 | 668 | hunkno = hunkno + 1 |
| 678 | validhunks = validhunks + 1 | 669 | validhunks = validhunks + 1 |
| @@ -715,7 +706,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) | |||
| 715 | return true | 706 | return true |
| 716 | end | 707 | end |
| 717 | local backupname = source .. ".orig" | 708 | local backupname = source .. ".orig" |
| 718 | if exists(backupname) then | 709 | if fs.exists(backupname) then |
| 719 | warning(string.format("can't backup original file to %s - aborting", | 710 | warning(string.format("can't backup original file to %s - aborting", |
| 720 | backupname)) | 711 | backupname)) |
| 721 | return false | 712 | return false |
diff --git a/src/luarocks/tools/patch.tl b/src/luarocks/tools/patch.tl index 1babbc88..83c16ab7 100644 --- a/src/luarocks/tools/patch.tl +++ b/src/luarocks/tools/patch.tl | |||
| @@ -22,7 +22,7 @@ local record patch | |||
| 22 | invalid: boolean | 22 | invalid: boolean |
| 23 | text: {string} | 23 | text: {string} |
| 24 | end | 24 | end |
| 25 | record File --! | 25 | record File |
| 26 | at: integer | 26 | at: integer |
| 27 | str: string | 27 | str: string |
| 28 | len: integer | 28 | len: integer |
| @@ -31,7 +31,7 @@ local record patch | |||
| 31 | close: function(File): boolean | 31 | close: function(File): boolean |
| 32 | end | 32 | end |
| 33 | record Files | 33 | record Files |
| 34 | source: {string} --! | 34 | source: {string} |
| 35 | target: {string} | 35 | target: {string} |
| 36 | epoch: {boolean} | 36 | epoch: {boolean} |
| 37 | hunks: {{Hunk}} | 37 | hunks: {{Hunk}} |
| @@ -53,7 +53,7 @@ end | |||
| 53 | 53 | ||
| 54 | -- logging | 54 | -- logging |
| 55 | local debugmode = false | 55 | local debugmode = false |
| 56 | local function debug(_: string) end --! | 56 | local function dbg(_: string) end |
| 57 | local function info(_: string) end | 57 | local function info(_: string) end |
| 58 | local function warning(s: string) io.stderr:write(s .. '\n') end | 58 | local function warning(s: string) io.stderr:write(s .. '\n') end |
| 59 | 59 | ||
| @@ -79,7 +79,7 @@ local function table_copy<K, V>(t: {K: V}): {K: V} | |||
| 79 | return t2 | 79 | return t2 |
| 80 | end | 80 | end |
| 81 | 81 | ||
| 82 | local function string_as_file(s: string): File --! | 82 | local function string_as_file(s: string): File |
| 83 | return { | 83 | return { |
| 84 | at = 0, | 84 | at = 0, |
| 85 | str = s, | 85 | str = s, |
| @@ -122,7 +122,7 @@ local function file_lines(f: FILE): function(): string | |||
| 122 | elseif f then | 122 | elseif f then |
| 123 | local chunk = f:read(CHUNK_SIZE) | 123 | local chunk = f:read(CHUNK_SIZE) |
| 124 | if chunk then | 124 | if chunk then |
| 125 | buffer = buffer:sub(pos_beg) .. chunk --! funcy stuff with pos | 125 | buffer = buffer:sub(pos_beg) .. chunk |
| 126 | pos_beg = 1 | 126 | pos_beg = 1 |
| 127 | else | 127 | else |
| 128 | f = nil | 128 | f = nil |
| @@ -178,11 +178,11 @@ function patch.read_patch(filename: string, data: string): Files, boolean | |||
| 178 | } | 178 | } |
| 179 | local hunkactual: Hunk = {linessrc=nil, linestgt=nil} | 179 | local hunkactual: Hunk = {linessrc=nil, linestgt=nil} |
| 180 | 180 | ||
| 181 | info(string.format("reading patch %s", filename)) --! | 181 | info(string.format("reading patch %s", filename)) |
| 182 | 182 | ||
| 183 | local fp: FILE | 183 | local fp: FILE |
| 184 | if data then | 184 | if data then |
| 185 | fp = string_as_file(data) as FILE --! cast | 185 | fp = string_as_file(data) as FILE |
| 186 | else | 186 | else |
| 187 | fp = filename == '-' and io.stdin or open(filename, "rb") | 187 | fp = filename == '-' and io.stdin or open(filename, "rb") |
| 188 | end | 188 | end |
| @@ -271,7 +271,7 @@ function patch.read_patch(filename: string, data: string): Files, boolean | |||
| 271 | elseif startswith(line, "--- ") then | 271 | elseif startswith(line, "--- ") then |
| 272 | state = 'filenames' | 272 | state = 'filenames' |
| 273 | if debugmode and #files.source > 0 then | 273 | if debugmode and #files.source > 0 then |
| 274 | debug(string.format("- %2d hunks for %s", #files.hunks[nextfileno], | 274 | dbg(string.format("- %2d hunks for %s", #files.hunks[nextfileno], |
| 275 | files.source[nextfileno])) | 275 | files.source[nextfileno])) |
| 276 | end | 276 | end |
| 277 | end | 277 | end |
| @@ -385,7 +385,7 @@ function patch.read_patch(filename: string, data: string): Files, boolean | |||
| 385 | else | 385 | else |
| 386 | -- duplicated message when an eof is reached | 386 | -- duplicated message when an eof is reached |
| 387 | if debugmode and #files.source > 0 then | 387 | if debugmode and #files.source > 0 then |
| 388 | debug(string.format("- %2d hunks for %s", #files.hunks[nextfileno], | 388 | dbg(string.format("- %2d hunks for %s", #files.hunks[nextfileno], |
| 389 | files.source[nextfileno])) | 389 | files.source[nextfileno])) |
| 390 | end | 390 | end |
| 391 | end | 391 | end |
| @@ -406,7 +406,7 @@ local function find_hunk(file: {string}, h: Hunk, hno: integer): boolean | |||
| 406 | if l > fuzz then | 406 | if l > fuzz then |
| 407 | -- todo: \ No newline at the end of file | 407 | -- todo: \ No newline at the end of file |
| 408 | if startswith(hline, " ") or startswith(hline, "-") then | 408 | if startswith(hline, " ") or startswith(hline, "-") then |
| 409 | local line = file[lineno] --! cast | 409 | local line = file[lineno] |
| 410 | lineno = lineno + 1 | 410 | lineno = lineno + 1 |
| 411 | if not line or #line == 0 then | 411 | if not line or #line == 0 then |
| 412 | found = false | 412 | found = false |
| @@ -468,7 +468,7 @@ local function check_patched(file: {string}, hunks: {Hunk}): boolean | |||
| 468 | if #file < h.starttgt then | 468 | if #file < h.starttgt then |
| 469 | error('nomatch', 0) | 469 | error('nomatch', 0) |
| 470 | end | 470 | end |
| 471 | lineno = h.starttgt as integer --! cast | 471 | lineno = h.starttgt as integer |
| 472 | for _, hline in ipairs(h.text) do | 472 | for _, hline in ipairs(h.text) do |
| 473 | -- todo: \ No newline at the end of file | 473 | -- todo: \ No newline at the end of file |
| 474 | if not startswith(hline, "-") and not startswith(hline, "\\") then | 474 | if not startswith(hline, "-") and not startswith(hline, "\\") then |
| @@ -502,9 +502,9 @@ local function patch_hunks(srcname: string, tgtname: string, hunks: {Hunk}): boo | |||
| 502 | -- of patching. Also issue a warning about mixed lineends | 502 | -- of patching. Also issue a warning about mixed lineends |
| 503 | 503 | ||
| 504 | local srclineno = 1 | 504 | local srclineno = 1 |
| 505 | local lineends = {['\n']=0, ['\r\n']=0, ['\r']=0} | 505 | local lineends: {string: integer} = {['\n']=0, ['\r\n']=0, ['\r']=0} |
| 506 | for hno, h in ipairs(hunks) do | 506 | for hno, h in ipairs(hunks) do |
| 507 | debug(string.format("processing hunk %d for file %s", hno, tgtname)) | 507 | dbg(string.format("processing hunk %d for file %s", hno, tgtname)) |
| 508 | -- skip to line just before hunk starts | 508 | -- skip to line just before hunk starts |
| 509 | while srclineno < h.startsrc do | 509 | while srclineno < h.startsrc do |
| 510 | local line = src_readline() | 510 | local line = src_readline() |
| @@ -533,7 +533,7 @@ local function patch_hunks(srcname: string, tgtname: string, hunks: {Hunk}): boo | |||
| 533 | local line2write = hline:sub(2) | 533 | local line2write = hline:sub(2) |
| 534 | -- detect if line ends are consistent in source file | 534 | -- detect if line ends are consistent in source file |
| 535 | local sum = 0 | 535 | local sum = 0 |
| 536 | for _,v in pairs(lineends as {string:any}) do if v as integer > 0 then sum=sum+1 end end --! unchecked | 536 | for _,v in pairs(lineends) do if v > 0 then sum=sum+1 end end |
| 537 | if sum == 1 then | 537 | if sum == 1 then |
| 538 | local newline: string | 538 | local newline: string |
| 539 | for k,v in pairs(lineends as {string:any}) do if v ~= 0 then newline = k end end | 539 | for k,v in pairs(lineends as {string:any}) do if v ~= 0 then newline = k end end |
| @@ -649,7 +649,7 @@ local function patch_file(source: string, target: string, epoch: boolean, hunks: | |||
| 649 | if endlstrip(line) == hunkfind[hunklineno] then | 649 | if endlstrip(line) == hunkfind[hunklineno] then |
| 650 | hunklineno = hunklineno + 1 | 650 | hunklineno = hunklineno + 1 |
| 651 | else | 651 | else |
| 652 | debug(string.format("hunk no.%d doesn't match source file %s", | 652 | dbg(string.format("hunk no.%d doesn't match source file %s", |
| 653 | hunkno, source)) | 653 | hunkno, source)) |
| 654 | -- file may be already patched, but check other hunks anyway | 654 | -- file may be already patched, but check other hunks anyway |
| 655 | hunkno = hunkno + 1 | 655 | hunkno = hunkno + 1 |
| @@ -663,7 +663,7 @@ local function patch_file(source: string, target: string, epoch: boolean, hunks: | |||
| 663 | end | 663 | end |
| 664 | -- check if processed line is the last line | 664 | -- check if processed line is the last line |
| 665 | if lineno == hunk.startsrc + #hunkfind - 1 then | 665 | if lineno == hunk.startsrc + #hunkfind - 1 then |
| 666 | debug(string.format("file %s hunk no.%d -- is ready to be patched", | 666 | dbg(string.format("file %s hunk no.%d -- is ready to be patched", |
| 667 | source, hunkno)) | 667 | source, hunkno)) |
| 668 | hunkno = hunkno + 1 | 668 | hunkno = hunkno + 1 |
| 669 | validhunks = validhunks + 1 | 669 | validhunks = validhunks + 1 |
| @@ -706,7 +706,7 @@ local function patch_file(source: string, target: string, epoch: boolean, hunks: | |||
| 706 | return true | 706 | return true |
| 707 | end | 707 | end |
| 708 | local backupname = source .. ".orig" | 708 | local backupname = source .. ".orig" |
| 709 | if exists(backupname) then | 709 | if fs.exists(backupname) then |
| 710 | warning(string.format("can't backup original file to %s - aborting", | 710 | warning(string.format("can't backup original file to %s - aborting", |
| 711 | backupname)) | 711 | backupname)) |
| 712 | return false | 712 | return false |
diff --git a/src/luarocks/tools/tar.lua b/src/luarocks/tools/tar.lua index 25e1d0ec..6db1334a 100644 --- a/src/luarocks/tools/tar.lua +++ b/src/luarocks/tools/tar.lua | |||
| @@ -111,7 +111,7 @@ local function read_header_block(block) | |||
| 111 | 111 | ||
| 112 | if header.typeflag == "unknown" then | 112 | if header.typeflag == "unknown" then |
| 113 | if checksum_header(block) ~= header.chksum then | 113 | if checksum_header(block) ~= header.chksum then |
| 114 | return false, "Failed header checksum" | 114 | return nil, "Failed header checksum" |
| 115 | end | 115 | end |
| 116 | end | 116 | end |
| 117 | return header | 117 | return header |
| @@ -136,13 +136,12 @@ function tar.untar(filename, destdir) | |||
| 136 | break | 136 | break |
| 137 | end | 137 | end |
| 138 | 138 | ||
| 139 | local headerp | 139 | local header |
| 140 | headerp, err = read_header_block(block) | 140 | header, err = read_header_block(block) |
| 141 | if not headerp then | 141 | if not header then |
| 142 | ok = false | 142 | ok = false |
| 143 | break | 143 | break |
| 144 | end | 144 | end |
| 145 | local header = headerp | ||
| 146 | local file_data = "" | 145 | local file_data = "" |
| 147 | if header.size > 0 then | 146 | if header.size > 0 then |
| 148 | local nread = math.ceil(header.size / blocksize) * blocksize | 147 | local nread = math.ceil(header.size / blocksize) * blocksize |
diff --git a/src/luarocks/tools/tar.tl b/src/luarocks/tools/tar.tl index a156bf9f..4d726cbc 100644 --- a/src/luarocks/tools/tar.tl +++ b/src/luarocks/tools/tar.tl | |||
| @@ -84,7 +84,7 @@ local function nullterm(s: string): string | |||
| 84 | return s:match("^[^%z]*") | 84 | return s:match("^[^%z]*") |
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | local function read_header_block(block: string): boolean | Header, string | 87 | local function read_header_block(block: string): Header, string |
| 88 | local header: Header = {} | 88 | local header: Header = {} |
| 89 | header.name = nullterm(block:sub(1,100)) | 89 | header.name = nullterm(block:sub(1,100)) |
| 90 | header.mode = nullterm(block:sub(101,108)):gsub(" ", "") | 90 | header.mode = nullterm(block:sub(101,108)):gsub(" ", "") |
| @@ -111,7 +111,7 @@ local function read_header_block(block: string): boolean | Header, string | |||
| 111 | -- end | 111 | -- end |
| 112 | if header.typeflag == "unknown" then | 112 | if header.typeflag == "unknown" then |
| 113 | if checksum_header(block) ~= header.chksum then | 113 | if checksum_header(block) ~= header.chksum then |
| 114 | return false, "Failed header checksum" | 114 | return nil, "Failed header checksum" |
| 115 | end | 115 | end |
| 116 | end | 116 | end |
| 117 | return header | 117 | return header |
| @@ -136,13 +136,12 @@ function tar.untar(filename: string, destdir: string): boolean, string | |||
| 136 | break | 136 | break |
| 137 | end | 137 | end |
| 138 | 138 | ||
| 139 | local headerp: boolean | Header | 139 | local header: Header |
| 140 | headerp, err = read_header_block(block) | 140 | header, err = read_header_block(block) |
| 141 | if not headerp then | 141 | if not header then |
| 142 | ok = false | 142 | ok = false |
| 143 | break | 143 | break |
| 144 | end | 144 | end |
| 145 | local header: Header = headerp as Header --! cast | ||
| 146 | local file_data = "" | 145 | local file_data = "" |
| 147 | if header.size > 0 then | 146 | if header.size > 0 then |
| 148 | local nread = math.ceil(header.size / blocksize) * blocksize | 147 | local nread = math.ceil(header.size / blocksize) * blocksize |
diff --git a/src/luarocks/tools/zip.lua b/src/luarocks/tools/zip.lua index b54d9e86..f692796d 100644 --- a/src/luarocks/tools/zip.lua +++ b/src/luarocks/tools/zip.lua | |||
| @@ -110,12 +110,12 @@ else | |||
| 110 | error("unknown zlib library", 0) | 110 | error("unknown zlib library", 0) |
| 111 | end | 111 | end |
| 112 | 112 | ||
| 113 | local function number_to_lestring(number, nbytes) | 113 | local function number_to_lestring(num, nbytes) |
| 114 | local out = {} | 114 | local out = {} |
| 115 | for _ = 1, nbytes do | 115 | for _ = 1, nbytes do |
| 116 | local byte = number % 256 | 116 | local byte = num % 256 |
| 117 | table.insert(out, string.char(byte)) | 117 | table.insert(out, string.char(byte)) |
| 118 | number = (number - byte) / 256 | 118 | num = math.floor((num - byte) / 256) |
| 119 | end | 119 | end |
| 120 | return table.concat(out) | 120 | return table.concat(out) |
| 121 | end | 121 | end |
diff --git a/src/luarocks/tools/zip.tl b/src/luarocks/tools/zip.tl index 82a19011..ad65f20a 100644 --- a/src/luarocks/tools/zip.tl +++ b/src/luarocks/tools/zip.tl | |||
| @@ -59,7 +59,7 @@ local function shr(n: integer, m: integer): integer | |||
| 59 | return math.floor(n / 2^m) | 59 | return math.floor(n / 2^m) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | local function shl(n: integer, m: integer): integer | 62 | local function shl(n: integer, m: integer): integer |
| 63 | return (n * 2^m) as integer | 63 | return (n * 2^m) as integer |
| 64 | end | 64 | end |
| 65 | 65 | ||
| @@ -110,12 +110,12 @@ else | |||
| 110 | error("unknown zlib library", 0) | 110 | error("unknown zlib library", 0) |
| 111 | end | 111 | end |
| 112 | 112 | ||
| 113 | local function number_to_lestring(number: number, nbytes: number): string | 113 | local function number_to_lestring(num: integer, nbytes: number): string |
| 114 | local out = {} | 114 | local out = {} |
| 115 | for _ = 1, nbytes do | 115 | for _ = 1, nbytes do |
| 116 | local byte: integer = number as integer % 256 --! cast I don't like | 116 | local byte: integer = num % 256 |
| 117 | table.insert(out, string.char(byte)) | 117 | table.insert(out, string.char(byte)) |
| 118 | number = (number - byte) / 256 | 118 | num = (num - byte) // 256 |
| 119 | end | 119 | end |
| 120 | return table.concat(out) | 120 | return table.concat(out) |
| 121 | end | 121 | end |
diff --git a/src/luarocks/type/manifest.tl b/src/luarocks/type/manifest.tl index 11bdc566..d6a6012c 100644 --- a/src/luarocks/type/manifest.tl +++ b/src/luarocks/type/manifest.tl | |||
| @@ -82,7 +82,7 @@ local manifest_formats = type_check.declare_schemas({ | |||
| 82 | -- mismatches. | 82 | -- mismatches. |
| 83 | -- @return boolean or (nil, string): true if type checking | 83 | -- @return boolean or (nil, string): true if type checking |
| 84 | -- succeeded, or nil and an error message if it failed. | 84 | -- succeeded, or nil and an error message if it failed. |
| 85 | function type_manifest.check(manifest: Manifest, globals: {string: any}): boolean, string --! | 85 | function type_manifest.check(manifest: Manifest, globals: {string: any}): boolean, string |
| 86 | local format = manifest_formats["3.0"] | 86 | local format = manifest_formats["3.0"] |
| 87 | local ok, err = type_check.check_undeclared_globals(globals, format) | 87 | local ok, err = type_check.check_undeclared_globals(globals, format) |
| 88 | if not ok then return nil, err end | 88 | if not ok then return nil, err end |
diff --git a/src/luarocks/type_check.tl b/src/luarocks/type_check.tl index 1b332be0..e8086a58 100644 --- a/src/luarocks/type_check.tl +++ b/src/luarocks/type_check.tl | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | ||
| 2 | local record type_check | 2 | local record type_check |
| 3 | type_check_table: function(version: string, tbl: {any: any}, typetbl: TableSchema, context: string): boolean, string --! tbl and typetbl types) | 3 | type_check_table: function(version: string, tbl: {any: any}, typetbl: TableSchema, context: string): boolean, string |
| 4 | 4 | ||
| 5 | record TableSchema | 5 | record TableSchema |
| 6 | fields: {string: TableSchema} | 6 | fields: {string: TableSchema} |
| @@ -134,7 +134,7 @@ local function type_check_item(version: string, item: any, typetbl: TableSchema, | |||
| 134 | end | 134 | end |
| 135 | local pattern = typetbl._pattern | 135 | local pattern = typetbl._pattern |
| 136 | if pattern then | 136 | if pattern then |
| 137 | if not item:match("^"..pattern.."$") then --! cast or tostring | 137 | if not item:match("^"..pattern.."$") then |
| 138 | local what = typetbl._name or ("'"..pattern.."'") | 138 | local what = typetbl._name or ("'"..pattern.."'") |
| 139 | return nil, "Type mismatch on field "..context..": invalid value '"..item.."' does not match " .. what | 139 | return nil, "Type mismatch on field "..context..": invalid value '"..item.."' does not match " .. what |
| 140 | end | 140 | end |
| @@ -219,7 +219,7 @@ function type_check.type_check_table(version: string, tbl: {any: any}, typetbl: | |||
| 219 | return true | 219 | return true |
| 220 | end | 220 | end |
| 221 | 221 | ||
| 222 | function type_check.check_undeclared_globals(globals: {string: any}, typetbl: TableSchema): boolean, string --! tbl and typetbl types | 222 | function type_check.check_undeclared_globals(globals: {string: any}, typetbl: TableSchema): boolean, string |
| 223 | local undeclared = {} | 223 | local undeclared = {} |
| 224 | for glob, _ in pairs(globals) do | 224 | for glob, _ in pairs(globals) do |
| 225 | if not (typetbl.fields[glob] or typetbl.fields["MUST_"..glob]) then | 225 | if not (typetbl.fields[glob] or typetbl.fields["MUST_"..glob]) then |
