diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-04-12 23:05:43 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-04-12 23:05:43 -0300 |
| commit | 130f460fca140b2873d284d0057b326b64621d1d (patch) | |
| tree | 825a90c51e9fd9b15f98d1c7e9a38eca439862c5 | |
| parent | 26db61478504c7b13099b942aeebbdd6ffa4472b (diff) | |
| download | luarocks-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-- | Makefile | 14 | ||||
| -rwxr-xr-x | configure | 47 | ||||
| -rw-r--r-- | rockspec | 2 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 56 | ||||
| -rw-r--r-- | src/luarocks/path.lua | 11 |
5 files changed, 88 insertions, 42 deletions
| @@ -22,7 +22,7 @@ manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ | |||
| 22 | help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ | 22 | help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ |
| 23 | admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua purge.lua | 23 | admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua purge.lua |
| 24 | 24 | ||
| 25 | CONFIG_FILE = $(SYSCONFDIR)/config.lua | 25 | CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua |
| 26 | 26 | ||
| 27 | all: built | 27 | all: 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 | ||
| 122 | install_bins: built | 126 | install_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 | ||
| 126 | install_luas: built | 134 | install_luas: built |
| 127 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" | 135 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" |
| @@ -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 |
| 278 | fi | 284 | fi |
| 279 | 285 | ||
| 280 | if [ "$LUA_VERSION" = "5.2" ] | ||
| 281 | then | ||
| 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 "******************************" | ||
| 290 | fi | ||
| 291 | |||
| 292 | if [ "$LUA_DIR_SET" != "yes" ] | 286 | if [ "$LUA_DIR_SET" != "yes" ] |
| 293 | then | 287 | then |
| 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." |
| 377 | fi | 371 | fi |
| 378 | 372 | ||
| 373 | if [ "$LUA_VERSION" = "5.2" ] | ||
| 374 | then | ||
| 375 | LUA_OTHER_VERSION=5.1 | ||
| 376 | else | ||
| 377 | LUA_OTHER_VERSION=5.2 | ||
| 378 | fi | ||
| 379 | |||
| 380 | LUAROCKS_ROCKS_SUBDIR=/lib/luarocks/rocks | ||
| 381 | if [ "$VERSIONED_ROCKS_DIR" = "yes" ] | ||
| 382 | then | ||
| 383 | LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR-$LUA_VERSION | ||
| 384 | echo "Using versioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" | ||
| 385 | elif [ -e "$PREFIX/share/lua/$LUA_VERSION/luarocks/site_config.lua" ] | ||
| 386 | then | ||
| 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" | ||
| 390 | elif [ -e "$PREFIX/share/lua/$LUA_OTHER_VERSION/luarocks/site_config.lua" ] | ||
| 391 | then | ||
| 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" | ||
| 395 | else | ||
| 396 | echo "Using unversioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" | ||
| 397 | fi | ||
| 398 | |||
| 379 | if [ -f config.unix ]; then | 399 | if [ -f config.unix ]; then |
| 380 | rm -f config.unix | 400 | rm -f config.unix |
| 381 | fi | 401 | fi |
| @@ -405,6 +425,7 @@ LUAROCKS_UNAME_M=$LUAROCKS_UNAME_M | |||
| 405 | LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S | 425 | LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S |
| 406 | LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER | 426 | LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER |
| 407 | LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER | 427 | LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER |
| 428 | LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR | ||
| 408 | 429 | ||
| 409 | EOF | 430 | EOF |
| 410 | 431 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | package = "LuaRocks" | 1 | package = "LuaRocks" |
| 2 | local VER = "2.0.12" | 2 | local VER = "2.0.13" |
| 3 | local REV = "1" | 3 | local REV = "1" |
| 4 | version = VER.."-"..REV | 4 | version = 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 | ||
| 16 | module("luarocks.cfg") | 16 | module("luarocks.cfg") |
| 17 | 17 | ||
| 18 | lua_version = _VERSION:sub(5) | ||
| 19 | local version_suffix = lua_version:gsub("%.", "_") | ||
| 20 | |||
| 18 | -- Load site-local global configurations | 21 | -- Load site-local global configurations |
| 19 | local ok, site_config = pcall(require, "luarocks.site_config") | 22 | local ok, site_config = pcall(require, "luarocks.site_config_"..version_suffix) |
| 23 | if not ok then | ||
| 24 | ok, site_config = pcall(require, "luarocks.site_config") | ||
| 25 | end | ||
| 20 | if not ok then | 26 | if 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 | ||
| 27 | lua_version = _VERSION:sub(5) | 33 | program_version = "2.0.13" |
| 28 | program_version = "2.0.12" | ||
| 29 | 34 | ||
| 30 | local persist = require("luarocks.persist") | 35 | local persist = require("luarocks.persist") |
| 31 | 36 | ||
| @@ -97,38 +102,50 @@ end | |||
| 97 | 102 | ||
| 98 | -- Path configuration: | 103 | -- Path configuration: |
| 99 | 104 | ||
| 100 | local version_suffix = lua_version:gsub ("%.", "_") | ||
| 101 | local sys_config_file, home_config_file | 105 | local sys_config_file, home_config_file |
| 106 | local sys_config_dir, home_config_dir | ||
| 102 | local sys_config_ok, home_config_ok = false, false | 107 | local sys_config_ok, home_config_ok = false, false |
| 103 | sys_config_file = site_config["LUAROCKS_SYSCONFIG_" .. version_suffix] or site_config.LUAROCKS_SYSCONFIG | 108 | sys_config_dir = site_config.LUAROCKS_SYSCONFDIR |
| 104 | if detected.windows then | 109 | if 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/" |
| 109 | else | 114 | else |
| 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/" |
| 114 | end | 119 | end |
| 115 | 120 | ||
| 116 | variables = {} | 121 | variables = {} |
| 117 | rocks_trees = {} | 122 | rocks_trees = {} |
| 118 | 123 | ||
| 119 | local ok, err = persist.load_into_table(sys_config_file, _M) | 124 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..lua_version..".lua" |
| 120 | if ok then | 125 | local err |
| 121 | sys_config_ok = true | 126 | sys_config_ok, err = persist.load_into_table(sys_config_file, _M) |
| 122 | else -- nil or false | 127 | |
| 123 | sys_config_ok = ok | 128 | if 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 | 131 | end |
| 132 | if err and ok == nil then | ||
| 133 | io.stderr:write(err.."\n") | ||
| 127 | end | 134 | end |
| 128 | 135 | ||
| 129 | if not site_config.LUAROCKS_FORCE_CONFIG then | 136 | if 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 | ||
| 29 | function rocks_dir(tree) | 29 | function 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 |
| 36 | end | 36 | end |
| 37 | 37 | ||
| 38 | function root_dir(rocks_dir) | 38 | function 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 .. ".*$") | ||
| 42 | end | 41 | end |
| 43 | 42 | ||
| 44 | function rocks_tree_to_string(tree) | 43 | function rocks_tree_to_string(tree) |
| @@ -79,10 +78,10 @@ end | |||
| 79 | 78 | ||
| 80 | function manifest_file(tree) | 79 | function 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 |
| 87 | end | 86 | end |
| 88 | 87 | ||
