diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-09-20 22:45:56 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-09-20 22:45:56 -0300 |
| commit | ff226c67e35c9b451abb38382774fccf947727f8 (patch) | |
| tree | c2ace8e4e8a6eba95ac2a1f42da562291a16c944 /src | |
| parent | 666faa41661e0f6aaa1620a5751a4117013bf9b1 (diff) | |
| download | luarocks-ff226c67e35c9b451abb38382774fccf947727f8.tar.gz luarocks-ff226c67e35c9b451abb38382774fccf947727f8.tar.bz2 luarocks-ff226c67e35c9b451abb38382774fccf947727f8.zip | |
Use zipped manifests. Makes LR a bit faster!
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/add.lua | 9 | ||||
| -rw-r--r-- | src/luarocks/fs/unix/tools.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/index.lua | 19 | ||||
| -rw-r--r-- | src/luarocks/manif.lua | 53 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 9 |
5 files changed, 69 insertions, 23 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 54991291..831d3b92 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
| @@ -68,6 +68,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
| 68 | 68 | ||
| 69 | util.printout("Updating manifest...") | 69 | util.printout("Updating manifest...") |
| 70 | manif.make_manifest(local_cache, "one", true) | 70 | manif.make_manifest(local_cache, "one", true) |
| 71 | |||
| 72 | manif.zip_manifests() | ||
| 73 | |||
| 71 | util.printout("Updating index.html...") | 74 | util.printout("Updating index.html...") |
| 72 | index.make_index(local_cache) | 75 | index.make_index(local_cache) |
| 73 | 76 | ||
| @@ -80,8 +83,10 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
| 80 | 83 | ||
| 81 | table.insert(files, "index.html") | 84 | table.insert(files, "index.html") |
| 82 | table.insert(files, "manifest") | 85 | table.insert(files, "manifest") |
| 83 | table.insert(files, "manifest-5.1") | 86 | for ver in util.lua_versions() do |
| 84 | table.insert(files, "manifest-5.2") | 87 | table.insert(files, "manifest-"..ver) |
| 88 | table.insert(files, "manifest-"..ver..".zip") | ||
| 89 | end | ||
| 85 | 90 | ||
| 86 | -- TODO abstract away explicit 'curl' call | 91 | -- TODO abstract away explicit 'curl' call |
| 87 | 92 | ||
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 64992b91..9e4acf73 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
| @@ -206,7 +206,7 @@ end | |||
| 206 | -- @return boolean: true on success, false on failure. | 206 | -- @return boolean: true on success, false on failure. |
| 207 | function unzip(zipfile) | 207 | function unzip(zipfile) |
| 208 | assert(zipfile) | 208 | assert(zipfile) |
| 209 | return fs.execute(vars.UNZIP, zipfile) | 209 | return fs.execute_string(fs.quiet(vars.UNZIP.." "..fs.Q(zipfile))) |
| 210 | end | 210 | end |
| 211 | 211 | ||
| 212 | --- Test is file/directory exists | 212 | --- Test is file/directory exists |
diff --git a/src/luarocks/index.lua b/src/luarocks/index.lua index 6147a4d2..e0785d9c 100644 --- a/src/luarocks/index.lua +++ b/src/luarocks/index.lua | |||
| @@ -66,7 +66,7 @@ Lua modules available from this location for use with <a href="http://www.luaroc | |||
| 66 | <table class="main"> | 66 | <table class="main"> |
| 67 | ]] | 67 | ]] |
| 68 | 68 | ||
| 69 | local index_package_start = [[ | 69 | local index_package_begin = [[ |
| 70 | <td class="package"> | 70 | <td class="package"> |
| 71 | <p><a name="$anchor"></a><a href="#$anchor" class="pkg"><b>$package</b></a> - $summary<br/> | 71 | <p><a name="$anchor"></a><a href="#$anchor" class="pkg"><b>$package</b></a> - $summary<br/> |
| 72 | </p><blockquote><p>$detailed<br/> | 72 | </p><blockquote><p>$detailed<br/> |
| @@ -81,10 +81,15 @@ local index_package_end = [[ | |||
| 81 | <tr><td colspan="2" class="spacer"></td></tr> | 81 | <tr><td colspan="2" class="spacer"></td></tr> |
| 82 | ]] | 82 | ]] |
| 83 | 83 | ||
| 84 | local index_footer = [[ | 84 | local index_footer_begin = [[ |
| 85 | </table> | 85 | </table> |
| 86 | <p class="manifest"> | 86 | <p class="manifest"> |
| 87 | <a href="manifest">manifest file</a> • <a href="manifest-5.1">Lua 5.1 manifest file</a> • <a href="manifest-5.2">Lua 5.2 manifest file</a> | 87 | <a href="manifest">manifest file</a> |
| 88 | ]] | ||
| 89 | local index_manifest_ver = [[ | ||
| 90 | • <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>) | ||
| 91 | ]] | ||
| 92 | local index_footer_end = [[ | ||
| 88 | </p> | 93 | </p> |
| 89 | </body> | 94 | </body> |
| 90 | </html> | 95 | </html> |
| @@ -128,7 +133,7 @@ function make_index(repo) | |||
| 128 | out:write(index_header) | 133 | out:write(index_header) |
| 129 | for package, version_list in util.sortedpairs(manifest.repository) do | 134 | for package, version_list in util.sortedpairs(manifest.repository) do |
| 130 | local latest_rockspec = nil | 135 | local latest_rockspec = nil |
| 131 | local output = index_package_start | 136 | local output = index_package_begin |
| 132 | for version, data in util.sortedpairs(version_list, deps.compare_versions) do | 137 | for version, data in util.sortedpairs(version_list, deps.compare_versions) do |
| 133 | local versions = {} | 138 | local versions = {} |
| 134 | output = output..version..': ' | 139 | output = output..version..': ' |
| @@ -170,6 +175,10 @@ function make_index(repo) | |||
| 170 | end | 175 | end |
| 171 | out:write(output) | 176 | out:write(output) |
| 172 | end | 177 | end |
| 173 | out:write(index_footer) | 178 | out:write(index_footer_begin) |
| 179 | for ver in util.lua_versions() do | ||
| 180 | out:write((index_manifest_ver:gsub("$VER", ver))) | ||
| 181 | end | ||
| 182 | out:write(index_footer_end) | ||
| 174 | out:close() | 183 | out:close() |
| 175 | end | 184 | end |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index d0bd5e04..03377d52 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
| @@ -103,26 +103,40 @@ function load_manifest(repo_url) | |||
| 103 | if manif_core.manifest_cache[repo_url] then | 103 | if manif_core.manifest_cache[repo_url] then |
| 104 | return manif_core.manifest_cache[repo_url] | 104 | return manif_core.manifest_cache[repo_url] |
| 105 | end | 105 | end |
| 106 | 106 | ||
| 107 | local vmanifest = "manifest-"..cfg.lua_version | 107 | local filenames = { |
| 108 | 108 | "manifest-"..cfg.lua_version..".zip", | |
| 109 | local protocol, pathname = dir.split_url(repo_url) | 109 | "manifest-"..cfg.lua_version, |
| 110 | "manifest", | ||
| 111 | } | ||
| 112 | |||
| 113 | local protocol, repodir = dir.split_url(repo_url) | ||
| 114 | local pathname | ||
| 110 | if protocol == "file" then | 115 | if protocol == "file" then |
| 111 | local file = dir.path(pathname, vmanifest) | 116 | for _, filename in ipairs(filenames) do |
| 112 | if fs.exists(file) then | 117 | pathname = dir.path(repodir, filename) |
| 113 | pathname = file | 118 | if fs.exists(pathname) then |
| 114 | else | 119 | break |
| 115 | pathname = dir.path(pathname, "manifest") | 120 | end |
| 116 | end | 121 | end |
| 117 | else | 122 | else |
| 118 | local file, err = fetch_manifest_from(repo_url, vmanifest) | 123 | local err |
| 119 | if not file then | 124 | for _, filename in ipairs(filenames) do |
| 120 | file, err = fetch_manifest_from(repo_url, "manifest") | 125 | pathname, err = fetch_manifest_from(repo_url, filename) |
| 126 | if pathname then | ||
| 127 | break | ||
| 128 | end | ||
| 121 | end | 129 | end |
| 122 | if not file then | 130 | if not pathname then |
| 123 | return nil, err | 131 | return nil, err |
| 124 | end | 132 | end |
| 125 | pathname = file | 133 | end |
| 134 | if pathname:match(".*%.zip$") then | ||
| 135 | local dir = dir.dir_name(pathname) | ||
| 136 | fs.change_dir(dir) | ||
| 137 | fs.unzip(pathname) | ||
| 138 | fs.pop_dir() | ||
| 139 | pathname = pathname:match("(.*)%.zip$") | ||
| 126 | end | 140 | end |
| 127 | return manif_core.manifest_loader(pathname, repo_url) | 141 | return manif_core.manifest_loader(pathname, repo_url) |
| 128 | end | 142 | end |
| @@ -343,7 +357,7 @@ function make_manifest(repo, deps_mode, versioned) | |||
| 343 | if not ok then return nil, err end | 357 | if not ok then return nil, err end |
| 344 | 358 | ||
| 345 | if versioned then | 359 | if versioned then |
| 346 | for _, luaver in ipairs({"5.1", "5.2"}) do | 360 | for luaver in util.lua_versions() do |
| 347 | local vmanifest = { repository = {}, modules = {}, commands = {} } | 361 | local vmanifest = { repository = {}, modules = {}, commands = {} } |
| 348 | local ok, err = store_results(results, vmanifest, deps_mode, repo, luaver, cache) | 362 | local ok, err = store_results(results, vmanifest, deps_mode, repo, luaver, cache) |
| 349 | save_table(repo, "manifest-"..luaver, vmanifest) | 363 | save_table(repo, "manifest-"..luaver, vmanifest) |
| @@ -397,6 +411,15 @@ function update_manifest(name, version, repo, deps_mode) | |||
| 397 | return save_table(repo, "manifest", manifest) | 411 | return save_table(repo, "manifest", manifest) |
| 398 | end | 412 | end |
| 399 | 413 | ||
| 414 | function zip_manifests() | ||
| 415 | for ver in util.lua_versions() do | ||
| 416 | local file = "manifest-"..ver | ||
| 417 | local zip = file..".zip" | ||
| 418 | fs.delete(dir.path(fs.current_dir(), zip)) | ||
| 419 | fs.zip(zip, file) | ||
| 420 | end | ||
| 421 | end | ||
| 422 | |||
| 400 | local function find_providers(file, root) | 423 | local function find_providers(file, root) |
| 401 | assert(type(file) == "string") | 424 | assert(type(file) == "string") |
| 402 | root = root or cfg.root_dir | 425 | root = root or cfg.root_dir |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index ba20acfa..e3260359 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -319,6 +319,15 @@ function sortedpairs(tbl, sort_function) | |||
| 319 | return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) | 319 | return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) |
| 320 | end | 320 | end |
| 321 | 321 | ||
| 322 | function lua_versions() | ||
| 323 | local versions = { "5.1", "5.2" } | ||
| 324 | local i = 0 | ||
| 325 | return function() | ||
| 326 | i = i + 1 | ||
| 327 | return versions[i] | ||
| 328 | end | ||
| 329 | end | ||
| 330 | |||
| 322 | function starts_with(s, prefix) | 331 | function starts_with(s, prefix) |
| 323 | return s:sub(1,#prefix) == prefix | 332 | return s:sub(1,#prefix) == prefix |
| 324 | end | 333 | end |
