From 232317a633c5952f882ab4a891fa245d130dcc29 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Thu, 20 Mar 2014 22:42:36 +0400 Subject: Fixed strange things in deps modules + fixed a bug with luarocks.fs.lua.get_md5 --- src/luarocks/build/builtin.lua | 2 -- src/luarocks/fetch/git.lua | 2 +- src/luarocks/fetch/hg.lua | 2 +- src/luarocks/fs/lua.lua | 10 +++++----- src/luarocks/fs/unix.lua | 1 - src/luarocks/fs/win32.lua | 2 +- src/luarocks/tools/patch.lua | 8 +------- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index e154e65c..fa03f0d2 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -173,11 +173,9 @@ function builtin.run(rockspec) end local ok = true - local err = "Build error" local built_modules = {} local luadir = path.lua_dir(rockspec.name, rockspec.version) local libdir = path.lib_dir(rockspec.name, rockspec.version) - local docdir = path.doc_dir(rockspec.name, rockspec.version) --TODO EXEWRAPPER -- On Windows, compiles an .exe for each Lua file in build.install.bin, and -- replaces the filename with the .exe name. Strips the .lua extension if it exists, diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 7fe4c4ee..824ea905 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua @@ -67,7 +67,7 @@ function git.get_sources(rockspec, extract, dest_dir, depth) if not fs.execute(unpack(command)) then return nil, "Failed cloning git repository." end - local ok, err = fs.change_dir(module) + ok, err = fs.change_dir(module) if not ok then return nil, err end if tag_or_branch and not git_can_clone_by_tag() then local checkout_command = {fs.Q(git_cmd), "checkout", tag_or_branch} diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.lua index 44af3afa..31b4f716 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.lua @@ -45,7 +45,7 @@ function hg.get_sources(rockspec, extract, dest_dir) if not fs.execute(unpack(command)) then return nil, "Failed cloning hg repository." end - local ok, err = fs.change_dir(module) + ok, err = fs.change_dir(module) if not ok then return nil, err end fs.delete(dir.path(store_dir, module, ".hg")) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 495327ea..cd705eef 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -30,7 +30,7 @@ local dir_stack = {} math.randomseed(os.time()) -dir_separator = "/" +local dir_separator = "/" --- Quote argument for shell processing. -- Adds single quotes and escapes. @@ -683,10 +683,10 @@ if md5_ok then -- @return string: The MD5 checksum or nil + error function fs_lua.get_md5(file) file = fs.absolute_name(file) - local file = io.open(file, "rb") - if not file then return nil, "Failed to open file for reading: "..file end - local computed = md5.sumhexa(file:read("*a")) - file:close() + local file_handler = io.open(file, "rb") + if not file_handler then return nil, "Failed to open file for reading: "..file end + local computed = md5.sumhexa(file_handler:read("*a")) + file_handler:close() if computed then return computed end return nil, "Failed to compute MD5 hash for file "..file end diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 3e6b9080..a70ed116 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua @@ -7,7 +7,6 @@ local fs = require("luarocks.fs") local cfg = require("luarocks.cfg") local dir = require("luarocks.dir") -local fs = require("luarocks.fs") local util = require("luarocks.util") math.randomseed(os.time()) diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index c4c20349..238a25e9 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua @@ -144,7 +144,7 @@ function win32.copy_binary(filename, dest) end local exe_pattern = "%.[Ee][Xx][Ee]$" local base = dir.base_name(filename) - local dest = dir.dir_name(dest) + dest = dir.dir_name(dest) if base:match(exe_pattern) then base = base:gsub(exe_pattern, ".lua") local helpname = dest.."/"..base diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index a3e1602d..4479e642 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -6,6 +6,7 @@ -- Code is heavilly based on the Python-based patch.py version 8.06-1 -- Copyright (c) 2008 rainforce.org, MIT License -- Project home: http://code.google.com/p/python-patch/ . +-- Version 0.1 --module("luarocks.tools.patch", package.seeall) local patch = {} @@ -13,8 +14,6 @@ local patch = {} local fs = require("luarocks.fs") local util = require("luarocks.util") -local version = '0.1' - local io = io local os = os local string = string @@ -397,7 +396,6 @@ local function find_hunk(file, h, hno) for i=0,#file do local found = true local location = lineno - local total = #h.text - fuzz for l, hline in ipairs(h.text) do if l > fuzz then -- todo: \ No newline at the end of file @@ -448,9 +446,6 @@ local function load_file(filename) end local function find_hunks(file, hunks) - local matched = true - local lineno = 1 - local hno = nil for hno, h in ipairs(hunks) do find_hunk(file, h, hno) end @@ -459,7 +454,6 @@ end local function check_patched(file, hunks) local matched = true local lineno = 1 - local hno = nil local ok, err = pcall(function() if #file == 0 then error 'nomatch' -- cgit v1.2.3-55-g6feb