aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormpeterv <petjamelnik@yandex.ru>2014-03-20 20:59:24 +0400
committermpeterv <petjamelnik@yandex.ru>2014-03-20 20:59:24 +0400
commit3af05c7e5d7999500508c51a5d405e59c14363cc (patch)
treee62ad5efc7a62ab26039129a3be88d3b6f970771 /src
parent548de234ebce046a8004c7badbdd5da4ad2e56ee (diff)
downloadluarocks-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.lua7
-rw-r--r--src/luarocks/build/cmake.lua7
-rw-r--r--src/luarocks/build/command.lua7
-rw-r--r--src/luarocks/build/make.lua7
-rw-r--r--src/luarocks/fetch/cvs.lua7
-rw-r--r--src/luarocks/fetch/git.lua7
-rw-r--r--src/luarocks/fetch/git_file.lua7
-rw-r--r--src/luarocks/fetch/git_http.lua7
-rw-r--r--src/luarocks/fetch/hg.lua7
-rw-r--r--src/luarocks/fetch/sscm.lua7
-rw-r--r--src/luarocks/fetch/svn.lua7
-rw-r--r--src/luarocks/fs/unix.lua17
-rw-r--r--src/luarocks/fs/win32.lua27
-rw-r--r--src/luarocks/tools/patch.lua9
-rw-r--r--src/luarocks/tools/tar.lua7
-rw-r--r--src/luarocks/tools/zip.lua11
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.
3module("luarocks.build.builtin", package.seeall) 3--module("luarocks.build.builtin", package.seeall)
4local builtin = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local path = require("luarocks.path") 7local 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.
48function run(rockspec) 49function 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
264end 265end
266
267return 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.
3module("luarocks.build.cmake", package.seeall) 3--module("luarocks.build.cmake", package.seeall)
4local cmake = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local util = require("luarocks.util") 7local 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.
13function run(rockspec) 14function 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
58end 59end
60
61return 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.
3module("luarocks.build.command", package.seeall) 3--module("luarocks.build.command", package.seeall)
4local command = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local util = require("luarocks.util") 7local 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.
12function run(rockspec) 13function 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
32end 33end
34
35return 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.
3module("luarocks.build.make", package.seeall) 3--module("luarocks.build.make", package.seeall)
4local make = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local util = require("luarocks.util") 7local 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.
39function run(rockspec) 40function 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
92end 93end
94
95return 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.
3module("luarocks.fetch.cvs", package.seeall) 3--module("luarocks.fetch.cvs", package.seeall)
4local cvs = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 7local 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.
16function get_sources(rockspec, extract, dest_dir) 17function 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
44end 45end
45 46
47
48return 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.
3module("luarocks.fetch.git", package.seeall) 3--module("luarocks.fetch.git", package.seeall)
4local git = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 7local 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.
30function get_sources(rockspec, extract, dest_dir, depth) 31function 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
83end 84end
85
86return 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.
3module("luarocks.fetch.git_file", package.seeall) 3--module("luarocks.fetch.git_file", package.seeall)
4local git_file = {}
4 5
5local git = require("luarocks.fetch.git") 6local 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.
14function get_sources(rockspec, extract, dest_dir) 15function 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)
17end 18end
19
20return 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.
10module("luarocks.fetch.git_http", package.seeall) 10--module("luarocks.fetch.git_http", package.seeall)
11local git_http = {}
11 12
12local git = require("luarocks.fetch.git") 13local 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.
21function get_sources(rockspec, extract, dest_dir) 22function 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, "--")
24end 25end
26
27return 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.
3module("luarocks.fetch.hg", package.seeall) 3--module("luarocks.fetch.hg", package.seeall)
4local hg = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 7local 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.
16function get_sources(rockspec, extract, dest_dir) 17function 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
55end 56end
56 57
58
59return 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
3module("luarocks.fetch.sscm", package.seeall) 3--module("luarocks.fetch.sscm", package.seeall)
4local sscm = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 7local 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.
15function get_sources(rockspec, extract, dest_dir) 16function 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
42end 43end
44
45return 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.
3module("luarocks.fetch.svn", package.seeall) 3--module("luarocks.fetch.svn", package.seeall)
4local svn = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 7local 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.
16function get_sources(rockspec, extract, dest_dir) 17function 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
54end 55end
55 56
57
58return 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.
3module("luarocks.fs.unix", package.seeall) 3--module("luarocks.fs.unix", package.seeall)
4local unix = {}
4 5
5local fs = require("luarocks.fs") 6local 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.
17function quiet(cmd) 18function unix.quiet(cmd)
18 return cmd.." 1> /dev/null 2> /dev/null" 19 return cmd.." 1> /dev/null 2> /dev/null"
19end 20end
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.
27function absolute_name(pathname, relative_to) 28function 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.
46function wrap_script(file, dest, name, version) 47function 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.
75function is_actual_binary(filename) 76function 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 ~= "#!"
90end 91end
91 92
92function copy_binary(filename, dest) 93function unix.copy_binary(filename, dest)
93 return fs.copy(filename, dest, "0755") 94 return fs.copy(filename, dest, "0755")
94end 95end
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.
106function replace_file(old_file, new_file) 107function unix.replace_file(old_file, new_file)
107 return os.rename(new_file, old_file) 108 return os.rename(new_file, old_file)
108end 109end
110
111return 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.
4module("luarocks.fs.win32", package.seeall) 4--module("luarocks.fs.win32", package.seeall)
5local win32 = {}
5 6
6local fs = require("luarocks.fs") 7local 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.
24function quiet(cmd) 25function win32.quiet(cmd)
25 return cmd.." 2> NUL 1> NUL" 26 return cmd.." 2> NUL 1> NUL"
26end 27end
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.
46function Q(arg) 47function 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.
67function Qb(arg) 68function 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.
89function absolute_name(pathname, relative_to) 90function 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.
110function wrap_script(file, dest, name, version) 111function 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
129end 130end
130 131
131function is_actual_binary(name) 132function 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
137end 138end
138 139
139function copy_binary(filename, dest) 140function 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
159end 160end
160 161
161function chmod(filename, mode) 162function win32.chmod(filename, mode)
162 return true 163 return true
163end 164end
164 165
165function get_permissions(filename) 166function win32.get_permissions(filename)
166 return "" 167 return ""
167end 168end
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.
180function replace_file(old_file, new_file) 181function 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)
183end 184end
@@ -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.
191function is_writable(file) 192function 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
214end 215end
216
217return 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
10module("luarocks.tools.patch", package.seeall) 10--module("luarocks.tools.patch", package.seeall)
11local patch = {}
11 12
12local fs = require("luarocks.fs") 13local fs = require("luarocks.fs")
13local util = require("luarocks.util") 14local 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
154end 155end
155 156
156function read_patch(filename, data) 157function 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
565end 566end
566 567
567function apply_patch(patch, strip) 568function 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
707end 708end
709
710return 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)
3module("luarocks.tools.tar", package.seeall) 3--module("luarocks.tools.tar", package.seeall)
4local tar = {}
4 5
5local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
6local dir = require("luarocks.dir") 7local dir = require("luarocks.dir")
@@ -82,7 +83,7 @@ local function read_header_block(block)
82 return header 83 return header
83end 84end
84 85
85function untar(filename, destdir) 86function 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
146end 147end
148
149return 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.
4module("luarocks.tools.zip", package.seeall) 4--module("luarocks.tools.zip", package.seeall)
5local zip = {}
5 6
6local zlib = require("zlib") 7local zlib = require("zlib")
7local fs = require("luarocks.fs") 8local 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.
191function new_zipwriter(name) 192function 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.
217function zip(zipfile, ...) 218function 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
244end 245end
245 246
247
248return zip