From 3af05c7e5d7999500508c51a5d405e59c14363cc Mon Sep 17 00:00:00 2001 From: mpeterv Date: Thu, 20 Mar 2014 20:59:24 +0400 Subject: Un-module bundled deps --- src/luarocks/build/builtin.lua | 7 +++++-- src/luarocks/build/cmake.lua | 7 +++++-- src/luarocks/build/command.lua | 7 +++++-- src/luarocks/build/make.lua | 7 +++++-- src/luarocks/fetch/cvs.lua | 7 +++++-- src/luarocks/fetch/git.lua | 7 +++++-- src/luarocks/fetch/git_file.lua | 7 +++++-- src/luarocks/fetch/git_http.lua | 7 +++++-- src/luarocks/fetch/hg.lua | 7 +++++-- src/luarocks/fetch/sscm.lua | 7 +++++-- src/luarocks/fetch/svn.lua | 7 +++++-- src/luarocks/fs/unix.lua | 17 ++++++++++------- src/luarocks/fs/win32.lua | 27 +++++++++++++++------------ src/luarocks/tools/patch.lua | 9 ++++++--- src/luarocks/tools/tar.lua | 7 +++++-- src/luarocks/tools/zip.lua | 11 +++++++---- 16 files changed, 98 insertions(+), 50 deletions(-) (limited to 'src') 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 @@ --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. -module("luarocks.build.builtin", package.seeall) +--module("luarocks.build.builtin", package.seeall) +local builtin = {} local fs = require("luarocks.fs") local path = require("luarocks.path") @@ -45,7 +46,7 @@ end -- @param rockspec table: the loaded rockspec. -- @return boolean or (nil, string): true if no errors ocurred, -- nil and an error message otherwise. -function run(rockspec) +function builtin.run(rockspec) assert(type(rockspec) == "table") local compile_object, compile_library, compile_wrapper_binary --TODO EXEWRAPPER @@ -262,3 +263,5 @@ function run(rockspec) end return true end + +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 @@ --- Build back-end for CMake-based modules. -module("luarocks.build.cmake", package.seeall) +--module("luarocks.build.cmake", package.seeall) +local cmake = {} local fs = require("luarocks.fs") local util = require("luarocks.util") @@ -10,7 +11,7 @@ local cfg = require("luarocks.cfg") -- @param rockspec table: the loaded rockspec. -- @return boolean or (nil, string): true if no errors ocurred, -- nil and an error message otherwise. -function run(rockspec) +function cmake.run(rockspec) assert(type(rockspec) == "table") local build = rockspec.build local variables = build.variables or {} @@ -56,3 +57,5 @@ function run(rockspec) end return true end + +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 @@ --- Build back-end for raw listing of commands in rockspec files. -module("luarocks.build.command", package.seeall) +--module("luarocks.build.command", package.seeall) +local command = {} local fs = require("luarocks.fs") local util = require("luarocks.util") @@ -9,7 +10,7 @@ local util = require("luarocks.util") -- @param rockspec table: the loaded rockspec. -- @return boolean or (nil, string): true if no errors ocurred, -- nil and an error message otherwise. -function run(rockspec) +function command.run(rockspec) assert(type(rockspec) == "table") local build = rockspec.build @@ -30,3 +31,5 @@ function run(rockspec) end return true end + +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 @@ --- Build back-end for using Makefile-based packages. -module("luarocks.build.make", package.seeall) +--module("luarocks.build.make", package.seeall) +local make = {} local fs = require("luarocks.fs") local util = require("luarocks.util") @@ -36,7 +37,7 @@ end -- @param rockspec table: the loaded rockspec. -- @return boolean or (nil, string): true if no errors ocurred, -- nil and an error message otherwise. -function run(rockspec) +function make.run(rockspec) assert(type(rockspec) == "table") local build = rockspec.build @@ -90,3 +91,5 @@ function run(rockspec) end return true end + +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 @@ --- Fetch back-end for retrieving sources from CVS. -module("luarocks.fetch.cvs", package.seeall) +--module("luarocks.fetch.cvs", package.seeall) +local cvs = {} local fs = require("luarocks.fs") local dir = require("luarocks.dir") @@ -13,7 +14,7 @@ local util = require("luarocks.util") -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function cvs.get_sources(rockspec, extract, dest_dir) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) @@ -43,3 +44,5 @@ function get_sources(rockspec, extract, dest_dir) return module, store_dir end + +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 @@ --- Fetch back-end for retrieving sources from GIT. -module("luarocks.fetch.git", package.seeall) +--module("luarocks.fetch.git", package.seeall) +local git = {} local fs = require("luarocks.fs") local dir = require("luarocks.dir") @@ -27,7 +28,7 @@ end -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir, depth) +function git.get_sources(rockspec, extract, dest_dir, depth) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) @@ -81,3 +82,5 @@ function get_sources(rockspec, extract, dest_dir, depth) fs.pop_dir() return module, store_dir end + +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 @@ --- Fetch back-end for retrieving sources from local Git repositories. -module("luarocks.fetch.git_file", package.seeall) +--module("luarocks.fetch.git_file", package.seeall) +local git_file = {} local git = require("luarocks.fetch.git") @@ -11,7 +12,9 @@ local git = require("luarocks.fetch.git") -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function git_file.get_sources(rockspec, extract, dest_dir) rockspec.source.url = rockspec.source.url:gsub("^git.file://", "") return git.get_sources(rockspec, extract, dest_dir) end + +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 @@ -- source = { url = "git+http://example.com/foo.git" } -- Prefer using the normal git:// fetch mode as it is more widely -- available in older versions of LuaRocks. -module("luarocks.fetch.git_http", package.seeall) +--module("luarocks.fetch.git_http", package.seeall) +local git_http = {} local git = require("luarocks.fetch.git") @@ -18,7 +19,9 @@ local git = require("luarocks.fetch.git") -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function git_http.get_sources(rockspec, extract, dest_dir) rockspec.source.url = rockspec.source.url:gsub("^git.", "") return git.get_sources(rockspec, extract, dest_dir, "--") end + +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 @@ --- Fetch back-end for retrieving sources from HG. -module("luarocks.fetch.hg", package.seeall) +--module("luarocks.fetch.hg", package.seeall) +local hg = {} local fs = require("luarocks.fs") local dir = require("luarocks.dir") @@ -13,7 +14,7 @@ local util = require("luarocks.util") -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function hg.get_sources(rockspec, extract, dest_dir) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) @@ -54,3 +55,5 @@ function get_sources(rockspec, extract, dest_dir) return module, store_dir end + +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 @@ --- Fetch back-end for retrieving sources from Surround SCM Server -module("luarocks.fetch.sscm", package.seeall) +--module("luarocks.fetch.sscm", package.seeall) +local sscm = {} local fs = require("luarocks.fs") local dir = require("luarocks.dir") @@ -12,7 +13,7 @@ local dir = require("luarocks.dir") -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function sscm.get_sources(rockspec, extract, dest_dir) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) @@ -40,3 +41,5 @@ function get_sources(rockspec, extract, dest_dir) -- FIXME: This function does not honor the dest_dir parameter. return module, working_dir end + +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 @@ --- Fetch back-end for retrieving sources from Subversion. -module("luarocks.fetch.svn", package.seeall) +--module("luarocks.fetch.svn", package.seeall) +local svn = {} local fs = require("luarocks.fs") local dir = require("luarocks.dir") @@ -13,7 +14,7 @@ local util = require("luarocks.util") -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function svn.get_sources(rockspec, extract, dest_dir) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) @@ -53,3 +54,5 @@ function get_sources(rockspec, extract, dest_dir) return module, store_dir end + +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 @@ --- Unix implementation of filesystem and platform abstractions. -module("luarocks.fs.unix", package.seeall) +--module("luarocks.fs.unix", package.seeall) +local unix = {} local fs = require("luarocks.fs") @@ -14,7 +15,7 @@ math.randomseed(os.time()) --- Annotate command string for quiet execution. -- @param cmd string: A command-line string. -- @return string: The command-line, with silencing annotation. -function quiet(cmd) +function unix.quiet(cmd) return cmd.." 1> /dev/null 2> /dev/null" end @@ -24,7 +25,7 @@ end -- pathname absolute, or the current dir in the dir stack if -- not given. -- @return string: The pathname converted to absolute. -function absolute_name(pathname, relative_to) +function unix.absolute_name(pathname, relative_to) assert(type(pathname) == "string") assert(type(relative_to) == "string" or not relative_to) @@ -43,7 +44,7 @@ end -- @param version string: rock version to be used in loader context. -- @return boolean or (nil, string): True if succeeded, or nil and -- an error message. -function wrap_script(file, dest, name, version) +function unix.wrap_script(file, dest, name, version) assert(type(file) == "string") assert(type(dest) == "string") @@ -72,7 +73,7 @@ end -- @param filename string: the file name with full path. -- @return boolean: returns true if file is an actual binary -- (or if it couldn't check) or false if it is a Lua wrapper. -function is_actual_binary(filename) +function unix.is_actual_binary(filename) if filename:match("%.lua$") then return false end @@ -89,7 +90,7 @@ function is_actual_binary(filename) return first ~= "#!" end -function copy_binary(filename, dest) +function unix.copy_binary(filename, dest) return fs.copy(filename, dest, "0755") end @@ -103,6 +104,8 @@ end -- which will replace old_file. -- @return boolean or (nil, string): True if succeeded, or nil and -- an error message. -function replace_file(old_file, new_file) +function unix.replace_file(old_file, new_file) return os.rename(new_file, old_file) end + +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 @@ --- Windows implementation of filesystem and platform abstractions. -- Download http://unxutils.sourceforge.net/ for Windows GNU utilities -- used by this module. -module("luarocks.fs.win32", package.seeall) +--module("luarocks.fs.win32", package.seeall) +local win32 = {} local fs = require("luarocks.fs") @@ -21,7 +22,7 @@ os.execute = function(cmd, ...) return _execute(_prefix..cmd, ...) end --- Annotate command string for quiet execution. -- @param cmd string: A command-line string. -- @return string: The command-line, with silencing annotation. -function quiet(cmd) +function win32.quiet(cmd) return cmd.." 2> NUL 1> NUL" end @@ -43,7 +44,7 @@ end -- Adds double quotes and escapes. -- @param arg string: Unquoted argument. -- @return string: Quoted argument. -function Q(arg) +function win32.Q(arg) assert(type(arg) == "string") -- Quote DIR for Windows if arg:match("^[%.a-zA-Z]?:?[\\/]") then @@ -64,7 +65,7 @@ end -- Adds double quotes and escapes. -- @param arg string: Unquoted argument. -- @return string: Quoted argument. -function Qb(arg) +function win32.Qb(arg) assert(type(arg) == "string") -- Quote DIR for Windows if arg:match("^[%.a-zA-Z]?:?[\\/]") then @@ -86,7 +87,7 @@ end -- pathname absolute, or the current dir in the dir stack if -- not given. -- @return string: The pathname converted to absolute. -function absolute_name(pathname, relative_to) +function win32.absolute_name(pathname, relative_to) assert(type(pathname) == "string") assert(type(relative_to) == "string" or not relative_to) @@ -107,7 +108,7 @@ end -- @param version string: rock version to be used in loader context. -- @return boolean or (nil, string): True if succeeded, or nil and -- an error message. -function wrap_script(file, dest, name, version) +function win32.wrap_script(file, dest, name, version) assert(type(file) == "string") assert(type(dest) == "string") @@ -128,7 +129,7 @@ function wrap_script(file, dest, name, version) return true end -function is_actual_binary(name) +function win32.is_actual_binary(name) name = name:lower() if name:match("%.bat$") or name:match("%.exe$") then return true @@ -136,7 +137,7 @@ function is_actual_binary(name) return false end -function copy_binary(filename, dest) +function win32.copy_binary(filename, dest) local ok, err = fs.copy(filename, dest) if not ok then return nil, err @@ -158,11 +159,11 @@ function copy_binary(filename, dest) return true end -function chmod(filename, mode) +function win32.chmod(filename, mode) return true end -function get_permissions(filename) +function win32.get_permissions(filename) return "" end @@ -177,7 +178,7 @@ end -- which will replace old_file. -- @return boolean or (nil, string): True if succeeded, or nil and -- an error message. -function replace_file(old_file, new_file) +function win32.replace_file(old_file, new_file) os.remove(old_file) return os.rename(new_file, old_file) end @@ -188,7 +189,7 @@ end -- for checking the result of subsequent operations. -- @param file string: filename to test -- @return boolean: true if file exists, false otherwise. -function is_writable(file) +function win32.is_writable(file) assert(file) file = dir.normalize(file) local result @@ -212,3 +213,5 @@ function is_writable(file) end return result end + +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 @@ -- Copyright (c) 2008 rainforce.org, MIT License -- Project home: http://code.google.com/p/python-patch/ . -module("luarocks.tools.patch", package.seeall) +--module("luarocks.tools.patch", package.seeall) +local patch = {} local fs = require("luarocks.fs") local util = require("luarocks.util") @@ -153,7 +154,7 @@ local function match_linerange(line) return m1, m2, m3, m4 end -function read_patch(filename, data) +function patch.read_patch(filename, data) -- define possible file regions that will direct the parser flow local state = 'header' -- 'header' - comments before the patch body @@ -564,7 +565,7 @@ local function strip_dirs(filename, strip) return filename end -function apply_patch(patch, strip) +function patch.apply_patch(patch, strip) local all_ok = true local total = #patch.source for fileno, filename in ipairs(patch.source) do @@ -705,3 +706,5 @@ function apply_patch(patch, strip) -- todo: check for premature eof return all_ok end + +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 @@ --- A pure-Lua implementation of untar (unpacking .tar archives) -module("luarocks.tools.tar", package.seeall) +--module("luarocks.tools.tar", package.seeall) +local tar = {} local fs = require("luarocks.fs") local dir = require("luarocks.dir") @@ -82,7 +83,7 @@ local function read_header_block(block) return header end -function untar(filename, destdir) +function tar.untar(filename, destdir) assert(type(filename) == "string") assert(type(destdir) == "string") @@ -144,3 +145,5 @@ function untar(filename, destdir) end return true end + +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 @@ --- A Lua implementation of .zip file archiving (used for creating .rock files), -- using only lua-zlib. -module("luarocks.tools.zip", package.seeall) +--module("luarocks.tools.zip", package.seeall) +local zip = {} local zlib = require("zlib") local fs = require("luarocks.fs") @@ -188,7 +189,7 @@ end --- Return a zip handle open for writing. -- @param name filename of the zipfile to be created. -- @return a zip handle, or nil in case of error. -function new_zipwriter(name) +function zip.new_zipwriter(name) local zw = {} @@ -214,8 +215,8 @@ end -- additional arguments. -- @return boolean or (boolean, string): true on success, -- false and an error message on failure. -function zip(zipfile, ...) - local zw = new_zipwriter(zipfile) +function zip.zip(zipfile, ...) + local zw = zip.new_zipwriter(zipfile) if not zw then return nil, "error opening "..zipfile end @@ -243,3 +244,5 @@ function zip(zipfile, ...) return ok, err end + +return zip -- cgit v1.2.3-55-g6feb