diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-04 12:48:01 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-04 12:48:01 +0300 |
| commit | 6606ae90f54bc142a2129f491b0aad8e7352b18d (patch) | |
| tree | b0b82ac5307cf4d4c254199faf129e896b7fe909 | |
| parent | dcf9bf6248e4ead25eb1981631021a72a7875a19 (diff) | |
| parent | bfab09559cdbbc7e163490129ac7d3c4060b905d (diff) | |
| download | luarocks-6606ae90f54bc142a2129f491b0aad8e7352b18d.tar.gz luarocks-6606ae90f54bc142a2129f491b0aad8e7352b18d.tar.bz2 luarocks-6606ae90f54bc142a2129f491b0aad8e7352b18d.zip | |
Merge branch 'master' into luarocks-3
| -rw-r--r-- | spec/make_spec.lua | 69 | ||||
| -rw-r--r-- | spec/persist.lua | 55 | ||||
| -rw-r--r-- | src/luarocks/manif.lua | 133 | ||||
| -rw-r--r-- | src/luarocks/persist.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/repos.lua | 254 | ||||
| -rw-r--r-- | test/test_environment.lua | 10 | ||||
| -rw-r--r-- | test/testfiles/mixed_deploy_type/mdt.c | 6 | ||||
| -rw-r--r-- | test/testfiles/mixed_deploy_type/mdt.lua | 1 | ||||
| -rw-r--r-- | test/testfiles/mixed_deploy_type/mdt_file | 1 | ||||
| -rw-r--r-- | test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec | 21 | ||||
| -rw-r--r-- | test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec | 21 |
11 files changed, 385 insertions, 191 deletions
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index ae79a29c..89036d26 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
| @@ -2,11 +2,11 @@ local test_env = require("test/test_environment") | |||
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | 3 | local run = test_env.run |
| 4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
| 5 | local env_variables = test_env.env_variables | ||
| 5 | 6 | ||
| 6 | test_env.unload_luarocks() | 7 | test_env.unload_luarocks() |
| 7 | 8 | ||
| 8 | local extra_rocks = { | 9 | local extra_rocks = { |
| 9 | "lpeg-1.0.0-1.rockspec", | ||
| 10 | "/luasocket-3.0rc1-2.src.rock", | 10 | "/luasocket-3.0rc1-2.src.rock", |
| 11 | "/luasocket-3.0rc1-2.rockspec", | 11 | "/luasocket-3.0rc1-2.rockspec", |
| 12 | "/lxsh-0.8.6-2.src.rock", | 12 | "/lxsh-0.8.6-2.src.rock", |
| @@ -98,4 +98,71 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
| 98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | 98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) |
| 99 | end) | 99 | end) |
| 100 | end) | 100 | end) |
| 101 | |||
| 102 | describe("LuaRocks make upgrading rockspecs with mixed deploy types", function() | ||
| 103 | setup(function() | ||
| 104 | test_env.copy_dir(testing_paths.testing_dir .. "/testfiles/mixed_deploy_type", "mdt") | ||
| 105 | end) | ||
| 106 | |||
| 107 | teardown(function() | ||
| 108 | test_env.remove_dir("mdt") | ||
| 109 | os.remove("mdt."..test_env.lib_extension) | ||
| 110 | end) | ||
| 111 | |||
| 112 | it("modules with same name from lua/ and lib/ when upgrading", function() | ||
| 113 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec")) | ||
| 114 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
| 115 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 116 | |||
| 117 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec")) | ||
| 118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
| 119 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 120 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
| 121 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 122 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua")) | ||
| 123 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) | ||
| 124 | end) | ||
| 125 | |||
| 126 | it("modules with same name from lua/ and lib/ when upgrading with --keep", function() | ||
| 127 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec")) | ||
| 128 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
| 129 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 130 | |||
| 131 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec --keep")) | ||
| 132 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
| 133 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 134 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
| 135 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 136 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua")) | ||
| 137 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) | ||
| 138 | end) | ||
| 139 | |||
| 140 | it("modules with same name from lua/ and lib/ when downgrading", function() | ||
| 141 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec")) | ||
| 142 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
| 143 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 144 | |||
| 145 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec")) | ||
| 146 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
| 147 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 148 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt."..test_env.lib_extension)) | ||
| 149 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) | ||
| 150 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
| 151 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 152 | end) | ||
| 153 | |||
| 154 | it("modules with same name from lua/ and lib/ when downgrading with --keep", function() | ||
| 155 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec")) | ||
| 156 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
| 157 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 158 | |||
| 159 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec --keep")) | ||
| 160 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
| 161 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 162 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
| 163 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
| 164 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua")) | ||
| 165 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) | ||
| 166 | end) | ||
| 167 | end) | ||
| 101 | end) | 168 | end) |
diff --git a/spec/persist.lua b/spec/persist.lua new file mode 100644 index 00000000..6b69dab4 --- /dev/null +++ b/spec/persist.lua | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | |||
| 3 | test_env.unload_luarocks() | ||
| 4 | local persist = require("luarocks.persist") | ||
| 5 | |||
| 6 | describe("Luarocks persist test #whitebox #w_persist", function() | ||
| 7 | describe("persist.save_from_table_to_string", function() | ||
| 8 | it("simple table", function() | ||
| 9 | assert.are.same([[ | ||
| 10 | bar = 1234 | ||
| 11 | foo = "string" | ||
| 12 | ]], persist.save_from_table_to_string({foo = "string", bar = 1234})) | ||
| 13 | end) | ||
| 14 | |||
| 15 | it("nested tables", function() | ||
| 16 | assert.are.same([[ | ||
| 17 | bar = { | ||
| 18 | baz = "string" | ||
| 19 | } | ||
| 20 | foo = { | ||
| 21 | 1, 2, 3, 4 | ||
| 22 | } | ||
| 23 | ]], persist.save_from_table_to_string({foo = {1, 2, 3, 4}, bar = {baz = "string"}})) | ||
| 24 | end) | ||
| 25 | |||
| 26 | it("strings with quotes", function() | ||
| 27 | assert.are.same([[ | ||
| 28 | bar = "a \\backslash?" | ||
| 29 | foo = "a \"quote\"?" | ||
| 30 | ]], persist.save_from_table_to_string({foo = 'a "quote"?', bar = 'a \\backslash?'})) | ||
| 31 | end) | ||
| 32 | |||
| 33 | it("multiline strings", function() | ||
| 34 | assert.are.same([===[ | ||
| 35 | bar = [==[ | ||
| 36 | ]] | ||
| 37 | ]=]]==] | ||
| 38 | foo = [[ | ||
| 39 | First line | ||
| 40 | Second line]] | ||
| 41 | ]===], persist.save_from_table_to_string({foo = "First line\nSecond line", bar = "]]\n]=]"})) | ||
| 42 | end) | ||
| 43 | |||
| 44 | it("multiline strings ending with brackets", function() | ||
| 45 | assert.are.same([===[ | ||
| 46 | bar = [==[ | ||
| 47 | ]] | ||
| 48 | ]=]==] | ||
| 49 | foo = [=[ | ||
| 50 | First line | ||
| 51 | Second line [1]]=] | ||
| 52 | ]===], persist.save_from_table_to_string({foo = "First line\nSecond line [1]", bar = "]]\n]="})) | ||
| 53 | end) | ||
| 54 | end) | ||
| 55 | end) | ||
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 8277b3a5..7fdfecda 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
| @@ -9,7 +9,6 @@ local persist = require("luarocks.persist") | |||
| 9 | local fetch = require("luarocks.fetch") | 9 | local fetch = require("luarocks.fetch") |
| 10 | local dir = require("luarocks.dir") | 10 | local dir = require("luarocks.dir") |
| 11 | local fs = require("luarocks.fs") | 11 | local fs = require("luarocks.fs") |
| 12 | local util = require("luarocks.util") | ||
| 13 | local cfg = require("luarocks.core.cfg") | 12 | local cfg = require("luarocks.core.cfg") |
| 14 | local path = require("luarocks.path") | 13 | local path = require("luarocks.path") |
| 15 | 14 | ||
| @@ -110,85 +109,89 @@ function manif.load_manifest(repo_url, lua_version) | |||
| 110 | return manif.manifest_loader(pathname, repo_url, lua_version) | 109 | return manif.manifest_loader(pathname, repo_url, lua_version) |
| 111 | end | 110 | end |
| 112 | 111 | ||
| 113 | local function relative_path(from_dir, to_file) | 112 | --- Get type and name of an item (a module or a command) provided by a file. |
| 114 | -- It is assumed that `from_dir` is prefix of `to_file`. | 113 | -- @param deploy_type string: rock manifest subtree the file comes from ("bin", "lua", or "lib"). |
| 115 | return (to_file:sub(#from_dir + 1):gsub("^[\\/]*", "")) | 114 | -- @param file_path string: path to the file relatively to deploy_type subdirectory. |
| 115 | -- @return (string, string): item type ("module" or "command") and name. | ||
| 116 | function manif.get_provided_item(deploy_type, file_path) | ||
| 117 | assert(type(deploy_type) == "string") | ||
| 118 | assert(type(file_path) == "string") | ||
| 119 | local item_type = deploy_type == "bin" and "command" or "module" | ||
| 120 | local item_name = item_type == "command" and file_path or path.path_to_module(file_path) | ||
| 121 | return item_type, item_name | ||
| 116 | end | 122 | end |
| 117 | 123 | ||
| 118 | local function file_manifest_coordinates(manifest, file, root) | 124 | local function get_providers(item_type, item_name, repo) |
| 119 | local deploy_bin = path.deploy_bin_dir(root) | 125 | assert(type(item_type) == "string") |
| 120 | local deploy_lua = path.deploy_lua_dir(root) | 126 | assert(type(item_name) == "string") |
| 121 | local deploy_lib = path.deploy_lib_dir(root) | 127 | local rocks_dir = path.rocks_dir(repo or cfg.root_dir) |
| 122 | 128 | local manifest = manif.load_local_manifest(rocks_dir) | |
| 123 | if util.starts_with(file, deploy_lua) then | 129 | return manifest and manifest[item_type .. "s"][item_name] |
| 124 | return "modules", path.path_to_module(relative_path(deploy_lua, file):gsub("\\", "/")), deploy_lua | ||
| 125 | elseif util.starts_with(file, deploy_lib) then | ||
| 126 | return "modules", path.path_to_module(relative_path(deploy_lib, file):gsub("\\", "/")), deploy_lib | ||
| 127 | elseif util.starts_with(file, deploy_bin) then | ||
| 128 | return "commands", relative_path(deploy_bin, file), deploy_bin | ||
| 129 | else | ||
| 130 | assert(false, "Assertion failed: '"..file.."' is not a deployed file.") | ||
| 131 | end | ||
| 132 | end | 130 | end |
| 133 | 131 | ||
| 134 | local function find_providers(file, root) | 132 | --- Given a name of a module or a command, figure out which rock name and version |
| 135 | assert(type(file) == "string") | 133 | -- correspond to it in the rock tree manifest. |
| 136 | root = root or cfg.root_dir | 134 | -- @param item_type string: "module" or "command". |
| 137 | 135 | -- @param item_name string: module or command name. | |
| 138 | local manifest, err = manif.load_local_manifest(path.rocks_dir(root)) | 136 | -- @param root string or nil: A local root dir for a rocks tree. If not given, the default is used. |
| 139 | if not manifest then | 137 | -- @return (string, string) or nil: name and version of the provider rock or nil if there |
| 140 | return nil, "untracked" | 138 | -- is no provider. |
| 139 | function manif.get_current_provider(item_type, item_name, repo) | ||
| 140 | local providers = get_providers(item_type, item_name, repo) | ||
| 141 | if providers then | ||
| 142 | return providers[1]:match("([^/]*)/([^/]*)") | ||
| 141 | end | 143 | end |
| 144 | end | ||
| 142 | 145 | ||
| 143 | local type_key, key = file_manifest_coordinates(manifest, file, root) | 146 | function manif.get_next_provider(item_type, item_name, repo) |
| 144 | 147 | local providers = get_providers(item_type, item_name, repo) | |
| 145 | local providers = manifest[type_key][key] | 148 | if providers and providers[2] then |
| 146 | if not providers then | 149 | return providers[2]:match("([^/]*)/([^/]*)") |
| 147 | return nil, "untracked" | ||
| 148 | end | 150 | end |
| 149 | return providers | ||
| 150 | end | 151 | end |
| 151 | 152 | ||
| 152 | --- Given a path of a deployed file, figure out which rock name and version | 153 | --- Given a name of a module or a command provided by a package, figure out |
| 153 | -- correspond to it in the tree manifest. | 154 | -- which file provides it. |
| 154 | -- @param file string: The full path of a deployed file. | 155 | -- @param name string: package name. |
| 156 | -- @param version string: package version. | ||
| 157 | -- @param item_type string: "module" or "command". | ||
| 158 | -- @param item_name string: module or command name. | ||
| 155 | -- @param root string or nil: A local root dir for a rocks tree. If not given, the default is used. | 159 | -- @param root string or nil: A local root dir for a rocks tree. If not given, the default is used. |
| 156 | -- @return string, string: name and version of the provider rock. | 160 | -- @return (string, string): rock manifest subtree the file comes from ("bin", "lua", or "lib") |
| 157 | function manif.find_current_provider(file, root) | 161 | -- and path to the providing file relatively to that subtree. |
| 158 | local providers, err = find_providers(file, root) | 162 | function manif.get_providing_file(name, version, item_type, item_name, repo) |
| 159 | if not providers then return nil, err end | 163 | local rocks_dir = path.rocks_dir(repo or cfg.root_dir) |
| 160 | return providers[1]:match("([^/]*)/([^/]*)") | 164 | local manifest = manif.load_local_manifest(rocks_dir) |
| 161 | end | ||
| 162 | 165 | ||
| 163 | function manif.find_next_provider(file, root) | 166 | local entry_table = manifest.repository[name][version][1] |
| 164 | local providers, err = find_providers(file, root) | 167 | local file_path = entry_table[item_type .. "s"][item_name] |
| 165 | if not providers then return nil, err end | 168 | |
| 166 | if providers[2] then | 169 | if item_type == "command" then |
| 167 | return providers[2]:match("([^/]*)/([^/]*)") | 170 | return "bin", file_path |
| 168 | else | ||
| 169 | return nil | ||
| 170 | end | 171 | end |
| 171 | end | ||
| 172 | 172 | ||
| 173 | --- Given a file conflicting with a module or command | 173 | -- A module can be in "lua" or "lib". Decide based on extension first: |
| 174 | -- provided by a version of a package, return which file | 174 | -- most likely Lua modules are in "lua/" and C modules are in "lib/". |
| 175 | -- in that version corresponds to the conflicting item. | 175 | if file_path:match("%." .. cfg.lua_extension .. "$") then |
| 176 | -- @param name string: name of the package with conflicting module or command. | 176 | return "lua", file_path |
| 177 | -- @param version string: version of the package with conflicting module or command. | 177 | elseif file_path:match("%." .. cfg.lib_extension .. "$") then |
| 178 | -- @param file string: full, unversioned path to a deployed file. | 178 | return "lib", file_path |
| 179 | -- @return string: full, unversioned path to a deployed file in | ||
| 180 | -- given package that conflicts with given file. | ||
| 181 | function manif.find_conflicting_file(name, version, file, root) | ||
| 182 | root = root or cfg.root_dir | ||
| 183 | |||
| 184 | local manifest = manif.load_local_manifest(path.rocks_dir(root)) | ||
| 185 | if not manifest then | ||
| 186 | return | ||
| 187 | end | 179 | end |
| 188 | 180 | ||
| 189 | local entry_table = manifest.repository[name][version][1] | 181 | -- Fallback to rock manifest scanning. |
| 190 | local type_key, key, deploy_dir = file_manifest_coordinates(manifest, file, root) | 182 | local rock_manifest = manif.load_rock_manifest(name, version) |
| 191 | return dir.path(deploy_dir, entry_table[type_key][key]) | 183 | local subtree = rock_manifest.lib |
| 184 | |||
| 185 | for path_part in file_path:gmatch("[^/]+") do | ||
| 186 | if type(subtree) == "table" then | ||
| 187 | subtree = subtree[path_part] | ||
| 188 | else | ||
| 189 | -- Assume it's in "lua/" if it's not in "lib/". | ||
| 190 | return "lua", file_path | ||
| 191 | end | ||
| 192 | end | ||
| 193 | |||
| 194 | return type(subtree) == "string" and "lib" or "lua", file_path | ||
| 192 | end | 195 | end |
| 193 | 196 | ||
| 194 | return manif | 197 | return manif |
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua index 16ff5065..6d5e917b 100644 --- a/src/luarocks/persist.lua +++ b/src/luarocks/persist.lua | |||
| @@ -25,14 +25,15 @@ local function write_value(out, v, level, sub_order) | |||
| 25 | if v:match("[\r\n]") then | 25 | if v:match("[\r\n]") then |
| 26 | local open, close = "[[", "]]" | 26 | local open, close = "[[", "]]" |
| 27 | local equals = 0 | 27 | local equals = 0 |
| 28 | while v:find(close, 1, true) do | 28 | local v_with_bracket = v.."]" |
| 29 | while v_with_bracket:find(close, 1, true) do | ||
| 29 | equals = equals + 1 | 30 | equals = equals + 1 |
| 30 | local eqs = ("="):rep(equals) | 31 | local eqs = ("="):rep(equals) |
| 31 | open, close = "["..eqs.."[", "]"..eqs.."]" | 32 | open, close = "["..eqs.."[", "]"..eqs.."]" |
| 32 | end | 33 | end |
| 33 | out:write(open.."\n"..v..close) | 34 | out:write(open.."\n"..v..close) |
| 34 | else | 35 | else |
| 35 | out:write("\""..v:gsub("\\", "\\\\"):gsub("\"", "\\\"").."\"") | 36 | out:write(("%q"):format(v)) |
| 36 | end | 37 | end |
| 37 | else | 38 | else |
| 38 | out:write(tostring(v)) | 39 | out:write(tostring(v)) |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index bbc9da79..41e8f344 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
| @@ -10,6 +10,23 @@ local dir = require("luarocks.dir") | |||
| 10 | local manif = require("luarocks.manif") | 10 | local manif = require("luarocks.manif") |
| 11 | local deps = require("luarocks.deps") | 11 | local deps = require("luarocks.deps") |
| 12 | 12 | ||
| 13 | -- Tree of files installed by a package are stored | ||
| 14 | -- in its rock manifest. Some of these files have to | ||
| 15 | -- be deployed to locations where Lua can load them as | ||
| 16 | -- modules or where they can be used as commands. | ||
| 17 | -- These files are characterised by pair | ||
| 18 | -- (deploy_type, file_path), where deploy_type is the first | ||
| 19 | -- component of the file path and file_path is the rest of the | ||
| 20 | -- path. Only files with deploy_type in {"lua", "lib", "bin"} | ||
| 21 | -- are deployed somewhere. | ||
| 22 | -- Each deployed file provides an "item". An item is | ||
| 23 | -- characterised by pair (item_type, item_name). | ||
| 24 | -- item_type is "command" for files with deploy_type | ||
| 25 | -- "bin" and "module" for deploy_type in {"lua", "lib"}. | ||
| 26 | -- item_name is same as file_path for commands | ||
| 27 | -- and is produced using path.path_to_module(file_path) | ||
| 28 | -- for modules. | ||
| 29 | |||
| 13 | --- Get all installed versions of a package. | 30 | --- Get all installed versions of a package. |
| 14 | -- @param name string: a package name. | 31 | -- @param name string: a package name. |
| 15 | -- @return table or nil: An array of strings listing installed | 32 | -- @return table or nil: An array of strings listing installed |
| @@ -193,44 +210,56 @@ end | |||
| 193 | local function delete_suffixed(file, suffix) | 210 | local function delete_suffixed(file, suffix) |
| 194 | local suffixed_file, err = find_suffixed(file, suffix) | 211 | local suffixed_file, err = find_suffixed(file, suffix) |
| 195 | if not suffixed_file then | 212 | if not suffixed_file then |
| 196 | return nil, "Could not remove " .. file .. ": " .. err, "not found" | 213 | return nil, "Could not remove " .. file .. ": " .. err |
| 197 | end | 214 | end |
| 198 | 215 | ||
| 199 | fs.delete(suffixed_file) | 216 | fs.delete(suffixed_file) |
| 200 | if fs.exists(suffixed_file) then | 217 | if fs.exists(suffixed_file) then |
| 201 | return nil, "Failed deleting " .. suffixed_file .. ": file still exists", "fail" | 218 | return nil, "Failed deleting " .. suffixed_file .. ": file still exists" |
| 202 | end | 219 | end |
| 203 | 220 | ||
| 204 | return true | 221 | return true |
| 205 | end | 222 | end |
| 206 | 223 | ||
| 207 | local function resolve_conflict(target, deploy_dir, name, version, cur_name, cur_version, suffix) | 224 | -- Files can be deployed using versioned and non-versioned names. |
| 208 | if name < cur_name or (name == cur_name and deps.compare_versions(version, cur_version)) then | 225 | -- Several items with same type and name can exist if they are |
| 226 | -- provided by different packages or versions. In any case | ||
| 227 | -- item from the newest version of lexicographically smallest package | ||
| 228 | -- is deployed using non-versioned name and others use versioned names. | ||
| 229 | |||
| 230 | local function get_deploy_paths(name, version, deploy_type, file_path) | ||
| 231 | local deploy_dir = cfg["deploy_" .. deploy_type .. "_dir"] | ||
| 232 | local non_versioned = dir.path(deploy_dir, file_path) | ||
| 233 | local versioned = path.versioned_name(non_versioned, deploy_dir, name, version) | ||
| 234 | return non_versioned, versioned | ||
| 235 | end | ||
| 236 | |||
| 237 | local function prepare_target(name, version, deploy_type, file_path, suffix) | ||
| 238 | local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path) | ||
| 239 | local item_type, item_name = manif.get_provided_item(deploy_type, file_path) | ||
| 240 | local cur_name, cur_version = manif.get_current_provider(item_type, item_name) | ||
| 241 | |||
| 242 | if not cur_name then | ||
| 243 | return non_versioned | ||
| 244 | elseif name < cur_name or (name == cur_name and deps.compare_versions(version, cur_version)) then | ||
| 209 | -- New version has priority. Move currently provided version back using versioned name. | 245 | -- New version has priority. Move currently provided version back using versioned name. |
| 210 | local cur_target = manif.find_conflicting_file(cur_name, cur_version, target) | 246 | local cur_deploy_type, cur_file_path = manif.get_providing_file(cur_name, cur_version, item_type, item_name) |
| 211 | local versioned = path.versioned_name(cur_target, deploy_dir, cur_name, cur_version) | 247 | local cur_non_versioned, cur_versioned = get_deploy_paths(cur_name, cur_version, cur_deploy_type, cur_file_path) |
| 212 | 248 | ||
| 213 | local ok, err = fs.make_dir(dir.dir_name(versioned)) | 249 | local dir_ok, dir_err = fs.make_dir(dir.dir_name(cur_versioned)) |
| 214 | if not ok then | 250 | if not dir_ok then return nil, dir_err end |
| 215 | return nil, err | ||
| 216 | end | ||
| 217 | 251 | ||
| 218 | ok, err = move_suffixed(cur_target, versioned, suffix) | 252 | local move_ok, move_err = move_suffixed(cur_non_versioned, cur_versioned, suffix) |
| 219 | if not ok then | 253 | if not move_ok then return nil, move_err end |
| 220 | return nil, err | ||
| 221 | end | ||
| 222 | 254 | ||
| 223 | return target | 255 | return non_versioned |
| 224 | else | 256 | else |
| 225 | -- Current version has priority, deploy new version using versioned name. | 257 | -- Current version has priority, deploy new version using versioned name. |
| 226 | return path.versioned_name(target, deploy_dir, name, version) | 258 | return versioned |
| 227 | end | 259 | end |
| 228 | end | 260 | end |
| 229 | 261 | ||
| 230 | --- Deploy a package from the rocks subdirectory. | 262 | --- Deploy a package from the rocks subdirectory. |
| 231 | -- It is maintained that for each module and command the one that is provided | ||
| 232 | -- by the newest version of the lexicographically smallest package | ||
| 233 | -- is installed using unversioned name, and other versions use versioned names. | ||
| 234 | -- @param name string: name of package | 263 | -- @param name string: name of package |
| 235 | -- @param version string: exact package version in string format | 264 | -- @param version string: exact package version in string format |
| 236 | -- @param wrap_bin_scripts bool: whether commands written in Lua should be wrapped. | 265 | -- @param wrap_bin_scripts bool: whether commands written in Lua should be wrapped. |
| @@ -242,50 +271,45 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) | |||
| 242 | assert(type(version) == "string") | 271 | assert(type(version) == "string") |
| 243 | assert(type(wrap_bin_scripts) == "boolean") | 272 | assert(type(wrap_bin_scripts) == "boolean") |
| 244 | 273 | ||
| 245 | local function deploy_file_tree(file_tree, path_fn, deploy_dir, move_fn, suffix) | 274 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) |
| 246 | local source_dir = path_fn(name, version) | 275 | if not rock_manifest then return nil, load_err end |
| 247 | return recurse_rock_manifest_tree(file_tree, | ||
| 248 | function(parent_path, parent_module, file) | ||
| 249 | local source = dir.path(source_dir, parent_path, file) | ||
| 250 | local target = dir.path(deploy_dir, parent_path, file) | ||
| 251 | |||
| 252 | local cur_name, cur_version = manif.find_current_provider(target) | ||
| 253 | if cur_name then | ||
| 254 | local resolve_err | ||
| 255 | target, resolve_err = resolve_conflict(target, deploy_dir, name, version, cur_name, cur_version, suffix) | ||
| 256 | if not target then | ||
| 257 | return nil, resolve_err | ||
| 258 | end | ||
| 259 | end | ||
| 260 | 276 | ||
| 261 | local ok, err = fs.make_dir(dir.dir_name(target)) | 277 | local function deploy_file_tree(deploy_type, source_dir, move_fn, suffix) |
| 262 | if not ok then return nil, err end | 278 | if not rock_manifest[deploy_type] then |
| 279 | return true | ||
| 280 | end | ||
| 263 | 281 | ||
| 264 | local suffixed_target, mover = move_fn(source, target, name, version) | 282 | return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(parent_path, parent_module, file) |
| 265 | if fs.exists(suffixed_target) then | 283 | local file_path = parent_path .. file |
| 266 | local backup = suffixed_target | 284 | local source = dir.path(source_dir, file_path) |
| 267 | repeat | 285 | |
| 268 | backup = backup.."~" | 286 | local target, prepare_err = prepare_target(name, version, deploy_type, file_path, suffix) |
| 269 | until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. | 287 | if not target then return nil, prepare_err end |
| 270 | 288 | ||
| 271 | util.printerr("Warning: "..suffixed_target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) | 289 | local dir_ok, dir_err = fs.make_dir(dir.dir_name(target)) |
| 272 | local ok, err = fs.move(suffixed_target, backup) | 290 | if not dir_ok then return nil, dir_err end |
| 273 | if not ok then | ||
| 274 | return nil, err | ||
| 275 | end | ||
| 276 | end | ||
| 277 | 291 | ||
| 278 | ok, err = mover() | 292 | local suffixed_target, mover = move_fn(source, target) |
| 279 | fs.remove_dir_tree_if_empty(dir.dir_name(source)) | 293 | if fs.exists(suffixed_target) then |
| 280 | return ok, err | 294 | local backup = suffixed_target |
| 295 | repeat | ||
| 296 | backup = backup.."~" | ||
| 297 | until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. | ||
| 298 | |||
| 299 | util.printerr("Warning: "..suffixed_target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) | ||
| 300 | local move_ok, move_err = fs.move(suffixed_target, backup) | ||
| 301 | if not move_ok then return nil, move_err end | ||
| 281 | end | 302 | end |
| 282 | ) | ||
| 283 | end | ||
| 284 | 303 | ||
| 285 | local rock_manifest, err = manif.load_rock_manifest(name, version) | 304 | local move_ok, move_err = mover() |
| 286 | if not rock_manifest then return nil, err end | 305 | if not move_ok then return nil, move_err end |
| 306 | |||
| 307 | fs.remove_dir_tree_if_empty(dir.dir_name(source)) | ||
| 308 | return true | ||
| 309 | end) | ||
| 310 | end | ||
| 287 | 311 | ||
| 288 | local function install_binary(source, target, name, version) | 312 | local function install_binary(source, target) |
| 289 | if wrap_bin_scripts and fs.is_lua(source) then | 313 | if wrap_bin_scripts and fs.is_lua(source) then |
| 290 | return target .. (cfg.wrapper_suffix or ""), function() return fs.wrap_script(source, target, name, version) end | 314 | return target .. (cfg.wrapper_suffix or ""), function() return fs.wrap_script(source, target, name, version) end |
| 291 | else | 315 | else |
| @@ -299,29 +323,20 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) | |||
| 299 | end | 323 | end |
| 300 | end | 324 | end |
| 301 | 325 | ||
| 302 | local ok, err = true | 326 | local ok, err = deploy_file_tree("bin", path.bin_dir(name, version), install_binary, cfg.wrapper_suffix) |
| 303 | if rock_manifest.bin then | 327 | if not ok then return nil, err end |
| 304 | ok, err = deploy_file_tree(rock_manifest.bin, path.bin_dir, cfg.deploy_bin_dir, install_binary, cfg.wrapper_suffix) | ||
| 305 | end | ||
| 306 | if ok and rock_manifest.lua then | ||
| 307 | ok, err = deploy_file_tree(rock_manifest.lua, path.lua_dir, cfg.deploy_lua_dir, make_mover(cfg.perm_read)) | ||
| 308 | end | ||
| 309 | if ok and rock_manifest.lib then | ||
| 310 | ok, err = deploy_file_tree(rock_manifest.lib, path.lib_dir, cfg.deploy_lib_dir, make_mover(cfg.perm_exec)) | ||
| 311 | end | ||
| 312 | 328 | ||
| 313 | if not ok then | 329 | ok, err = deploy_file_tree("lua", path.lua_dir(name, version), make_mover(cfg.perm_read)) |
| 314 | return nil, err | 330 | if not ok then return nil, err end |
| 315 | end | 331 | |
| 332 | ok, err = deploy_file_tree("lib", path.lib_dir(name, version), make_mover(cfg.perm_exec)) | ||
| 333 | if not ok then return nil, err end | ||
| 316 | 334 | ||
| 317 | local writer = require("luarocks.manif.writer") | 335 | local writer = require("luarocks.manif.writer") |
| 318 | return writer.add_to_manifest(name, version, nil, deps_mode) | 336 | return writer.add_to_manifest(name, version, nil, deps_mode) |
| 319 | end | 337 | end |
| 320 | 338 | ||
| 321 | --- Delete a package from the local repository. | 339 | --- Delete a package from the local repository. |
| 322 | -- It is maintained that for each module and command the one that is provided | ||
| 323 | -- by the newest version of the lexicographically smallest package | ||
| 324 | -- is installed using unversioned name, and other versions use versioned names. | ||
| 325 | -- @param name string: name of package | 340 | -- @param name string: name of package |
| 326 | -- @param version string: exact package version in string format | 341 | -- @param version string: exact package version in string format |
| 327 | -- @param deps_mode: string: Which trees to check dependencies for: | 342 | -- @param deps_mode: string: Which trees to check dependencies for: |
| @@ -336,65 +351,68 @@ function repos.delete_version(name, version, deps_mode, quick) | |||
| 336 | assert(type(version) == "string") | 351 | assert(type(version) == "string") |
| 337 | assert(type(deps_mode) == "string") | 352 | assert(type(deps_mode) == "string") |
| 338 | 353 | ||
| 339 | local function delete_deployed_file_tree(file_tree, deploy_dir, suffix) | 354 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) |
| 340 | return recurse_rock_manifest_tree(file_tree, | 355 | if not rock_manifest then return nil, load_err end |
| 341 | function(parent_path, parent_module, file) | ||
| 342 | local target = dir.path(deploy_dir, parent_path, file) | ||
| 343 | local versioned = path.versioned_name(target, deploy_dir, name, version) | ||
| 344 | |||
| 345 | local ok, err, err_type = delete_suffixed(versioned, suffix) | ||
| 346 | if ok then | ||
| 347 | fs.remove_dir_tree_if_empty(dir.dir_name(versioned)) | ||
| 348 | return true | ||
| 349 | elseif err_type == "fail" then | ||
| 350 | return nil, err | ||
| 351 | end | ||
| 352 | 356 | ||
| 353 | ok, err = delete_suffixed(target, suffix) | 357 | local function delete_deployed_file_tree(deploy_type, suffix) |
| 354 | if not ok then | 358 | if not rock_manifest[deploy_type] then |
| 355 | return nil, err | 359 | return true |
| 356 | end | 360 | end |
| 357 | 361 | ||
| 358 | if not quick then | 362 | return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(parent_path, parent_module, file) |
| 359 | local next_name, next_version = manif.find_next_provider(target) | 363 | local file_path = parent_path .. file |
| 360 | if next_name then | 364 | local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path) |
| 361 | local next_target = manif.find_conflicting_file(next_name, next_version, target) | ||
| 362 | local next_versioned = path.versioned_name(next_target, deploy_dir, next_name, next_version) | ||
| 363 | 365 | ||
| 364 | ok, err = move_suffixed(next_versioned, next_target, suffix) | 366 | -- Figure out if the file is deployed using versioned or non-versioned name. |
| 365 | if not ok then | 367 | local target |
| 366 | return nil, err | 368 | local item_type, item_name = manif.get_provided_item(deploy_type, file_path) |
| 367 | end | 369 | local cur_name, cur_version = manif.get_current_provider(item_type, item_name) |
| 368 | 370 | ||
| 369 | fs.remove_dir_tree_if_empty(dir.dir_name(versioned)) | 371 | if cur_name == name and cur_version == version then |
| 370 | end | 372 | -- This package has highest priority, should be in non-versioned location. |
| 373 | target = non_versioned | ||
| 374 | else | ||
| 375 | target = versioned | ||
| 376 | end | ||
| 377 | |||
| 378 | local ok, err = delete_suffixed(target, suffix) | ||
| 379 | if not ok then return nil, err end | ||
| 380 | |||
| 381 | if not quick and target == non_versioned then | ||
| 382 | -- If another package provides this file, move its version | ||
| 383 | -- into non-versioned location instead. | ||
| 384 | local next_name, next_version = manif.get_next_provider(item_type, item_name) | ||
| 385 | |||
| 386 | if next_name then | ||
| 387 | local next_deploy_type, next_file_path = manif.get_providing_file(next_name, next_version, item_type, item_name) | ||
| 388 | local next_non_versioned, next_versioned = get_deploy_paths(next_name, next_version, next_deploy_type, next_file_path) | ||
| 389 | |||
| 390 | local move_ok, move_err = move_suffixed(next_versioned, next_non_versioned, suffix) | ||
| 391 | if not move_ok then return nil, move_err end | ||
| 392 | |||
| 393 | fs.remove_dir_tree_if_empty(dir.dir_name(next_versioned)) | ||
| 371 | end | 394 | end |
| 372 | fs.remove_dir_tree_if_empty(dir.dir_name(target)) | ||
| 373 | return true | ||
| 374 | end | 395 | end |
| 375 | ) | ||
| 376 | end | ||
| 377 | 396 | ||
| 378 | local rock_manifest, err = manif.load_rock_manifest(name, version) | 397 | fs.remove_dir_tree_if_empty(dir.dir_name(target)) |
| 379 | if not rock_manifest then return nil, err end | 398 | return true |
| 380 | 399 | end) | |
| 381 | local ok = true | ||
| 382 | if rock_manifest.bin then | ||
| 383 | ok, err = delete_deployed_file_tree(rock_manifest.bin, cfg.deploy_bin_dir, cfg.wrapper_suffix) | ||
| 384 | end | ||
| 385 | if ok and rock_manifest.lua then | ||
| 386 | ok, err = delete_deployed_file_tree(rock_manifest.lua, cfg.deploy_lua_dir) | ||
| 387 | end | ||
| 388 | if ok and rock_manifest.lib then | ||
| 389 | ok, err = delete_deployed_file_tree(rock_manifest.lib, cfg.deploy_lib_dir) | ||
| 390 | end | 400 | end |
| 401 | |||
| 402 | local ok, err = delete_deployed_file_tree("bin", cfg.wrapper_suffix) | ||
| 403 | if not ok then return nil, err end | ||
| 404 | |||
| 405 | ok, err = delete_deployed_file_tree("lua") | ||
| 406 | if not ok then return nil, err end | ||
| 407 | |||
| 408 | ok, err = delete_deployed_file_tree("lib") | ||
| 391 | if not ok then return nil, err end | 409 | if not ok then return nil, err end |
| 392 | 410 | ||
| 393 | fs.delete(path.install_dir(name, version)) | 411 | fs.delete(path.install_dir(name, version)) |
| 394 | if not get_installed_versions(name) then | 412 | if not get_installed_versions(name) then |
| 395 | fs.delete(dir.path(cfg.rocks_dir, name)) | 413 | fs.delete(dir.path(cfg.rocks_dir, name)) |
| 396 | end | 414 | end |
| 397 | 415 | ||
| 398 | if quick then | 416 | if quick then |
| 399 | return true | 417 | return true |
| 400 | end | 418 | end |
diff --git a/test/test_environment.lua b/test/test_environment.lua index 76dee718..f60835a0 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
| @@ -214,7 +214,7 @@ function test_env.set_args() | |||
| 214 | return true | 214 | return true |
| 215 | end | 215 | end |
| 216 | 216 | ||
| 217 | local function copy_dir(source_path, target_path) | 217 | function test_env.copy_dir(source_path, target_path) |
| 218 | local testing_paths = test_env.testing_paths | 218 | local testing_paths = test_env.testing_paths |
| 219 | if test_env.TEST_TARGET_OS == "windows" then | 219 | if test_env.TEST_TARGET_OS == "windows" then |
| 220 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) | 220 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) |
| @@ -430,8 +430,8 @@ local function build_environment(rocks, env_variables) | |||
| 430 | end | 430 | end |
| 431 | end | 431 | end |
| 432 | 432 | ||
| 433 | copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) | 433 | test_env.copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) |
| 434 | copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) | 434 | test_env.copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) |
| 435 | end | 435 | end |
| 436 | 436 | ||
| 437 | --- Reset testing environment | 437 | --- Reset testing environment |
| @@ -441,12 +441,12 @@ local function reset_environment(testing_paths, md5sums) | |||
| 441 | 441 | ||
| 442 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then | 442 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then |
| 443 | test_env.remove_dir(testing_paths.testing_tree) | 443 | test_env.remove_dir(testing_paths.testing_tree) |
| 444 | copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) | 444 | test_env.copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) |
| 445 | end | 445 | end |
| 446 | 446 | ||
| 447 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | 447 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then |
| 448 | test_env.remove_dir(testing_paths.testing_sys_tree) | 448 | test_env.remove_dir(testing_paths.testing_sys_tree) |
| 449 | copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) | 449 | test_env.copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) |
| 450 | end | 450 | end |
| 451 | print("\n[ENVIRONMENT RESET]") | 451 | print("\n[ENVIRONMENT RESET]") |
| 452 | end | 452 | end |
diff --git a/test/testfiles/mixed_deploy_type/mdt.c b/test/testfiles/mixed_deploy_type/mdt.c new file mode 100644 index 00000000..a162ce23 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mdt.c | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | #include "lua.h" | ||
| 2 | |||
| 3 | int luaopen_mdt(lua_State *L) { | ||
| 4 | lua_pushstring(L, "mdt.c"); | ||
| 5 | return 1; | ||
| 6 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mdt.lua b/test/testfiles/mixed_deploy_type/mdt.lua new file mode 100644 index 00000000..c9ca9c68 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mdt.lua | |||
| @@ -0,0 +1 @@ | |||
| return "mdt.lua" | |||
diff --git a/test/testfiles/mixed_deploy_type/mdt_file b/test/testfiles/mixed_deploy_type/mdt_file new file mode 100644 index 00000000..1a15f7d7 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mdt_file | |||
| @@ -0,0 +1 @@ | |||
| return "mdt_file" | |||
diff --git a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec new file mode 100644 index 00000000..91b725da --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | package = "mixed_deploy_type" | ||
| 2 | version = "0.1.0-1" | ||
| 3 | source = { | ||
| 4 | url = "http://example.com" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | homepage = "http://example.com", | ||
| 8 | license = "*** please specify a license ***" | ||
| 9 | } | ||
| 10 | dependencies = {} | ||
| 11 | build = { | ||
| 12 | type = "builtin", | ||
| 13 | modules = { | ||
| 14 | mdt = "mdt/mdt.lua" | ||
| 15 | }, | ||
| 16 | install = { | ||
| 17 | lua = { | ||
| 18 | mdt_file = "mdt/mdt_file" | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec new file mode 100644 index 00000000..9ca03180 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | package = "mixed_deploy_type" | ||
| 2 | version = "0.2.0-1" | ||
| 3 | source = { | ||
| 4 | url = "http://example.com" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | homepage = "http://example.com", | ||
| 8 | license = "*** please specify a license ***" | ||
| 9 | } | ||
| 10 | dependencies = {} | ||
| 11 | build = { | ||
| 12 | type = "builtin", | ||
| 13 | modules = { | ||
| 14 | mdt = "mdt/mdt.c" | ||
| 15 | }, | ||
| 16 | install = { | ||
| 17 | lib = { | ||
| 18 | mdt_file = "mdt/mdt_file" | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
