From 4f983c3fc840e6d3bf4b4980bdfd04e9dcd265e0 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 16 Sep 2011 15:16:18 -0300 Subject: Rename luarocks.config to luarocks.site_config, to avoid confusion with the system-wide configuration file. Thanks to Ignacio for the investigation. Closes #41. --- Makefile | 42 ++++++++++++++++++++-------------------- install.bat | 34 ++++++++++++++++----------------- src/luarocks/cfg.lua | 54 ++++++++++++++++++++++++++-------------------------- 3 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index fb16b3fc..182077c7 100644 --- a/Makefile +++ b/Makefile @@ -26,45 +26,45 @@ CONFIG_FILE = $(SYSCONFDIR)/config.lua all: built -src/luarocks/config.lua: config.unix - rm -f src/luarocks/config.lua - echo 'module("luarocks.config")' >> src/luarocks/config.lua +src/luarocks/site_config.lua: config.unix + rm -f src/luarocks/site_config.lua + echo 'module("luarocks.site_config")' >> src/luarocks/site_config.lua if [ -n "$(PREFIX)" ] ;\ then \ - echo "LUAROCKS_PREFIX=[[$(PREFIX)]]" >> src/luarocks/config.lua ;\ + echo "LUAROCKS_PREFIX=[[$(PREFIX)]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(LUA_INCDIR)" ] ;\ then \ - echo "LUA_INCDIR=[[$(LUA_INCDIR)]]" >> src/luarocks/config.lua ;\ + echo "LUA_INCDIR=[[$(LUA_INCDIR)]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(LUA_LIBDIR)" ] ;\ then \ - echo "LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> src/luarocks/config.lua ;\ + echo "LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(LUA_BINDIR)" ] ;\ then \ - echo "LUA_BINDIR=[[$(LUA_BINDIR)]]" >> src/luarocks/config.lua ;\ + echo "LUA_BINDIR=[[$(LUA_BINDIR)]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(LUA_SUFFIX)" ] ;\ then \ - echo "LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> src/luarocks/config.lua ;\ + echo "LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(SYSCONFDIR)" ] ;\ then \ - echo "LUAROCKS_SYSCONFIG=[[$(SYSCONFDIR)/config.lua]]" >> src/luarocks/config.lua ;\ + echo "LUAROCKS_SYSCONFIG=[[$(SYSCONFDIR)/config.lua]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(ROCKS_TREE)" ] ;\ then \ - echo "LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> src/luarocks/config.lua ;\ + echo "LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> src/luarocks/site_config.lua ;\ fi if [ -n "$(FORCE_CONFIG)" ] ;\ then \ - echo "LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/config.lua ;\ + echo "LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/site_config.lua ;\ fi - echo "LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> src/luarocks/config.lua - echo "LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/config.lua - echo "LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/config.lua - echo "LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/config.lua + echo "LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> src/luarocks/site_config.lua + echo "LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/site_config.lua + echo "LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/site_config.lua + echo "LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/site_config.lua build_bins: for f in $(BIN_FILES) ;\ @@ -76,7 +76,7 @@ build_bins: rm src/bin/$$f.bak ;\ done -built: cleanup_bins src/luarocks/config.lua build_bins +built: cleanup_bins src/luarocks/site_config.lua build_bins touch built @echo @echo "Done. Type 'make install' to install into $(PREFIX)." @@ -106,7 +106,7 @@ cleanup_bins: done clean: cleanup_bins - rm -f src/luarocks/config.lua + rm -f src/luarocks/site_config.lua rm -f built install_bins: @@ -117,9 +117,9 @@ install_luas: mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" cd src/luarocks && for f in $(LUAROCKS_FILES); do d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"`; mkdir -p "$$d"; cp "$$f" "$$d"; done -install_config: +install_site_config: mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" - cd src/luarocks && cp config.lua "$(DESTDIR)$(LUADIR)/luarocks" + cd src/luarocks && cp site_config.lua "$(DESTDIR)$(LUADIR)/luarocks" write_sysconfig: mkdir -p "$(DESTDIR)$(ROCKS_TREE)" @@ -138,9 +138,9 @@ write_sysconfig: echo '}' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ fi -install: built install_bins install_luas install_config write_sysconfig +install: built install_bins install_luas install_site_config write_sysconfig -bootstrap: src/luarocks/config.lua install_config write_sysconfig +bootstrap: src/luarocks/site_config.lua install_site_config write_sysconfig LUA_PATH="$$PWD/src/?.lua;$$LUA_PATH" src/bin/luarocks make rockspec install_rock: install_bins install_luas diff --git a/install.bat b/install.bat index df2a18d8..3b5742ee 100644 --- a/install.bat +++ b/install.bat @@ -269,27 +269,27 @@ IF ERRORLEVEL 1 GOTO ERROR XCOPY /S src\luarocks\*.* "%LUADIR%\luarocks" >NUL IF ERRORLEVEL 1 GOTO ERROR -IF EXIST "%LUADIR%\luarocks\config.lua" RENAME "%LUADIR%\luarocks\config.lua" config.lua.bak -ECHO module("luarocks.config")>> "%LUADIR%\luarocks\config.lua" -ECHO LUA_INCDIR=[[%LUA_INCDIR%]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUA_LIBDIR=[[%LUA_LIBDIR%]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUA_BINDIR=[[%LUA_BINDIR%]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUA_INTERPRETER=[[%LUA_INTERPRETER%]]>> "%LUADIR%\luarocks\config.lua" +IF EXIST "%LUADIR%\luarocks\site_config.lua" RENAME "%LUADIR%\luarocks\site_config.lua" site_config.lua.bak +ECHO module("luarocks.site_config")>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUA_INCDIR=[[%LUA_INCDIR%]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUA_LIBDIR=[[%LUA_LIBDIR%]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUA_BINDIR=[[%LUA_BINDIR%]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUA_INTERPRETER=[[%LUA_INTERPRETER%]]>> "%LUADIR%\luarocks\site_config.lua" IF [%USE_MINGW%]==[ON] ( -ECHO LUAROCKS_UNAME_S=[[MINGW]]>> "%LUADIR%\luarocks\config.lua" +ECHO LUAROCKS_UNAME_S=[[MINGW]]>> "%LUADIR%\luarocks\site_config.lua" ) ELSE ( -ECHO LUAROCKS_UNAME_S=[[WindowsNT]]>> "%LUADIR%\luarocks\config.lua" +ECHO LUAROCKS_UNAME_S=[[WindowsNT]]>> "%LUADIR%\luarocks\site_config.lua" ) -ECHO LUAROCKS_UNAME_M=[[x86]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUAROCKS_SYSCONFIG=[[%SYSCONFDIR%/config.lua]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUAROCKS_ROCKS_TREE=[[%ROCKS_TREE%]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUAROCKS_PREFIX=[[%PREFIX%]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUAROCKS_DOWNLOADER=[[curl]]>> "%LUADIR%\luarocks\config.lua" -ECHO LUAROCKS_MD5CHECKER=[[md5sum]]>> "%LUADIR%\luarocks\config.lua" -IF NOT [%FORCE_CONFIG%]==[] ECHO local LUAROCKS_FORCE_CONFIG=true>> "%LUADIR%\luarocks\config.lua" -IF EXIST "%LUADIR%\luarocks\config.lua.bak" TYPE "%LUADIR%\luarocks\config.lua.bak">> "%LUADIR%\luarocks\config.lua" +ECHO LUAROCKS_UNAME_M=[[x86]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUAROCKS_SYSCONFIG=[[%SYSCONFDIR%/config.lua]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUAROCKS_ROCKS_TREE=[[%ROCKS_TREE%]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUAROCKS_PREFIX=[[%PREFIX%]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUAROCKS_DOWNLOADER=[[curl]]>> "%LUADIR%\luarocks\site_config.lua" +ECHO LUAROCKS_MD5CHECKER=[[md5sum]]>> "%LUADIR%\luarocks\site_config.lua" +IF NOT [%FORCE_CONFIG%]==[] ECHO local LUAROCKS_FORCE_CONFIG=true>> "%LUADIR%\luarocks\site_config.lua" +IF EXIST "%LUADIR%\luarocks\site_config.lua.bak" TYPE "%LUADIR%\luarocks\site_config.lua.bak">> "%LUADIR%\luarocks\site_config.lua" -IF EXIST "%LUADIR%\luarocks\config.lua.bak" DEL /F /Q "%LUADIR%\luarocks\config.lua.bak" +IF EXIST "%LUADIR%\luarocks\site_config.lua.bak" DEL /F /Q "%LUADIR%\luarocks\site_config.lua.bak" SET CONFIG_FILE=%SYSCONFDIR%\config.lua diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index d2858cca..476bfbc3 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -10,19 +10,19 @@ local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, -- -- End-users shouldn't edit this file. They can override any defaults -- set in this file using their system-wide $LUAROCKS_SYSCONFIG file --- (see luarocks.config) or their user-specific configuration file +-- (see luarocks.site_config) or their user-specific configuration file -- (~/.luarocks/config.lua on Unix or %APPDATA%/luarocks/config.lua on -- Windows). module("luarocks.cfg") -- Load site-local global configurations -local ok, config = pcall(require, "luarocks.config") +local ok, site_config = pcall(require, "luarocks.site_config") if not ok then - io.stderr:write("Site-local luarocks/config.lua file not found. Incomplete installation?\n") - config = {} + io.stderr:write("Site-local luarocks/site_config.lua file not found. Incomplete installation?\n") + site_config = {} end -_M.config = config +_M.site_config = site_config program_version = "2.0.5" user_agent = "LuaRocks/"..program_version @@ -46,12 +46,12 @@ local detected = {} local system,proc -- A proper installation of LuaRocks will hardcode the system --- and proc values with config.LUAROCKS_UNAME_S and config.LUAROCKS_UNAME_M, +-- and proc values with site_config.LUAROCKS_UNAME_S and site_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 = config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") -proc = config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") +system = site_config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") +proc = site_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 @@ -105,9 +105,9 @@ end variables = {} rocks_trees = {} -persist.load_into_table(config.LUAROCKS_SYSCONFIG or sys_config_file, _M) +persist.load_into_table(site_config.LUAROCKS_SYSCONFIG or sys_config_file, _M) -if not config.LUAROCKS_FORCE_CONFIG then +if not site_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 @@ -120,8 +120,8 @@ if not next(rocks_trees) then if home_tree then table.insert(rocks_trees, home_tree) end - if config.LUAROCKS_ROCKS_TREE then - table.insert(rocks_trees, config.LUAROCKS_ROCKS_TREE) + if site_config.LUAROCKS_ROCKS_TREE then + table.insert(rocks_trees, site_config.LUAROCKS_ROCKS_TREE) end end @@ -146,9 +146,9 @@ local defaults = { }, lua_extension = "lua", - lua_interpreter = config.LUA_INTERPRETER or "lua", - downloader = config.LUAROCKS_DOWNLOADER or "wget", - md5checker = config.LUAROCKS_MD5CHECKER or "md5sum", + lua_interpreter = site_config.LUA_INTERPRETER or "lua", + downloader = site_config.LUAROCKS_DOWNLOADER or "wget", + md5checker = site_config.LUAROCKS_MD5CHECKER or "md5sum", variables = { MAKE = "make", @@ -213,15 +213,15 @@ if detected.windows then defaults.external_lib_extension = "dll" defaults.obj_extension = "obj" defaults.external_deps_dirs = { "c:/external/" } - 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.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" + defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" + defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" defaults.cmake_generator = "MinGW Makefiles" defaults.makefile = "Makefile.win" defaults.variables.MAKE = "nmake" -- TODO: Split Windows flavors between mingw and msvc defaults.variables.CC = "cl" defaults.variables.RC = "rc" - defaults.variables.WRAPPER = config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.obj" + defaults.variables.WRAPPER = site_config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.obj" defaults.variables.LD = "link" defaults.variables.MT = "mt" defaults.variables.CFLAGS = "/MD /O2" @@ -249,15 +249,15 @@ if detected.mingw32 then defaults.external_lib_extension = "dll" defaults.obj_extension = "o" defaults.external_deps_dirs = { "c:/external/" } - 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.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua5.1/bin" + defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" + defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" defaults.cmake_generator = "MinGW Makefiles" defaults.make = "mingw32-make" -- TODO: Split Windows flavors between mingw and msvc defaults.makefile = "Makefile.win" defaults.variables.CC = "mingw32-gcc" defaults.variables.RC = "windres" - defaults.variables.WRAPPER = config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.o" + defaults.variables.WRAPPER = site_config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.o" defaults.variables.LD = "mingw32-gcc" defaults.variables.CFLAGS = "-O2" defaults.variables.LIBFLAG = "-shared" @@ -281,9 +281,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 = 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.LUA_BINDIR = site_config.LUA_BINDIR or "/usr/local/bin" + defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR or "/usr/local/include" + defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR or "/usr/local/lib" defaults.variables.CFLAGS = "-O2" defaults.cmake_generator = "Unix Makefiles" defaults.platforms = { "unix" } @@ -356,7 +356,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 = config.LUAROCKS_PREFIX +defaults.variables.LUAROCKS_PREFIX = site_config.LUAROCKS_PREFIX -- Use defaults: -- cgit v1.2.3-55-g6feb