aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-21 00:49:10 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-21 00:49:10 +0300
commit4bcf20973324660c30f99f7b3a4f2afea1e7211f (patch)
tree305135c454eae2450f627661a03a09e722198f55
parent434042b9783359fea051d3649b03e9270e305dbb (diff)
downloadluarocks-4bcf20973324660c30f99f7b3a4f2afea1e7211f.tar.gz
luarocks-4bcf20973324660c30f99f7b3a4f2afea1e7211f.tar.bz2
luarocks-4bcf20973324660c30f99f7b3a4f2afea1e7211f.zip
cache, index, add, refresh_cache, remove, show, upload
-rw-r--r--src/luarocks/admin/cache.lua2
-rw-r--r--src/luarocks/admin/cmd/add-original.lua134
-rw-r--r--src/luarocks/admin/cmd/add.lua65
-rw-r--r--src/luarocks/admin/cmd/refresh_cache-original.lua31
-rw-r--r--src/luarocks/admin/cmd/refresh_cache.lua19
-rw-r--r--src/luarocks/admin/cmd/remove-original.lua95
-rw-r--r--src/luarocks/admin/cmd/remove.lua47
-rw-r--r--src/luarocks/admin/index-original.lua185
-rw-r--r--src/luarocks/admin/index.lua26
-rw-r--r--src/luarocks/cmd/show-original.lua314
-rw-r--r--src/luarocks/cmd/show.lua85
-rw-r--r--src/luarocks/cmd/upload-original.lua128
-rw-r--r--src/luarocks/cmd/upload.lua60
-rw-r--r--src/luarocks/cmd/upload.tl15
14 files changed, 1085 insertions, 121 deletions
diff --git a/src/luarocks/admin/cache.lua b/src/luarocks/admin/cache.lua
index 48551f7a..11bcc818 100644
--- a/src/luarocks/admin/cache.lua
+++ b/src/luarocks/admin/cache.lua
@@ -12,7 +12,7 @@ local util = require("luarocks.util")
12function cache.get_upload_server(server) 12function cache.get_upload_server(server)
13 if not server then server = cfg.upload_server end 13 if not server then server = cfg.upload_server end
14 if not server then 14 if not server then
15 return nil, "No server specified and no default configured with upload_server." 15 return nil, nil, "No server specified and no default configured with upload_server."
16 end 16 end
17 return server, cfg.upload_servers and cfg.upload_servers[server] 17 return server, cfg.upload_servers and cfg.upload_servers[server]
18end 18end
diff --git a/src/luarocks/admin/cmd/add-original.lua b/src/luarocks/admin/cmd/add-original.lua
new file mode 100644
index 00000000..aa444c50
--- /dev/null
+++ b/src/luarocks/admin/cmd/add-original.lua
@@ -0,0 +1,134 @@
1
2--- Module implementing the luarocks-admin "add" command.
3-- Adds a rock or rockspec to a rocks server.
4local add = {}
5
6local cfg = require("luarocks.core.cfg")
7local util = require("luarocks.util")
8local dir = require("luarocks.dir")
9local writer = require("luarocks.manif.writer")
10local fs = require("luarocks.fs")
11local cache = require("luarocks.admin.cache")
12local index = require("luarocks.admin.index")
13
14function add.add_to_parser(parser)
15 local cmd = parser:command("add", "Add a rock or rockspec to a rocks server.", util.see_also())
16
17 cmd:argument("rock", "A local rockspec or rock file.")
18 :args("+")
19
20 cmd:option("--server", "The server to use. If not given, the default server "..
21 "set in the upload_server variable from the configuration file is used instead.")
22 :target("add_server")
23 cmd:flag("--no-refresh", "Do not refresh the local cache prior to "..
24 "generation of the updated manifest.")
25 cmd:flag("--index", "Produce an index.html file for the manifest. This "..
26 "flag is automatically set if an index.html file already exists.")
27end
28
29local function zip_manifests()
30 for ver in util.lua_versions() do
31 local file = "manifest-"..ver
32 local zip = file..".zip"
33 fs.delete(dir.path(fs.current_dir(), zip))
34 fs.zip(zip, file)
35 end
36end
37
38local function add_files_to_server(refresh, rockfiles, server, upload_server, do_index)
39 assert(type(refresh) == "boolean" or not refresh)
40 assert(type(rockfiles) == "table")
41 assert(type(server) == "string")
42 assert(type(upload_server) == "table" or not upload_server)
43
44 local download_url, login_url = cache.get_server_urls(server, upload_server)
45 local at = fs.current_dir()
46 local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url
47
48 local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password)
49 if not local_cache then
50 return nil, protocol
51 end
52
53 if not login_url then
54 login_url = protocol.."://"..server_path
55 end
56
57 local ok, err = fs.change_dir(at)
58 if not ok then return nil, err end
59
60 local files = {}
61 for _, rockfile in ipairs(rockfiles) do
62 if fs.exists(rockfile) then
63 util.printout("Copying file "..rockfile.." to "..local_cache.."...")
64 local absolute = fs.absolute_name(rockfile)
65 fs.copy(absolute, local_cache, "read")
66 table.insert(files, dir.base_name(absolute))
67 else
68 util.printerr("File "..rockfile.." not found")
69 end
70 end
71 if #files == 0 then
72 return nil, "No files found"
73 end
74
75 local ok, err = fs.change_dir(local_cache)
76 if not ok then return nil, err end
77
78 util.printout("Updating manifest...")
79 writer.make_manifest(local_cache, "one", true)
80
81 zip_manifests()
82
83 if fs.exists("index.html") then
84 do_index = true
85 end
86
87 if do_index then
88 util.printout("Updating index.html...")
89 index.make_index(local_cache)
90 end
91
92 local login_info = ""
93 if user then login_info = " -u "..user end
94 if password then login_info = login_info..":"..password end
95 if not login_url:match("/$") then
96 login_url = login_url .. "/"
97 end
98
99 if do_index then
100 table.insert(files, "index.html")
101 end
102 table.insert(files, "manifest")
103 for ver in util.lua_versions() do
104 table.insert(files, "manifest-"..ver)
105 table.insert(files, "manifest-"..ver..".zip")
106 end
107
108 -- TODO abstract away explicit 'curl' call
109
110 local cmd
111 if protocol == "rsync" then
112 local srv, path = server_path:match("([^/]+)(/.+)")
113 cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/"
114 elseif protocol == "file" then
115 return fs.copy_contents(local_cache, server_path)
116 elseif upload_server and upload_server.sftp then
117 local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$")
118 cmd = cfg.variables.SCP.." "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2
119 else
120 cmd = cfg.variables.CURL.." "..login_info.." -T '{"..table.concat(files, ",").."}' "..login_url
121 end
122
123 util.printout(cmd)
124 return fs.execute(cmd)
125end
126
127function add.command(args)
128 local server, server_table = cache.get_upload_server(args.add_server or args.server)
129 if not server then return nil, server_table end
130 return add_files_to_server(not args.no_refresh, args.rock, server, server_table, args.index)
131end
132
133
134return add
diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua
index aa444c50..29b9e705 100644
--- a/src/luarocks/admin/cmd/add.lua
+++ b/src/luarocks/admin/cmd/add.lua
@@ -1,8 +1,9 @@
1local _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 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
1 3
2--- Module implementing the luarocks-admin "add" command.
3-- Adds a rock or rockspec to a rocks server.
4local add = {} 4local add = {}
5 5
6
6local cfg = require("luarocks.core.cfg") 7local cfg = require("luarocks.core.cfg")
7local util = require("luarocks.util") 8local util = require("luarocks.util")
8local dir = require("luarocks.dir") 9local dir = require("luarocks.dir")
@@ -11,35 +12,37 @@ local fs = require("luarocks.fs")
11local cache = require("luarocks.admin.cache") 12local cache = require("luarocks.admin.cache")
12local index = require("luarocks.admin.index") 13local index = require("luarocks.admin.index")
13 14
15local argparse = require("luarocks.vendor.argparse")
16
17
18
19
20
14function add.add_to_parser(parser) 21function add.add_to_parser(parser)
15 local cmd = parser:command("add", "Add a rock or rockspec to a rocks server.", util.see_also()) 22 local cmd = parser:command("add", "Add a rock or rockspec to a rocks server.", util.see_also())
16 23
17 cmd:argument("rock", "A local rockspec or rock file.") 24 cmd:argument("rocks", "A local rockspec or rock file."):
18 :args("+") 25 args("+")
19 26
20 cmd:option("--server", "The server to use. If not given, the default server ".. 27 cmd:option("--server", "The server to use. If not given, the default server " ..
21 "set in the upload_server variable from the configuration file is used instead.") 28 "set in the upload_server variable from the configuration file is used instead."):
22 :target("add_server") 29 target("add_server")
23 cmd:flag("--no-refresh", "Do not refresh the local cache prior to ".. 30 cmd:flag("--no-refresh", "Do not refresh the local cache prior to " ..
24 "generation of the updated manifest.") 31 "generation of the updated manifest.")
25 cmd:flag("--index", "Produce an index.html file for the manifest. This ".. 32 cmd:flag("--index", "Produce an index.html file for the manifest. This " ..
26 "flag is automatically set if an index.html file already exists.") 33 "flag is automatically set if an index.html file already exists.")
27end 34end
28 35
29local function zip_manifests() 36local function zip_manifests()
30 for ver in util.lua_versions() do 37 for ver in util.lua_versions() do
31 local file = "manifest-"..ver 38 local file = "manifest-" .. ver
32 local zip = file..".zip" 39 local zip = file .. ".zip"
33 fs.delete(dir.path(fs.current_dir(), zip)) 40 fs.delete(dir.path(fs.current_dir(), zip))
34 fs.zip(zip, file) 41 fs.zip(zip, file)
35 end 42 end
36end 43end
37 44
38local function add_files_to_server(refresh, rockfiles, server, upload_server, do_index) 45local function add_files_to_server(refresh, rockfiles, server, upload_server, do_index)
39 assert(type(refresh) == "boolean" or not refresh)
40 assert(type(rockfiles) == "table")
41 assert(type(server) == "string")
42 assert(type(upload_server) == "table" or not upload_server)
43 46
44 local download_url, login_url = cache.get_server_urls(server, upload_server) 47 local download_url, login_url = cache.get_server_urls(server, upload_server)
45 local at = fs.current_dir() 48 local at = fs.current_dir()
@@ -51,7 +54,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
51 end 54 end
52 55
53 if not login_url then 56 if not login_url then
54 login_url = protocol.."://"..server_path 57 login_url = protocol .. "://" .. server_path
55 end 58 end
56 59
57 local ok, err = fs.change_dir(at) 60 local ok, err = fs.change_dir(at)
@@ -60,12 +63,12 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
60 local files = {} 63 local files = {}
61 for _, rockfile in ipairs(rockfiles) do 64 for _, rockfile in ipairs(rockfiles) do
62 if fs.exists(rockfile) then 65 if fs.exists(rockfile) then
63 util.printout("Copying file "..rockfile.." to "..local_cache.."...") 66 util.printout("Copying file " .. rockfile .. " to " .. local_cache .. "...")
64 local absolute = fs.absolute_name(rockfile) 67 local absolute = fs.absolute_name(rockfile)
65 fs.copy(absolute, local_cache, "read") 68 fs.copy(absolute, local_cache, "read")
66 table.insert(files, dir.base_name(absolute)) 69 table.insert(files, dir.base_name(absolute))
67 else 70 else
68 util.printerr("File "..rockfile.." not found") 71 util.printerr("File " .. rockfile .. " not found")
69 end 72 end
70 end 73 end
71 if #files == 0 then 74 if #files == 0 then
@@ -90,8 +93,8 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
90 end 93 end
91 94
92 local login_info = "" 95 local login_info = ""
93 if user then login_info = " -u "..user end 96 if user then login_info = " -u " .. user end
94 if password then login_info = login_info..":"..password end 97 if password then login_info = login_info .. ":" .. password end
95 if not login_url:match("/$") then 98 if not login_url:match("/$") then
96 login_url = login_url .. "/" 99 login_url = login_url .. "/"
97 end 100 end
@@ -101,23 +104,23 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
101 end 104 end
102 table.insert(files, "manifest") 105 table.insert(files, "manifest")
103 for ver in util.lua_versions() do 106 for ver in util.lua_versions() do
104 table.insert(files, "manifest-"..ver) 107 table.insert(files, "manifest-" .. ver)
105 table.insert(files, "manifest-"..ver..".zip") 108 table.insert(files, "manifest-" .. ver .. ".zip")
106 end 109 end
107 110
108 -- TODO abstract away explicit 'curl' call 111
109 112
110 local cmd 113 local cmd
111 if protocol == "rsync" then 114 if protocol == "rsync" then
112 local srv, path = server_path:match("([^/]+)(/.+)") 115 local srv, path = server_path:match("([^/]+)(/.+)")
113 cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" 116 cmd = cfg.variables.RSYNC .. " " .. cfg.variables.RSYNCFLAGS .. " -e ssh " .. local_cache .. "/ " .. user .. "@" .. srv .. ":" .. path .. "/"
114 elseif protocol == "file" then 117 elseif protocol == "file" then
115 return fs.copy_contents(local_cache, server_path) 118 return fs.copy_contents(local_cache, server_path)
116 elseif upload_server and upload_server.sftp then 119 elseif upload_server and upload_server.sftp then
117 local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$") 120 local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$")
118 cmd = cfg.variables.SCP.." "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2 121 cmd = cfg.variables.SCP .. " " .. table.concat(files, " ") .. " " .. user .. "@" .. part1 .. ":/" .. part2
119 else 122 else
120 cmd = cfg.variables.CURL.." "..login_info.." -T '{"..table.concat(files, ",").."}' "..login_url 123 cmd = cfg.variables.CURL .. " " .. login_info .. " -T '{" .. table.concat(files, ",") .. "}' " .. login_url
121 end 124 end
122 125
123 util.printout(cmd) 126 util.printout(cmd)
@@ -125,9 +128,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
125end 128end
126 129
127function add.command(args) 130function add.command(args)
128 local server, server_table = cache.get_upload_server(args.add_server or args.server) 131 local server, server_table, err = cache.get_upload_server(args.add_server or args.server)
129 if not server then return nil, server_table end 132 if not server then return nil, err end
130 return add_files_to_server(not args.no_refresh, args.rock, server, server_table, args.index) 133 return add_files_to_server(not args.no_refresh, args.rocks, server, server_table, args.index)
131end 134end
132 135
133 136
diff --git a/src/luarocks/admin/cmd/refresh_cache-original.lua b/src/luarocks/admin/cmd/refresh_cache-original.lua
new file mode 100644
index 00000000..f8d51893
--- /dev/null
+++ b/src/luarocks/admin/cmd/refresh_cache-original.lua
@@ -0,0 +1,31 @@
1
2--- Module implementing the luarocks-admin "refresh_cache" command.
3local refresh_cache = {}
4
5local cfg = require("luarocks.core.cfg")
6local util = require("luarocks.util")
7local cache = require("luarocks.admin.cache")
8
9function refresh_cache.add_to_parser(parser)
10 local cmd = parser:command("refresh_cache", "Refresh local cache of a remote rocks server.", util.see_also())
11
12 cmd:option("--from", "The server to use. If not given, the default server "..
13 "set in the upload_server variable from the configuration file is used instead.")
14 :argname("<server>")
15end
16
17function refresh_cache.command(args)
18 local server, upload_server = cache.get_upload_server(args.server)
19 if not server then return nil, upload_server end
20 local download_url = cache.get_server_urls(server, upload_server)
21
22 local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password)
23 if not ok then
24 return nil, err
25 else
26 return true
27 end
28end
29
30
31return refresh_cache
diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua
index f8d51893..9565be45 100644
--- a/src/luarocks/admin/cmd/refresh_cache.lua
+++ b/src/luarocks/admin/cmd/refresh_cache.lua
@@ -1,22 +1,29 @@
1 1
2--- Module implementing the luarocks-admin "refresh_cache" command. 2
3local refresh_cache = {} 3local refresh_cache = {}
4 4
5
5local cfg = require("luarocks.core.cfg") 6local cfg = require("luarocks.core.cfg")
6local util = require("luarocks.util") 7local util = require("luarocks.util")
7local cache = require("luarocks.admin.cache") 8local cache = require("luarocks.admin.cache")
8 9
10local argparse = require("luarocks.vendor.argparse")
11
12
13
14
15
9function refresh_cache.add_to_parser(parser) 16function refresh_cache.add_to_parser(parser)
10 local cmd = parser:command("refresh_cache", "Refresh local cache of a remote rocks server.", util.see_also()) 17 local cmd = parser:command("refresh_cache", "Refresh local cache of a remote rocks server.", util.see_also())
11 18
12 cmd:option("--from", "The server to use. If not given, the default server ".. 19 cmd:option("--from", "The server to use. If not given, the default server " ..
13 "set in the upload_server variable from the configuration file is used instead.") 20 "set in the upload_server variable from the configuration file is used instead."):
14 :argname("<server>") 21 argname("<server>")
15end 22end
16 23
17function refresh_cache.command(args) 24function refresh_cache.command(args)
18 local server, upload_server = cache.get_upload_server(args.server) 25 local server, upload_server, err = cache.get_upload_server(args.server)
19 if not server then return nil, upload_server end 26 if not server then return nil, err end
20 local download_url = cache.get_server_urls(server, upload_server) 27 local download_url = cache.get_server_urls(server, upload_server)
21 28
22 local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) 29 local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password)
diff --git a/src/luarocks/admin/cmd/remove-original.lua b/src/luarocks/admin/cmd/remove-original.lua
new file mode 100644
index 00000000..ed7644e0
--- /dev/null
+++ b/src/luarocks/admin/cmd/remove-original.lua
@@ -0,0 +1,95 @@
1
2--- Module implementing the luarocks-admin "remove" command.
3-- Removes a rock or rockspec from a rocks server.
4local admin_remove = {}
5
6local cfg = require("luarocks.core.cfg")
7local util = require("luarocks.util")
8local dir = require("luarocks.dir")
9local writer = require("luarocks.manif.writer")
10local fs = require("luarocks.fs")
11local cache = require("luarocks.admin.cache")
12local index = require("luarocks.admin.index")
13
14function admin_remove.add_to_parser(parser)
15 local cmd = parser:command("remove", "Remove a rock or rockspec from a rocks server.", util.see_also())
16
17 cmd:argument("rock", "A local rockspec or rock file.")
18 :args("+")
19
20 cmd:option("--server", "The server to use. If not given, the default server "..
21 "set in the upload_server variable from the configuration file is used instead.")
22 cmd:flag("--no-refresh", "Do not refresh the local cache prior to "..
23 "generation of the updated manifest.")
24end
25
26local function remove_files_from_server(refresh, rockfiles, server, upload_server)
27 assert(type(refresh) == "boolean" or not refresh)
28 assert(type(rockfiles) == "table")
29 assert(type(server) == "string")
30 assert(type(upload_server) == "table" or not upload_server)
31
32 local download_url, login_url = cache.get_server_urls(server, upload_server)
33 local at = fs.current_dir()
34 local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url
35
36 local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password)
37 if not local_cache then
38 return nil, protocol
39 end
40
41 local ok, err = fs.change_dir(at)
42 if not ok then return nil, err end
43
44 local nr_files = 0
45 for _, rockfile in ipairs(rockfiles) do
46 local basename = dir.base_name(rockfile)
47 local file = dir.path(local_cache, basename)
48 util.printout("Removing file "..file.."...")
49 fs.delete(file)
50 if not fs.exists(file) then
51 nr_files = nr_files + 1
52 else
53 util.printerr("Failed removing "..file)
54 end
55 end
56 if nr_files == 0 then
57 return nil, "No files removed."
58 end
59
60 local ok, err = fs.change_dir(local_cache)
61 if not ok then return nil, err end
62
63 util.printout("Updating manifest...")
64 writer.make_manifest(local_cache, "one", true)
65 util.printout("Updating index.html...")
66 index.make_index(local_cache)
67
68 if protocol == "file" then
69 local cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." --delete "..local_cache.."/ ".. server_path.."/"
70 util.printout(cmd)
71 fs.execute(cmd)
72 return true
73 end
74
75 if protocol ~= "rsync" then
76 return nil, "This command requires 'rsync', check your configuration."
77 end
78
79 local srv, path = server_path:match("([^/]+)(/.+)")
80 local cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." --delete -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/"
81
82 util.printout(cmd)
83 fs.execute(cmd)
84
85 return true
86end
87
88function admin_remove.command(args)
89 local server, server_table = cache.get_upload_server(args.server)
90 if not server then return nil, server_table end
91 return remove_files_from_server(not args.no_refresh, args.rock, server, server_table)
92end
93
94
95return admin_remove
diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.lua
index ed7644e0..619a7354 100644
--- a/src/luarocks/admin/cmd/remove.lua
+++ b/src/luarocks/admin/cmd/remove.lua
@@ -1,8 +1,9 @@
1local _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 ipairs = _tl_compat and _tl_compat.ipairs or ipairs
2
1 3
2--- Module implementing the luarocks-admin "remove" command.
3-- Removes a rock or rockspec from a rocks server.
4local admin_remove = {} 4local admin_remove = {}
5 5
6
6local cfg = require("luarocks.core.cfg") 7local cfg = require("luarocks.core.cfg")
7local util = require("luarocks.util") 8local util = require("luarocks.util")
8local dir = require("luarocks.dir") 9local dir = require("luarocks.dir")
@@ -11,23 +12,25 @@ local fs = require("luarocks.fs")
11local cache = require("luarocks.admin.cache") 12local cache = require("luarocks.admin.cache")
12local index = require("luarocks.admin.index") 13local index = require("luarocks.admin.index")
13 14
15local argparse = require("luarocks.vendor.argparse")
16
17
18
19
20
14function admin_remove.add_to_parser(parser) 21function admin_remove.add_to_parser(parser)
15 local cmd = parser:command("remove", "Remove a rock or rockspec from a rocks server.", util.see_also()) 22 local cmd = parser:command("remove", "Remove a rock or rockspec from a rocks server.", util.see_also())
16 23
17 cmd:argument("rock", "A local rockspec or rock file.") 24 cmd:argument("rocks", "A local rockspec or rock file."):
18 :args("+") 25 args("+")
19 26
20 cmd:option("--server", "The server to use. If not given, the default server ".. 27 cmd:option("--server", "The server to use. If not given, the default server " ..
21 "set in the upload_server variable from the configuration file is used instead.") 28 "set in the upload_server variable from the configuration file is used instead.")
22 cmd:flag("--no-refresh", "Do not refresh the local cache prior to ".. 29 cmd:flag("--no-refresh", "Do not refresh the local cache prior to " ..
23 "generation of the updated manifest.") 30 "generation of the updated manifest.")
24end 31end
25 32
26local function remove_files_from_server(refresh, rockfiles, server, upload_server) 33local function remove_files_from_server(refresh, rockfiles, server, upload_server)
27 assert(type(refresh) == "boolean" or not refresh)
28 assert(type(rockfiles) == "table")
29 assert(type(server) == "string")
30 assert(type(upload_server) == "table" or not upload_server)
31 34
32 local download_url, login_url = cache.get_server_urls(server, upload_server) 35 local download_url, login_url = cache.get_server_urls(server, upload_server)
33 local at = fs.current_dir() 36 local at = fs.current_dir()
@@ -45,12 +48,12 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
45 for _, rockfile in ipairs(rockfiles) do 48 for _, rockfile in ipairs(rockfiles) do
46 local basename = dir.base_name(rockfile) 49 local basename = dir.base_name(rockfile)
47 local file = dir.path(local_cache, basename) 50 local file = dir.path(local_cache, basename)
48 util.printout("Removing file "..file.."...") 51 util.printout("Removing file " .. file .. "...")
49 fs.delete(file) 52 fs.delete(file)
50 if not fs.exists(file) then 53 if not fs.exists(file) then
51 nr_files = nr_files + 1 54 nr_files = nr_files + 1
52 else 55 else
53 util.printerr("Failed removing "..file) 56 util.printerr("Failed removing " .. file)
54 end 57 end
55 end 58 end
56 if nr_files == 0 then 59 if nr_files == 0 then
@@ -66,10 +69,10 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
66 index.make_index(local_cache) 69 index.make_index(local_cache)
67 70
68 if protocol == "file" then 71 if protocol == "file" then
69 local cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." --delete "..local_cache.."/ ".. server_path.."/" 72 local cmd = cfg.variables.RSYNC .. " " .. cfg.variables.RSYNCFLAGS .. " --delete " .. local_cache .. "/ " .. server_path .. "/"
70 util.printout(cmd) 73 util.printout(cmd)
71 fs.execute(cmd) 74 fs.execute(cmd)
72 return true 75 return true
73 end 76 end
74 77
75 if protocol ~= "rsync" then 78 if protocol ~= "rsync" then
@@ -77,7 +80,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
77 end 80 end
78 81
79 local srv, path = server_path:match("([^/]+)(/.+)") 82 local srv, path = server_path:match("([^/]+)(/.+)")
80 local cmd = cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." --delete -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" 83 local cmd = cfg.variables.RSYNC .. " " .. cfg.variables.RSYNCFLAGS .. " --delete -e ssh " .. local_cache .. "/ " .. user .. "@" .. srv .. ":" .. path .. "/"
81 84
82 util.printout(cmd) 85 util.printout(cmd)
83 fs.execute(cmd) 86 fs.execute(cmd)
@@ -86,9 +89,9 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
86end 89end
87 90
88function admin_remove.command(args) 91function admin_remove.command(args)
89 local server, server_table = cache.get_upload_server(args.server) 92 local server, server_table, err = cache.get_upload_server(args.server)
90 if not server then return nil, server_table end 93 if not server then return nil, err end
91 return remove_files_from_server(not args.no_refresh, args.rock, server, server_table) 94 return remove_files_from_server(not args.no_refresh, args.rocks, server, server_table)
92end 95end
93 96
94 97
diff --git a/src/luarocks/admin/index-original.lua b/src/luarocks/admin/index-original.lua
new file mode 100644
index 00000000..64c8c1eb
--- /dev/null
+++ b/src/luarocks/admin/index-original.lua
@@ -0,0 +1,185 @@
1
2--- Module which builds the index.html page to be used in rocks servers.
3local index = {}
4
5local util = require("luarocks.util")
6local fs = require("luarocks.fs")
7local vers = require("luarocks.core.vers")
8local persist = require("luarocks.persist")
9local dir = require("luarocks.dir")
10local manif = require("luarocks.manif")
11
12local ext_url_target = ' target="_blank"'
13
14local index_header = [[
15<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
16<html>
17<head>
18<title>Available rocks</title>
19<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
20<style>
21body {
22 background-color: white;
23 font-family: "bitstream vera sans", "verdana", "sans";
24 font-size: 14px;
25}
26a {
27 color: #0000c0;
28 text-decoration: none;
29}
30a.pkg {
31 color: black;
32}
33a:hover {
34 text-decoration: underline;
35}
36td.main {
37 border-style: none;
38}
39blockquote {
40 font-size: 12px;
41}
42td.package {
43 background-color: #f0f0f0;
44 vertical-align: top;
45}
46td.spacer {
47 height: 5px;
48}
49td.version {
50 background-color: #d0d0d0;
51 vertical-align: top;
52 text-align: left;
53 padding: 5px;
54 width: 100px;
55}
56p.manifest {
57 font-size: 8px;
58}
59</style>
60</head>
61<body>
62<h1>Available rocks</h1>
63<p>
64Lua modules available from this location for use with <a href="http://www.luarocks.org">LuaRocks</a>:
65</p>
66<table class="main">
67]]
68
69local index_package_begin = [[
70<td class="package">
71<p><a name="$anchor"></a><a href="#$anchor" class="pkg"><b>$package</b></a> - $summary<br/>
72</p><blockquote><p>$detailed<br/>
73$externaldependencies
74<font size="-1"><a href="$original">latest sources</a> $homepage | License: $license</font></p>
75</blockquote></a></td>
76<td class="version">
77]]
78
79local index_package_end = [[
80</td></tr>
81<tr><td colspan="2" class="spacer"></td></tr>
82]]
83
84local index_footer_begin = [[
85</table>
86<p class="manifest">
87<a href="manifest">manifest file</a>
88]]
89local index_manifest_ver = [[
90&bull; <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>)
91]]
92local index_footer_end = [[
93</p>
94</body>
95</html>
96]]
97
98function index.format_external_dependencies(rockspec)
99 if rockspec.external_dependencies then
100 local deplist = {}
101 local listed_set = {}
102 local plats = nil
103 for name, desc in util.sortedpairs(rockspec.external_dependencies) do
104 if name ~= "platforms" then
105 table.insert(deplist, name:lower())
106 listed_set[name] = true
107 else
108 plats = desc
109 end
110 end
111 if plats then
112 for plat, entries in util.sortedpairs(plats) do
113 for name, desc in util.sortedpairs(entries) do
114 if not listed_set[name] then
115 table.insert(deplist, name:lower() .. " (on "..plat..")")
116 end
117 end
118 end
119 end
120 return '<p><b>External dependencies:</b> ' .. table.concat(deplist, ',&nbsp;').. '</p>'
121 else
122 return ""
123 end
124end
125
126function index.make_index(repo)
127 if not fs.is_dir(repo) then
128 return nil, "Cannot access repository at "..repo
129 end
130 local manifest = manif.load_manifest(repo)
131 local out = io.open(dir.path(repo, "index.html"), "w")
132
133 out:write(index_header)
134 for package, version_list in util.sortedpairs(manifest.repository) do
135 local latest_rockspec = nil
136 local output = index_package_begin
137 for version, data in util.sortedpairs(version_list, vers.compare_versions) do
138 local versions = {}
139 output = output..version..':&nbsp;'
140 table.sort(data, function(a,b) return a.arch < b.arch end)
141 for _, item in ipairs(data) do
142 local file
143 if item.arch == 'rockspec' then
144 file = ("%s-%s.rockspec"):format(package, version)
145 if not latest_rockspec then latest_rockspec = file end
146 else
147 file = ("%s-%s.%s.rock"):format(package, version, item.arch)
148 end
149 table.insert(versions, '<a href="'..file..'">'..item.arch..'</a>')
150 end
151 output = output .. table.concat(versions, ',&nbsp;') .. '<br/>'
152 end
153 output = output .. index_package_end
154 if latest_rockspec then
155 local rockspec = persist.load_into_table(dir.path(repo, latest_rockspec))
156 local descript = rockspec.description or {}
157 local vars = {
158 anchor = package,
159 package = rockspec.package,
160 original = rockspec.source.url,
161 summary = descript.summary or "",
162 detailed = descript.detailed or "",
163 license = descript.license or "N/A",
164 homepage = descript.homepage and ('| <a href="'..descript.homepage..'"'..ext_url_target..'>project homepage</a>') or "",
165 externaldependencies = index.format_external_dependencies(rockspec)
166 }
167 vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ")
168 vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"'..ext_url_target..'>%1</a>')
169 output = output:gsub("$(%w+)", vars)
170 else
171 output = output:gsub("$anchor", package)
172 output = output:gsub("$package", package)
173 output = output:gsub("$(%w+)", "")
174 end
175 out:write(output)
176 end
177 out:write(index_footer_begin)
178 for ver in util.lua_versions() do
179 out:write((index_manifest_ver:gsub("$VER", ver)))
180 end
181 out:write(index_footer_end)
182 out:close()
183end
184
185return index
diff --git a/src/luarocks/admin/index.lua b/src/luarocks/admin/index.lua
index 64c8c1eb..8fec0f6f 100644
--- a/src/luarocks/admin/index.lua
+++ b/src/luarocks/admin/index.lua
@@ -1,7 +1,8 @@
1local _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 2
2--- Module which builds the index.html page to be used in rocks servers.
3local index = {} 3local index = {}
4 4
5
5local util = require("luarocks.util") 6local util = require("luarocks.util")
6local fs = require("luarocks.fs") 7local fs = require("luarocks.fs")
7local vers = require("luarocks.core.vers") 8local vers = require("luarocks.core.vers")
@@ -9,6 +10,11 @@ local persist = require("luarocks.persist")
9local dir = require("luarocks.dir") 10local dir = require("luarocks.dir")
10local manif = require("luarocks.manif") 11local manif = require("luarocks.manif")
11 12
13
14
15
16
17
12local ext_url_target = ' target="_blank"' 18local ext_url_target = ' target="_blank"'
13 19
14local index_header = [[ 20local index_header = [[
@@ -112,12 +118,12 @@ function index.format_external_dependencies(rockspec)
112 for plat, entries in util.sortedpairs(plats) do 118 for plat, entries in util.sortedpairs(plats) do
113 for name, desc in util.sortedpairs(entries) do 119 for name, desc in util.sortedpairs(entries) do
114 if not listed_set[name] then 120 if not listed_set[name] then
115 table.insert(deplist, name:lower() .. " (on "..plat..")") 121 table.insert(deplist, name:lower() .. " (on " .. plat .. ")")
116 end 122 end
117 end 123 end
118 end 124 end
119 end 125 end
120 return '<p><b>External dependencies:</b> ' .. table.concat(deplist, ',&nbsp;').. '</p>' 126 return '<p><b>External dependencies:</b> ' .. table.concat(deplist, ',&nbsp;') .. '</p>'
121 else 127 else
122 return "" 128 return ""
123 end 129 end
@@ -125,7 +131,7 @@ end
125 131
126function index.make_index(repo) 132function index.make_index(repo)
127 if not fs.is_dir(repo) then 133 if not fs.is_dir(repo) then
128 return nil, "Cannot access repository at "..repo 134 return nil, "Cannot access repository at " .. repo
129 end 135 end
130 local manifest = manif.load_manifest(repo) 136 local manifest = manif.load_manifest(repo)
131 local out = io.open(dir.path(repo, "index.html"), "w") 137 local out = io.open(dir.path(repo, "index.html"), "w")
@@ -136,8 +142,8 @@ function index.make_index(repo)
136 local output = index_package_begin 142 local output = index_package_begin
137 for version, data in util.sortedpairs(version_list, vers.compare_versions) do 143 for version, data in util.sortedpairs(version_list, vers.compare_versions) do
138 local versions = {} 144 local versions = {}
139 output = output..version..':&nbsp;' 145 output = output .. version .. ':&nbsp;'
140 table.sort(data, function(a,b) return a.arch < b.arch end) 146 table.sort(data, function(a, b) return a.arch < b.arch end)
141 for _, item in ipairs(data) do 147 for _, item in ipairs(data) do
142 local file 148 local file
143 if item.arch == 'rockspec' then 149 if item.arch == 'rockspec' then
@@ -146,7 +152,7 @@ function index.make_index(repo)
146 else 152 else
147 file = ("%s-%s.%s.rock"):format(package, version, item.arch) 153 file = ("%s-%s.%s.rock"):format(package, version, item.arch)
148 end 154 end
149 table.insert(versions, '<a href="'..file..'">'..item.arch..'</a>') 155 table.insert(versions, '<a href="' .. file .. '">' .. item.arch .. '</a>')
150 end 156 end
151 output = output .. table.concat(versions, ',&nbsp;') .. '<br/>' 157 output = output .. table.concat(versions, ',&nbsp;') .. '<br/>'
152 end 158 end
@@ -161,11 +167,11 @@ function index.make_index(repo)
161 summary = descript.summary or "", 167 summary = descript.summary or "",
162 detailed = descript.detailed or "", 168 detailed = descript.detailed or "",
163 license = descript.license or "N/A", 169 license = descript.license or "N/A",
164 homepage = descript.homepage and ('| <a href="'..descript.homepage..'"'..ext_url_target..'>project homepage</a>') or "", 170 homepage = descript.homepage and ('| <a href="' .. descript.homepage .. '"' .. ext_url_target .. '>project homepage</a>') or "",
165 externaldependencies = index.format_external_dependencies(rockspec) 171 externaldependencies = index.format_external_dependencies(rockspec),
166 } 172 }
167 vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ") 173 vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ")
168 vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"'..ext_url_target..'>%1</a>') 174 vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '<a href="%1"' .. ext_url_target .. '>%1</a>')
169 output = output:gsub("$(%w+)", vars) 175 output = output:gsub("$(%w+)", vars)
170 else 176 else
171 output = output:gsub("$anchor", package) 177 output = output:gsub("$anchor", package)
diff --git a/src/luarocks/cmd/show-original.lua b/src/luarocks/cmd/show-original.lua
new file mode 100644
index 00000000..88cbbada
--- /dev/null
+++ b/src/luarocks/cmd/show-original.lua
@@ -0,0 +1,314 @@
1--- Module implementing the LuaRocks "show" command.
2-- Shows information about an installed rock.
3local show = {}
4
5local queries = require("luarocks.queries")
6local search = require("luarocks.search")
7local dir = require("luarocks.core.dir")
8local fs = require("luarocks.fs")
9local cfg = require("luarocks.core.cfg")
10local util = require("luarocks.util")
11local path = require("luarocks.path")
12local fetch = require("luarocks.fetch")
13local manif = require("luarocks.manif")
14local repos = require("luarocks.repos")
15
16function show.add_to_parser(parser)
17 local cmd = parser:command("show", [[
18Show information about an installed rock.
19
20Without any flags, show all module information.
21With flags, return only the desired information.]], util.see_also())
22 :summary("Show information about an installed rock.")
23
24 cmd:argument("rock", "Name of an installed rock.")
25 :action(util.namespaced_name_action)
26 cmd:argument("version", "Rock version.")
27 :args("?")
28
29 cmd:flag("--home", "Show home page of project.")
30 cmd:flag("--modules", "Show all modules provided by the package as used by require().")
31 cmd:flag("--deps", "Show packages the package depends on.")
32 cmd:flag("--build-deps", "Show build-only dependencies for the package.")
33 cmd:flag("--test-deps", "Show dependencies for testing the package.")
34 cmd:flag("--rockspec", "Show the full path of the rockspec file.")
35 cmd:flag("--mversion", "Show the package version.")
36 cmd:flag("--rock-tree", "Show local tree where rock is installed.")
37 cmd:flag("--rock-namespace", "Show rock namespace.")
38 cmd:flag("--rock-dir", "Show data directory of the installed rock.")
39 cmd:flag("--rock-license", "Show rock license.")
40 cmd:flag("--issues", "Show URL for project's issue tracker.")
41 cmd:flag("--labels", "List the labels of the rock.")
42 cmd:flag("--porcelain", "Produce machine-friendly output.")
43end
44
45local friendly_template = [[
46 :
47?namespace:${namespace}/${package} ${version} - ${summary}
48!namespace:${package} ${version} - ${summary}
49 :
50*detailed :${detailed}
51?detailed :
52?license :License: \t${license}
53?homepage :Homepage: \t${homepage}
54?issues :Issues: \t${issues}
55?labels :Labels: \t${labels}
56?location :Installed in: \t${location}
57?commands :
58?commands :Commands:
59*commands :\t${name} (${file})
60?modules :
61?modules :Modules:
62*modules :\t${name} (${file})
63?bdeps :
64?bdeps :Has build dependency on:
65*bdeps :\t${name} (${label})
66?tdeps :
67?tdeps :Tests depend on:
68*tdeps :\t${name} (${label})
69?deps :
70?deps :Depends on:
71*deps :\t${name} (${label})
72?ideps :
73?ideps :Indirectly pulling:
74*ideps :\t${name} (${label})
75 :
76]]
77
78local porcelain_template = [[
79?namespace:namespace\t${namespace}
80?package :package\t${package}
81?version :version\t${version}
82?summary :summary\t${summary}
83*detailed :detailed\t${detailed}
84?license :license\t${license}
85?homepage :homepage\t${homepage}
86?issues :issues\t${issues}
87?labels :labels\t${labels}
88?location :location\t${location}
89*commands :command\t${name}\t${file}
90*modules :module\t${name}\t${file}
91*bdeps :build_dependency\t${name}\t${label}
92*tdeps :test_dependency\t${name}\t${label}
93*deps :dependency\t${name}\t${label}
94*ideps :indirect_dependency\t${name}\t${label}
95]]
96
97local function keys_as_string(t, sep)
98 local keys = util.keys(t)
99 table.sort(keys)
100 return table.concat(keys, sep or " ")
101end
102
103local function word_wrap(line)
104 local width = tonumber(os.getenv("COLUMNS")) or 80
105 if width > 80 then width = 80 end
106 if #line > width then
107 local brk = width
108 while brk > 0 and line:sub(brk, brk) ~= " " do
109 brk = brk - 1
110 end
111 if brk > 0 then
112 return line:sub(1, brk-1) .. "\n" .. word_wrap(line:sub(brk+1))
113 end
114 end
115 return line
116end
117
118local function format_text(text)
119 text = text:gsub("^%s*",""):gsub("%s$", ""):gsub("\n[ \t]+","\n"):gsub("([^\n])\n([^\n])","%1 %2")
120 local paragraphs = util.split_string(text, "\n\n")
121 for n, line in ipairs(paragraphs) do
122 paragraphs[n] = word_wrap(line)
123 end
124 return (table.concat(paragraphs, "\n\n"):gsub("%s$", ""))
125end
126
127local function installed_rock_label(dep, tree)
128 local installed, version
129 local rocks_provided = util.get_rocks_provided()
130 if rocks_provided[dep.name] then
131 installed, version = true, rocks_provided[dep.name]
132 else
133 installed, version = search.pick_installed_rock(dep, tree)
134 end
135 return installed and "using "..version or "missing"
136end
137
138local function render(template, data)
139 local out = {}
140 for cmd, var, line in template:gmatch("(.)([a-z]*)%s*:([^\n]*)\n") do
141 line = line:gsub("\\t", "\t")
142 local d = data[var]
143 if cmd == " " then
144 table.insert(out, line)
145 elseif cmd == "?" or cmd == "*" or cmd == "!" then
146 if (cmd == "!" and d == nil)
147 or (cmd ~= "!" and (type(d) == "string"
148 or (type(d) == "table" and next(d)))) then
149 local n = cmd == "*" and #d or 1
150 for i = 1, n do
151 local tbl = cmd == "*" and d[i] or data
152 if type(tbl) == "string" then
153 tbl = tbl:gsub("%%", "%%%%")
154 end
155 table.insert(out, (line:gsub("${([a-z]+)}", tbl)))
156 end
157 end
158 end
159 end
160 return table.concat(out, "\n")
161end
162
163local function adjust_path(name, version, basedir, pathname, suffix)
164 pathname = dir.path(basedir, pathname)
165 local vpathname = path.versioned_name(pathname, basedir, name, version)
166 return (fs.exists(vpathname)
167 and vpathname
168 or pathname) .. (suffix or "")
169end
170
171local function modules_to_list(name, version, repo)
172 local ret = {}
173 local rock_manifest = manif.load_rock_manifest(name, version, repo)
174
175 local lua_dir = path.deploy_lua_dir(repo)
176 local lib_dir = path.deploy_lib_dir(repo)
177 repos.recurse_rock_manifest_entry(rock_manifest.lua, function(pathname)
178 table.insert(ret, {
179 name = path.path_to_module(pathname),
180 file = adjust_path(name, version, lua_dir, pathname),
181 })
182 end)
183 repos.recurse_rock_manifest_entry(rock_manifest.lib, function(pathname)
184 table.insert(ret, {
185 name = path.path_to_module(pathname),
186 file = adjust_path(name, version, lib_dir, pathname),
187 })
188 end)
189 table.sort(ret, function(a, b)
190 if a.name == b.name then
191 return a.file < b.file
192 end
193 return a.name < b.name
194 end)
195 return ret
196end
197
198local function commands_to_list(name, version, repo)
199 local ret = {}
200 local rock_manifest = manif.load_rock_manifest(name, version, repo)
201
202 local bin_dir = path.deploy_bin_dir(repo)
203 repos.recurse_rock_manifest_entry(rock_manifest.bin, function(pathname)
204 table.insert(ret, {
205 name = name,
206 file = adjust_path(name, version, bin_dir, pathname, cfg.wrapper_suffix),
207 })
208 end)
209 table.sort(ret, function(a, b)
210 if a.name == b.name then
211 return a.file < b.file
212 end
213 return a.name < b.name
214 end)
215 return ret
216end
217
218local function deps_to_list(dependencies, tree)
219 local ret = {}
220 for _, dep in ipairs(dependencies or {}) do
221 table.insert(ret, { name = tostring(dep), label = installed_rock_label(dep, tree) })
222 end
223 return ret
224end
225
226local function indirect_deps(mdeps, rdeps, tree)
227 local ret = {}
228 local direct_deps = {}
229 for _, dep in ipairs(rdeps) do
230 direct_deps[dep] = true
231 end
232 for dep_name in util.sortedpairs(mdeps or {}) do
233 if not direct_deps[dep_name] then
234 table.insert(ret, { name = tostring(dep_name), label = installed_rock_label(queries.new(dep_name), tree) })
235 end
236 end
237 return ret
238end
239
240local function show_rock(template, namespace, name, version, rockspec, repo, minfo, tree)
241 local desc = rockspec.description or {}
242 local data = {
243 namespace = namespace,
244 package = rockspec.package,
245 version = rockspec.version,
246 summary = desc.summary or "",
247 detailed = desc.detailed and util.split_string(format_text(desc.detailed), "\n"),
248 license = desc.license,
249 homepage = desc.homepage,
250 issues = desc.issues_url,
251 labels = desc.labels and table.concat(desc.labels, ", "),
252 location = path.rocks_tree_to_string(repo),
253 commands = commands_to_list(name, version, repo),
254 modules = modules_to_list(name, version, repo),
255 bdeps = deps_to_list(rockspec.build_dependencies, tree),
256 tdeps = deps_to_list(rockspec.test_dependencies, tree),
257 deps = deps_to_list(rockspec.dependencies, tree),
258 ideps = indirect_deps(minfo.dependencies, rockspec.dependencies, tree),
259 }
260 util.printout(render(template, data))
261end
262
263--- Driver function for "show" command.
264-- @return boolean: True if succeeded, nil on errors.
265function show.command(args)
266 local query = queries.new(args.rock, args.namespace, args.version, true)
267
268 local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree)
269 if not name then
270 return nil, version
271 end
272 local tree = path.rocks_tree_to_string(repo)
273 local directory = path.install_dir(name, version, repo)
274 local namespace = path.read_namespace(name, version, tree)
275 local rockspec_file = path.rockspec_file(name, version, repo)
276 local rockspec, err = fetch.load_local_rockspec(rockspec_file)
277 if not rockspec then return nil,err end
278
279 local descript = rockspec.description or {}
280 local manifest, err = manif.load_manifest(repo_url)
281 if not manifest then return nil,err end
282 local minfo = manifest.repository[name][version][1]
283
284 if args.rock_tree then util.printout(tree)
285 elseif args.rock_namespace then util.printout(namespace)
286 elseif args.rock_dir then util.printout(directory)
287 elseif args.home then util.printout(descript.homepage)
288 elseif args.rock_license then util.printout(descript.license)
289 elseif args.issues then util.printout(descript.issues_url)
290 elseif args.labels then util.printout(descript.labels and table.concat(descript.labels, "\n"))
291 elseif args.modules then util.printout(keys_as_string(minfo.modules, "\n"))
292 elseif args.deps then
293 for _, dep in ipairs(rockspec.dependencies) do
294 util.printout(tostring(dep))
295 end
296 elseif args.build_deps then
297 for _, dep in ipairs(rockspec.build_dependencies) do
298 util.printout(tostring(dep))
299 end
300 elseif args.test_deps then
301 for _, dep in ipairs(rockspec.test_dependencies) do
302 util.printout(tostring(dep))
303 end
304 elseif args.rockspec then util.printout(rockspec_file)
305 elseif args.mversion then util.printout(version)
306 elseif args.porcelain then
307 show_rock(porcelain_template, namespace, name, version, rockspec, repo, minfo, args.tree)
308 else
309 show_rock(friendly_template, namespace, name, version, rockspec, repo, minfo, args.tree)
310 end
311 return true
312end
313
314return show
diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua
index 88cbbada..0ae5cbc6 100644
--- a/src/luarocks/cmd/show.lua
+++ b/src/luarocks/cmd/show.lua
@@ -1,6 +1,12 @@
1--- Module implementing the LuaRocks "show" command. 1local _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 ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local math = _tl_compat and _tl_compat.math or math; local os = _tl_compat and _tl_compat.os or os; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table
2-- Shows information about an installed rock. 2
3local show = {} 3local show = {Return = {}, }
4
5
6
7
8
9
4 10
5local queries = require("luarocks.queries") 11local queries = require("luarocks.queries")
6local search = require("luarocks.search") 12local search = require("luarocks.search")
@@ -13,18 +19,38 @@ local fetch = require("luarocks.fetch")
13local manif = require("luarocks.manif") 19local manif = require("luarocks.manif")
14local repos = require("luarocks.repos") 20local repos = require("luarocks.repos")
15 21
22
23
24
25local argparse = require("luarocks.vendor.argparse")
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
16function show.add_to_parser(parser) 42function show.add_to_parser(parser)
17 local cmd = parser:command("show", [[ 43 local cmd = parser:command("show", [[
18Show information about an installed rock. 44Show information about an installed rock.
19 45
20Without any flags, show all module information. 46Without any flags, show all module information.
21With flags, return only the desired information.]], util.see_also()) 47With flags, return only the desired information.]], util.see_also()):
22 :summary("Show information about an installed rock.") 48 summary("Show information about an installed rock.")
23 49
24 cmd:argument("rock", "Name of an installed rock.") 50 cmd:argument("rock", "Name of an installed rock."):
25 :action(util.namespaced_name_action) 51 action(util.namespaced_name_action)
26 cmd:argument("version", "Rock version.") 52 cmd:argument("version", "Rock version."):
27 :args("?") 53 args("?")
28 54
29 cmd:flag("--home", "Show home page of project.") 55 cmd:flag("--home", "Show home page of project.")
30 cmd:flag("--modules", "Show all modules provided by the package as used by require().") 56 cmd:flag("--modules", "Show all modules provided by the package as used by require().")
@@ -101,7 +127,7 @@ local function keys_as_string(t, sep)
101end 127end
102 128
103local function word_wrap(line) 129local function word_wrap(line)
104 local width = tonumber(os.getenv("COLUMNS")) or 80 130 local width = math.tointeger(os.getenv("COLUMNS")) or 80
105 if width > 80 then width = 80 end 131 if width > 80 then width = 80 end
106 if #line > width then 132 if #line > width then
107 local brk = width 133 local brk = width
@@ -109,14 +135,14 @@ local function word_wrap(line)
109 brk = brk - 1 135 brk = brk - 1
110 end 136 end
111 if brk > 0 then 137 if brk > 0 then
112 return line:sub(1, brk-1) .. "\n" .. word_wrap(line:sub(brk+1)) 138 return line:sub(1, brk - 1) .. "\n" .. word_wrap(line:sub(brk + 1))
113 end 139 end
114 end 140 end
115 return line 141 return line
116end 142end
117 143
118local function format_text(text) 144local function format_text(text)
119 text = text:gsub("^%s*",""):gsub("%s$", ""):gsub("\n[ \t]+","\n"):gsub("([^\n])\n([^\n])","%1 %2") 145 text = text:gsub("^%s*", ""):gsub("%s$", ""):gsub("\n[ \t]+", "\n"):gsub("([^\n])\n([^\n])", "%1 %2")
120 local paragraphs = util.split_string(text, "\n\n") 146 local paragraphs = util.split_string(text, "\n\n")
121 for n, line in ipairs(paragraphs) do 147 for n, line in ipairs(paragraphs) do
122 paragraphs[n] = word_wrap(line) 148 paragraphs[n] = word_wrap(line)
@@ -130,9 +156,11 @@ local function installed_rock_label(dep, tree)
130 if rocks_provided[dep.name] then 156 if rocks_provided[dep.name] then
131 installed, version = true, rocks_provided[dep.name] 157 installed, version = true, rocks_provided[dep.name]
132 else 158 else
133 installed, version = search.pick_installed_rock(dep, tree) 159 local name
160 name, version = search.pick_installed_rock(dep, tree)
161 installed = name ~= nil
134 end 162 end
135 return installed and "using "..version or "missing" 163 return installed and "using " .. version or "missing"
136end 164end
137 165
138local function render(template, data) 166local function render(template, data)
@@ -143,12 +171,15 @@ local function render(template, data)
143 if cmd == " " then 171 if cmd == " " then
144 table.insert(out, line) 172 table.insert(out, line)
145 elseif cmd == "?" or cmd == "*" or cmd == "!" then 173 elseif cmd == "?" or cmd == "*" or cmd == "!" then
146 if (cmd == "!" and d == nil) 174 if (cmd == "!" and d == nil) or
147 or (cmd ~= "!" and (type(d) == "string" 175 (cmd ~= "!" and (type(d) == "string" or
148 or (type(d) == "table" and next(d)))) then 176 (type(d) == "table" and next(d) ~= nil))) then
149 local n = cmd == "*" and #d or 1 177 local n = type(d) == "table" and #d or 1
178 if cmd ~= "*" then
179 n = 1
180 end
150 for i = 1, n do 181 for i = 1, n do
151 local tbl = cmd == "*" and d[i] or data 182 local tbl = cmd == "*" and type(d) == "table" and d[i] or data
152 if type(tbl) == "string" then 183 if type(tbl) == "string" then
153 tbl = tbl:gsub("%%", "%%%%") 184 tbl = tbl:gsub("%%", "%%%%")
154 end 185 end
@@ -163,9 +194,9 @@ end
163local function adjust_path(name, version, basedir, pathname, suffix) 194local function adjust_path(name, version, basedir, pathname, suffix)
164 pathname = dir.path(basedir, pathname) 195 pathname = dir.path(basedir, pathname)
165 local vpathname = path.versioned_name(pathname, basedir, name, version) 196 local vpathname = path.versioned_name(pathname, basedir, name, version)
166 return (fs.exists(vpathname) 197 return (fs.exists(vpathname) and
167 and vpathname 198 vpathname or
168 or pathname) .. (suffix or "") 199 pathname) .. (suffix or "")
169end 200end
170 201
171local function modules_to_list(name, version, repo) 202local function modules_to_list(name, version, repo)
@@ -217,7 +248,7 @@ end
217 248
218local function deps_to_list(dependencies, tree) 249local function deps_to_list(dependencies, tree)
219 local ret = {} 250 local ret = {}
220 for _, dep in ipairs(dependencies or {}) do 251 for _, dep in ipairs(dependencies.queries or {}) do
221 table.insert(ret, { name = tostring(dep), label = installed_rock_label(dep, tree) }) 252 table.insert(ret, { name = tostring(dep), label = installed_rock_label(dep, tree) })
222 end 253 end
223 return ret 254 return ret
@@ -260,8 +291,8 @@ local function show_rock(template, namespace, name, version, rockspec, repo, min
260 util.printout(render(template, data)) 291 util.printout(render(template, data))
261end 292end
262 293
263--- Driver function for "show" command. 294
264-- @return boolean: True if succeeded, nil on errors. 295
265function show.command(args) 296function show.command(args)
266 local query = queries.new(args.rock, args.namespace, args.version, true) 297 local query = queries.new(args.rock, args.namespace, args.version, true)
267 298
@@ -274,11 +305,11 @@ function show.command(args)
274 local namespace = path.read_namespace(name, version, tree) 305 local namespace = path.read_namespace(name, version, tree)
275 local rockspec_file = path.rockspec_file(name, version, repo) 306 local rockspec_file = path.rockspec_file(name, version, repo)
276 local rockspec, err = fetch.load_local_rockspec(rockspec_file) 307 local rockspec, err = fetch.load_local_rockspec(rockspec_file)
277 if not rockspec then return nil,err end 308 if not rockspec then return nil, err end
278 309
279 local descript = rockspec.description or {} 310 local descript = rockspec.description or {}
280 local manifest, err = manif.load_manifest(repo_url) 311 local manifest, err = manif.load_manifest(repo_url)
281 if not manifest then return nil,err end 312 if not manifest then return nil, err end
282 local minfo = manifest.repository[name][version][1] 313 local minfo = manifest.repository[name][version][1]
283 314
284 if args.rock_tree then util.printout(tree) 315 if args.rock_tree then util.printout(tree)
diff --git a/src/luarocks/cmd/upload-original.lua b/src/luarocks/cmd/upload-original.lua
new file mode 100644
index 00000000..6b84e452
--- /dev/null
+++ b/src/luarocks/cmd/upload-original.lua
@@ -0,0 +1,128 @@
1
2local upload = {}
3
4local signing = require("luarocks.signing")
5local util = require("luarocks.util")
6local fetch = require("luarocks.fetch")
7local pack = require("luarocks.pack")
8local cfg = require("luarocks.core.cfg")
9local Api = require("luarocks.upload.api")
10
11function upload.add_to_parser(parser)
12 local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) "..
13 "and upload it and the rockspec to the public rocks repository.", util.see_also())
14 :summary("Upload a rockspec to the public rocks repository.")
15
16 cmd:argument("rockspec", "Rockspec for the rock to upload.")
17 cmd:argument("src-rock", "A corresponding .src.rock file; if not given it will be generated.")
18 :args("?")
19
20 cmd:flag("--skip-pack", "Do not pack and send source rock.")
21 cmd:option("--api-key", "Pass an API key. It will be stored for subsequent uses.")
22 :argname("<key>")
23 cmd:option("--temp-key", "Use the given a temporary API key in this "..
24 "invocation only. It will not be stored.")
25 :argname("<key>")
26 cmd:flag("--force", "Replace existing rockspec if the same revision of a "..
27 "module already exists. This should be used only in case of upload "..
28 "mistakes: when updating a rockspec, increment the revision number "..
29 "instead.")
30 cmd:flag("--sign", "Upload a signature file alongside each file as well.")
31 cmd:flag("--debug"):hidden(true)
32end
33
34local function is_dev_version(version)
35 return version:match("^dev") or version:match("^scm")
36end
37
38function upload.command(args)
39 local api, err = Api.new(args)
40 if not api then
41 return nil, err
42 end
43 if cfg.verbose then
44 api.debug = true
45 end
46
47 local rockspec, err, errcode = fetch.load_rockspec(args.rockspec)
48 if err then
49 return nil, err, errcode
50 end
51
52 util.printout("Sending " .. tostring(args.rockspec) .. " ...")
53 local res, err = api:method("check_rockspec", {
54 package = rockspec.package,
55 version = rockspec.version
56 })
57 if not res then return nil, err end
58
59 if not res.module then
60 util.printout("Will create new module (" .. tostring(rockspec.package) .. ")")
61 end
62 if res.version and not args.force then
63 return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload")
64 end
65
66 local sigfname
67 local rock_sigfname
68
69 if args.sign then
70 sigfname, err = signing.sign_file(args.rockspec)
71 if err then
72 return nil, "Failed signing rockspec: " .. err
73 end
74 util.printout("Signed rockspec: "..sigfname)
75 end
76
77 local rock_fname
78 if args.src_rock then
79 rock_fname = args.src_rock
80 elseif not args.skip_pack and not is_dev_version(rockspec.version) then
81 util.printout("Packing " .. tostring(rockspec.package))
82 rock_fname, err = pack.pack_source_rock(args.rockspec)
83 if not rock_fname then
84 return nil, err
85 end
86 end
87
88 if rock_fname and args.sign then
89 rock_sigfname, err = signing.sign_file(rock_fname)
90 if err then
91 return nil, "Failed signing rock: " .. err
92 end
93 util.printout("Signed packed rock: "..rock_sigfname)
94 end
95
96 local multipart = require("luarocks.upload.multipart")
97
98 res, err = api:method("upload", nil, {
99 rockspec_file = multipart.new_file(args.rockspec),
100 rockspec_sig = sigfname and multipart.new_file(sigfname),
101 })
102 if not res then return nil, err end
103
104 if res.is_new and #res.manifests == 0 then
105 util.printerr("Warning: module not added to root manifest due to name taken.")
106 end
107
108 local module_url = res.module_url
109
110 if rock_fname then
111 if (not res.version) or (not res.version.id) then
112 return nil, "Invalid response from server."
113 end
114 util.printout(("Sending " .. tostring(rock_fname) .. " ..."))
115 res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, {
116 rock_file = multipart.new_file(rock_fname),
117 rock_sig = rock_sigfname and multipart.new_file(rock_sigfname),
118 })
119 if not res then return nil, err end
120 end
121
122 util.printout()
123 util.printout("Done: " .. tostring(module_url))
124 util.printout()
125 return true
126end
127
128return upload
diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua
index 6b84e452..576fdc65 100644
--- a/src/luarocks/cmd/upload.lua
+++ b/src/luarocks/cmd/upload.lua
@@ -1,5 +1,15 @@
1local _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 string = _tl_compat and _tl_compat.string or string
2local upload = {Response = {version = {}, }, }
3
4
5
6
7
8
9
10
11
1 12
2local upload = {}
3 13
4local signing = require("luarocks.signing") 14local signing = require("luarocks.signing")
5local util = require("luarocks.util") 15local util = require("luarocks.util")
@@ -8,25 +18,33 @@ local pack = require("luarocks.pack")
8local cfg = require("luarocks.core.cfg") 18local cfg = require("luarocks.core.cfg")
9local Api = require("luarocks.upload.api") 19local Api = require("luarocks.upload.api")
10 20
21
22
23local argparse = require("luarocks.vendor.argparse")
24
25
26
27
28
11function upload.add_to_parser(parser) 29function upload.add_to_parser(parser)
12 local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) ".. 30 local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) " ..
13 "and upload it and the rockspec to the public rocks repository.", util.see_also()) 31 "and upload it and the rockspec to the public rocks repository.", util.see_also()):
14 :summary("Upload a rockspec to the public rocks repository.") 32 summary("Upload a rockspec to the public rocks repository.")
15 33
16 cmd:argument("rockspec", "Rockspec for the rock to upload.") 34 cmd:argument("rockspec", "Rockspec for the rock to upload.")
17 cmd:argument("src-rock", "A corresponding .src.rock file; if not given it will be generated.") 35 cmd:argument("src-rock", "A corresponding .src.rock file; if not given it will be generated."):
18 :args("?") 36 args("?")
19 37
20 cmd:flag("--skip-pack", "Do not pack and send source rock.") 38 cmd:flag("--skip-pack", "Do not pack and send source rock.")
21 cmd:option("--api-key", "Pass an API key. It will be stored for subsequent uses.") 39 cmd:option("--api-key", "Pass an API key. It will be stored for subsequent uses."):
22 :argname("<key>") 40 argname("<key>")
23 cmd:option("--temp-key", "Use the given a temporary API key in this ".. 41 cmd:option("--temp-key", "Use the given a temporary API key in this " ..
24 "invocation only. It will not be stored.") 42 "invocation only. It will not be stored."):
25 :argname("<key>") 43 argname("<key>")
26 cmd:flag("--force", "Replace existing rockspec if the same revision of a ".. 44 cmd:flag("--force", "Replace existing rockspec if the same revision of a " ..
27 "module already exists. This should be used only in case of upload ".. 45 "module already exists. This should be used only in case of upload " ..
28 "mistakes: when updating a rockspec, increment the revision number ".. 46 "mistakes: when updating a rockspec, increment the revision number " ..
29 "instead.") 47 "instead.")
30 cmd:flag("--sign", "Upload a signature file alongside each file as well.") 48 cmd:flag("--sign", "Upload a signature file alongside each file as well.")
31 cmd:flag("--debug"):hidden(true) 49 cmd:flag("--debug"):hidden(true)
32end 50end
@@ -52,7 +70,7 @@ function upload.command(args)
52 util.printout("Sending " .. tostring(args.rockspec) .. " ...") 70 util.printout("Sending " .. tostring(args.rockspec) .. " ...")
53 local res, err = api:method("check_rockspec", { 71 local res, err = api:method("check_rockspec", {
54 package = rockspec.package, 72 package = rockspec.package,
55 version = rockspec.version 73 version = rockspec.version,
56 }) 74 })
57 if not res then return nil, err end 75 if not res then return nil, err end
58 76
@@ -60,7 +78,7 @@ function upload.command(args)
60 util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") 78 util.printout("Will create new module (" .. tostring(rockspec.package) .. ")")
61 end 79 end
62 if res.version and not args.force then 80 if res.version and not args.force then
63 return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload") 81 return nil, "Revision " .. rockspec.version .. " already exists on the server. " .. util.see_help("upload")
64 end 82 end
65 83
66 local sigfname 84 local sigfname
@@ -71,7 +89,7 @@ function upload.command(args)
71 if err then 89 if err then
72 return nil, "Failed signing rockspec: " .. err 90 return nil, "Failed signing rockspec: " .. err
73 end 91 end
74 util.printout("Signed rockspec: "..sigfname) 92 util.printout("Signed rockspec: " .. sigfname)
75 end 93 end
76 94
77 local rock_fname 95 local rock_fname
@@ -90,14 +108,14 @@ function upload.command(args)
90 if err then 108 if err then
91 return nil, "Failed signing rock: " .. err 109 return nil, "Failed signing rock: " .. err
92 end 110 end
93 util.printout("Signed packed rock: "..rock_sigfname) 111 util.printout("Signed packed rock: " .. rock_sigfname)
94 end 112 end
95 113
96 local multipart = require("luarocks.upload.multipart") 114 local multipart = require("luarocks.upload.multipart")
97 115
98 res, err = api:method("upload", nil, { 116 res, err = api:method("upload", nil, {
99 rockspec_file = multipart.new_file(args.rockspec), 117 rockspec_file = multipart.new_file(args.rockspec),
100 rockspec_sig = sigfname and multipart.new_file(sigfname), 118 rockspec_sig = sigfname and multipart.new_file(sigfname),
101 }) 119 })
102 if not res then return nil, err end 120 if not res then return nil, err end
103 121
diff --git a/src/luarocks/cmd/upload.tl b/src/luarocks/cmd/upload.tl
index 19b8f6ef..db62a9e9 100644
--- a/src/luarocks/cmd/upload.tl
+++ b/src/luarocks/cmd/upload.tl
@@ -1,6 +1,13 @@
1 1
2local record upload 2local record upload
3 record Response 3 record Response
4 module: string
5 is_new: boolean
6 module_url: boolean
7 manifests: {string}
8 record version
9 id: string
10 end
4 end 11 end
5end 12end
6 13
@@ -11,6 +18,8 @@ local pack = require("luarocks.pack")
11local cfg = require("luarocks.core.cfg") 18local cfg = require("luarocks.core.cfg")
12local Api = require("luarocks.upload.api") 19local Api = require("luarocks.upload.api")
13 20
21local type Response = upload.Response
22
14local argparse = require("luarocks.vendor.argparse") 23local argparse = require("luarocks.vendor.argparse")
15local type Parser = argparse.Parser 24local type Parser = argparse.Parser
16 25
@@ -62,7 +71,7 @@ function upload.command(args: Args): boolean, string, string
62 local res, err = api:method("check_rockspec", { 71 local res, err = api:method("check_rockspec", {
63 package = rockspec.package, 72 package = rockspec.package,
64 version = rockspec.version 73 version = rockspec.version
65 }) 74 }) as (Response, string)
66 if not res then return nil, err end 75 if not res then return nil, err end
67 76
68 if not res.module then 77 if not res.module then
@@ -107,7 +116,7 @@ function upload.command(args: Args): boolean, string, string
107 res, err = api:method("upload", nil, { 116 res, err = api:method("upload", nil, {
108 rockspec_file = multipart.new_file(args.rockspec), 117 rockspec_file = multipart.new_file(args.rockspec),
109 rockspec_sig = sigfname and multipart.new_file(sigfname), 118 rockspec_sig = sigfname and multipart.new_file(sigfname),
110 }) 119 }) as (Response, string)
111 if not res then return nil, err end 120 if not res then return nil, err end
112 121
113 if res.is_new and #res.manifests == 0 then 122 if res.is_new and #res.manifests == 0 then
@@ -124,7 +133,7 @@ function upload.command(args: Args): boolean, string, string
124 res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, { 133 res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, {
125 rock_file = multipart.new_file(rock_fname), 134 rock_file = multipart.new_file(rock_fname),
126 rock_sig = rock_sigfname and multipart.new_file(rock_sigfname), 135 rock_sig = rock_sigfname and multipart.new_file(rock_sigfname),
127 }) 136 }) as (Response, string)
128 if not res then return nil, err end 137 if not res then return nil, err end
129 end 138 end
130 139