diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 11:19:54 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 19:29:10 -0300 |
| commit | 27ecdd5df9e258a3da879cdcb3432e7ff5123222 (patch) | |
| tree | 9aaf94fddebb7dcff3a03f5f9ce2d4a3b2205900 /src | |
| parent | eeee65fafbfc6544ea211ec05a2f689b004e90a1 (diff) | |
| download | luarocks-27ecdd5df9e258a3da879cdcb3432e7ff5123222.tar.gz luarocks-27ecdd5df9e258a3da879cdcb3432e7ff5123222.tar.bz2 luarocks-27ecdd5df9e258a3da879cdcb3432e7ff5123222.zip | |
luarocks-admin: only create index.html if it already exists or --index is given
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/admin/cache.lua | 7 | ||||
| -rw-r--r-- | src/luarocks/admin/cmd/add.lua | 28 | ||||
| -rw-r--r-- | src/luarocks/admin/cmd/refresh_cache.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/admin/cmd/remove.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 1 |
5 files changed, 27 insertions, 13 deletions
diff --git a/src/luarocks/admin/cache.lua b/src/luarocks/admin/cache.lua index 5b54203b..1fd4d55a 100644 --- a/src/luarocks/admin/cache.lua +++ b/src/luarocks/admin/cache.lua | |||
| @@ -32,7 +32,7 @@ function cache.get_server_urls(server, upload_server) | |||
| 32 | return download_url, login_url | 32 | return download_url, login_url |
| 33 | end | 33 | end |
| 34 | 34 | ||
| 35 | function cache.split_server_url(server, url, user, password) | 35 | function cache.split_server_url(url, user, password) |
| 36 | local protocol, server_path = dir.split_url(url) | 36 | local protocol, server_path = dir.split_url(url) |
| 37 | if protocol == "file" then | 37 | if protocol == "file" then |
| 38 | server_path = fs.absolute_name(server_path) | 38 | server_path = fs.absolute_name(server_path) |
| @@ -50,6 +50,7 @@ function cache.split_server_url(server, url, user, password) | |||
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | local function download_cache(protocol, server_path, user, password) | 52 | local function download_cache(protocol, server_path, user, password) |
| 53 | os.remove("index.html") | ||
| 53 | -- TODO abstract away explicit 'wget' call | 54 | -- TODO abstract away explicit 'wget' call |
| 54 | if protocol == "rsync" then | 55 | if protocol == "rsync" then |
| 55 | local srv, path = server_path:match("([^/]+)(/.+)") | 56 | local srv, path = server_path:match("([^/]+)(/.+)") |
| @@ -64,8 +65,8 @@ local function download_cache(protocol, server_path, user, password) | |||
| 64 | end | 65 | end |
| 65 | end | 66 | end |
| 66 | 67 | ||
| 67 | function cache.refresh_local_cache(server, url, given_user, given_password) | 68 | function cache.refresh_local_cache(url, given_user, given_password) |
| 68 | local local_cache, protocol, server_path, user, password = cache.split_server_url(server, url, given_user, given_password) | 69 | local local_cache, protocol, server_path, user, password = cache.split_server_url(url, given_user, given_password) |
| 69 | 70 | ||
| 70 | local ok, err = fs.make_dir(local_cache) | 71 | local ok, err = fs.make_dir(local_cache) |
| 71 | if not ok then | 72 | if not ok then |
diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua index b6c817c6..5cfec980 100644 --- a/src/luarocks/admin/cmd/add.lua +++ b/src/luarocks/admin/cmd/add.lua | |||
| @@ -18,8 +18,12 @@ Arguments are local files, which may be rockspecs or rocks. | |||
| 18 | The flag --server indicates which server to use. | 18 | The flag --server indicates which server to use. |
| 19 | If not given, the default server set in the upload_server variable | 19 | If not given, the default server set in the upload_server variable |
| 20 | from the configuration file is used instead. | 20 | from the configuration file is used instead. |
| 21 | The flag --no-refresh indicates the local cache should not be refreshed | 21 | |
| 22 | prior to generation of the updated manifest. | 22 | --no-refresh The local cache should not be refreshed |
| 23 | prior to generation of the updated manifest. | ||
| 24 | --index Produce an index.html file for the manifest. | ||
| 25 | This flag is automatically set if an index.html | ||
| 26 | file already exists. | ||
| 23 | ]] | 27 | ]] |
| 24 | 28 | ||
| 25 | local function zip_manifests() | 29 | local function zip_manifests() |
| @@ -31,7 +35,7 @@ local function zip_manifests() | |||
| 31 | end | 35 | end |
| 32 | end | 36 | end |
| 33 | 37 | ||
| 34 | local function add_files_to_server(refresh, rockfiles, server, upload_server) | 38 | local function add_files_to_server(refresh, rockfiles, server, upload_server, do_index) |
| 35 | assert(type(refresh) == "boolean" or not refresh) | 39 | assert(type(refresh) == "boolean" or not refresh) |
| 36 | assert(type(rockfiles) == "table") | 40 | assert(type(rockfiles) == "table") |
| 37 | assert(type(server) == "string") | 41 | assert(type(server) == "string") |
| @@ -41,7 +45,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
| 41 | local at = fs.current_dir() | 45 | local at = fs.current_dir() |
| 42 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 46 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
| 43 | 47 | ||
| 44 | local local_cache, protocol, server_path, user, password = refresh_fn(server, download_url, cfg.upload_user, cfg.upload_password) | 48 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
| 45 | if not local_cache then | 49 | if not local_cache then |
| 46 | return nil, protocol | 50 | return nil, protocol |
| 47 | end | 51 | end |
| @@ -76,8 +80,14 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
| 76 | 80 | ||
| 77 | zip_manifests() | 81 | zip_manifests() |
| 78 | 82 | ||
| 79 | util.printout("Updating index.html...") | 83 | if fs.exists("index.html") then |
| 80 | index.make_index(local_cache) | 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 | ||
| 81 | 91 | ||
| 82 | local login_info = "" | 92 | local login_info = "" |
| 83 | if user then login_info = " -u "..user end | 93 | if user then login_info = " -u "..user end |
| @@ -86,7 +96,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
| 86 | login_url = login_url .. "/" | 96 | login_url = login_url .. "/" |
| 87 | end | 97 | end |
| 88 | 98 | ||
| 89 | table.insert(files, "index.html") | 99 | if do_index then |
| 100 | table.insert(files, "index.html") | ||
| 101 | end | ||
| 90 | table.insert(files, "manifest") | 102 | table.insert(files, "manifest") |
| 91 | for ver in util.lua_versions() do | 103 | for ver in util.lua_versions() do |
| 92 | table.insert(files, "manifest-"..ver) | 104 | table.insert(files, "manifest-"..ver) |
| @@ -119,7 +131,7 @@ function add.command(flags, ...) | |||
| 119 | end | 131 | end |
| 120 | local server, server_table = cache.get_upload_server(flags["server"]) | 132 | local server, server_table = cache.get_upload_server(flags["server"]) |
| 121 | if not server then return nil, server_table end | 133 | if not server then return nil, server_table end |
| 122 | return add_files_to_server(not flags["no-refresh"], files, server, server_table) | 134 | return add_files_to_server(not flags["no-refresh"], files, server, server_table, flags["index"]) |
| 123 | end | 135 | end |
| 124 | 136 | ||
| 125 | 137 | ||
diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua index 947dbfb0..3ffe56d9 100644 --- a/src/luarocks/admin/cmd/refresh_cache.lua +++ b/src/luarocks/admin/cmd/refresh_cache.lua | |||
| @@ -18,7 +18,7 @@ function refresh_cache.command(flags) | |||
| 18 | if not server then return nil, upload_server end | 18 | if not server then return nil, upload_server end |
| 19 | local download_url = cache.get_server_urls(server, upload_server) | 19 | local download_url = cache.get_server_urls(server, upload_server) |
| 20 | 20 | ||
| 21 | local ok, err = cache.refresh_local_cache(server, download_url, cfg.upload_user, cfg.upload_password) | 21 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) |
| 22 | if not ok then | 22 | if not ok then |
| 23 | return nil, err | 23 | return nil, err |
| 24 | else | 24 | else |
diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.lua index 173cc1a9..f005c83c 100644 --- a/src/luarocks/admin/cmd/remove.lua +++ b/src/luarocks/admin/cmd/remove.lua | |||
| @@ -32,7 +32,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
| 32 | local at = fs.current_dir() | 32 | local at = fs.current_dir() |
| 33 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 33 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
| 34 | 34 | ||
| 35 | local local_cache, protocol, server_path, user, password = refresh_fn(server, download_url, cfg.upload_user, cfg.upload_password) | 35 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
| 36 | if not local_cache then | 36 | if not local_cache then |
| 37 | return nil, protocol | 37 | return nil, protocol |
| 38 | end | 38 | end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 85c83744..7fdefce0 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -98,6 +98,7 @@ local supported_flags = { | |||
| 98 | ["help"] = true, | 98 | ["help"] = true, |
| 99 | ["home"] = true, | 99 | ["home"] = true, |
| 100 | ["homepage"] = "\"<url>\"", | 100 | ["homepage"] = "\"<url>\"", |
| 101 | ["index"] = true, | ||
| 101 | ["issues"] = true, | 102 | ["issues"] = true, |
| 102 | ["keep"] = true, | 103 | ["keep"] = true, |
| 103 | ["labels"] = true, | 104 | ["labels"] = true, |
