diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2012-03-09 21:36:20 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-03-09 21:36:20 -0300 |
| commit | 37aded056fae788088855b36281b1d23b0131fdb (patch) | |
| tree | 32562f8400a8ff3a1ea298cb662e5bf3929d565d | |
| parent | 9b9df2fa3475531aba8e41e38ba7d452d802cfb6 (diff) | |
| download | luarocks-37aded056fae788088855b36281b1d23b0131fdb.tar.gz luarocks-37aded056fae788088855b36281b1d23b0131fdb.tar.bz2 luarocks-37aded056fae788088855b36281b1d23b0131fdb.zip | |
Further steps for Lua 5.2 support
| -rw-r--r-- | Makefile | 2 | ||||
| -rwxr-xr-x | configure | 120 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 25 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/fs/lua.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/fs/unix/tools.lua | 3 | ||||
| -rw-r--r-- | src/luarocks/fs/win32/tools.lua | 3 | ||||
| -rw-r--r-- | src/luarocks/persist.lua | 21 |
8 files changed, 123 insertions, 60 deletions
| @@ -7,7 +7,7 @@ PREFIX ?= /usr/local | |||
| 7 | ROCKS_TREE ?= $(PREFIX) | 7 | ROCKS_TREE ?= $(PREFIX) |
| 8 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks | 8 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks |
| 9 | BINDIR ?= $(PREFIX)/bin | 9 | BINDIR ?= $(PREFIX)/bin |
| 10 | LUADIR ?= $(PREFIX)/share/lua/5.1/ | 10 | LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)/ |
| 11 | LUA_DIR ?= /usr/local | 11 | LUA_DIR ?= /usr/local |
| 12 | LUA_BINDIR ?= $(LUA_DIR)/bin | 12 | LUA_BINDIR ?= $(LUA_DIR)/bin |
| 13 | 13 | ||
| @@ -13,6 +13,7 @@ LUA_DIR="/usr" | |||
| 13 | LUA_BINDIR="/usr/bin" | 13 | LUA_BINDIR="/usr/bin" |
| 14 | LUA_INCDIR="/usr/include" | 14 | LUA_INCDIR="/usr/include" |
| 15 | LUA_LIBDIR="/usr/lib" | 15 | LUA_LIBDIR="/usr/lib" |
| 16 | LUA_VERSION="5.1" | ||
| 16 | 17 | ||
| 17 | # ---------------------------------------------------------------------------- | 18 | # ---------------------------------------------------------------------------- |
| 18 | # FUNCTION DEFINITIONS | 19 | # FUNCTION DEFINITIONS |
| @@ -37,6 +38,8 @@ system's package manager. | |||
| 37 | --rocks-tree=FILE Root of the local tree of installed rocks. | 38 | --rocks-tree=FILE Root of the local tree of installed rocks. |
| 38 | Default is \$PREFIX | 39 | Default is \$PREFIX |
| 39 | 40 | ||
| 41 | --lua-version=VERSION Use specific Lua version: 5.1 or 5.2 (EXPERIMENTAL) | ||
| 42 | Default is "$LUA_VERSION" | ||
| 40 | --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. | 43 | --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. |
| 41 | Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) | 44 | Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) |
| 42 | --with-lua=PREFIX Use Lua from given prefix. | 45 | --with-lua=PREFIX Use Lua from given prefix. |
| @@ -83,6 +86,14 @@ find_program() { | |||
| 83 | fi | 86 | fi |
| 84 | } | 87 | } |
| 85 | 88 | ||
| 89 | die() { | ||
| 90 | echo "$*" | ||
| 91 | echo | ||
| 92 | echo "configure failed." | ||
| 93 | echo | ||
| 94 | exit 1 | ||
| 95 | } | ||
| 96 | |||
| 86 | find_helper() { | 97 | find_helper() { |
| 87 | explanation="$1" | 98 | explanation="$1" |
| 88 | shift | 99 | shift |
| @@ -99,8 +110,7 @@ find_helper() { | |||
| 99 | shift | 110 | shift |
| 100 | done | 111 | done |
| 101 | echo "Could not find a $explanation. Tried: $tried." | 112 | echo "Could not find a $explanation. Tried: $tried." |
| 102 | echo "Make sure one of them is installed and available in your PATH." | 113 | die "Make sure one of them is installed and available in your PATH." |
| 103 | exit 1 | ||
| 104 | } | 114 | } |
| 105 | 115 | ||
| 106 | case `echo -n x` in | 116 | case `echo -n x` in |
| @@ -112,11 +122,6 @@ echo_n() { | |||
| 112 | echo $echo_n_flag "$*" | 122 | echo $echo_n_flag "$*" |
| 113 | } | 123 | } |
| 114 | 124 | ||
| 115 | die() { | ||
| 116 | echo "$*" | ||
| 117 | exit 1 | ||
| 118 | } | ||
| 119 | |||
| 120 | # ---------------------------------------------------------------------------- | 125 | # ---------------------------------------------------------------------------- |
| 121 | # MAIN PROGRAM | 126 | # MAIN PROGRAM |
| 122 | # ---------------------------------------------------------------------------- | 127 | # ---------------------------------------------------------------------------- |
| @@ -162,6 +167,12 @@ do | |||
| 162 | LUA_SUFFIX="$value" | 167 | LUA_SUFFIX="$value" |
| 163 | LUA_SUFFIX_SET=yes | 168 | LUA_SUFFIX_SET=yes |
| 164 | ;; | 169 | ;; |
| 170 | --lua-version) | ||
| 171 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 172 | LUA_VERSION="$value" | ||
| 173 | [ "$LUA_VERSION" = "5.1" -o "$LUA_VERSION" = "5.2" ] || die "Invalid Lua version in flag $key." | ||
| 174 | LUA_VERSION_SET=yes | ||
| 175 | ;; | ||
| 165 | --with-lua) | 176 | --with-lua) |
| 166 | [ -n "$value" ] || die "Missing value in flag $key." | 177 | [ -n "$value" ] || die "Missing value in flag $key." |
| 167 | LUA_DIR="$value" | 178 | LUA_DIR="$value" |
| @@ -181,7 +192,7 @@ do | |||
| 181 | [ -n "$value" ] || die "Missing value in flag $key." | 192 | [ -n "$value" ] || die "Missing value in flag $key." |
| 182 | case "$value" in | 193 | case "$value" in |
| 183 | wget|curl) LUAROCKS_DOWNLOADER="$value" ;; | 194 | wget|curl) LUAROCKS_DOWNLOADER="$value" ;; |
| 184 | *) echo "Invalid option: $value. See --help." ; exit 1 ;; | 195 | *) die "Invalid option: $value. See --help." ;; |
| 185 | esac | 196 | esac |
| 186 | LUAROCKS_DOWNLOADER_SET=yes | 197 | LUAROCKS_DOWNLOADER_SET=yes |
| 187 | ;; | 198 | ;; |
| @@ -189,19 +200,17 @@ do | |||
| 189 | [ -n "$value" ] || die "Missing value in flag $key." | 200 | [ -n "$value" ] || die "Missing value in flag $key." |
| 190 | case "$value" in | 201 | case "$value" in |
| 191 | md5sum|openssl|md5) LUAROCKS_MD5CHECKER="$value" ;; | 202 | md5sum|openssl|md5) LUAROCKS_MD5CHECKER="$value" ;; |
| 192 | *) echo "Invalid option: $value. See --help." ; exit 1 ;; | 203 | *) die "Invalid option: $value. See --help." ;; |
| 193 | esac | 204 | esac |
| 194 | LUAROCKS_MD5CHECKER_SET=yes | 205 | LUAROCKS_MD5CHECKER_SET=yes |
| 195 | ;; | 206 | ;; |
| 196 | *) | 207 | *) |
| 197 | echo "Error: Unknown flag: $1" | 208 | die "Error: Unknown flag: $1" |
| 198 | exit 1 | ||
| 199 | ;; | 209 | ;; |
| 200 | esac | 210 | esac |
| 201 | shift | 211 | shift |
| 202 | done | 212 | done |
| 203 | 213 | ||
| 204 | |||
| 205 | if [ "$PREFIX_SET" = "yes" -a ! "$SYSCONFDIR_SET" = "yes" ] | 214 | if [ "$PREFIX_SET" = "yes" -a ! "$SYSCONFDIR_SET" = "yes" ] |
| 206 | then | 215 | then |
| 207 | if [ "$PREFIX" = "/usr" ] | 216 | if [ "$PREFIX" = "/usr" ] |
| @@ -216,28 +225,70 @@ then | |||
| 216 | ROCKS_TREE=$PREFIX | 225 | ROCKS_TREE=$PREFIX |
| 217 | fi | 226 | fi |
| 218 | 227 | ||
| 219 | if [ "$LUA_SUFFIX_SET" != "yes" ] | 228 | detect_lua_version() { |
| 220 | then | 229 | detected_lua=`$1 -e 'print(_VERSION:sub(5))' 2> /dev/null` |
| 221 | for suffix in "" "5.1" "51" "" | 230 | if [ "$detected_lua" = "5.1" -o "$detected_lua" = "5.2" ] |
| 222 | do | 231 | then |
| 223 | LUA_SUFFIX="$suffix" | 232 | echo "Lua version detected: $detected_lua" |
| 224 | if [ "$LUA_DIR_SET" = "yes" ] | 233 | if [ "$LUA_VERSION_SET" != "yes" ] |
| 234 | then | ||
| 235 | LUA_VERSION=$detected_lua | ||
| 236 | elif [ "$LUA_VERSION" != "$detected_lua" ] | ||
| 225 | then | 237 | then |
| 226 | if [ -f "$LUA_DIR/bin/lua$suffix" ] | 238 | die "This clashes with the value of --with-lua-version. Please check your configuration." |
| 227 | then | ||
| 228 | find_lua="$LUA_DIR" | ||
| 229 | fi | ||
| 230 | else | ||
| 231 | find_lua=`find_program lua$suffix` | ||
| 232 | fi | 239 | fi |
| 233 | if [ -n "$find_lua" ] | 240 | fi |
| 241 | } | ||
| 242 | |||
| 243 | search_interpreter() { | ||
| 244 | LUA_SUFFIX="$1" | ||
| 245 | if [ "$LUA_DIR_SET" = "yes" ] | ||
| 246 | then | ||
| 247 | if [ -f "$LUA_DIR/bin/lua$suffix" ] | ||
| 234 | then | 248 | then |
| 235 | echo "Lua interpreter found: $find_lua/lua$suffix..." | 249 | find_lua="$LUA_DIR/bin" |
| 236 | break | ||
| 237 | fi | 250 | fi |
| 251 | else | ||
| 252 | find_lua=`find_program lua$suffix` | ||
| 253 | fi | ||
| 254 | if [ -n "$find_lua" ] | ||
| 255 | then | ||
| 256 | echo "Lua interpreter found: $find_lua/lua$suffix..." | ||
| 257 | detect_lua_version "$find_lua/lua$suffix" | ||
| 258 | return 0 | ||
| 259 | fi | ||
| 260 | return 1 | ||
| 261 | } | ||
| 262 | |||
| 263 | if [ "$LUA_SUFFIX_SET" != "yes" ] | ||
| 264 | then | ||
| 265 | if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ] | ||
| 266 | then | ||
| 267 | suffixes="5.1 51" | ||
| 268 | elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.2" ] | ||
| 269 | then | ||
| 270 | suffixes="5.2 52" | ||
| 271 | else | ||
| 272 | suffixes="5.2 52 5.1 51" | ||
| 273 | fi | ||
| 274 | for suffix in "" `echo $suffixes` "" | ||
| 275 | do | ||
| 276 | search_interpreter "$suffix" && break | ||
| 238 | done | 277 | done |
| 239 | fi | 278 | fi |
| 240 | 279 | ||
| 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 | |||
| 241 | if [ "$LUA_DIR_SET" != "yes" ] | 292 | if [ "$LUA_DIR_SET" != "yes" ] |
| 242 | then | 293 | then |
| 243 | echo_n "Looking for Lua... " | 294 | echo_n "Looking for Lua... " |
| @@ -253,8 +304,7 @@ then | |||
| 253 | echo "lua$LUA_SUFFIX found in \$PATH: $find_lua" | 304 | echo "lua$LUA_SUFFIX found in \$PATH: $find_lua" |
| 254 | else | 305 | else |
| 255 | echo "lua$LUA_SUFFIX not found in \$PATH." | 306 | echo "lua$LUA_SUFFIX not found in \$PATH." |
| 256 | echo "You may want to use the flags --with-lua and/or --lua-suffix. See --help." | 307 | die "You may want to use the flags --with-lua and/or --lua-suffix. See --help." |
| 257 | exit 1 | ||
| 258 | fi | 308 | fi |
| 259 | fi | 309 | fi |
| 260 | 310 | ||
| @@ -279,15 +329,14 @@ if [ -f "$lua_h" ] | |||
| 279 | then | 329 | then |
| 280 | echo "lua.h found in $lua_h" | 330 | echo "lua.h found in $lua_h" |
| 281 | else | 331 | else |
| 282 | LUA_INCDIR="$LUA_INCDIR/lua5.1" | 332 | LUA_INCDIR="$LUA_INCDIR/lua/$LUA_VERSION" |
| 283 | d_lua_h="$LUA_INCDIR/lua.h" | 333 | d_lua_h="$LUA_INCDIR/lua.h" |
| 284 | if [ -f "$d_lua_h" ] | 334 | if [ -f "$d_lua_h" ] |
| 285 | then | 335 | then |
| 286 | echo "lua.h found in $d_lua_h (Debian/Ubuntu)" | 336 | echo "lua.h found in $d_lua_h (Debian/Ubuntu)" |
| 287 | else | 337 | else |
| 288 | echo "lua.h not found (looked in $lua_h)" | 338 | echo "lua.h not found (looked in $lua_h)" |
| 289 | echo "You may want to use the flag --with-lua-include. See --help." | 339 | die "You may want to use the flag --with-lua-include. See --help." |
| 290 | exit 1 | ||
| 291 | fi | 340 | fi |
| 292 | fi | 341 | fi |
| 293 | 342 | ||
| @@ -308,16 +357,14 @@ if uname -s | |||
| 308 | then | 357 | then |
| 309 | LUAROCKS_UNAME_S=`uname -s` | 358 | LUAROCKS_UNAME_S=`uname -s` |
| 310 | else | 359 | else |
| 311 | echo "Could not determine operating system. 'uname -s' failed." | 360 | die "Could not determine operating system. 'uname -s' failed." |
| 312 | exit 1 | ||
| 313 | fi | 361 | fi |
| 314 | echo_n "Configuring for architecture... " | 362 | echo_n "Configuring for architecture... " |
| 315 | if uname -m | 363 | if uname -m |
| 316 | then | 364 | then |
| 317 | LUAROCKS_UNAME_M=`uname -m` | 365 | LUAROCKS_UNAME_M=`uname -m` |
| 318 | else | 366 | else |
| 319 | echo "Could not determine processor architecture. 'uname -m' failed." | 367 | die "Could not determine processor architecture. 'uname -m' failed." |
| 320 | exit 1 | ||
| 321 | fi | 368 | fi |
| 322 | 369 | ||
| 323 | if [ -f config.unix ]; then | 370 | if [ -f config.unix ]; then |
| @@ -334,6 +381,7 @@ cat <<EOF > config.unix | |||
| 334 | # This file was automatically generated by the configure script. | 381 | # This file was automatically generated by the configure script. |
| 335 | # Run "./configure --help" for details. | 382 | # Run "./configure --help" for details. |
| 336 | 383 | ||
| 384 | LUA_VERSION=$LUA_VERSION | ||
| 337 | PREFIX=$PREFIX | 385 | PREFIX=$PREFIX |
| 338 | SYSCONFDIR=$SYSCONFDIR | 386 | SYSCONFDIR=$SYSCONFDIR |
| 339 | ROCKS_TREE=$ROCKS_TREE | 387 | ROCKS_TREE=$ROCKS_TREE |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 9628a291..8527ba52 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | -- (~/.luarocks/config.lua on Unix or %APPDATA%/luarocks/config.lua on | 11 | -- (~/.luarocks/config.lua on Unix or %APPDATA%/luarocks/config.lua on |
| 12 | -- Windows). | 12 | -- Windows). |
| 13 | 13 | ||
| 14 | local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert = | 14 | local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, _VERSION = |
| 15 | rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert | 15 | rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, _VERSION |
| 16 | 16 | ||
| 17 | module("luarocks.cfg") | 17 | module("luarocks.cfg") |
| 18 | 18 | ||
| @@ -25,6 +25,7 @@ end | |||
| 25 | 25 | ||
| 26 | _M.site_config = site_config | 26 | _M.site_config = site_config |
| 27 | 27 | ||
| 28 | lua_version = _VERSION:sub(5) | ||
| 28 | program_version = "2.0.8" | 29 | program_version = "2.0.8" |
| 29 | user_agent = "LuaRocks/"..program_version | 30 | user_agent = "LuaRocks/"..program_version |
| 30 | 31 | ||
| @@ -150,8 +151,8 @@ local defaults = { | |||
| 150 | use_extensions = false, | 151 | use_extensions = false, |
| 151 | accept_unknown_fields = false, | 152 | accept_unknown_fields = false, |
| 152 | 153 | ||
| 153 | lua_modules_path = "/share/lua/5.1/", | 154 | lua_modules_path = "/share/lua/"..lua_version, |
| 154 | lib_modules_path = "/lib/lua/5.1/", | 155 | lib_modules_path = "/lib/lua/"..lua_version, |
| 155 | 156 | ||
| 156 | arch = "unknown", | 157 | arch = "unknown", |
| 157 | lib_extension = "unknown", | 158 | lib_extension = "unknown", |
| @@ -230,9 +231,9 @@ if detected.windows then | |||
| 230 | defaults.external_lib_extension = "dll" | 231 | defaults.external_lib_extension = "dll" |
| 231 | defaults.obj_extension = "obj" | 232 | defaults.obj_extension = "obj" |
| 232 | defaults.external_deps_dirs = { "c:/external/" } | 233 | defaults.external_deps_dirs = { "c:/external/" } |
| 233 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" | 234 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..lua_version.."/bin" |
| 234 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" | 235 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua"..lua_version.."/include" |
| 235 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" | 236 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua"..lua_version.."/lib" |
| 236 | defaults.cmake_generator = "MinGW Makefiles" | 237 | defaults.cmake_generator = "MinGW Makefiles" |
| 237 | defaults.makefile = "Makefile.win" | 238 | defaults.makefile = "Makefile.win" |
| 238 | defaults.variables.MAKE = "nmake" -- TODO: Split Windows flavors between mingw and msvc | 239 | defaults.variables.MAKE = "nmake" -- TODO: Split Windows flavors between mingw and msvc |
| @@ -241,10 +242,10 @@ if detected.windows then | |||
| 241 | defaults.variables.WRAPPER = site_config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.obj" | 242 | defaults.variables.WRAPPER = site_config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.obj" |
| 242 | defaults.variables.LD = "link" | 243 | defaults.variables.LD = "link" |
| 243 | defaults.variables.MT = "mt" | 244 | defaults.variables.MT = "mt" |
| 244 | defaults.variables.LUALIB = "lua5.1.lib" | 245 | defaults.variables.LUALIB = "lua"..lua_version..".lib" |
| 245 | defaults.variables.CFLAGS = "/MD /O2" | 246 | defaults.variables.CFLAGS = "/MD /O2" |
| 246 | defaults.variables.LIBFLAG = "/dll" | 247 | defaults.variables.LIBFLAG = "/dll" |
| 247 | defaults.variables.LUALIB = "lua5.1.lib" | 248 | defaults.variables.LUALIB = "lua"..lua_version..".lib" |
| 248 | defaults.external_deps_patterns = { | 249 | defaults.external_deps_patterns = { |
| 249 | bin = { "?.exe", "?.bat" }, | 250 | bin = { "?.exe", "?.bat" }, |
| 250 | lib = { "?.lib", "?.dll", "lib?.dll" }, | 251 | lib = { "?.lib", "?.dll", "lib?.dll" }, |
| @@ -268,9 +269,9 @@ if detected.mingw32 then | |||
| 268 | defaults.external_lib_extension = "dll" | 269 | defaults.external_lib_extension = "dll" |
| 269 | defaults.obj_extension = "o" | 270 | defaults.obj_extension = "o" |
| 270 | defaults.external_deps_dirs = { "c:/external/" } | 271 | defaults.external_deps_dirs = { "c:/external/" } |
| 271 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" | 272 | defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..lua_version.."/bin" |
| 272 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" | 273 | defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua"..lua_version.."/include" |
| 273 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" | 274 | defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua"..lua_version.."/lib" |
| 274 | defaults.cmake_generator = "MinGW Makefiles" | 275 | defaults.cmake_generator = "MinGW Makefiles" |
| 275 | defaults.make = "mingw32-make" -- TODO: Split Windows flavors between mingw and msvc | 276 | defaults.make = "mingw32-make" -- TODO: Split Windows flavors between mingw and msvc |
| 276 | defaults.makefile = "Makefile.win" | 277 | defaults.makefile = "Makefile.win" |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 9cc9f2c4..194e0e7e 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -317,7 +317,7 @@ local function match_dep(dep, blacklist) | |||
| 317 | 317 | ||
| 318 | local versions | 318 | local versions |
| 319 | if dep.name == "lua" then | 319 | if dep.name == "lua" then |
| 320 | versions = { (_VERSION:gsub("Lua ", "")) } | 320 | versions = { cfg.lua_version } |
| 321 | else | 321 | else |
| 322 | versions = manif_core.get_versions(dep.name) | 322 | versions = manif_core.get_versions(dep.name) |
| 323 | end | 323 | end |
| @@ -470,7 +470,7 @@ function fulfill_dependencies(rockspec) | |||
| 470 | if not match_dep(dep) then | 470 | if not match_dep(dep) then |
| 471 | local rock = search.find_suitable_rock(dep) | 471 | local rock = search.find_suitable_rock(dep) |
| 472 | if not rock then | 472 | if not rock then |
| 473 | return nil, "Could not find a rock to satisfy dependency: "..show_dep(dep) | 473 | return nil, "Could not satisfy dependency: "..show_dep(dep) |
| 474 | end | 474 | end |
| 475 | local ok, err, errcode = install.run(rock) | 475 | local ok, err, errcode = install.run(rock) |
| 476 | if not ok then | 476 | if not ok then |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 1cae25f4..191ef35c 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -59,7 +59,7 @@ function is_writable(file) | |||
| 59 | if fh then fh:close() end | 59 | if fh then fh:close() end |
| 60 | os.remove(file2) | 60 | os.remove(file2) |
| 61 | else | 61 | else |
| 62 | local fh = io.open(file, 'rb+') | 62 | local fh = io.open(file, 'r+b') |
| 63 | result = fh ~= nil | 63 | result = fh ~= nil |
| 64 | if fh then fh:close() end | 64 | if fh then fh:close() end |
| 65 | end | 65 | end |
| @@ -129,7 +129,8 @@ if lfs_ok then | |||
| 129 | -- @return boolean: true if command succeeds (status code 0), false | 129 | -- @return boolean: true if command succeeds (status code 0), false |
| 130 | -- otherwise. | 130 | -- otherwise. |
| 131 | function execute_string(cmd) | 131 | function execute_string(cmd) |
| 132 | if os.execute(cmd) == 0 then | 132 | local code = os.execute(cmd) |
| 133 | if code == 0 or code == true then | ||
| 133 | return true | 134 | return true |
| 134 | else | 135 | else |
| 135 | return false | 136 | return false |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index d6d60adc..37efcf66 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
| @@ -17,7 +17,8 @@ local vars = cfg.variables | |||
| 17 | -- otherwise. | 17 | -- otherwise. |
| 18 | function execute_string(cmd) | 18 | function execute_string(cmd) |
| 19 | local actual_cmd = "cd " .. fs.Q(fs.current_dir()) .. " && " .. cmd | 19 | local actual_cmd = "cd " .. fs.Q(fs.current_dir()) .. " && " .. cmd |
| 20 | if os.execute(actual_cmd) == 0 then | 20 | local code = os.execute(actual_cmd) |
| 21 | if code == 0 or code == true then | ||
| 21 | return true | 22 | return true |
| 22 | else | 23 | else |
| 23 | return false | 24 | return false |
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 2ad84371..6115f382 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua | |||
| @@ -110,7 +110,8 @@ end | |||
| 110 | -- @return boolean: true if command succeeds (status code 0), false | 110 | -- @return boolean: true if command succeeds (status code 0), false |
| 111 | -- otherwise. | 111 | -- otherwise. |
| 112 | function execute_string(cmd) | 112 | function execute_string(cmd) |
| 113 | if os.execute(command_at(fs.current_dir(), cmd)) == 0 then | 113 | local code = os.execute(command_at(fs.current_dir(), cmd)) |
| 114 | if code == 0 or code == true then | ||
| 114 | return true | 115 | return true |
| 115 | else | 116 | else |
| 116 | return false | 117 | return false |
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua index 6d411e0f..182b3da6 100644 --- a/src/luarocks/persist.lua +++ b/src/luarocks/persist.lua | |||
| @@ -18,17 +18,28 @@ function load_into_table(filename, tbl) | |||
| 18 | assert(type(filename) == "string") | 18 | assert(type(filename) == "string") |
| 19 | assert(type(tbl) == "table" or not tbl) | 19 | assert(type(tbl) == "table" or not tbl) |
| 20 | 20 | ||
| 21 | local chunk, err = loadfile(filename) | 21 | local result, chunk, ran, err |
| 22 | local result = tbl or {} | ||
| 23 | if setfenv then -- Lua 5.1 | ||
| 24 | chunk, err = loadfile(filename) | ||
| 25 | if chunk then | ||
| 26 | setfenv(chunk, result) | ||
| 27 | ran, err = pcall(chunk) | ||
| 28 | end | ||
| 29 | else -- Lua 5.2 | ||
| 30 | chunk, err = loadfile(filename, "t", result) | ||
| 31 | if chunk then | ||
| 32 | ran, err = pcall(chunk) | ||
| 33 | end | ||
| 34 | end | ||
| 35 | |||
| 22 | if not chunk then | 36 | if not chunk then |
| 23 | if err:sub(1,5) ~= filename:sub(1,5) then | 37 | if err:sub(1,5) ~= filename:sub(1,5) then |
| 24 | return false, err | 38 | return false, err |
| 25 | end | 39 | end |
| 26 | return nil, "Error loading file: "..err | 40 | return nil, "Error loading file: "..err |
| 27 | end | 41 | end |
| 28 | local result = tbl or {} | 42 | if not ran then |
| 29 | setfenv(chunk, result) | ||
| 30 | local ok, err = pcall(chunk) | ||
| 31 | if not ok then | ||
| 32 | return nil, "Error running file: "..err | 43 | return nil, "Error running file: "..err |
| 33 | end | 44 | end |
| 34 | return result | 45 | return result |
