From 4c7a5bc9914b1dada3616057cd9b7b214200efe7 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Fri, 26 Jun 2015 14:46:05 +0300 Subject: Add '--rockspec-format' option for write_rockspec command '--rockspec-format' option allows selecting rockspec format version when writing a rockspec. --- src/luarocks/util.lua | 1 + src/luarocks/write_rockspec.lua | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) 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 = { ["rock-tree"] = true, ["rock-trees"] = true, ["rockspec"] = true, + ["rockspec-format"] = "", ["server"] = "", ["skip-pack"] = true, ["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. Note that the generated file is a _starting point_ for writing a rockspec, and is not guaranteed to be complete or correct. ---output= Write the rockspec with the given filename. - If not given, a file is written in the current - directory with a filename based on given name and version. ---license="" A license string, such as "MIT/X11" or "GNU GPL v3". ---summary="" A short one-line description summary. ---detailed="" A longer description string. ---homepage= Project homepage. ---lua-version= Supported Lua versions. Accepted values are "5.1", "5.2", - "5.3", "5.1,5.2", "5.2,5.3", or "5.1,5.2,5.3". ---tag= Tag to use. Will attempt to extract version number from it. ---lib=[,] A comma-separated list of libraries that C files need to - link to. +--output= Write the rockspec with the given filename. + If not given, a file is written in the current + directory with a filename based on given name and version. +--license="" A license string, such as "MIT/X11" or "GNU GPL v3". +--summary="" A short one-line description summary. +--detailed="" A longer description string. +--homepage= Project homepage. +--lua-version= Supported Lua versions. Accepted values are "5.1", "5.2", + "5.3", "5.1,5.2", "5.2,5.3", or "5.1,5.2,5.3". +--rockspec-format= Rockspec format version, such as "1.0" or "1.1". +--tag= Tag to use. Will attempt to extract version number from it. +--lib=[,] A comma-separated list of libraries that C files need to + link to. ]] local function open_file(name) @@ -246,6 +247,7 @@ function write_rockspec.run(...) end local rockspec = { + rockspec_format = flags["rockspec-format"], package = name, name = name:lower(), version = version.."-1", -- cgit v1.2.3-55-g6feb From 19ce8a62a8ac32f9af9aa7255d3f9fa097eed676 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Fri, 26 Jun 2015 14:47:19 +0300 Subject: Add a test for '--rockspec-format' option --- test/testing.lua | 1 + test/testing.sh | 1 + 2 files changed, 2 insertions(+) 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 = { end, test_write_rockspec = function() return run "$luarocks write_rockspec git://github.com/keplerproject/luarocks" end, 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, + 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, 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, fail_write_rockspec_args = function() return run "$luarocks write_rockspec invalid" end, 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 && test_write_rockspec() { $luarocks write_rockspec git://github.com/keplerproject/luarocks; } test_write_rockspec_lib() { $luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2; } +test_write_rockspec_format() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2; } 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"; } fail_write_rockspec_args() { $luarocks write_rockspec invalid; } fail_write_rockspec_args_url() { $luarocks write_rockspec http://example.com/invalid.zip; } -- cgit v1.2.3-55-g6feb