From f072d458fa89d1af16284353a9a74d2172abc83c Mon Sep 17 00:00:00 2001 From: hisham Date: Sun, 5 Jul 2009 03:46:41 +0000 Subject: progress converting LuaRocks commands to 2.0 format git-svn-id: http://luarocks.org/svn/luarocks/trunk@38 9ca3f7c1-7366-0410-b1a3-b5c78f85698c --- src/luarocks.lua | 2 +- src/luarocks/cfg.lua | 98 ++++++++++++++++++++++++------------------ src/luarocks/command_line.lua | 15 +++++-- src/luarocks/fs/lua.lua | 13 ++++++ src/luarocks/fs/unix/tools.lua | 9 ++++ src/luarocks/list.lua | 4 +- src/luarocks/make_manifest.lua | 4 +- src/luarocks/manif.lua | 34 +++++++++------ src/luarocks/pack.lua | 33 +++++++++++++- src/luarocks/path.lua | 84 ++++++++++++++++++++++-------------- src/luarocks/remove.lua | 14 +++--- src/luarocks/rep.lua | 10 ++--- src/luarocks/util.lua | 2 - src/luarocks/validate.lua | 3 +- 14 files changed, 211 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/luarocks.lua b/src/luarocks.lua index 8530fd90..3e2088a4 100644 --- a/src/luarocks.lua +++ b/src/luarocks.lua @@ -23,7 +23,7 @@ local function load_rocks_trees() local any_ok = false local trees = {} for _, tree in pairs(cfg.rocks_trees) do - local rocks_dir = tree .. "/rocks/" + local rocks_dir = path.rocks_dir(tree) local manifest, err = manif_core.load_local_manifest(rocks_dir) if manifest then any_ok = true diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index f74c40ad..d4bcbfb6 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -10,6 +10,7 @@ local rawset, next, table, pairs, print, require, io, os, setmetatable, pcall = module("luarocks.cfg") program_version = "1.1" +user_agent = "LuaRocks/"..program_version local persist = require("luarocks.persist") @@ -24,6 +25,8 @@ else os.exit(1) end +-- System detection: + local detected = {} local system,proc @@ -61,6 +64,8 @@ else -- Fall back to Unix in unknown systems. end +-- Path configuration: + local sys_config_file, home_config_file, home_tree if detected.windows then home = os.getenv("APPDATA") or "c:" @@ -88,46 +93,65 @@ if not LUAROCKS_FORCE_CONFIG then end end +if not next(rocks_trees) then + if home_tree then + table.insert(rocks_trees, home_tree) + end + if LUAROCKS_ROCKS_TREE then + table.insert(rocks_trees, LUAROCKS_ROCKS_TREE) + end +end + +-- Configure defaults: + +local root = LUAROCKS_ROCKS_TREE or home_tree local defaults = { + root_dir = root, + rocks_dir = root.."/lib/luarocks/rocks", + scripts_dir = root.."/bin/", + lua_modules_dir = root.."/share/lua/5.1/", + bin_modules_dir = root.."/lib/lua/5.1/", + arch = "unknown", lib_extension = "unknown", obj_extension = "unknown", + rocks_servers = { "http://luarocks.luaforge.net/rocks" }, + lua_extension = "lua", lua_interpreter = LUA_INTERPRETER or "lua", downloader = LUAROCKS_DOWNLOADER or "wget", md5checker = LUAROCKS_MD5CHECKER or "md5sum", - variables = {} -} -defaults.external_deps_subdirs = { - bin = "bin", - lib = "lib", - include = "include" + variables = {}, + + external_deps_subdirs = { + bin = "bin", + lib = "lib", + include = "include" + }, + runtime_external_deps_subdirs = { + bin = "bin", + lib = "lib", + include = "include" + }, } -defaults.runtime_external_deps_subdirs = defaults.external_deps_subdirs if detected.windows then home_config_file = home_config_file:gsub("\\","/") + defaults.arch = "win32-"..proc + defaults.platforms = {"win32", "windows" } defaults.lib_extension = "dll" + defaults.external_lib_extension = "dll" defaults.obj_extension = "obj" - local rootdir = LUAROCKS_ROCKS_TREE or home_tree - defaults.root_dir = rootdir - defaults.rocks_dir = rootdir.."/rocks/" - defaults.scripts_dir = rootdir.."/bin/" defaults.external_deps_dirs = { "c:/external/" } defaults.variables.LUA_BINDIR = LUA_BINDIR and LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" defaults.variables.LUA_INCDIR = LUA_INCDIR and LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" defaults.variables.LUA_LIBDIR = LUA_LIBDIR and LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" - defaults.arch = "win32-"..proc - defaults.platforms = {"win32", "windows" } defaults.cmake_generator = "MinGW Makefiles" - -- TODO: Split Windows flavors between mingw and msvc - -- defaults.make = "make" - -- defaults.makefile = "Makefile" - defaults.make = "nmake" + defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc defaults.makefile = "Makefile.win" defaults.variables.CC = "cl" defaults.variables.LD = "link" @@ -148,11 +172,8 @@ end if detected.unix then defaults.lib_extension = "so" + defaults.external_lib_extension = "so" defaults.obj_extension = "o" - local rootdir = LUAROCKS_ROCKS_TREE or home_tree - defaults.root_dir = rootdir - defaults.rocks_dir = rootdir.."/rocks/" - defaults.scripts_dir = rootdir.."/bin/" defaults.external_deps_dirs = { "/usr/local", "/usr" } defaults.variables.LUA_BINDIR = LUA_BINDIR or "/usr/local/bin" defaults.variables.LUA_INCDIR = LUA_INCDIR or "/usr/local/include" @@ -186,8 +207,6 @@ if detected.cygwin then defaults.variables.LIBFLAG = "-shared" end -defaults.external_lib_extension = defaults.lib_extension - if detected.macosx then defaults.external_lib_extension = "dylib" defaults.arch = "macosx-"..proc @@ -224,16 +243,10 @@ defaults.variables.LIB_EXTENSION = defaults.lib_extension defaults.variables.OBJ_EXTENSION = defaults.obj_extension defaults.variables.LUAROCKS_PREFIX = LUAROCKS_PREFIX -local cfg_mt = { - __index = function(t, k) - local default = defaults[k] - if default then - rawset(t, k, default) - end - return default - end -} +-- Use defaults: +-- Populate values from 'defaults.variables' in 'variables' if they were not +-- already set by user. if not _M.variables then _M.variables = {} end @@ -243,15 +256,14 @@ for k,v in pairs(defaults.variables) do end end -setmetatable(_M, cfg_mt) - -if not next(rocks_trees) then - if home_tree then - table.insert(rocks_trees, home_tree) - end - if LUAROCKS_ROCKS_TREE then - table.insert(rocks_trees, LUAROCKS_ROCKS_TREE) +-- For values not set in the config file, use values from the 'defaults' table. +local cfg_mt = { + __index = function(t, k) + local default = defaults[k] + if default then + rawset(t, k, default) + end + return default end -end - -user_agent = "LuaRocks/"..program_version +} +setmetatable(_M, cfg_mt) diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 972302ee..963916bd 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -5,6 +5,7 @@ module("luarocks.command_line", package.seeall) local util = require("luarocks.util") local cfg = require("luarocks.cfg") local fs = require("luarocks.fs") +local path = require("luarocks.path") --- Display an error message and exit. -- @param message string: The error message. @@ -50,16 +51,20 @@ function run_command(...) end local root_dir = fs.absolute_name(flags["to"]) cfg.root_dir = root_dir - cfg.rocks_dir = root_dir.."/rocks" - cfg.scripts_dir = root_dir.."/bin" + cfg.rocks_dir = path.rocks_dir(root_dir) + cfg.scripts_dir = path.scripts_dir(root_dir) + cfg.lua_modules_dir = path.lua_modules_dir(root_dir) + cfg.bin_modules_dir = path.bin_modules_dir(root_dir) else local trees = cfg.rocks_trees for i = #trees, 1, -1 do local tree = trees[i] if fs.make_dir(tree) and fs.is_writable(tree) then cfg.root_dir = tree - cfg.rocks_dir = tree.."/rocks" - cfg.scripts_dir = rawget(cfg, "scripts_dir") or tree.."/bin" + cfg.rocks_dir = path.rocks_dir(tree) + cfg.scripts_dir = rawget(cfg, "scripts_dir") or path.scripts_dir(tree) + cfg.lua_modules_dir = rawget(cfg, "lua_modules_dir") or path.lua_modules_dir(tree) + cfg.bin_modules_dir = rawget(cfg, "bin_modules_dir") or path.bin_modules_dir(tree) break end end @@ -68,6 +73,8 @@ function run_command(...) cfg.root_dir = cfg.root_dir:gsub("/+$", "") cfg.rocks_dir = cfg.rocks_dir:gsub("/+$", "") cfg.scripts_dir = cfg.scripts_dir:gsub("/+$", "") + cfg.lua_modules_dir = cfg.lua_modules_dir:gsub("/+$", "") + cfg.bin_modules_dir = cfg.bin_modules_dir:gsub("/+$", "") cfg.variables.ROCKS_TREE = cfg.root_dir cfg.variables.SCRIPTS_DIR = cfg.scripts_dir diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 91cabe51..013fad5f 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -177,6 +177,19 @@ function remove_dir_if_empty(d) lfs.rmdir(d) end +--- Remove a directory if it is empty. +-- Does not return errors (for example, if directory is not empty or +-- if already does not exist) +-- @param d string: pathname of directory to remove. +function remove_dir_tree_if_empty(d) + assert(d) + for i=1,10 do + print(d) + lfs.rmdir(d) + d = dir.dir_name(d) + end +end + --- Copy a file. -- @param src string: Pathname of source -- @param dest string: Pathname of destination diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 5d3afd5e..71dfe074 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -79,6 +79,15 @@ function remove_dir_if_empty(d) fs.execute_string("rmdir "..fs.Q(d).." 1> /dev/null 2> /dev/null") end +--- Remove a directory if it is empty. +-- Does not return errors (for example, if directory is not empty or +-- if already does not exist) +-- @param dir string: pathname of directory to remove. +function remove_dir_tree_if_empty(d) + assert(d) + fs.execute_string("rmdir -p "..fs.Q(d).." 1> /dev/null 2> /dev/null") +end + --- Copy a file. -- @param src string: Pathname of source -- @param dest string: Pathname of destination diff --git a/src/luarocks/list.lua b/src/luarocks/list.lua index f918640c..87c5a2ae 100644 --- a/src/luarocks/list.lua +++ b/src/luarocks/list.lua @@ -6,7 +6,7 @@ module("luarocks.list", package.seeall) local search = require("luarocks.search") local cfg = require("luarocks.cfg") local util = require("luarocks.util") -local dir = require("luarocks.dir") +local path = require("luarocks.path") help_summary = "Lists currently installed rocks." @@ -24,7 +24,7 @@ function run(...) local query = search.make_query(filter or "", version) query.exact_name = false for _, tree in ipairs(cfg.rocks_trees) do - search.manifest_search(results, dir.path(tree, "rocks"), query) + search.manifest_search(results, path.rocks_dir(tree), query) end print() print("Installed rocks:") diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index 6edbd14b..622c21a0 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua @@ -23,10 +23,10 @@ function run(repo) print("Making manifest for "..repo) - ok = manif.make_manifest(repo) + ok, err = manif.make_manifest(repo) if ok then print("Generating index.html for "..repo) manif.make_index(repo) end - return ok + return ok, err end diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 74289ee5..5f4e60a9 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -28,20 +28,31 @@ local function rename_module(file, pkgid) return dir.path(path, pkgid.."-"..name) end -local function make_global_lib(repo, manifest) - local lib_dir = dir.path(dir.dir_name(repo), "lib") - fs.make_dir(lib_dir) +local function update_global_lib(repo, manifest) + fs.make_dir(cfg.lua_modules_dir) + fs.make_dir(cfg.bin_modules_dir) for rock, modules in pairs(manifest.modules) do for module, file in pairs(modules) do - if not file:match("^"..lib_dir) then + local module_type, modules_dir + + if file:match("%."..cfg.lua_extension.."$") then + module_type = "lua" + modules_dir = cfg.lua_modules_dir + else + module_type = "bin" + modules_dir = cfg.bin_modules_dir + end + + if not file:match("^"..modules_dir) then local path_in_rock = dir.strip_base_dir(file:sub(#dir.path(repo, module)+2)) local module_dir = dir.dir_name(path_in_rock) - local dest = dir.path(lib_dir, path_in_rock) + local dest = dir.path(modules_dir, path_in_rock) if module_dir ~= "" then fs.make_dir(dir.dir_name(dest)) end if not fs.exists(dest) then - fs.copy(file, dest) + fs.move(file, dest) + fs.remove_dir_tree_if_empty(dir.dir_name(file)) manifest.modules[rock][module] = dest else local current = find_module_at_file(dest, modules) @@ -55,14 +66,14 @@ local function make_global_lib(repo, manifest) local ok, err = fs.move(dest, newname) if ok then manifest.modules[rock][current] = newname - fs.copy(file, dest) + fs.move(file, dest) + fs.remove_dir_tree_if_empty(dir.dir_name(file)) manifest.modules[rock][module] = dest else util.warning(err) end end end - -- TODO end else print("DBG file already in place.") @@ -275,7 +286,7 @@ function update_manifest(name, version, repo) local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} store_results(results, manifest) - make_global_lib(repo, manifest) + update_global_lib(repo, manifest) return save_manifest(repo, manifest) end @@ -299,10 +310,7 @@ function make_manifest(repo) local manifest = { repository = {}, modules = {}, commands = {} } manif_core.manifest_cache[repo] = manifest store_results(results, manifest) - local lib_dir = dir.path(dir.dir_name(repo), "lib") - -- TODO - fs.delete(lib_dir) - make_global_lib(repo, manifest) + update_global_lib(repo, manifest) return save_manifest(repo, manifest) end diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 7b1c68dd..4bfdb320 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua @@ -10,6 +10,7 @@ local fs = require("luarocks.fs") local cfg = require("luarocks.cfg") local util = require("luarocks.util") local dir = require("luarocks.dir") +local manif = require("luarocks.manif") help_summary = "Create a rock, packing sources or binaries." help_arguments = "{| []}" @@ -81,10 +82,37 @@ local function pack_binary_rock(name, version) if not fs.exists(prefix) then return nil, "'"..name.." "..version.."' does not seem to be an installed rock." end + local name_version = name .. "-" .. version local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") - fs.change_dir(prefix) - if not rep.is_binary_rock(name, version) then + + local temp_dir = fs.make_temp_dir("pack") + fs.copy_contents(prefix, temp_dir) + + local is_binary = false + local manifest = manif.load_manifest(cfg.rocks_dir) + for module_name, module_data in pairs(manifest.modules) do + for package, file in pairs(module_data) do + if package == name.."/"..version then + local dest + if file:match("^"..cfg.lua_modules_dir) then + local pathname = file:sub(#cfg.lua_modules_dir + 1) + dest = dir.path(temp_dir, "lua", dir.dir_name(pathname)) + elseif file:match("^"..cfg.bin_modules_dir) then + local pathname = file:sub(#cfg.bin_modules_dir + 1) + dest = dir.path(temp_dir, "lib", dir.dir_name(pathname)) + is_binary = true + end + if dest then + fs.make_dir(dest) + fs.copy(file, dest) + end + end + end + end + + fs.change_dir(temp_dir) + if not is_binary and not rep.has_binaries(name, version) then rock_file = rock_file:gsub("%."..cfg.arch:gsub("%-","%%-").."%.", ".all.") end fs.delete(rock_file) @@ -92,6 +120,7 @@ local function pack_binary_rock(name, version) return nil, "Failed packing "..rock_file end fs.pop_dir() + fs.delete(temp_dir) return rock_file end diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index c9085431..fccabc99 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua @@ -16,115 +16,135 @@ function rockspec_name_from_rock(rock_name) return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" end +function rocks_dir(repo) + return dir.path(repo, "lib", "luarocks", "rocks") +end + +function scripts_dir(repo) + return dir.path(repo, "bin") +end + +function lua_modules_dir(repo) + return dir.path(repo, "share", "lua", "5.1") +end + +function bin_modules_dir(repo) + return dir.path(repo, "lib", "lua", "5.1") +end + +function manifest_file(repo) + return dir.path(repo, "lib", "luarocks", "rocks", "manifest") +end + --- Get the repository directory for all versions of a package. -- @param name string: The package name. -- @return string: The resulting path -- does not guarantee that --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- the package (and by extension, the path) exists. -function versions_dir(name, repo) +function versions_dir(name, rocks_dir) assert(type(name) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name) + return dir.path(rocks_dir or cfg.rocks_dir, name) end --- Get the local installation directory (prefix) for a package. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the path) exists. -function install_dir(name, version, repo) +function install_dir(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version) + return dir.path(rocks_dir or cfg.rocks_dir, name, version) end --- Get the local filename of the rockspec of an installed rock. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the file) exists. -function rockspec_file(name, version, repo) +function rockspec_file(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") + return dir.path(rocks_dir or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") end --- Get the local installation directory for C libraries of a package. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the path) exists. -function lib_dir(name, version, repo) +function lib_dir(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version, "lib") + return dir.path(rocks_dir or cfg.rocks_dir, name, version, "lib") end --- Get the local installation directory for Lua modules of a package. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the path) exists. -function lua_dir(name, version, repo) +function lua_dir(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version, "lua") + return dir.path(rocks_dir or cfg.rocks_dir, name, version, "lua") end --- Get the local installation directory for documentation of a package. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the path) exists. -function doc_dir(name, version, repo) +function doc_dir(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version, "doc") + return dir.path(rocks_dir or cfg.rocks_dir, name, version, "doc") end --- Get the local installation directory for configuration files of a package. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the path) exists. -function conf_dir(name, version, repo) +function conf_dir(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version, "conf") + return dir.path(rocks_dir or cfg.rocks_dir, name, version, "conf") end --- Get the local installation directory for command-line scripts -- of a package. -- @param name string: The package name. -- @param version string: The package version. --- @param repo string or nil: If given, specifies the local repository to use. +-- @param rocks_dir string or nil: If given, specifies the local repository to use. -- @return string: The resulting path -- does not guarantee that -- the package (and by extension, the path) exists. -function bin_dir(name, version, repo) +function bin_dir(name, version, rocks_dir) assert(type(name) == "string") assert(type(version) == "string") - assert(not repo or type(repo) == "string") + assert(not rocks_dir or type(rocks_dir) == "string") - return dir.path(repo or cfg.rocks_dir, name, version, "bin") + return dir.path(rocks_dir or cfg.rocks_dir, name, version, "bin") end --- Extract name, version and arch of a rock filename. diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index d7162336..ba70f53e 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua @@ -101,7 +101,7 @@ local function delete_versions(name, versions) return true end ---- Driver function for the "install" command. +--- Driver function for the "remove" command. -- @param name string: name of a rock. If a version is given, refer to -- a specific version; otherwise, try to remove all versions. -- @param version string: When passing a package name, a version number @@ -117,6 +117,8 @@ function run(...) local results = {} search.manifest_search(results, cfg.rocks_dir, search.make_query(name, version)) + print("remove functionality is currently broken") + --[[ local versions = results[name] if not versions then return nil, "Could not find rock '"..name..(version and " "..version or "").."' in local tree." @@ -139,10 +141,11 @@ function run(...) print() end local ok, err1 = delete_versions(name, versions) - local ok, err2 = manif.make_manifest(cfg.rocks_dir) - if err1 or err2 then - return nil, err1 or err2 - end + -- FIXME + -- local ok, err2 = manif.make_manifest(cfg.rocks_dir) + -- if err1 or err2 then + -- return nil, err1 or err2 + -- end else if not second then print("Will not remove "..name.." "..version..".") @@ -159,5 +162,6 @@ function run(...) return nil, "Failed removing." end end + ]] return true end diff --git a/src/luarocks/rep.lua b/src/luarocks/rep.lua index 392c4353..2c7659c1 100644 --- a/src/luarocks/rep.lua +++ b/src/luarocks/rep.lua @@ -143,17 +143,13 @@ function package_commands(package, version) return result end ---- Check if a rock contains binary parts or if it is pure Lua. +--- Check if a rock contains binary executables. -- @param name string: name of an installed rock -- @param version string: version of an installed rock -- @return boolean: returns true if rock contains platform-specific --- binary code, or false if it is a pure-Lua rock. -function is_binary_rock(name, version) +-- binary executables, or false if it is a pure-Lua rock. +function has_binaries(name, version) local bin_dir = path.bin_dir(name, version) - local lib_dir = path.lib_dir(name, version) - if fs.exists(lib_dir) then - return true - end if fs.exists(bin_dir) then for _, name in pairs(fs.find(bin_dir)) do if fs.is_actual_binary(dir.path(bin_dir, name)) then diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 5686d0cf..6e9c3547 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -127,9 +127,7 @@ local var_format_pattern = "%$%((%a[%a%d_]+)%)" --- Display a warning message. -- @param msg string: the warning message function warning(msg) - print() print("Warning: "..msg) - print() end --- Create a new shallow copy of a table: a new table with diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua index 36163afe..fdcfd7c8 100644 --- a/src/luarocks/validate.lua +++ b/src/luarocks/validate.lua @@ -3,6 +3,7 @@ module("luarocks.validate", package.seeall) local fs = require("luarocks.fs") local dir = require("luarocks.dir") +local path = require("luarocks.path") local cfg = require("luarocks.cfg") local build = require("luarocks.build") local install = require("luarocks.install") @@ -36,7 +37,7 @@ end local function prepare_sandbox(file) local root_dir = fs.make_temp_dir(file):gsub("/+$", "") cfg.root_dir = root_dir - cfg.rocks_dir = root_dir.."/rocks" + cfg.rocks_dir = path.rocks_dir(root_dir) cfg.scripts_dir = root_dir.."/bin" cfg.variables.ROCKS_TREE = cfg.root_dir cfg.variables.SCRIPTS_DIR = cfg.scripts_dir -- cgit v1.2.3-55-g6feb