diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/manif.lua | 4 | ||||
-rw-r--r-- | src/luarocks/pack.lua | 36 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 39351497..c677a22c 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -30,7 +30,7 @@ local function save_table(where, name, tbl) | |||
30 | return persist.save_from_table(filename, tbl) | 30 | return persist.save_from_table(filename, tbl) |
31 | end | 31 | end |
32 | 32 | ||
33 | function load_rock_manifest(name, version) | 33 | function load_rock_manifest(name, version, root) |
34 | assert(type(name) == "string") | 34 | assert(type(name) == "string") |
35 | assert(type(version) == "string") | 35 | assert(type(version) == "string") |
36 | 36 | ||
@@ -38,7 +38,7 @@ function load_rock_manifest(name, version) | |||
38 | if rock_manifest_cache[name_version] then | 38 | if rock_manifest_cache[name_version] then |
39 | return rock_manifest_cache[name_version].rock_manifest | 39 | return rock_manifest_cache[name_version].rock_manifest |
40 | end | 40 | end |
41 | local pathname = path.rock_manifest_file(name, version) | 41 | local pathname = path.rock_manifest_file(name, version, root) |
42 | local rock_manifest = persist.load_into_table(pathname) | 42 | local rock_manifest = persist.load_into_table(pathname) |
43 | if not rock_manifest then return nil end | 43 | if not rock_manifest then return nil end |
44 | rock_manifest_cache[name_version] = rock_manifest | 44 | rock_manifest_cache[name_version] = rock_manifest |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index aaa3d37e..46c00e41 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -11,6 +11,7 @@ local cfg = require("luarocks.cfg") | |||
11 | local util = require("luarocks.util") | 11 | local util = require("luarocks.util") |
12 | local dir = require("luarocks.dir") | 12 | local dir = require("luarocks.dir") |
13 | local manif = require("luarocks.manif") | 13 | local manif = require("luarocks.manif") |
14 | local search = require("luarocks.search") | ||
14 | 15 | ||
15 | help_summary = "Create a rock, packing sources or binaries." | 16 | help_summary = "Create a rock, packing sources or binaries." |
16 | help_arguments = "{<rockspec>|<name> [<version>]}" | 17 | help_arguments = "{<rockspec>|<name> [<version>]}" |
@@ -82,27 +83,40 @@ end | |||
82 | local function pack_binary_rock(name, version) | 83 | local function pack_binary_rock(name, version) |
83 | assert(type(name) == "string") | 84 | assert(type(name) == "string") |
84 | assert(type(version) == "string" or not version) | 85 | assert(type(version) == "string" or not version) |
85 | 86 | ||
86 | local versions = rep.get_versions(name) | 87 | local query = search.make_query(name, version) |
87 | 88 | query.exact_name = true | |
88 | if not versions then | 89 | local results = {} |
90 | for _, tree in ipairs(cfg.rocks_trees) do | ||
91 | search.manifest_search(results, path.rocks_dir(tree), query) | ||
92 | end | ||
93 | if not next(results) then | ||
89 | return nil, "'"..name.."' does not seem to be an installed rock." | 94 | return nil, "'"..name.."' does not seem to be an installed rock." |
90 | end | 95 | end |
96 | |||
97 | local versions = results[name] | ||
98 | |||
91 | if not version then | 99 | if not version then |
92 | if #versions > 1 then | 100 | local first = next(versions) |
101 | if next(versions, first) then | ||
93 | return nil, "Please specify which version of '"..name.."' to pack." | 102 | return nil, "Please specify which version of '"..name.."' to pack." |
94 | end | 103 | end |
95 | version = versions[1] | 104 | version = first |
96 | end | 105 | end |
97 | if not version:match("[^-]+%-%d+") then | 106 | if not version:match("[^-]+%-%d+") then |
98 | return nil, "Expected version "..version.." in version-revision format." | 107 | return nil, "Expected version "..version.." in version-revision format." |
99 | end | 108 | end |
100 | local prefix = path.install_dir(name, version) | 109 | |
110 | local info = versions[version][1] | ||
111 | |||
112 | local root = path.root_dir(info.repo) | ||
113 | local prefix = path.install_dir(name, version, root) | ||
114 | |||
101 | if not fs.exists(prefix) then | 115 | if not fs.exists(prefix) then |
102 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." | 116 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." |
103 | end | 117 | end |
104 | 118 | ||
105 | local rock_manifest = manif.load_rock_manifest(name, version) | 119 | local rock_manifest = manif.load_rock_manifest(name, version, root) |
106 | if not rock_manifest then | 120 | if not rock_manifest then |
107 | return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks 2 tree?" | 121 | return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks 2 tree?" |
108 | end | 122 | end |
@@ -115,11 +129,11 @@ local function pack_binary_rock(name, version) | |||
115 | 129 | ||
116 | local is_binary = false | 130 | local is_binary = false |
117 | if rock_manifest.lib then | 131 | if rock_manifest.lib then |
118 | copy_back_files(name, version, rock_manifest.lib, cfg.deploy_lib_dir, dir.path(temp_dir, "lib")) | 132 | copy_back_files(name, version, rock_manifest.lib, path.deploy_lib_dir(root), dir.path(temp_dir, "lib")) |
119 | is_binary = true | 133 | is_binary = true |
120 | end | 134 | end |
121 | if rock_manifest.lua then | 135 | if rock_manifest.lua then |
122 | copy_back_files(name, version, rock_manifest.lua, cfg.deploy_lua_dir, dir.path(temp_dir, "lua")) | 136 | copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(root), dir.path(temp_dir, "lua")) |
123 | end | 137 | end |
124 | 138 | ||
125 | fs.change_dir(temp_dir) | 139 | fs.change_dir(temp_dir) |