From f02d6d296428902c4536353e55f43de11effd675 Mon Sep 17 00:00:00 2001 From: hisham Date: Thu, 22 Oct 2009 22:38:14 +0000 Subject: use new install and config scheme git-svn-id: http://luarocks.org/svn/luarocks/trunk@107 9ca3f7c1-7366-0410-b1a3-b5c78f85698c --- src/luarocks/cfg.lua | 41 ++++++++++++++++++++++------------------- src/luarocks/fetch.lua | 24 +++++++++++++++++------- src/luarocks/make.lua | 4 ++-- 3 files changed, 41 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 2758ce0f..881db683 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -9,7 +9,10 @@ local rawset, next, table, pairs, print, require, io, os, setmetatable, pcall, i -- file format documentation for details. module("luarocks.cfg") -program_version = "2.0" +-- Load site-local global configurations +local config = require("luarocks.config") + +program_version = "2.0.1" user_agent = "LuaRocks/"..program_version local persist = require("luarocks.persist") @@ -31,12 +34,12 @@ local detected = {} local system,proc -- A proper installation of LuaRocks will hardcode the system --- and proc values with LUAROCKS_UNAME_S and LUAROCKS_UNAME_M, +-- and proc values with config.LUAROCKS_UNAME_S and config.LUAROCKS_UNAME_M, -- so that this detection does not run every time. When it is -- performed, we use the Unix way to identify the system, -- even on Windows (assuming UnxUtils or Cygwin). -system = LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") -proc = LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") +system = config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") +proc = config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") if proc:match("i[%d]86") then proc = "x86" elseif proc:match("amd64") or proc:match("x86_64") then @@ -82,9 +85,9 @@ end variables = {} rocks_trees = {} -persist.load_into_table(LUAROCKS_SYSCONFIG or sys_config_file, _M) +persist.load_into_table(config.LUAROCKS_SYSCONFIG or sys_config_file, _M) -if not LUAROCKS_FORCE_CONFIG then +if not config.LUAROCKS_FORCE_CONFIG then home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file local home_overrides = persist.load_into_table(home_config_file, { home = home }) if home_overrides then @@ -97,14 +100,14 @@ 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) + if config.LUAROCKS_ROCKS_TREE then + table.insert(rocks_trees, config.LUAROCKS_ROCKS_TREE) end end -- Configure defaults: -local root = LUAROCKS_ROCKS_TREE or home_tree +local root = config.LUAROCKS_ROCKS_TREE or home_tree local defaults = { root_dir = root, rocks_dir = root.."/lib/luarocks/rocks", @@ -123,9 +126,9 @@ local defaults = { }, lua_extension = "lua", - lua_interpreter = LUA_INTERPRETER or "lua", - downloader = LUAROCKS_DOWNLOADER or "wget", - md5checker = LUAROCKS_MD5CHECKER or "md5sum", + lua_interpreter = config.LUA_INTERPRETER or "lua", + downloader = config.LUAROCKS_DOWNLOADER or "wget", + md5checker = config.LUAROCKS_MD5CHECKER or "md5sum", variables = {}, @@ -149,9 +152,9 @@ if detected.windows then defaults.external_lib_extension = "dll" defaults.obj_extension = "obj" 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.variables.LUA_BINDIR = config.LUA_BINDIR and config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" + defaults.variables.LUA_INCDIR = config.LUA_INCDIR and config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" + defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR and config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" defaults.cmake_generator = "MinGW Makefiles" defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc defaults.makefile = "Makefile.win" @@ -178,9 +181,9 @@ if detected.unix then defaults.external_lib_extension = "so" defaults.obj_extension = "o" 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" - defaults.variables.LUA_LIBDIR = LUA_LIBDIR or "/usr/local/lib" + defaults.variables.LUA_BINDIR = config.LUA_BINDIR or "/usr/local/bin" + defaults.variables.LUA_INCDIR = config.LUA_INCDIR or "/usr/local/include" + defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR or "/usr/local/lib" defaults.variables.CFLAGS = "-O2" defaults.cmake_generator = "Unix Makefiles" defaults.make = "make" @@ -245,7 +248,7 @@ end defaults.variables.LUA = defaults.lua_interpreter defaults.variables.LIB_EXTENSION = defaults.lib_extension defaults.variables.OBJ_EXTENSION = defaults.obj_extension -defaults.variables.LUAROCKS_PREFIX = LUAROCKS_PREFIX +defaults.variables.LUAROCKS_PREFIX = config.LUAROCKS_PREFIX -- Use defaults: diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 5e1f870d..073b14d1 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -146,9 +146,13 @@ function load_local_rockspec(filename) util.platform_overrides(rockspec.hooks) local basename = dir.base_name(filename) - rockspec.name = basename:match("(.*)-[^-]*-[0-9]*") - if not rockspec.name then - return nil, "Expected filename in format 'name-version-revision.rockspec'." + if basename == "rockspec" then + rockspec.name = rockspec.package:lower() + else + rockspec.name = basename:match("(.*)-[^-]*-[0-9]*") + if not rockspec.name then + return nil, "Expected filename in format 'name-version-revision.rockspec'." + end end local protocol, pathname = dir.split_url(rockspec.source.url) @@ -164,7 +168,7 @@ function load_local_rockspec(filename) end local name_version = rockspec.package:lower() .. "-" .. rockspec.version - if basename ~= name_version .. ".rockspec" then + if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." end @@ -207,9 +211,15 @@ end function load_rockspec(filename, location) assert(type(filename) == "string") - local name = dir.base_name(filename):match("(.*)%.rockspec") - if not name then - return nil, "Filename '"..filename.."' does not look like a rockspec." + local name + local basename = dir.base_name(filename) + if basename == "rockspec" then + name = "rockspec" + else + name = basename:match("(.*)%.rockspec") + if not name and not basename == "rockspec" then + return nil, "Filename '"..filename.."' does not look like a rockspec." + end end local err, errcode diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua index 1365cf13..cb2ba374 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua @@ -34,7 +34,7 @@ function run(...) if not rockspec then local files = fs.list_dir(fs.current_dir()) for _, file in pairs(files) do - if file:match(".rockspec$") then + if file:match("rockspec$") then if rockspec then return nil, "Please specify which rockspec file to use." else @@ -46,7 +46,7 @@ function run(...) return nil, "Argument missing: please specify a rockspec to use on current directory." end end - if not rockspec:match("%.rockspec$") then + if not rockspec:match("rockspec$") then return nil, "Invalid argument: 'make' takes a rockspec as a parameter. See help." end -- cgit v1.2.3-55-g6feb