aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-10-22 22:38:14 +0000
committerhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-10-22 22:38:14 +0000
commitf02d6d296428902c4536353e55f43de11effd675 (patch)
tree85e2dfbf6a64bfb97f23d9402d90e136653458fb /src
parentbcd4c4609a082d8acc9f2da3a7538a7181820f54 (diff)
downloadluarocks-f02d6d296428902c4536353e55f43de11effd675.tar.gz
luarocks-f02d6d296428902c4536353e55f43de11effd675.tar.bz2
luarocks-f02d6d296428902c4536353e55f43de11effd675.zip
use new install and config scheme
git-svn-id: http://luarocks.org/svn/luarocks/trunk@107 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cfg.lua41
-rw-r--r--src/luarocks/fetch.lua24
-rw-r--r--src/luarocks/make.lua4
3 files changed, 41 insertions, 28 deletions
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
9-- file format documentation</a> for details. 9-- file format documentation</a> for details.
10module("luarocks.cfg") 10module("luarocks.cfg")
11 11
12program_version = "2.0" 12-- Load site-local global configurations
13local config = require("luarocks.config")
14
15program_version = "2.0.1"
13user_agent = "LuaRocks/"..program_version 16user_agent = "LuaRocks/"..program_version
14 17
15local persist = require("luarocks.persist") 18local persist = require("luarocks.persist")
@@ -31,12 +34,12 @@ local detected = {}
31local system,proc 34local system,proc
32 35
33-- A proper installation of LuaRocks will hardcode the system 36-- A proper installation of LuaRocks will hardcode the system
34-- and proc values with LUAROCKS_UNAME_S and LUAROCKS_UNAME_M, 37-- and proc values with config.LUAROCKS_UNAME_S and config.LUAROCKS_UNAME_M,
35-- so that this detection does not run every time. When it is 38-- so that this detection does not run every time. When it is
36-- performed, we use the Unix way to identify the system, 39-- performed, we use the Unix way to identify the system,
37-- even on Windows (assuming UnxUtils or Cygwin). 40-- even on Windows (assuming UnxUtils or Cygwin).
38system = LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") 41system = config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l")
39proc = LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") 42proc = config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l")
40if proc:match("i[%d]86") then 43if proc:match("i[%d]86") then
41 proc = "x86" 44 proc = "x86"
42elseif proc:match("amd64") or proc:match("x86_64") then 45elseif proc:match("amd64") or proc:match("x86_64") then
@@ -82,9 +85,9 @@ end
82variables = {} 85variables = {}
83rocks_trees = {} 86rocks_trees = {}
84 87
85persist.load_into_table(LUAROCKS_SYSCONFIG or sys_config_file, _M) 88persist.load_into_table(config.LUAROCKS_SYSCONFIG or sys_config_file, _M)
86 89
87if not LUAROCKS_FORCE_CONFIG then 90if not config.LUAROCKS_FORCE_CONFIG then
88 home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file 91 home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file
89 local home_overrides = persist.load_into_table(home_config_file, { home = home }) 92 local home_overrides = persist.load_into_table(home_config_file, { home = home })
90 if home_overrides then 93 if home_overrides then
@@ -97,14 +100,14 @@ if not next(rocks_trees) then
97 if home_tree then 100 if home_tree then
98 table.insert(rocks_trees, home_tree) 101 table.insert(rocks_trees, home_tree)
99 end 102 end
100 if LUAROCKS_ROCKS_TREE then 103 if config.LUAROCKS_ROCKS_TREE then
101 table.insert(rocks_trees, LUAROCKS_ROCKS_TREE) 104 table.insert(rocks_trees, config.LUAROCKS_ROCKS_TREE)
102 end 105 end
103end 106end
104 107
105-- Configure defaults: 108-- Configure defaults:
106 109
107local root = LUAROCKS_ROCKS_TREE or home_tree 110local root = config.LUAROCKS_ROCKS_TREE or home_tree
108local defaults = { 111local defaults = {
109 root_dir = root, 112 root_dir = root,
110 rocks_dir = root.."/lib/luarocks/rocks", 113 rocks_dir = root.."/lib/luarocks/rocks",
@@ -123,9 +126,9 @@ local defaults = {
123 }, 126 },
124 127
125 lua_extension = "lua", 128 lua_extension = "lua",
126 lua_interpreter = LUA_INTERPRETER or "lua", 129 lua_interpreter = config.LUA_INTERPRETER or "lua",
127 downloader = LUAROCKS_DOWNLOADER or "wget", 130 downloader = config.LUAROCKS_DOWNLOADER or "wget",
128 md5checker = LUAROCKS_MD5CHECKER or "md5sum", 131 md5checker = config.LUAROCKS_MD5CHECKER or "md5sum",
129 132
130 variables = {}, 133 variables = {},
131 134
@@ -149,9 +152,9 @@ if detected.windows then
149 defaults.external_lib_extension = "dll" 152 defaults.external_lib_extension = "dll"
150 defaults.obj_extension = "obj" 153 defaults.obj_extension = "obj"
151 defaults.external_deps_dirs = { "c:/external/" } 154 defaults.external_deps_dirs = { "c:/external/" }
152 defaults.variables.LUA_BINDIR = LUA_BINDIR and LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" 155 defaults.variables.LUA_BINDIR = config.LUA_BINDIR and config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin"
153 defaults.variables.LUA_INCDIR = LUA_INCDIR and LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" 156 defaults.variables.LUA_INCDIR = config.LUA_INCDIR and config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include"
154 defaults.variables.LUA_LIBDIR = LUA_LIBDIR and LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" 157 defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR and config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib"
155 defaults.cmake_generator = "MinGW Makefiles" 158 defaults.cmake_generator = "MinGW Makefiles"
156 defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc 159 defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc
157 defaults.makefile = "Makefile.win" 160 defaults.makefile = "Makefile.win"
@@ -178,9 +181,9 @@ if detected.unix then
178 defaults.external_lib_extension = "so" 181 defaults.external_lib_extension = "so"
179 defaults.obj_extension = "o" 182 defaults.obj_extension = "o"
180 defaults.external_deps_dirs = { "/usr/local", "/usr" } 183 defaults.external_deps_dirs = { "/usr/local", "/usr" }
181 defaults.variables.LUA_BINDIR = LUA_BINDIR or "/usr/local/bin" 184 defaults.variables.LUA_BINDIR = config.LUA_BINDIR or "/usr/local/bin"
182 defaults.variables.LUA_INCDIR = LUA_INCDIR or "/usr/local/include" 185 defaults.variables.LUA_INCDIR = config.LUA_INCDIR or "/usr/local/include"
183 defaults.variables.LUA_LIBDIR = LUA_LIBDIR or "/usr/local/lib" 186 defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR or "/usr/local/lib"
184 defaults.variables.CFLAGS = "-O2" 187 defaults.variables.CFLAGS = "-O2"
185 defaults.cmake_generator = "Unix Makefiles" 188 defaults.cmake_generator = "Unix Makefiles"
186 defaults.make = "make" 189 defaults.make = "make"
@@ -245,7 +248,7 @@ end
245defaults.variables.LUA = defaults.lua_interpreter 248defaults.variables.LUA = defaults.lua_interpreter
246defaults.variables.LIB_EXTENSION = defaults.lib_extension 249defaults.variables.LIB_EXTENSION = defaults.lib_extension
247defaults.variables.OBJ_EXTENSION = defaults.obj_extension 250defaults.variables.OBJ_EXTENSION = defaults.obj_extension
248defaults.variables.LUAROCKS_PREFIX = LUAROCKS_PREFIX 251defaults.variables.LUAROCKS_PREFIX = config.LUAROCKS_PREFIX
249 252
250-- Use defaults: 253-- Use defaults:
251 254
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)
146 util.platform_overrides(rockspec.hooks) 146 util.platform_overrides(rockspec.hooks)
147 147
148 local basename = dir.base_name(filename) 148 local basename = dir.base_name(filename)
149 rockspec.name = basename:match("(.*)-[^-]*-[0-9]*") 149 if basename == "rockspec" then
150 if not rockspec.name then 150 rockspec.name = rockspec.package:lower()
151 return nil, "Expected filename in format 'name-version-revision.rockspec'." 151 else
152 rockspec.name = basename:match("(.*)-[^-]*-[0-9]*")
153 if not rockspec.name then
154 return nil, "Expected filename in format 'name-version-revision.rockspec'."
155 end
152 end 156 end
153 157
154 local protocol, pathname = dir.split_url(rockspec.source.url) 158 local protocol, pathname = dir.split_url(rockspec.source.url)
@@ -164,7 +168,7 @@ function load_local_rockspec(filename)
164 end 168 end
165 169
166 local name_version = rockspec.package:lower() .. "-" .. rockspec.version 170 local name_version = rockspec.package:lower() .. "-" .. rockspec.version
167 if basename ~= name_version .. ".rockspec" then 171 if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then
168 return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." 172 return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)."
169 end 173 end
170 174
@@ -207,9 +211,15 @@ end
207function load_rockspec(filename, location) 211function load_rockspec(filename, location)
208 assert(type(filename) == "string") 212 assert(type(filename) == "string")
209 213
210 local name = dir.base_name(filename):match("(.*)%.rockspec") 214 local name
211 if not name then 215 local basename = dir.base_name(filename)
212 return nil, "Filename '"..filename.."' does not look like a rockspec." 216 if basename == "rockspec" then
217 name = "rockspec"
218 else
219 name = basename:match("(.*)%.rockspec")
220 if not name and not basename == "rockspec" then
221 return nil, "Filename '"..filename.."' does not look like a rockspec."
222 end
213 end 223 end
214 224
215 local err, errcode 225 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(...)
34 if not rockspec then 34 if not rockspec then
35 local files = fs.list_dir(fs.current_dir()) 35 local files = fs.list_dir(fs.current_dir())
36 for _, file in pairs(files) do 36 for _, file in pairs(files) do
37 if file:match(".rockspec$") then 37 if file:match("rockspec$") then
38 if rockspec then 38 if rockspec then
39 return nil, "Please specify which rockspec file to use." 39 return nil, "Please specify which rockspec file to use."
40 else 40 else
@@ -46,7 +46,7 @@ function run(...)
46 return nil, "Argument missing: please specify a rockspec to use on current directory." 46 return nil, "Argument missing: please specify a rockspec to use on current directory."
47 end 47 end
48 end 48 end
49 if not rockspec:match("%.rockspec$") then 49 if not rockspec:match("rockspec$") then
50 return nil, "Invalid argument: 'make' takes a rockspec as a parameter. See help." 50 return nil, "Invalid argument: 'make' takes a rockspec as a parameter. See help."
51 end 51 end
52 52