diff options
author | mpeterv <petjamelnik@yandex.ru> | 2014-03-20 20:59:24 +0400 |
---|---|---|
committer | mpeterv <petjamelnik@yandex.ru> | 2014-03-20 20:59:24 +0400 |
commit | 3af05c7e5d7999500508c51a5d405e59c14363cc (patch) | |
tree | e62ad5efc7a62ab26039129a3be88d3b6f970771 /src | |
parent | 548de234ebce046a8004c7badbdd5da4ad2e56ee (diff) | |
download | luarocks-3af05c7e5d7999500508c51a5d405e59c14363cc.tar.gz luarocks-3af05c7e5d7999500508c51a5d405e59c14363cc.tar.bz2 luarocks-3af05c7e5d7999500508c51a5d405e59c14363cc.zip |
Un-module bundled deps
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/build/builtin.lua | 7 | ||||
-rw-r--r-- | src/luarocks/build/cmake.lua | 7 | ||||
-rw-r--r-- | src/luarocks/build/command.lua | 7 | ||||
-rw-r--r-- | src/luarocks/build/make.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/cvs.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/git.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/git_file.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/git_http.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/hg.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/sscm.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch/svn.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fs/unix.lua | 17 | ||||
-rw-r--r-- | src/luarocks/fs/win32.lua | 27 | ||||
-rw-r--r-- | src/luarocks/tools/patch.lua | 9 | ||||
-rw-r--r-- | src/luarocks/tools/tar.lua | 7 | ||||
-rw-r--r-- | src/luarocks/tools/zip.lua | 11 |
16 files changed, 98 insertions, 50 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 5120c85c..e154e65c 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. | 2 | --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. |
3 | module("luarocks.build.builtin", package.seeall) | 3 | --module("luarocks.build.builtin", package.seeall) |
4 | local builtin = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
@@ -45,7 +46,7 @@ end | |||
45 | -- @param rockspec table: the loaded rockspec. | 46 | -- @param rockspec table: the loaded rockspec. |
46 | -- @return boolean or (nil, string): true if no errors ocurred, | 47 | -- @return boolean or (nil, string): true if no errors ocurred, |
47 | -- nil and an error message otherwise. | 48 | -- nil and an error message otherwise. |
48 | function run(rockspec) | 49 | function builtin.run(rockspec) |
49 | assert(type(rockspec) == "table") | 50 | assert(type(rockspec) == "table") |
50 | local compile_object, compile_library, compile_wrapper_binary --TODO EXEWRAPPER | 51 | local compile_object, compile_library, compile_wrapper_binary --TODO EXEWRAPPER |
51 | 52 | ||
@@ -262,3 +263,5 @@ function run(rockspec) | |||
262 | end | 263 | end |
263 | return true | 264 | return true |
264 | end | 265 | end |
266 | |||
267 | return builtin | ||
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index 0df3a921..83ec20f3 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Build back-end for CMake-based modules. | 2 | --- Build back-end for CMake-based modules. |
3 | module("luarocks.build.cmake", package.seeall) | 3 | --module("luarocks.build.cmake", package.seeall) |
4 | local cmake = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local util = require("luarocks.util") | 7 | local util = require("luarocks.util") |
@@ -10,7 +11,7 @@ local cfg = require("luarocks.cfg") | |||
10 | -- @param rockspec table: the loaded rockspec. | 11 | -- @param rockspec table: the loaded rockspec. |
11 | -- @return boolean or (nil, string): true if no errors ocurred, | 12 | -- @return boolean or (nil, string): true if no errors ocurred, |
12 | -- nil and an error message otherwise. | 13 | -- nil and an error message otherwise. |
13 | function run(rockspec) | 14 | function cmake.run(rockspec) |
14 | assert(type(rockspec) == "table") | 15 | assert(type(rockspec) == "table") |
15 | local build = rockspec.build | 16 | local build = rockspec.build |
16 | local variables = build.variables or {} | 17 | local variables = build.variables or {} |
@@ -56,3 +57,5 @@ function run(rockspec) | |||
56 | end | 57 | end |
57 | return true | 58 | return true |
58 | end | 59 | end |
60 | |||
61 | return cmake | ||
diff --git a/src/luarocks/build/command.lua b/src/luarocks/build/command.lua index aeec0da7..650e3236 100644 --- a/src/luarocks/build/command.lua +++ b/src/luarocks/build/command.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Build back-end for raw listing of commands in rockspec files. | 2 | --- Build back-end for raw listing of commands in rockspec files. |
3 | module("luarocks.build.command", package.seeall) | 3 | --module("luarocks.build.command", package.seeall) |
4 | local command = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local util = require("luarocks.util") | 7 | local util = require("luarocks.util") |
@@ -9,7 +10,7 @@ local util = require("luarocks.util") | |||
9 | -- @param rockspec table: the loaded rockspec. | 10 | -- @param rockspec table: the loaded rockspec. |
10 | -- @return boolean or (nil, string): true if no errors ocurred, | 11 | -- @return boolean or (nil, string): true if no errors ocurred, |
11 | -- nil and an error message otherwise. | 12 | -- nil and an error message otherwise. |
12 | function run(rockspec) | 13 | function command.run(rockspec) |
13 | assert(type(rockspec) == "table") | 14 | assert(type(rockspec) == "table") |
14 | 15 | ||
15 | local build = rockspec.build | 16 | local build = rockspec.build |
@@ -30,3 +31,5 @@ function run(rockspec) | |||
30 | end | 31 | end |
31 | return true | 32 | return true |
32 | end | 33 | end |
34 | |||
35 | return command | ||
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.lua index c4b21578..31deac64 100644 --- a/src/luarocks/build/make.lua +++ b/src/luarocks/build/make.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Build back-end for using Makefile-based packages. | 2 | --- Build back-end for using Makefile-based packages. |
3 | module("luarocks.build.make", package.seeall) | 3 | --module("luarocks.build.make", package.seeall) |
4 | local make = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local util = require("luarocks.util") | 7 | local util = require("luarocks.util") |
@@ -36,7 +37,7 @@ end | |||
36 | -- @param rockspec table: the loaded rockspec. | 37 | -- @param rockspec table: the loaded rockspec. |
37 | -- @return boolean or (nil, string): true if no errors ocurred, | 38 | -- @return boolean or (nil, string): true if no errors ocurred, |
38 | -- nil and an error message otherwise. | 39 | -- nil and an error message otherwise. |
39 | function run(rockspec) | 40 | function make.run(rockspec) |
40 | assert(type(rockspec) == "table") | 41 | assert(type(rockspec) == "table") |
41 | 42 | ||
42 | local build = rockspec.build | 43 | local build = rockspec.build |
@@ -90,3 +91,5 @@ function run(rockspec) | |||
90 | end | 91 | end |
91 | return true | 92 | return true |
92 | end | 93 | end |
94 | |||
95 | return make | ||
diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua index 6b4cf186..efb59d05 100644 --- a/src/luarocks/fetch/cvs.lua +++ b/src/luarocks/fetch/cvs.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Fetch back-end for retrieving sources from CVS. | 2 | --- Fetch back-end for retrieving sources from CVS. |
3 | module("luarocks.fetch.cvs", package.seeall) | 3 | --module("luarocks.fetch.cvs", package.seeall) |
4 | local cvs = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
@@ -13,7 +14,7 @@ local util = require("luarocks.util") | |||
13 | -- @return (string, string) or (nil, string): The absolute pathname of | 14 | -- @return (string, string) or (nil, string): The absolute pathname of |
14 | -- the fetched source tarball and the temporary directory created to | 15 | -- the fetched source tarball and the temporary directory created to |
15 | -- store it; or nil and an error message. | 16 | -- store it; or nil and an error message. |
16 | function get_sources(rockspec, extract, dest_dir) | 17 | function cvs.get_sources(rockspec, extract, dest_dir) |
17 | assert(type(rockspec) == "table") | 18 | assert(type(rockspec) == "table") |
18 | assert(type(dest_dir) == "string" or not dest_dir) | 19 | assert(type(dest_dir) == "string" or not dest_dir) |
19 | 20 | ||
@@ -43,3 +44,5 @@ function get_sources(rockspec, extract, dest_dir) | |||
43 | return module, store_dir | 44 | return module, store_dir |
44 | end | 45 | end |
45 | 46 | ||
47 | |||
48 | return cvs | ||
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 2bba4cdc..7fe4c4ee 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Fetch back-end for retrieving sources from GIT. | 2 | --- Fetch back-end for retrieving sources from GIT. |
3 | module("luarocks.fetch.git", package.seeall) | 3 | --module("luarocks.fetch.git", package.seeall) |
4 | local git = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
@@ -27,7 +28,7 @@ end | |||
27 | -- @return (string, string) or (nil, string): The absolute pathname of | 28 | -- @return (string, string) or (nil, string): The absolute pathname of |
28 | -- the fetched source tarball and the temporary directory created to | 29 | -- the fetched source tarball and the temporary directory created to |
29 | -- store it; or nil and an error message. | 30 | -- store it; or nil and an error message. |
30 | function get_sources(rockspec, extract, dest_dir, depth) | 31 | function git.get_sources(rockspec, extract, dest_dir, depth) |
31 | assert(type(rockspec) == "table") | 32 | assert(type(rockspec) == "table") |
32 | assert(type(dest_dir) == "string" or not dest_dir) | 33 | assert(type(dest_dir) == "string" or not dest_dir) |
33 | 34 | ||
@@ -81,3 +82,5 @@ function get_sources(rockspec, extract, dest_dir, depth) | |||
81 | fs.pop_dir() | 82 | fs.pop_dir() |
82 | return module, store_dir | 83 | return module, store_dir |
83 | end | 84 | end |
85 | |||
86 | return git | ||
diff --git a/src/luarocks/fetch/git_file.lua b/src/luarocks/fetch/git_file.lua index 1b18d0fa..0144bc2e 100644 --- a/src/luarocks/fetch/git_file.lua +++ b/src/luarocks/fetch/git_file.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Fetch back-end for retrieving sources from local Git repositories. | 2 | --- Fetch back-end for retrieving sources from local Git repositories. |
3 | module("luarocks.fetch.git_file", package.seeall) | 3 | --module("luarocks.fetch.git_file", package.seeall) |
4 | local git_file = {} | ||
4 | 5 | ||
5 | local git = require("luarocks.fetch.git") | 6 | local git = require("luarocks.fetch.git") |
6 | 7 | ||
@@ -11,7 +12,9 @@ local git = require("luarocks.fetch.git") | |||
11 | -- @return (string, string) or (nil, string): The absolute pathname of | 12 | -- @return (string, string) or (nil, string): The absolute pathname of |
12 | -- the fetched source tarball and the temporary directory created to | 13 | -- the fetched source tarball and the temporary directory created to |
13 | -- store it; or nil and an error message. | 14 | -- store it; or nil and an error message. |
14 | function get_sources(rockspec, extract, dest_dir) | 15 | function git_file.get_sources(rockspec, extract, dest_dir) |
15 | rockspec.source.url = rockspec.source.url:gsub("^git.file://", "") | 16 | rockspec.source.url = rockspec.source.url:gsub("^git.file://", "") |
16 | return git.get_sources(rockspec, extract, dest_dir) | 17 | return git.get_sources(rockspec, extract, dest_dir) |
17 | end | 18 | end |
19 | |||
20 | return git_file | ||
diff --git a/src/luarocks/fetch/git_http.lua b/src/luarocks/fetch/git_http.lua index b5fcd095..4ecd4816 100644 --- a/src/luarocks/fetch/git_http.lua +++ b/src/luarocks/fetch/git_http.lua | |||
@@ -7,7 +7,8 @@ | |||
7 | -- source = { url = "git+http://example.com/foo.git" } | 7 | -- source = { url = "git+http://example.com/foo.git" } |
8 | -- Prefer using the normal git:// fetch mode as it is more widely | 8 | -- Prefer using the normal git:// fetch mode as it is more widely |
9 | -- available in older versions of LuaRocks. | 9 | -- available in older versions of LuaRocks. |
10 | module("luarocks.fetch.git_http", package.seeall) | 10 | --module("luarocks.fetch.git_http", package.seeall) |
11 | local git_http = {} | ||
11 | 12 | ||
12 | local git = require("luarocks.fetch.git") | 13 | local git = require("luarocks.fetch.git") |
13 | 14 | ||
@@ -18,7 +19,9 @@ local git = require("luarocks.fetch.git") | |||
18 | -- @return (string, string) or (nil, string): The absolute pathname of | 19 | -- @return (string, string) or (nil, string): The absolute pathname of |
19 | -- the fetched source tarball and the temporary directory created to | 20 | -- the fetched source tarball and the temporary directory created to |
20 | -- store it; or nil and an error message. | 21 | -- store it; or nil and an error message. |
21 | function get_sources(rockspec, extract, dest_dir) | 22 | function git_http.get_sources(rockspec, extract, dest_dir) |
22 | rockspec.source.url = rockspec.source.url:gsub("^git.", "") | 23 | rockspec.source.url = rockspec.source.url:gsub("^git.", "") |
23 | return git.get_sources(rockspec, extract, dest_dir, "--") | 24 | return git.get_sources(rockspec, extract, dest_dir, "--") |
24 | end | 25 | end |
26 | |||
27 | return git_http | ||
diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index 32e40469..44af3afa 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Fetch back-end for retrieving sources from HG. | 2 | --- Fetch back-end for retrieving sources from HG. |
3 | module("luarocks.fetch.hg", package.seeall) | 3 | --module("luarocks.fetch.hg", package.seeall) |
4 | local hg = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
@@ -13,7 +14,7 @@ local util = require("luarocks.util") | |||
13 | -- @return (string, string) or (nil, string): The absolute pathname of | 14 | -- @return (string, string) or (nil, string): The absolute pathname of |
14 | -- the fetched source tarball and the temporary directory created to | 15 | -- the fetched source tarball and the temporary directory created to |
15 | -- store it; or nil and an error message. | 16 | -- store it; or nil and an error message. |
16 | function get_sources(rockspec, extract, dest_dir) | 17 | function hg.get_sources(rockspec, extract, dest_dir) |
17 | assert(type(rockspec) == "table") | 18 | assert(type(rockspec) == "table") |
18 | assert(type(dest_dir) == "string" or not dest_dir) | 19 | assert(type(dest_dir) == "string" or not dest_dir) |
19 | 20 | ||
@@ -54,3 +55,5 @@ function get_sources(rockspec, extract, dest_dir) | |||
54 | return module, store_dir | 55 | return module, store_dir |
55 | end | 56 | end |
56 | 57 | ||
58 | |||
59 | return hg | ||
diff --git a/src/luarocks/fetch/sscm.lua b/src/luarocks/fetch/sscm.lua index e52e8019..53ae86a3 100644 --- a/src/luarocks/fetch/sscm.lua +++ b/src/luarocks/fetch/sscm.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Fetch back-end for retrieving sources from Surround SCM Server | 2 | --- Fetch back-end for retrieving sources from Surround SCM Server |
3 | module("luarocks.fetch.sscm", package.seeall) | 3 | --module("luarocks.fetch.sscm", package.seeall) |
4 | local sscm = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
@@ -12,7 +13,7 @@ local dir = require("luarocks.dir") | |||
12 | -- @return (string, string) or (nil, string): The absolute pathname of | 13 | -- @return (string, string) or (nil, string): The absolute pathname of |
13 | -- the fetched source tarball and the temporary directory created to | 14 | -- the fetched source tarball and the temporary directory created to |
14 | -- store it; or nil and an error message. | 15 | -- store it; or nil and an error message. |
15 | function get_sources(rockspec, extract, dest_dir) | 16 | function sscm.get_sources(rockspec, extract, dest_dir) |
16 | assert(type(rockspec) == "table") | 17 | assert(type(rockspec) == "table") |
17 | assert(type(dest_dir) == "string" or not dest_dir) | 18 | assert(type(dest_dir) == "string" or not dest_dir) |
18 | 19 | ||
@@ -40,3 +41,5 @@ function get_sources(rockspec, extract, dest_dir) | |||
40 | -- FIXME: This function does not honor the dest_dir parameter. | 41 | -- FIXME: This function does not honor the dest_dir parameter. |
41 | return module, working_dir | 42 | return module, working_dir |
42 | end | 43 | end |
44 | |||
45 | return sscm | ||
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.lua index 7aa37ec5..63a443c7 100644 --- a/src/luarocks/fetch/svn.lua +++ b/src/luarocks/fetch/svn.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Fetch back-end for retrieving sources from Subversion. | 2 | --- Fetch back-end for retrieving sources from Subversion. |
3 | module("luarocks.fetch.svn", package.seeall) | 3 | --module("luarocks.fetch.svn", package.seeall) |
4 | local svn = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
@@ -13,7 +14,7 @@ local util = require("luarocks.util") | |||
13 | -- @return (string, string) or (nil, string): The absolute pathname of | 14 | -- @return (string, string) or (nil, string): The absolute pathname of |
14 | -- the fetched source tarball and the temporary directory created to | 15 | -- the fetched source tarball and the temporary directory created to |
15 | -- store it; or nil and an error message. | 16 | -- store it; or nil and an error message. |
16 | function get_sources(rockspec, extract, dest_dir) | 17 | function svn.get_sources(rockspec, extract, dest_dir) |
17 | assert(type(rockspec) == "table") | 18 | assert(type(rockspec) == "table") |
18 | assert(type(dest_dir) == "string" or not dest_dir) | 19 | assert(type(dest_dir) == "string" or not dest_dir) |
19 | 20 | ||
@@ -53,3 +54,5 @@ function get_sources(rockspec, extract, dest_dir) | |||
53 | return module, store_dir | 54 | return module, store_dir |
54 | end | 55 | end |
55 | 56 | ||
57 | |||
58 | return svn | ||
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 2dc5e492..3e6b9080 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- Unix implementation of filesystem and platform abstractions. | 2 | --- Unix implementation of filesystem and platform abstractions. |
3 | module("luarocks.fs.unix", package.seeall) | 3 | --module("luarocks.fs.unix", package.seeall) |
4 | local unix = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | 7 | ||
@@ -14,7 +15,7 @@ math.randomseed(os.time()) | |||
14 | --- Annotate command string for quiet execution. | 15 | --- Annotate command string for quiet execution. |
15 | -- @param cmd string: A command-line string. | 16 | -- @param cmd string: A command-line string. |
16 | -- @return string: The command-line, with silencing annotation. | 17 | -- @return string: The command-line, with silencing annotation. |
17 | function quiet(cmd) | 18 | function unix.quiet(cmd) |
18 | return cmd.." 1> /dev/null 2> /dev/null" | 19 | return cmd.." 1> /dev/null 2> /dev/null" |
19 | end | 20 | end |
20 | 21 | ||
@@ -24,7 +25,7 @@ end | |||
24 | -- pathname absolute, or the current dir in the dir stack if | 25 | -- pathname absolute, or the current dir in the dir stack if |
25 | -- not given. | 26 | -- not given. |
26 | -- @return string: The pathname converted to absolute. | 27 | -- @return string: The pathname converted to absolute. |
27 | function absolute_name(pathname, relative_to) | 28 | function unix.absolute_name(pathname, relative_to) |
28 | assert(type(pathname) == "string") | 29 | assert(type(pathname) == "string") |
29 | assert(type(relative_to) == "string" or not relative_to) | 30 | assert(type(relative_to) == "string" or not relative_to) |
30 | 31 | ||
@@ -43,7 +44,7 @@ end | |||
43 | -- @param version string: rock version to be used in loader context. | 44 | -- @param version string: rock version to be used in loader context. |
44 | -- @return boolean or (nil, string): True if succeeded, or nil and | 45 | -- @return boolean or (nil, string): True if succeeded, or nil and |
45 | -- an error message. | 46 | -- an error message. |
46 | function wrap_script(file, dest, name, version) | 47 | function unix.wrap_script(file, dest, name, version) |
47 | assert(type(file) == "string") | 48 | assert(type(file) == "string") |
48 | assert(type(dest) == "string") | 49 | assert(type(dest) == "string") |
49 | 50 | ||
@@ -72,7 +73,7 @@ end | |||
72 | -- @param filename string: the file name with full path. | 73 | -- @param filename string: the file name with full path. |
73 | -- @return boolean: returns true if file is an actual binary | 74 | -- @return boolean: returns true if file is an actual binary |
74 | -- (or if it couldn't check) or false if it is a Lua wrapper. | 75 | -- (or if it couldn't check) or false if it is a Lua wrapper. |
75 | function is_actual_binary(filename) | 76 | function unix.is_actual_binary(filename) |
76 | if filename:match("%.lua$") then | 77 | if filename:match("%.lua$") then |
77 | return false | 78 | return false |
78 | end | 79 | end |
@@ -89,7 +90,7 @@ function is_actual_binary(filename) | |||
89 | return first ~= "#!" | 90 | return first ~= "#!" |
90 | end | 91 | end |
91 | 92 | ||
92 | function copy_binary(filename, dest) | 93 | function unix.copy_binary(filename, dest) |
93 | return fs.copy(filename, dest, "0755") | 94 | return fs.copy(filename, dest, "0755") |
94 | end | 95 | end |
95 | 96 | ||
@@ -103,6 +104,8 @@ end | |||
103 | -- which will replace old_file. | 104 | -- which will replace old_file. |
104 | -- @return boolean or (nil, string): True if succeeded, or nil and | 105 | -- @return boolean or (nil, string): True if succeeded, or nil and |
105 | -- an error message. | 106 | -- an error message. |
106 | function replace_file(old_file, new_file) | 107 | function unix.replace_file(old_file, new_file) |
107 | return os.rename(new_file, old_file) | 108 | return os.rename(new_file, old_file) |
108 | end | 109 | end |
110 | |||
111 | return unix | ||
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index a3f0663b..c4c20349 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -1,7 +1,8 @@ | |||
1 | --- Windows implementation of filesystem and platform abstractions. | 1 | --- Windows implementation of filesystem and platform abstractions. |
2 | -- Download http://unxutils.sourceforge.net/ for Windows GNU utilities | 2 | -- Download http://unxutils.sourceforge.net/ for Windows GNU utilities |
3 | -- used by this module. | 3 | -- used by this module. |
4 | module("luarocks.fs.win32", package.seeall) | 4 | --module("luarocks.fs.win32", package.seeall) |
5 | local win32 = {} | ||
5 | 6 | ||
6 | local fs = require("luarocks.fs") | 7 | local fs = require("luarocks.fs") |
7 | 8 | ||
@@ -21,7 +22,7 @@ os.execute = function(cmd, ...) return _execute(_prefix..cmd, ...) end | |||
21 | --- Annotate command string for quiet execution. | 22 | --- Annotate command string for quiet execution. |
22 | -- @param cmd string: A command-line string. | 23 | -- @param cmd string: A command-line string. |
23 | -- @return string: The command-line, with silencing annotation. | 24 | -- @return string: The command-line, with silencing annotation. |
24 | function quiet(cmd) | 25 | function win32.quiet(cmd) |
25 | return cmd.." 2> NUL 1> NUL" | 26 | return cmd.." 2> NUL 1> NUL" |
26 | end | 27 | end |
27 | 28 | ||
@@ -43,7 +44,7 @@ end | |||
43 | -- Adds double quotes and escapes. | 44 | -- Adds double quotes and escapes. |
44 | -- @param arg string: Unquoted argument. | 45 | -- @param arg string: Unquoted argument. |
45 | -- @return string: Quoted argument. | 46 | -- @return string: Quoted argument. |
46 | function Q(arg) | 47 | function win32.Q(arg) |
47 | assert(type(arg) == "string") | 48 | assert(type(arg) == "string") |
48 | -- Quote DIR for Windows | 49 | -- Quote DIR for Windows |
49 | if arg:match("^[%.a-zA-Z]?:?[\\/]") then | 50 | if arg:match("^[%.a-zA-Z]?:?[\\/]") then |
@@ -64,7 +65,7 @@ end | |||
64 | -- Adds double quotes and escapes. | 65 | -- Adds double quotes and escapes. |
65 | -- @param arg string: Unquoted argument. | 66 | -- @param arg string: Unquoted argument. |
66 | -- @return string: Quoted argument. | 67 | -- @return string: Quoted argument. |
67 | function Qb(arg) | 68 | function win32.Qb(arg) |
68 | assert(type(arg) == "string") | 69 | assert(type(arg) == "string") |
69 | -- Quote DIR for Windows | 70 | -- Quote DIR for Windows |
70 | if arg:match("^[%.a-zA-Z]?:?[\\/]") then | 71 | if arg:match("^[%.a-zA-Z]?:?[\\/]") then |
@@ -86,7 +87,7 @@ end | |||
86 | -- pathname absolute, or the current dir in the dir stack if | 87 | -- pathname absolute, or the current dir in the dir stack if |
87 | -- not given. | 88 | -- not given. |
88 | -- @return string: The pathname converted to absolute. | 89 | -- @return string: The pathname converted to absolute. |
89 | function absolute_name(pathname, relative_to) | 90 | function win32.absolute_name(pathname, relative_to) |
90 | assert(type(pathname) == "string") | 91 | assert(type(pathname) == "string") |
91 | assert(type(relative_to) == "string" or not relative_to) | 92 | assert(type(relative_to) == "string" or not relative_to) |
92 | 93 | ||
@@ -107,7 +108,7 @@ end | |||
107 | -- @param version string: rock version to be used in loader context. | 108 | -- @param version string: rock version to be used in loader context. |
108 | -- @return boolean or (nil, string): True if succeeded, or nil and | 109 | -- @return boolean or (nil, string): True if succeeded, or nil and |
109 | -- an error message. | 110 | -- an error message. |
110 | function wrap_script(file, dest, name, version) | 111 | function win32.wrap_script(file, dest, name, version) |
111 | assert(type(file) == "string") | 112 | assert(type(file) == "string") |
112 | assert(type(dest) == "string") | 113 | assert(type(dest) == "string") |
113 | 114 | ||
@@ -128,7 +129,7 @@ function wrap_script(file, dest, name, version) | |||
128 | return true | 129 | return true |
129 | end | 130 | end |
130 | 131 | ||
131 | function is_actual_binary(name) | 132 | function win32.is_actual_binary(name) |
132 | name = name:lower() | 133 | name = name:lower() |
133 | if name:match("%.bat$") or name:match("%.exe$") then | 134 | if name:match("%.bat$") or name:match("%.exe$") then |
134 | return true | 135 | return true |
@@ -136,7 +137,7 @@ function is_actual_binary(name) | |||
136 | return false | 137 | return false |
137 | end | 138 | end |
138 | 139 | ||
139 | function copy_binary(filename, dest) | 140 | function win32.copy_binary(filename, dest) |
140 | local ok, err = fs.copy(filename, dest) | 141 | local ok, err = fs.copy(filename, dest) |
141 | if not ok then | 142 | if not ok then |
142 | return nil, err | 143 | return nil, err |
@@ -158,11 +159,11 @@ function copy_binary(filename, dest) | |||
158 | return true | 159 | return true |
159 | end | 160 | end |
160 | 161 | ||
161 | function chmod(filename, mode) | 162 | function win32.chmod(filename, mode) |
162 | return true | 163 | return true |
163 | end | 164 | end |
164 | 165 | ||
165 | function get_permissions(filename) | 166 | function win32.get_permissions(filename) |
166 | return "" | 167 | return "" |
167 | end | 168 | end |
168 | 169 | ||
@@ -177,7 +178,7 @@ end | |||
177 | -- which will replace old_file. | 178 | -- which will replace old_file. |
178 | -- @return boolean or (nil, string): True if succeeded, or nil and | 179 | -- @return boolean or (nil, string): True if succeeded, or nil and |
179 | -- an error message. | 180 | -- an error message. |
180 | function replace_file(old_file, new_file) | 181 | function win32.replace_file(old_file, new_file) |
181 | os.remove(old_file) | 182 | os.remove(old_file) |
182 | return os.rename(new_file, old_file) | 183 | return os.rename(new_file, old_file) |
183 | end | 184 | end |
@@ -188,7 +189,7 @@ end | |||
188 | -- for checking the result of subsequent operations. | 189 | -- for checking the result of subsequent operations. |
189 | -- @param file string: filename to test | 190 | -- @param file string: filename to test |
190 | -- @return boolean: true if file exists, false otherwise. | 191 | -- @return boolean: true if file exists, false otherwise. |
191 | function is_writable(file) | 192 | function win32.is_writable(file) |
192 | assert(file) | 193 | assert(file) |
193 | file = dir.normalize(file) | 194 | file = dir.normalize(file) |
194 | local result | 195 | local result |
@@ -212,3 +213,5 @@ function is_writable(file) | |||
212 | end | 213 | end |
213 | return result | 214 | return result |
214 | end | 215 | end |
216 | |||
217 | return win32 | ||
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index c518fc4d..a3e1602d 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -7,7 +7,8 @@ | |||
7 | -- Copyright (c) 2008 rainforce.org, MIT License | 7 | -- Copyright (c) 2008 rainforce.org, MIT License |
8 | -- Project home: http://code.google.com/p/python-patch/ . | 8 | -- Project home: http://code.google.com/p/python-patch/ . |
9 | 9 | ||
10 | module("luarocks.tools.patch", package.seeall) | 10 | --module("luarocks.tools.patch", package.seeall) |
11 | local patch = {} | ||
11 | 12 | ||
12 | local fs = require("luarocks.fs") | 13 | local fs = require("luarocks.fs") |
13 | local util = require("luarocks.util") | 14 | local util = require("luarocks.util") |
@@ -153,7 +154,7 @@ local function match_linerange(line) | |||
153 | return m1, m2, m3, m4 | 154 | return m1, m2, m3, m4 |
154 | end | 155 | end |
155 | 156 | ||
156 | function read_patch(filename, data) | 157 | function patch.read_patch(filename, data) |
157 | -- define possible file regions that will direct the parser flow | 158 | -- define possible file regions that will direct the parser flow |
158 | local state = 'header' | 159 | local state = 'header' |
159 | -- 'header' - comments before the patch body | 160 | -- 'header' - comments before the patch body |
@@ -564,7 +565,7 @@ local function strip_dirs(filename, strip) | |||
564 | return filename | 565 | return filename |
565 | end | 566 | end |
566 | 567 | ||
567 | function apply_patch(patch, strip) | 568 | function patch.apply_patch(patch, strip) |
568 | local all_ok = true | 569 | local all_ok = true |
569 | local total = #patch.source | 570 | local total = #patch.source |
570 | for fileno, filename in ipairs(patch.source) do | 571 | for fileno, filename in ipairs(patch.source) do |
@@ -705,3 +706,5 @@ function apply_patch(patch, strip) | |||
705 | -- todo: check for premature eof | 706 | -- todo: check for premature eof |
706 | return all_ok | 707 | return all_ok |
707 | end | 708 | end |
709 | |||
710 | return patch | ||
diff --git a/src/luarocks/tools/tar.lua b/src/luarocks/tools/tar.lua index 0c68ab2f..03f7de3c 100644 --- a/src/luarocks/tools/tar.lua +++ b/src/luarocks/tools/tar.lua | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | --- A pure-Lua implementation of untar (unpacking .tar archives) | 2 | --- A pure-Lua implementation of untar (unpacking .tar archives) |
3 | module("luarocks.tools.tar", package.seeall) | 3 | --module("luarocks.tools.tar", package.seeall) |
4 | local tar = {} | ||
4 | 5 | ||
5 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
6 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
@@ -82,7 +83,7 @@ local function read_header_block(block) | |||
82 | return header | 83 | return header |
83 | end | 84 | end |
84 | 85 | ||
85 | function untar(filename, destdir) | 86 | function tar.untar(filename, destdir) |
86 | assert(type(filename) == "string") | 87 | assert(type(filename) == "string") |
87 | assert(type(destdir) == "string") | 88 | assert(type(destdir) == "string") |
88 | 89 | ||
@@ -144,3 +145,5 @@ function untar(filename, destdir) | |||
144 | end | 145 | end |
145 | return true | 146 | return true |
146 | end | 147 | end |
148 | |||
149 | return tar | ||
diff --git a/src/luarocks/tools/zip.lua b/src/luarocks/tools/zip.lua index 35428d91..40cc089a 100644 --- a/src/luarocks/tools/zip.lua +++ b/src/luarocks/tools/zip.lua | |||
@@ -1,7 +1,8 @@ | |||
1 | 1 | ||
2 | --- A Lua implementation of .zip file archiving (used for creating .rock files), | 2 | --- A Lua implementation of .zip file archiving (used for creating .rock files), |
3 | -- using only lua-zlib. | 3 | -- using only lua-zlib. |
4 | module("luarocks.tools.zip", package.seeall) | 4 | --module("luarocks.tools.zip", package.seeall) |
5 | local zip = {} | ||
5 | 6 | ||
6 | local zlib = require("zlib") | 7 | local zlib = require("zlib") |
7 | local fs = require("luarocks.fs") | 8 | local fs = require("luarocks.fs") |
@@ -188,7 +189,7 @@ end | |||
188 | --- Return a zip handle open for writing. | 189 | --- Return a zip handle open for writing. |
189 | -- @param name filename of the zipfile to be created. | 190 | -- @param name filename of the zipfile to be created. |
190 | -- @return a zip handle, or nil in case of error. | 191 | -- @return a zip handle, or nil in case of error. |
191 | function new_zipwriter(name) | 192 | function zip.new_zipwriter(name) |
192 | 193 | ||
193 | local zw = {} | 194 | local zw = {} |
194 | 195 | ||
@@ -214,8 +215,8 @@ end | |||
214 | -- additional arguments. | 215 | -- additional arguments. |
215 | -- @return boolean or (boolean, string): true on success, | 216 | -- @return boolean or (boolean, string): true on success, |
216 | -- false and an error message on failure. | 217 | -- false and an error message on failure. |
217 | function zip(zipfile, ...) | 218 | function zip.zip(zipfile, ...) |
218 | local zw = new_zipwriter(zipfile) | 219 | local zw = zip.new_zipwriter(zipfile) |
219 | if not zw then | 220 | if not zw then |
220 | return nil, "error opening "..zipfile | 221 | return nil, "error opening "..zipfile |
221 | end | 222 | end |
@@ -243,3 +244,5 @@ function zip(zipfile, ...) | |||
243 | return ok, err | 244 | return ok, err |
244 | end | 245 | end |
245 | 246 | ||
247 | |||
248 | return zip | ||