aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2013-04-12 23:05:43 -0300
committerHisham Muhammad <hisham@gobolinux.org>2013-04-12 23:05:43 -0300
commit130f460fca140b2873d284d0057b326b64621d1d (patch)
tree825a90c51e9fd9b15f98d1c7e9a38eca439862c5
parent26db61478504c7b13099b942aeebbdd6ffa4472b (diff)
downloadluarocks-130f460fca140b2873d284d0057b326b64621d1d.tar.gz
luarocks-130f460fca140b2873d284d0057b326b64621d1d.tar.bz2
luarocks-130f460fca140b2873d284d0057b326b64621d1d.zip
General improvements for Lua 5.1 and 5.2 coexistance:
* Add --versioned-rocks-dir option to Unix installer, which makes it use paths such as /lib/luarocks/rocks-5.X, and /etc/luarocks/config-5.X.lua (where X is 1 or 2). * Make configure script on Unix autodetect the presence of previous LuaRocks installations and adapt accordingly to avoid conflicts. * Support luarocks.site_config_5_X for users who wish to run two versions from the same source tree (may be useful for LR development). * Try to load config-5.X.lua from home directory before trying config.lua.
-rw-r--r--Makefile14
-rwxr-xr-xconfigure47
-rw-r--r--rockspec2
-rw-r--r--src/luarocks/cfg.lua56
-rw-r--r--src/luarocks/path.lua11
5 files changed, 88 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index dc37529b..a102b2be 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \
22help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ 22help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \
23admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua purge.lua 23admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua purge.lua
24 24
25CONFIG_FILE = $(SYSCONFDIR)/config.lua 25CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua
26 26
27all: built 27all: built
28 28
@@ -51,7 +51,7 @@ src/luarocks/site_config.lua: config.unix
51 fi 51 fi
52 if [ -n "$(SYSCONFDIR)" ] ;\ 52 if [ -n "$(SYSCONFDIR)" ] ;\
53 then \ 53 then \
54 echo "LUAROCKS_SYSCONFIG=[[$(SYSCONFDIR)/config.lua]]" >> src/luarocks/site_config.lua ;\ 54 echo "LUAROCKS_SYSCONFDIR=[[$(SYSCONFDIR)]]" >> src/luarocks/site_config.lua ;\
55 fi 55 fi
56 if [ -n "$(ROCKS_TREE)" ] ;\ 56 if [ -n "$(ROCKS_TREE)" ] ;\
57 then \ 57 then \
@@ -61,6 +61,10 @@ src/luarocks/site_config.lua: config.unix
61 then \ 61 then \
62 echo "LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/site_config.lua ;\ 62 echo "LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/site_config.lua ;\
63 fi 63 fi
64 if [ -n "$(LUAROCKS_ROCKS_SUBDIR)" ] ;\
65 then \
66 echo "LUAROCKS_ROCKS_SUBDIR=[[$(LUAROCKS_ROCKS_SUBDIR)]]" >> src/luarocks/site_config.lua ;\
67 fi
64 if [ "$(LUA_DIR_SET)" = "yes" ] ;\ 68 if [ "$(LUA_DIR_SET)" = "yes" ] ;\
65 then \ 69 then \
66 echo "LUA_DIR_SET=true" >> src/luarocks/site_config.lua ;\ 70 echo "LUA_DIR_SET=true" >> src/luarocks/site_config.lua ;\
@@ -121,7 +125,11 @@ clean: cleanup_bins
121 125
122install_bins: built 126install_bins: built
123 mkdir -p "$(DESTDIR)$(BINDIR)" 127 mkdir -p "$(DESTDIR)$(BINDIR)"
124 cd src/bin && cp $(BIN_FILES) "$(DESTDIR)$(BINDIR)" 128 cd src/bin && for f in $(BIN_FILES); \
129 do \
130 cp "$$f" "$(DESTDIR)$(BINDIR)/$$f-$(LUA_VERSION)"; \
131 ln -nfs "$(DESTDIR)$(BINDIR)/$$f-$(LUA_VERSION)" "$(DESTDIR)$(BINDIR)/$$f"; \
132 done
125 133
126install_luas: built 134install_luas: built
127 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" 135 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
diff --git a/configure b/configure
index 2e98a9e5..42ecf03b 100755
--- a/configure
+++ b/configure
@@ -38,7 +38,7 @@ system's package manager.
38--rocks-tree=FILE Root of the local tree of installed rocks. 38--rocks-tree=FILE Root of the local tree of installed rocks.
39 Default is \$PREFIX 39 Default is \$PREFIX
40 40
41--lua-version=VERSION Use specific Lua version: 5.1 or 5.2 (EXPERIMENTAL) 41--lua-version=VERSION Use specific Lua version: 5.1 or 5.2
42 Default is "$LUA_VERSION" 42 Default is "$LUA_VERSION"
43--lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. 43--lua-suffix=SUFFIX Versioning suffix to use in Lua filenames.
44 Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) 44 Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...)
@@ -54,6 +54,9 @@ system's package manager.
54--with-md5-checker=TOOL Which tool to use as a downloader. 54--with-md5-checker=TOOL Which tool to use as a downloader.
55 Valid options are: md5sum, openssl 55 Valid options are: md5sum, openssl
56 Default is to auto-detect. 56 Default is to auto-detect.
57--versioned-rocks-dir Use a versioned rocks dir, such as
58 \$PREFIX/lib/luarocks/rocks-$LUA_VERSION/.
59 Default is to auto-detect the necessity.
57--force-config Use a single config location. Do not use the 60--force-config Use a single config location. Do not use the
58 \$LUAROCKS_CONFIG variable or the user's home 61 \$LUAROCKS_CONFIG variable or the user's home
59 directory. Useful to avoid conflicts when LuaRocks 62 directory. Useful to avoid conflicts when LuaRocks
@@ -162,6 +165,9 @@ do
162 --force-config) 165 --force-config)
163 FORCE_CONFIG=yes 166 FORCE_CONFIG=yes
164 ;; 167 ;;
168 --versioned-rocks-dir)
169 VERSIONED_ROCKS_DIR=yes
170 ;;
165 --lua-suffix) 171 --lua-suffix)
166 [ -n "$value" ] || die "Missing value in flag $key." 172 [ -n "$value" ] || die "Missing value in flag $key."
167 LUA_SUFFIX="$value" 173 LUA_SUFFIX="$value"
@@ -277,18 +283,6 @@ then
277 done 283 done
278fi 284fi
279 285
280if [ "$LUA_VERSION" = "5.2" ]
281then
282 echo "******************************"
283 echo "WARNING: Lua 5.2 support is still experimental."
284 echo "Bug reports, patches and pull requests are welcome"
285 echo "at the GitHub project:"
286 echo "http://github.com/keplerproject/luarocks"
287 echo "and the mailing list:"
288 echo "https://lists.sourceforge.net/lists/listinfo/luarocks-developers"
289 echo "******************************"
290fi
291
292if [ "$LUA_DIR_SET" != "yes" ] 286if [ "$LUA_DIR_SET" != "yes" ]
293then 287then
294 echo_n "Looking for Lua... " 288 echo_n "Looking for Lua... "
@@ -376,6 +370,32 @@ else
376 die "Could not determine processor architecture. 'uname -m' failed." 370 die "Could not determine processor architecture. 'uname -m' failed."
377fi 371fi
378 372
373if [ "$LUA_VERSION" = "5.2" ]
374then
375 LUA_OTHER_VERSION=5.1
376else
377 LUA_OTHER_VERSION=5.2
378fi
379
380LUAROCKS_ROCKS_SUBDIR=/lib/luarocks/rocks
381if [ "$VERSIONED_ROCKS_DIR" = "yes" ]
382then
383 LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR-$LUA_VERSION
384 echo "Using versioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR"
385elif [ -e "$PREFIX/share/lua/$LUA_VERSION/luarocks/site_config.lua" ]
386then
387 echo "Existing installation detected."
388 LUAROCKS_ROCKS_SUBDIR=`grep "LUAROCKS_ROCKS_SUBDIR" "$PREFIX/lib/lua/$LUA_VERSION/luarocks/site_config.lua" | sed 's,.*=\[\[(.*)\]\],\1,'`
389 echo "Using previously configured rocks dir: $LUAROCKS_ROCKS_DIR"
390elif [ -e "$PREFIX/share/lua/$LUA_OTHER_VERSION/luarocks/site_config.lua" ]
391then
392 echo "Existing installation detected for other Lua version ($LUA_OTHER_VERSION)."
393 LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR-$LUA_VERSION
394 echo "Using versioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR"
395else
396 echo "Using unversioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR"
397fi
398
379if [ -f config.unix ]; then 399if [ -f config.unix ]; then
380 rm -f config.unix 400 rm -f config.unix
381fi 401fi
@@ -405,6 +425,7 @@ LUAROCKS_UNAME_M=$LUAROCKS_UNAME_M
405LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S 425LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S
406LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER 426LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER
407LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER 427LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER
428LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR
408 429
409EOF 430EOF
410 431
diff --git a/rockspec b/rockspec
index 11cc2c63..1fa7fa8d 100644
--- a/rockspec
+++ b/rockspec
@@ -1,5 +1,5 @@
1package = "LuaRocks" 1package = "LuaRocks"
2local VER = "2.0.12" 2local VER = "2.0.13"
3local REV = "1" 3local REV = "1"
4version = VER.."-"..REV 4version = VER.."-"..REV
5 5
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 12a477a0..2f2c7a66 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -15,8 +15,14 @@ local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs,
15 15
16module("luarocks.cfg") 16module("luarocks.cfg")
17 17
18lua_version = _VERSION:sub(5)
19local version_suffix = lua_version:gsub("%.", "_")
20
18-- Load site-local global configurations 21-- Load site-local global configurations
19local ok, site_config = pcall(require, "luarocks.site_config") 22local ok, site_config = pcall(require, "luarocks.site_config_"..version_suffix)
23if not ok then
24 ok, site_config = pcall(require, "luarocks.site_config")
25end
20if not ok then 26if not ok then
21 io.stderr:write("Site-local luarocks/site_config.lua file not found. Incomplete installation?\n") 27 io.stderr:write("Site-local luarocks/site_config.lua file not found. Incomplete installation?\n")
22 site_config = {} 28 site_config = {}
@@ -24,8 +30,7 @@ end
24 30
25_M.site_config = site_config 31_M.site_config = site_config
26 32
27lua_version = _VERSION:sub(5) 33program_version = "2.0.13"
28program_version = "2.0.12"
29 34
30local persist = require("luarocks.persist") 35local persist = require("luarocks.persist")
31 36
@@ -97,38 +102,50 @@ end
97 102
98-- Path configuration: 103-- Path configuration:
99 104
100local version_suffix = lua_version:gsub ("%.", "_")
101local sys_config_file, home_config_file 105local sys_config_file, home_config_file
106local sys_config_dir, home_config_dir
102local sys_config_ok, home_config_ok = false, false 107local sys_config_ok, home_config_ok = false, false
103sys_config_file = site_config["LUAROCKS_SYSCONFIG_" .. version_suffix] or site_config.LUAROCKS_SYSCONFIG 108sys_config_dir = site_config.LUAROCKS_SYSCONFDIR
104if detected.windows then 109if detected.windows then
105 home = os.getenv("APPDATA") or "c:" 110 home = os.getenv("APPDATA") or "c:"
106 sys_config_file = sys_config_file or "c:/luarocks/config.lua" 111 sys_config_dir = sys_config_dir or "c:/luarocks"
107 home_config_file = home.."/luarocks/config.lua" 112 home_config_dir = home.."/luarocks"
108 home_tree = home.."/luarocks/" 113 home_tree = home.."/luarocks/"
109else 114else
110 home = os.getenv("HOME") or "" 115 home = os.getenv("HOME") or ""
111 sys_config_file = sys_config_file or "/etc/luarocks/config.lua" 116 sys_config_dir = sys_config_dir or "/etc/luarocks"
112 home_config_file = home.."/.luarocks/config.lua" 117 home_config_dir = home.."/.luarocks"
113 home_tree = home.."/.luarocks/" 118 home_tree = home.."/.luarocks/"
114end 119end
115 120
116variables = {} 121variables = {}
117rocks_trees = {} 122rocks_trees = {}
118 123
119local ok, err = persist.load_into_table(sys_config_file, _M) 124sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..lua_version..".lua"
120if ok then 125local err
121 sys_config_ok = true 126sys_config_ok, err = persist.load_into_table(sys_config_file, _M)
122else -- nil or false 127
123 sys_config_ok = ok 128if not sys_config_ok then
124 if err and ok == nil then 129 sys_config_file = sys_config_dir.."/config.lua"
125 io.stderr:write(err.."\n") 130 sys_config_ok, err = persist.load_into_table(sys_config_file, _M)
126 end 131end
132if err and ok == nil then
133 io.stderr:write(err.."\n")
127end 134end
128 135
129if not site_config.LUAROCKS_FORCE_CONFIG then 136if not site_config.LUAROCKS_FORCE_CONFIG then
130 home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG") or home_config_file 137 local home_overrides, err
131 local home_overrides, err = persist.load_into_table(home_config_file, { home = home }) 138 home_config_file = os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG")
139 if home_config_file then
140 home_overrides, err = persist.load_into_table(home_config_file, { home = home })
141 else
142 home_config_file = home_config_dir.."/config-"..lua_version..".lua"
143 home_overrides, err = persist.load_into_table(home_config_file, { home = home })
144 if not home_overrides then
145 home_config_file = home_config_dir.."/config.lua"
146 home_overrides, err = persist.load_into_table(home_config_file, { home = home })
147 end
148 end
132 if home_overrides then 149 if home_overrides then
133 home_config_ok = true 150 home_config_ok = true
134 local util = require("luarocks.util") 151 local util = require("luarocks.util")
@@ -169,6 +186,7 @@ local defaults = {
169 186
170 lua_modules_path = "/share/lua/"..lua_version, 187 lua_modules_path = "/share/lua/"..lua_version,
171 lib_modules_path = "/lib/lua/"..lua_version, 188 lib_modules_path = "/lib/lua/"..lua_version,
189 rocks_subdir = site_config.LUAROCKS_ROCKS_SUBDIR or "/lib/luarocks/rocks",
172 190
173 arch = "unknown", 191 arch = "unknown",
174 lib_extension = "unknown", 192 lib_extension = "unknown",
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index 2ce0e078..5e380992 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -28,17 +28,16 @@ end
28 28
29function rocks_dir(tree) 29function rocks_dir(tree)
30 if type(tree) == "string" then 30 if type(tree) == "string" then
31 return dir.path(tree, "lib", "luarocks", "rocks") 31 return dir.path(tree, cfg.rocks_subdir)
32 else 32 else
33 assert(type(tree) == "table") 33 assert(type(tree) == "table")
34 return tree.rocks_dir or dir.path(tree.root, "lib", "luarocks", "rocks") 34 return tree.rocks_dir or dir.path(tree.root, cfg.rocks_subdir)
35 end 35 end
36end 36end
37 37
38function root_dir(rocks_dir) 38function root_dir(rocks_dir)
39 assert(type(rocks_dir) == "string") 39 assert(type(rocks_dir) == "string")
40 local suffix = dir.path("lib", "luarocks") 40 return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$")
41 return rocks_dir:match("(.*)" .. suffix .. ".*$")
42end 41end
43 42
44function rocks_tree_to_string(tree) 43function rocks_tree_to_string(tree)
@@ -79,10 +78,10 @@ end
79 78
80function manifest_file(tree) 79function manifest_file(tree)
81 if type(tree) == "string" then 80 if type(tree) == "string" then
82 return dir.path(tree, "lib", "luarocks", "rocks", "manifest") 81 return dir.path(tree, cfg.rocks_subdir, "manifest")
83 else 82 else
84 assert(type(tree) == "table") 83 assert(type(tree) == "table")
85 return (tree.rocks_dir and dir.path(tree.rocks_dir, "manifest")) or dir.path(tree.root, "lib", "luarocks", "rocks", "manifest") 84 return (tree.rocks_dir and dir.path(tree.rocks_dir, "manifest")) or dir.path(tree.root, cfg.rocks_subdir, "manifest")
86 end 85 end
87end 86end
88 87