diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-06-29 21:28:03 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-06-29 21:28:03 -0300 |
| commit | 978abafcd957544c539dbc72057a243885eb50e9 (patch) | |
| tree | 40a14c40b25427cbf2abef56198e502ae27f2dd0 | |
| parent | 0601f27c2371c9f19c4175f866f7babfcabb7277 (diff) | |
| parent | 1eccb0385c6bef170ceee86a6415d7442c28699d (diff) | |
| download | luarocks-978abafcd957544c539dbc72057a243885eb50e9.tar.gz luarocks-978abafcd957544c539dbc72057a243885eb50e9.tar.bz2 luarocks-978abafcd957544c539dbc72057a243885eb50e9.zip | |
Merge branch 'master' into luarocks-3
| -rw-r--r-- | appveyor.yml | 2 | ||||
| -rw-r--r-- | src/luarocks/build/cmake.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 66 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 1 | ||||
| -rw-r--r-- | src/luarocks/write_rockspec.lua | 26 | ||||
| -rw-r--r-- | test/testing.lua | 1 | ||||
| -rwxr-xr-x | test/testing.sh | 1 |
7 files changed, 63 insertions, 42 deletions
diff --git a/appveyor.yml b/appveyor.yml index 140308ce..abf15af6 100644 --- a/appveyor.yml +++ b/appveyor.yml | |||
| @@ -11,7 +11,7 @@ environment: | |||
| 11 | matrix: | 11 | matrix: |
| 12 | - LUA_VER: 5.1.5 | 12 | - LUA_VER: 5.1.5 |
| 13 | - LUA_VER: 5.2.4 | 13 | - LUA_VER: 5.2.4 |
| 14 | - LUA_VER: 5.3.0 | 14 | - LUA_VER: 5.3.1 |
| 15 | - LJ_VER: 2.0.4 | 15 | - LJ_VER: 2.0.4 |
| 16 | - LJ_VER: 2.1 | 16 | - LJ_VER: 2.1 |
| 17 | 17 | ||
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index c8f5a669..7b16fa51 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
| @@ -35,14 +35,18 @@ function cmake.run(rockspec) | |||
| 35 | cmake_handler:close() | 35 | cmake_handler:close() |
| 36 | end | 36 | end |
| 37 | 37 | ||
| 38 | |||
| 39 | -- Execute cmake with variables. | 38 | -- Execute cmake with variables. |
| 40 | local args = "" | 39 | local args = "" |
| 40 | |||
| 41 | -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. | ||
| 41 | if cfg.cmake_generator then | 42 | if cfg.cmake_generator then |
| 42 | args = args .. ' -G"'..cfg.cmake_generator.. '"' | 43 | args = args .. ' -G"'..cfg.cmake_generator.. '"' |
| 44 | elseif cfg.is_platform("windows") and cfg.target_cpu:match("x86_64$") then | ||
| 45 | args = args .. " -DCMAKE_GENERATOR_PLATFORM=x64" | ||
| 43 | end | 46 | end |
| 47 | |||
| 44 | for k,v in pairs(variables) do | 48 | for k,v in pairs(variables) do |
| 45 | args = args .. ' -D' ..k.. '="' ..v.. '"' | 49 | args = args .. ' -D' ..k.. '="' ..tostring(v).. '"' |
| 46 | end | 50 | end |
| 47 | 51 | ||
| 48 | if not fs.execute_string(rockspec.variables.CMAKE.." -H. -Bbuild.luarocks "..args) then | 52 | if not fs.execute_string(rockspec.variables.CMAKE.." -H. -Bbuild.luarocks "..args) then |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 2a92c4dd..8321e9b9 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -144,34 +144,52 @@ end | |||
| 144 | cfg.variables = {} | 144 | cfg.variables = {} |
| 145 | cfg.rocks_trees = {} | 145 | cfg.rocks_trees = {} |
| 146 | 146 | ||
| 147 | -- The global environment in the config files; | 147 | -- Create global environment for the config files; |
| 148 | local env_for_config_file | 148 | local env_for_config_file = function() |
| 149 | env_for_config_file = { | 149 | local e |
| 150 | home = cfg.home, | 150 | e = { |
| 151 | lua_version = cfg.lua_version, | 151 | home = cfg.home, |
| 152 | platform = util.make_shallow_copy(detected), | 152 | lua_version = cfg.lua_version, |
| 153 | processor = cfg.target_cpu, -- remains for compat reasons | 153 | platform = util.make_shallow_copy(detected), |
| 154 | target_cpu = cfg.target_cpu, -- replaces `processor` | 154 | processor = cfg.target_cpu, -- remains for compat reasons |
| 155 | os_getenv = os.getenv, | 155 | target_cpu = cfg.target_cpu, -- replaces `processor` |
| 156 | dump_env = function() | 156 | os_getenv = os.getenv, |
| 157 | -- debug function, calling it from a config file will show all | 157 | dump_env = function() |
| 158 | -- available globals to that config file | 158 | -- debug function, calling it from a config file will show all |
| 159 | print(util.show_table(env_for_config_file, "global environment")) | 159 | -- available globals to that config file |
| 160 | end, | 160 | print(util.show_table(e, "global environment")) |
| 161 | } | 161 | end, |
| 162 | } | ||
| 163 | return e | ||
| 164 | end | ||
| 165 | |||
| 166 | -- Merge values from config files read into the `cfg` table | ||
| 167 | local merge_overrides = function(overrides) | ||
| 168 | -- remove some stuff we do not want to integrate | ||
| 169 | overrides.os_getenv = nil | ||
| 170 | overrides.dump_env = nil | ||
| 171 | -- remove tables to be copied verbatim instead of deeply merged | ||
| 172 | if overrides.rocks_trees then cfg.rocks_trees = nil end | ||
| 173 | if overrides.rocks_servers then cfg.rocks_servers = nil end | ||
| 174 | -- perform actual merge | ||
| 175 | util.deep_merge(cfg, overrides) | ||
| 176 | end | ||
| 162 | 177 | ||
| 163 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | 178 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" |
| 164 | do | 179 | do |
| 165 | local err, errcode | 180 | local err, errcode |
| 166 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file) | 181 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file()) |
| 167 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file | 182 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file |
| 168 | sys_config_file = sys_config_dir.."/config.lua" | 183 | sys_config_file = sys_config_dir.."/config.lua" |
| 169 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file) | 184 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file()) |
| 170 | end | 185 | end |
| 171 | if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error | 186 | if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error |
| 172 | io.stderr:write(err.."\n") | 187 | io.stderr:write(err.."\n") |
| 173 | os.exit(cfg.errorcodes.CONFIGFILE) | 188 | os.exit(cfg.errorcodes.CONFIGFILE) |
| 174 | end | 189 | end |
| 190 | if sys_config_ok then | ||
| 191 | merge_overrides(sys_config_ok) | ||
| 192 | end | ||
| 175 | end | 193 | end |
| 176 | 194 | ||
| 177 | if not site_config.LUAROCKS_FORCE_CONFIG then | 195 | if not site_config.LUAROCKS_FORCE_CONFIG then |
| @@ -179,24 +197,18 @@ if not site_config.LUAROCKS_FORCE_CONFIG then | |||
| 179 | local home_overrides, err, errcode | 197 | local home_overrides, err, errcode |
| 180 | home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") | 198 | home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") |
| 181 | if home_config_file then | 199 | if home_config_file then |
| 182 | home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file) | 200 | home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) |
| 183 | else | 201 | else |
| 184 | home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua" | 202 | home_config_file = home_config_dir.."/config-"..cfg.lua_version..".lua" |
| 185 | home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file) | 203 | home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) |
| 186 | if (not home_overrides) and (not errcode == "run") then | 204 | if (not home_overrides) and (not errcode == "run") then |
| 187 | home_config_file = home_config_dir.."/config.lua" | 205 | home_config_file = home_config_dir.."/config.lua" |
| 188 | home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file) | 206 | home_overrides, err, errcode = persist.load_into_table(home_config_file, env_for_config_file()) |
| 189 | end | 207 | end |
| 190 | end | 208 | end |
| 191 | if home_overrides then | 209 | if home_overrides then |
| 192 | home_config_ok = true | 210 | home_config_ok = true |
| 193 | if home_overrides.rocks_trees then | 211 | merge_overrides(home_overrides) |
| 194 | cfg.rocks_trees = nil | ||
| 195 | end | ||
| 196 | if home_overrides.rocks_servers then | ||
| 197 | cfg.rocks_servers = nil | ||
| 198 | end | ||
| 199 | util.deep_merge(cfg, home_overrides) | ||
| 200 | else | 212 | else |
| 201 | home_config_ok = home_overrides | 213 | home_config_ok = home_overrides |
| 202 | if errcode ~= "open" then | 214 | if errcode ~= "open" then |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 6fecf863..c06c8354 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -118,6 +118,7 @@ local supported_flags = { | |||
| 118 | ["rock-tree"] = true, | 118 | ["rock-tree"] = true, |
| 119 | ["rock-trees"] = true, | 119 | ["rock-trees"] = true, |
| 120 | ["rockspec"] = true, | 120 | ["rockspec"] = true, |
| 121 | ["rockspec-format"] = "<ver>", | ||
| 121 | ["server"] = "<server>", | 122 | ["server"] = "<server>", |
| 122 | ["skip-pack"] = true, | 123 | ["skip-pack"] = true, |
| 123 | ["source"] = true, | 124 | ["source"] = true, |
diff --git a/src/luarocks/write_rockspec.lua b/src/luarocks/write_rockspec.lua index 68942e07..972562c3 100644 --- a/src/luarocks/write_rockspec.lua +++ b/src/luarocks/write_rockspec.lua | |||
| @@ -24,18 +24,19 @@ If a repository URL is given with no version, it creates an 'scm' rock. | |||
| 24 | Note that the generated file is a _starting point_ for writing a | 24 | Note that the generated file is a _starting point_ for writing a |
| 25 | rockspec, and is not guaranteed to be complete or correct. | 25 | rockspec, and is not guaranteed to be complete or correct. |
| 26 | 26 | ||
| 27 | --output=<file> Write the rockspec with the given filename. | 27 | --output=<file> Write the rockspec with the given filename. |
| 28 | If not given, a file is written in the current | 28 | If not given, a file is written in the current |
| 29 | directory with a filename based on given name and version. | 29 | directory with a filename based on given name and version. |
| 30 | --license="<string>" A license string, such as "MIT/X11" or "GNU GPL v3". | 30 | --license="<string>" A license string, such as "MIT/X11" or "GNU GPL v3". |
| 31 | --summary="<txt>" A short one-line description summary. | 31 | --summary="<txt>" A short one-line description summary. |
| 32 | --detailed="<txt>" A longer description string. | 32 | --detailed="<txt>" A longer description string. |
| 33 | --homepage=<url> Project homepage. | 33 | --homepage=<url> Project homepage. |
| 34 | --lua-version=<ver> Supported Lua versions. Accepted values are "5.1", "5.2", | 34 | --lua-version=<ver> Supported Lua versions. Accepted values are "5.1", "5.2", |
| 35 | "5.3", "5.1,5.2", "5.2,5.3", or "5.1,5.2,5.3". | 35 | "5.3", "5.1,5.2", "5.2,5.3", or "5.1,5.2,5.3". |
| 36 | --tag=<tag> Tag to use. Will attempt to extract version number from it. | 36 | --rockspec-format=<ver> Rockspec format version, such as "1.0" or "1.1". |
| 37 | --lib=<lib>[,<lib>] A comma-separated list of libraries that C files need to | 37 | --tag=<tag> Tag to use. Will attempt to extract version number from it. |
| 38 | link to. | 38 | --lib=<lib>[,<lib>] A comma-separated list of libraries that C files need to |
| 39 | link to. | ||
| 39 | ]] | 40 | ]] |
| 40 | 41 | ||
| 41 | local function open_file(name) | 42 | local function open_file(name) |
| @@ -246,6 +247,7 @@ function write_rockspec.run(...) | |||
| 246 | end | 247 | end |
| 247 | 248 | ||
| 248 | local rockspec = { | 249 | local rockspec = { |
| 250 | rockspec_format = flags["rockspec-format"], | ||
| 249 | package = name, | 251 | package = name, |
| 250 | name = name:lower(), | 252 | name = name:lower(), |
| 251 | version = version.."-1", | 253 | version = version.."-1", |
diff --git a/test/testing.lua b/test/testing.lua index 44c6f098..48d4ac0e 100644 --- a/test/testing.lua +++ b/test/testing.lua | |||
| @@ -400,6 +400,7 @@ local tests = { | |||
| 400 | end, | 400 | end, |
| 401 | test_write_rockspec = function() return run "$luarocks write_rockspec git://github.com/keplerproject/luarocks" end, | 401 | test_write_rockspec = function() return run "$luarocks write_rockspec git://github.com/keplerproject/luarocks" end, |
| 402 | test_write_rockspec_lib = function() return run '$luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2' end, | 402 | test_write_rockspec_lib = function() return run '$luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2' end, |
| 403 | test_write_rockspec_format = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2' end, | ||
| 403 | test_write_rockspec_fullargs = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"' end, | 404 | test_write_rockspec_fullargs = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"' end, |
| 404 | fail_write_rockspec_args = function() return run "$luarocks write_rockspec invalid" end, | 405 | fail_write_rockspec_args = function() return run "$luarocks write_rockspec invalid" end, |
| 405 | fail_write_rockspec_args_url = function() return run "$luarocks write_rockspec http://example.com/invalid.zip" end, | 406 | fail_write_rockspec_args_url = function() return run "$luarocks write_rockspec http://example.com/invalid.zip" end, |
diff --git a/test/testing.sh b/test/testing.sh index 4338e48f..c43b4d52 100755 --- a/test/testing.sh +++ b/test/testing.sh | |||
| @@ -492,6 +492,7 @@ test_deps_mode_make_order_sys() { $luarocks build --tree="$testing_tree" lpeg && | |||
| 492 | 492 | ||
| 493 | test_write_rockspec() { $luarocks write_rockspec git://github.com/keplerproject/luarocks; } | 493 | test_write_rockspec() { $luarocks write_rockspec git://github.com/keplerproject/luarocks; } |
| 494 | test_write_rockspec_lib() { $luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2; } | 494 | test_write_rockspec_lib() { $luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2; } |
| 495 | test_write_rockspec_format() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2; } | ||
| 495 | test_write_rockspec_fullargs() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"; } | 496 | test_write_rockspec_fullargs() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"; } |
| 496 | fail_write_rockspec_args() { $luarocks write_rockspec invalid; } | 497 | fail_write_rockspec_args() { $luarocks write_rockspec invalid; } |
| 497 | fail_write_rockspec_args_url() { $luarocks write_rockspec http://example.com/invalid.zip; } | 498 | fail_write_rockspec_args_url() { $luarocks write_rockspec http://example.com/invalid.zip; } |
