diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-11-16 15:29:03 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-11-16 15:29:03 -0200 |
commit | 8d8e36451aae7f5832efe9ff64de4307e6e8b6a6 (patch) | |
tree | 4e6e247a8b0361cfc8678a005e5556e73704f033 | |
parent | 2b8301c6c41707fbf2778a1273761f31d771206a (diff) | |
parent | 579cd7541b0ed9bf9df3e9e87df7a5af4d490baa (diff) | |
download | luarocks-8d8e36451aae7f5832efe9ff64de4307e6e8b6a6.tar.gz luarocks-8d8e36451aae7f5832efe9ff64de4307e6e8b6a6.tar.bz2 luarocks-8d8e36451aae7f5832efe9ff64de4307e6e8b6a6.zip |
Merge branch 'master' of https://github.com/keplerproject/luarocks
-rw-r--r-- | .appveyor/build.bat | 7 | ||||
-rwxr-xr-x | configure | 21 | ||||
-rw-r--r-- | install.bat | 131 | ||||
-rw-r--r-- | src/luarocks/cfg.lua | 36 | ||||
-rw-r--r-- | src/luarocks/tools/patch.lua | 24 |
5 files changed, 110 insertions, 109 deletions
diff --git a/.appveyor/build.bat b/.appveyor/build.bat index 48e72514..a4ff6378 100644 --- a/.appveyor/build.bat +++ b/.appveyor/build.bat | |||
@@ -18,9 +18,8 @@ if not defined LUAROCKS_VER set LUAROCKS_VER=2.2.1 | |||
18 | set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3% | 18 | set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3% |
19 | 19 | ||
20 | if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external | 20 | if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external |
21 | if not defined LUAROCKS_INSTALL set LUAROCKS_INSTALL=%LUA_DIR%\LuaRocks | 21 | if not defined LR_ROOT set LR_ROOT=%LUA_DIR%\LuaRocks |
22 | if not defined LR_ROOT set LR_ROOT=%LUAROCKS_INSTALL%\%LUAROCKS_SHORTV% | 22 | if not defined LR_SYSTREE set LR_SYSTREE=%LR_ROOT%\systree |
23 | if not defined LR_SYSTREE set LR_SYSTREE=%LUAROCKS_INSTALL%\systree | ||
24 | 23 | ||
25 | :: | 24 | :: |
26 | :: ========================================================= | 25 | :: ========================================================= |
@@ -35,7 +34,7 @@ if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_ | |||
35 | :: ========================================================= | 34 | :: ========================================================= |
36 | 35 | ||
37 | cd %APPVEYOR_BUILD_FOLDER% | 36 | cd %APPVEYOR_BUILD_FOLDER% |
38 | call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%" /TREE "%LR_SYSTREE%" | 37 | call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LR_ROOT%" /TREE "%LR_SYSTREE%" |
39 | 38 | ||
40 | if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%" | 39 | if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%" |
41 | 40 | ||
@@ -71,26 +71,7 @@ EOF | |||
71 | # Helper functions | 71 | # Helper functions |
72 | 72 | ||
73 | find_program() { | 73 | find_program() { |
74 | path="$PATH" | 74 | command -v "$1" 2>/dev/null |
75 | item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" | ||
76 | path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" | ||
77 | found="no" | ||
78 | while [ -n "$item" ] | ||
79 | do | ||
80 | if [ -f "$item/$1" ] | ||
81 | then | ||
82 | found="yes" | ||
83 | break | ||
84 | fi | ||
85 | item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" | ||
86 | path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" | ||
87 | done | ||
88 | if [ "$found" = "yes" ] | ||
89 | then | ||
90 | echo "$item" | ||
91 | else | ||
92 | echo "" | ||
93 | fi | ||
94 | } | 75 | } |
95 | 76 | ||
96 | die() { | 77 | die() { |
diff --git a/install.bat b/install.bat index 57e3611c..42b01c43 100644 --- a/install.bat +++ b/install.bat | |||
@@ -8,6 +8,7 @@ local vars = {} | |||
8 | vars.PREFIX = nil | 8 | vars.PREFIX = nil |
9 | vars.VERSION = "2.2" | 9 | vars.VERSION = "2.2" |
10 | vars.SYSCONFDIR = nil | 10 | vars.SYSCONFDIR = nil |
11 | vars.CONFBACKUPDIR = nil | ||
11 | vars.SYSCONFFILENAME = nil | 12 | vars.SYSCONFFILENAME = nil |
12 | vars.CONFIG_FILE = nil | 13 | vars.CONFIG_FILE = nil |
13 | vars.TREE_ROOT = nil | 14 | vars.TREE_ROOT = nil |
@@ -79,7 +80,7 @@ end | |||
79 | 80 | ||
80 | local function exec(cmd) | 81 | local function exec(cmd) |
81 | --print(cmd) | 82 | --print(cmd) |
82 | local status = os.execute(cmd) | 83 | local status = os.execute("type NUL && "..cmd) |
83 | return (status == 0 or status == true) -- compat 5.1/5.2 | 84 | return (status == 0 or status == true) -- compat 5.1/5.2 |
84 | end | 85 | end |
85 | 86 | ||
@@ -97,7 +98,7 @@ local function permission() | |||
97 | return exec("net session >NUL 2>&1") -- fails if not admin | 98 | return exec("net session >NUL 2>&1") -- fails if not admin |
98 | end | 99 | end |
99 | 100 | ||
100 | -- rename file (full path) to backup (name only), appending number if required | 101 | -- rename filename (full path) to backupname (name only), appending number if required |
101 | -- returns the new name (name only) | 102 | -- returns the new name (name only) |
102 | local function backup(filename, backupname) | 103 | local function backup(filename, backupname) |
103 | local path = filename:match("(.+)%\\.-$").."\\" | 104 | local path = filename:match("(.+)%\\.-$").."\\" |
@@ -121,14 +122,12 @@ local function print_help() | |||
121 | Installs LuaRocks. | 122 | Installs LuaRocks. |
122 | 123 | ||
123 | /P [dir] Where to install LuaRocks. | 124 | /P [dir] Where to install LuaRocks. |
124 | Note that version; $VERSION, will be appended to this | ||
125 | path, so "/P c:\luarocks\" will install in | ||
126 | "c:\luarocks\$VERSION\" | ||
127 | Default is %PROGRAMFILES%\LuaRocks | 125 | Default is %PROGRAMFILES%\LuaRocks |
128 | 126 | ||
129 | Configuring the destinations: | 127 | Configuring the destinations: |
130 | /TREE [dir] Root of the local tree of installed rocks. | 128 | /TREE [dir] Root of the local system tree of installed rocks. |
131 | Default is %PROGRAMFILES%\LuaRocks\systree | 129 | Default is {BIN}\..\ if {BIN} ends with '\bin' |
130 | otherwise it is {BIN}\systree. | ||
132 | /SCRIPTS [dir] Where to install commandline scripts installed by | 131 | /SCRIPTS [dir] Where to install commandline scripts installed by |
133 | rocks. Default is {TREE}\bin. | 132 | rocks. Default is {TREE}\bin. |
134 | /LUAMOD [dir] Where to install Lua modules installed by rocks. | 133 | /LUAMOD [dir] Where to install Lua modules installed by rocks. |
@@ -255,7 +254,7 @@ local function check_flags() | |||
255 | die("Cannot combine option /L with any of /LUA /BIN /LIB /INC") | 254 | die("Cannot combine option /L with any of /LUA /BIN /LIB /INC") |
256 | end | 255 | end |
257 | if vars.LUA_VERSION ~= "5.1" then | 256 | if vars.LUA_VERSION ~= "5.1" then |
258 | die("Bundled Lua version is 5.1, cannot install 5.2") | 257 | die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) |
259 | end | 258 | end |
260 | end | 259 | end |
261 | if vars.LUA_VERSION ~= "5.1" then | 260 | if vars.LUA_VERSION ~= "5.1" then |
@@ -479,6 +478,28 @@ local function look_for_lua_install () | |||
479 | return false | 478 | return false |
480 | end | 479 | end |
481 | 480 | ||
481 | -- backup config[x.x].lua[.bak] and site_config[_x_x].lua | ||
482 | local function backup_config_files() | ||
483 | local temppath | ||
484 | while not temppath do | ||
485 | temppath = os.getenv("temp").."\\LR-config-backup-"..tostring(math.random(10000)) | ||
486 | if exists(temppath) then temppath = nil end | ||
487 | end | ||
488 | vars.CONFBACKUPDIR = temppath | ||
489 | mkdir(vars.CONFBACKUPDIR) | ||
490 | exec(S[[COPY "$PREFIX\config*.*" "$CONFBACKUPDIR" >NUL]]) | ||
491 | exec(S[[COPY "$PREFIX\lua\luarocks\site_config*.*" "$CONFBACKUPDIR" >NUL]]) | ||
492 | end | ||
493 | |||
494 | -- restore previously backed up config files | ||
495 | local function restore_config_files() | ||
496 | if not vars.CONFBACKUPDIR then return end -- there is no backup to restore | ||
497 | exec(S[[COPY "$CONFBACKUPDIR\config*.*" "$PREFIX" >NUL]]) | ||
498 | exec(S[[COPY "$CONFBACKUPDIR\site_config*.*" "$PREFIX\lua\luarocks" >NUL]]) | ||
499 | -- cleanup | ||
500 | exec(S[[RD /S /Q "$CONFBACKUPDIR"]]) | ||
501 | vars.CONFBACKUPDIR = nil | ||
502 | end | ||
482 | 503 | ||
483 | -- *********************************************************** | 504 | -- *********************************************************** |
484 | -- Installer script start | 505 | -- Installer script start |
@@ -586,11 +607,10 @@ else | |||
586 | end | 607 | end |
587 | 608 | ||
588 | vars.PREFIX = vars.PREFIX or os.getenv("PROGRAMFILES")..[[\LuaRocks]] | 609 | vars.PREFIX = vars.PREFIX or os.getenv("PROGRAMFILES")..[[\LuaRocks]] |
589 | vars.FULL_PREFIX = S"$PREFIX\\$VERSION" | 610 | vars.BINDIR = vars.PREFIX |
590 | vars.BINDIR = vars.FULL_PREFIX | 611 | vars.LIBDIR = vars.PREFIX |
591 | vars.LIBDIR = vars.FULL_PREFIX | 612 | vars.LUADIR = S"$PREFIX\\lua" |
592 | vars.LUADIR = S"$FULL_PREFIX\\lua" | 613 | vars.INCDIR = S"$PREFIX\\include" |
593 | vars.INCDIR = S"$FULL_PREFIX\\include" | ||
594 | vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") | 614 | vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") |
595 | 615 | ||
596 | if INSTALL_LUA then | 616 | if INSTALL_LUA then |
@@ -611,17 +631,23 @@ else | |||
611 | vars.UNAME_M = get_architecture() -- can only do when installation was found | 631 | vars.UNAME_M = get_architecture() -- can only do when installation was found |
612 | end | 632 | end |
613 | 633 | ||
614 | local datapath | 634 | -- check location of system tree |
615 | if vars.UNAME_M == "x86" then | 635 | if not vars.TREE_ROOT then |
616 | datapath = os.getenv("PROGRAMFILES") .. [[\LuaRocks]] | 636 | -- no system tree location given, so we need to construct a default value |
617 | else | 637 | if vars.LUA_BINDIR:lower():match([[([\/]+bin[\/]*)$]]) then |
618 | -- our target interpreter is 64bit, so the tree (with binaries) should go into 64bit program files | 638 | -- lua binary is located in a 'bin' subdirectory, so assume |
619 | datapath = os.getenv("ProgramW6432") .. [[\LuaRocks]] | 639 | -- default Lua layout and match rocktree on top |
640 | vars.TREE_ROOT = vars.LUA_BINDIR:lower():gsub([[[\/]+bin[\/]*$]], [[\]]) | ||
641 | else | ||
642 | -- no 'bin', so use a named tree next to the Lua executable | ||
643 | vars.TREE_ROOT = vars.LUA_BINDIR .. [[\systree]] | ||
644 | end | ||
620 | end | 645 | end |
646 | |||
647 | local datapath | ||
621 | vars.SYSCONFDIR = vars.SYSCONFDIR or vars.PREFIX | 648 | vars.SYSCONFDIR = vars.SYSCONFDIR or vars.PREFIX |
622 | vars.SYSCONFFILENAME = S"config-$LUA_VERSION.lua" | 649 | vars.SYSCONFFILENAME = S"config-$LUA_VERSION.lua" |
623 | vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME | 650 | vars.CONFIG_FILE = vars.SYSCONFDIR.."\\"..vars.SYSCONFFILENAME |
624 | vars.TREE_ROOT = vars.TREE_ROOT or datapath..[[\systree]] | ||
625 | if SELFCONTAINED then | 651 | if SELFCONTAINED then |
626 | vars.SYSCONFDIR = vars.PREFIX | 652 | vars.SYSCONFDIR = vars.PREFIX |
627 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] | 653 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] |
@@ -635,7 +661,7 @@ print(S[[ | |||
635 | ========================== | 661 | ========================== |
636 | 662 | ||
637 | Will configure LuaRocks with the following paths: | 663 | Will configure LuaRocks with the following paths: |
638 | LuaRocks : $FULL_PREFIX | 664 | LuaRocks : $PREFIX |
639 | Config file : $CONFIG_FILE | 665 | Config file : $CONFIG_FILE |
640 | Rocktree : $TREE_ROOT | 666 | Rocktree : $TREE_ROOT |
641 | 667 | ||
@@ -664,17 +690,19 @@ print([[ | |||
664 | -- *********************************************************** | 690 | -- *********************************************************** |
665 | -- Install LuaRocks files | 691 | -- Install LuaRocks files |
666 | -- *********************************************************** | 692 | -- *********************************************************** |
667 | if FORCE then | ||
668 | print(S"Removing $FULL_PREFIX...") | ||
669 | exec(S[[RD /S /Q "$FULL_PREFIX"]]) | ||
670 | print() | ||
671 | end | ||
672 | 693 | ||
673 | if exists(vars.FULL_PREFIX) then | 694 | if exists(vars.PREFIX) then |
674 | die(S"$FULL_PREFIX exists. Use /F to force removal and reinstallation.") | 695 | if not FORCE then |
696 | die(S"$PREFIX exists. Use /F to force removal and reinstallation.") | ||
697 | else | ||
698 | backup_config_files() | ||
699 | print(S"Removing $PREFIX...") | ||
700 | exec(S[[RD /S /Q "$PREFIX"]]) | ||
701 | print() | ||
702 | end | ||
675 | end | 703 | end |
676 | 704 | ||
677 | print(S"Installing LuaRocks in $FULL_PREFIX...") | 705 | print(S"Installing LuaRocks in $PREFIX...") |
678 | if not exists(vars.BINDIR) then | 706 | if not exists(vars.BINDIR) then |
679 | if not mkdir(vars.BINDIR) then | 707 | if not mkdir(vars.BINDIR) then |
680 | die() | 708 | die() |
@@ -776,37 +804,21 @@ exit /b %EXITCODE% | |||
776 | print(S"Created LuaRocks command: $BINDIR\\"..c..".bat") | 804 | print(S"Created LuaRocks command: $BINDIR\\"..c..".bat") |
777 | end | 805 | end |
778 | 806 | ||
779 | -- part below was commented out as its purpose was unclear | ||
780 | -- see https://github.com/keplerproject/luarocks/pull/197#issuecomment-30176548 | ||
781 | |||
782 | -- configure 'scripts' directory | ||
783 | -- if vars.TREE_BIN then | ||
784 | -- mkdir(vars.TREE_BIN) | ||
785 | -- if not USE_MINGW then | ||
786 | -- -- definitly not for MinGW because of conflicting runtimes | ||
787 | -- -- but is it ok to do it for others??? | ||
788 | -- exec(S[[COPY lua5.1\bin\*.dll "$TREE_BIN" >NUL]]) | ||
789 | -- end | ||
790 | -- else | ||
791 | -- if not USE_MINGW then | ||
792 | -- mkdir(S[[$TREE_ROOT\bin]]) | ||
793 | -- -- definitly not for MinGW because of conflicting runtimes | ||
794 | -- -- but is it ok to do it for others??? | ||
795 | -- exec(S[[COPY lua5.1\bin\*.dll "$TREE_ROOT"\bin >NUL]]) | ||
796 | -- end | ||
797 | -- end | ||
798 | |||
799 | -- *********************************************************** | 807 | -- *********************************************************** |
800 | -- Configure LuaRocks | 808 | -- Configure LuaRocks |
801 | -- *********************************************************** | 809 | -- *********************************************************** |
802 | 810 | ||
811 | restore_config_files() | ||
803 | print() | 812 | print() |
804 | print("Configuring LuaRocks...") | 813 | print("Configuring LuaRocks...") |
805 | 814 | ||
806 | -- Create a site-config file | 815 | -- Create a site-config file |
807 | local site_config = S("site_config_$LUA_VERSION"):gsub("%.","_") | 816 | local site_config = S("site_config_$LUA_VERSION"):gsub("%.","_") |
808 | if exists(S([[$LUADIR\luarocks\]]..site_config..[[.lua]])) then | 817 | if exists(S([[$LUADIR\luarocks\]]..site_config..[[.lua]])) then |
809 | exec(S([[RENAME "$LUADIR\luarocks\]]..site_config..[[.lua" site_config.lua.bak]])) | 818 | local nname = backup(S([[$LUADIR\luarocks\]]..site_config..[[.lua]]), site_config..".lua.bak") |
819 | print("***************") | ||
820 | print("*** WARNING *** LuaRocks site_config file already exists: '"..site_config..".lua'. The old file has been renamed to '"..nname.."'") | ||
821 | print("***************") | ||
810 | end | 822 | end |
811 | local f = io.open(vars.LUADIR.."\\luarocks\\"..site_config..".lua", "w") | 823 | local f = io.open(vars.LUADIR.."\\luarocks\\"..site_config..".lua", "w") |
812 | f:write(S[=[ | 824 | f:write(S[=[ |
@@ -832,13 +844,6 @@ site_config.LUAROCKS_MD5CHECKER=[[md5sum]] | |||
832 | if FORCE_CONFIG then | 844 | if FORCE_CONFIG then |
833 | f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n") | 845 | f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n") |
834 | end | 846 | end |
835 | if exists(vars.LUADIR.."\\luarocks\\"..site_config..".lua.bak") then | ||
836 | for line in io.lines(vars.LUADIR.."\\luarocks\\"..site_config..".lua.bak", "r") do | ||
837 | f:write(line) | ||
838 | f:write("\n") | ||
839 | end | ||
840 | exec(S([[DEL /F /Q "$LUADIR\luarocks\]]..site_config..[[.lua.bak"]])) | ||
841 | end | ||
842 | f:write("return site_config\n") | 847 | f:write("return site_config\n") |
843 | f:close() | 848 | f:close() |
844 | print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\]]..site_config..[[.lua]])) | 849 | print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\]]..site_config..[[.lua]])) |
@@ -913,17 +918,17 @@ if REGISTRY then | |||
913 | -- expand template with correct path information | 918 | -- expand template with correct path information |
914 | print() | 919 | print() |
915 | print([[Loading registry information for ".rockspec" files]]) | 920 | print([[Loading registry information for ".rockspec" files]]) |
916 | exec( S[[win32\lua5.1\bin\lua5.1.exe "$FULL_PREFIX\LuaRocks.reg.lua" "$FULL_PREFIX\LuaRocks.reg.template"]] ) | 921 | exec( S[[win32\lua5.1\bin\lua5.1.exe "$PREFIX\LuaRocks.reg.lua" "$PREFIX\LuaRocks.reg.template"]] ) |
917 | exec( S[[regedit /S "$FULL_PREFIX\\LuaRocks.reg"]] ) | 922 | exec( S[[regedit /S "$PREFIX\\LuaRocks.reg"]] ) |
918 | end | 923 | end |
919 | 924 | ||
920 | -- *********************************************************** | 925 | -- *********************************************************** |
921 | -- Cleanup | 926 | -- Cleanup |
922 | -- *********************************************************** | 927 | -- *********************************************************** |
923 | -- remove regsitry related files, no longer needed | 928 | -- remove regsitry related files, no longer needed |
924 | exec( S[[del "$FULL_PREFIX\LuaRocks.reg.*" >NUL]] ) | 929 | exec( S[[del "$PREFIX\LuaRocks.reg.*" >NUL]] ) |
925 | -- remove pe-parser module | 930 | -- remove pe-parser module |
926 | exec( S[[del "$FULL_PREFIX\pe-parser.lua" >NUL]] ) | 931 | exec( S[[del "$PREFIX\pe-parser.lua" >NUL]] ) |
927 | 932 | ||
928 | -- *********************************************************** | 933 | -- *********************************************************** |
929 | -- Exit handlers | 934 | -- Exit handlers |
@@ -943,8 +948,8 @@ Lua interpreter; | |||
943 | PATH : $LUA_BINDIR | 948 | PATH : $LUA_BINDIR |
944 | PATHEXT : .LUA | 949 | PATHEXT : .LUA |
945 | LuaRocks; | 950 | LuaRocks; |
946 | PATH : $FULL_PREFIX | 951 | PATH : $PREFIX |
947 | LUA_PATH : $FULL_PREFIX\lua\?.lua;$FULL_PREFIX\lua\?\init.lua | 952 | LUA_PATH : $PREFIX\lua\?.lua;$PREFIX\lua\?\init.lua |
948 | Local user rocktree (Note: %APPDATA% is user dependent); | 953 | Local user rocktree (Note: %APPDATA% is user dependent); |
949 | PATH : %APPDATA%\LuaRocks\bin | 954 | PATH : %APPDATA%\LuaRocks\bin |
950 | LUA_PATH : %APPDATA%\LuaRocks\share\lua\$LUA_VERSION\?.lua;%APPDATA%\LuaRocks\share\lua\$LUA_VERSION\?\init.lua | 955 | LUA_PATH : %APPDATA%\LuaRocks\share\lua\$LUA_VERSION\?.lua;%APPDATA%\LuaRocks\share\lua\$LUA_VERSION\?\init.lua |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 3b7f9c37..e3d6e74b 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -228,17 +228,33 @@ end | |||
228 | if not site_config.LUAROCKS_FORCE_CONFIG then | 228 | if not site_config.LUAROCKS_FORCE_CONFIG then |
229 | 229 | ||
230 | home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" | 230 | home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" |
231 | local list = { | ||
232 | os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG"), | ||
233 | home_config_file_default, | ||
234 | home_config_dir.."/config.lua", | ||
235 | } | ||
236 | -- first entry might be a silent nil, check and remove if so | ||
237 | if not list[1] then table.remove(list, 1) end | ||
238 | 231 | ||
239 | home_config_file = load_config_file(list) | 232 | local config_env_var = "LUAROCKS_CONFIG_" .. version_suffix |
240 | home_config_ok = (home_config_file ~= nil) | 233 | local config_env_value = os.getenv(config_env_var) |
234 | if not config_env_value then | ||
235 | config_env_var = "LUAROCKS_CONFIG" | ||
236 | config_env_value = os.getenv(config_env_var) | ||
237 | end | ||
238 | |||
239 | -- first try environment provided file, so we can explicitly warn when it is missing | ||
240 | if config_env_value then | ||
241 | local list = { config_env_value } | ||
242 | home_config_file = load_config_file(list) | ||
243 | home_config_ok = (home_config_file ~= nil) | ||
244 | if not home_config_ok then | ||
245 | io.stderr:write("Warning: could not load configuration file `"..config_env_value.."` given in environment variable "..config_env_var.."\n") | ||
246 | end | ||
247 | end | ||
241 | 248 | ||
249 | -- try the alternative defaults if there was no environment specified file or it didn't work | ||
250 | if not home_config_ok then | ||
251 | local list = { | ||
252 | home_config_file_default, | ||
253 | home_config_dir.."/config.lua", | ||
254 | } | ||
255 | home_config_file = load_config_file(list) | ||
256 | home_config_ok = (home_config_file ~= nil) | ||
257 | end | ||
242 | end | 258 | end |
243 | 259 | ||
244 | 260 | ||
@@ -375,7 +391,7 @@ local defaults = { | |||
375 | } | 391 | } |
376 | 392 | ||
377 | if cfg.platforms.windows then | 393 | if cfg.platforms.windows then |
378 | local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version | 394 | local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])) |
379 | extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" | 395 | extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" |
380 | 396 | ||
381 | home_config_file = home_config_file and home_config_file:gsub("\\","/") | 397 | home_config_file = home_config_file and home_config_file:gsub("\\","/") |
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index b53bad61..debaf636 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -200,8 +200,13 @@ function patch.read_patch(filename, data) | |||
200 | if state == 'hunkbody' then | 200 | if state == 'hunkbody' then |
201 | -- skip hunkskip and hunkbody code until definition of hunkhead read | 201 | -- skip hunkskip and hunkbody code until definition of hunkhead read |
202 | 202 | ||
203 | if line:match"^[\r\n]*$" then | ||
204 | -- prepend space to empty lines to interpret them as context properly | ||
205 | line = " " .. line | ||
206 | end | ||
207 | |||
203 | -- process line first | 208 | -- process line first |
204 | if line:match"^[- +\\]" or line:match"^[\r\n]*$" then | 209 | if line:match"^[- +\\]" then |
205 | -- gather stats about line endings | 210 | -- gather stats about line endings |
206 | local he = files.hunkends[nextfileno] | 211 | local he = files.hunkends[nextfileno] |
207 | if endswith(line, "\r\n") then | 212 | if endswith(line, "\r\n") then |
@@ -455,16 +460,15 @@ local function find_hunks(file, hunks) | |||
455 | end | 460 | end |
456 | 461 | ||
457 | local function check_patched(file, hunks) | 462 | local function check_patched(file, hunks) |
458 | local matched = true | ||
459 | local lineno = 1 | 463 | local lineno = 1 |
460 | local ok, err = pcall(function() | 464 | local ok, err = pcall(function() |
461 | if #file == 0 then | 465 | if #file == 0 then |
462 | error 'nomatch' | 466 | error('nomatch', 0) |
463 | end | 467 | end |
464 | for hno, h in ipairs(hunks) do | 468 | for hno, h in ipairs(hunks) do |
465 | -- skip to line just before hunk starts | 469 | -- skip to line just before hunk starts |
466 | if #file < h.starttgt then | 470 | if #file < h.starttgt then |
467 | error 'nomatch' | 471 | error('nomatch', 0) |
468 | end | 472 | end |
469 | lineno = h.starttgt | 473 | lineno = h.starttgt |
470 | for _, hline in ipairs(h.text) do | 474 | for _, hline in ipairs(h.text) do |
@@ -473,22 +477,18 @@ local function check_patched(file, hunks) | |||
473 | local line = file[lineno] | 477 | local line = file[lineno] |
474 | lineno = lineno + 1 | 478 | lineno = lineno + 1 |
475 | if #line == 0 then | 479 | if #line == 0 then |
476 | error 'nomatch' | 480 | error('nomatch', 0) |
477 | end | 481 | end |
478 | if endlstrip(line) ~= endlstrip(hline:sub(2)) then | 482 | if endlstrip(line) ~= endlstrip(hline:sub(2)) then |
479 | warning(format("file is not patched - failed hunk: %d", hno)) | 483 | warning(format("file is not patched - failed hunk: %d", hno)) |
480 | error 'nomatch' | 484 | error('nomatch', 0) |
481 | end | 485 | end |
482 | end | 486 | end |
483 | end | 487 | end |
484 | end | 488 | end |
485 | end) | 489 | end) |
486 | if err == 'nomatch' then | 490 | -- todo: display failed hunk, i.e. expected/found |
487 | matched = false | 491 | return err ~= 'nomatch' |
488 | end | ||
489 | -- todo: display failed hunk, i.e. expected/found | ||
490 | |||
491 | return matched | ||
492 | end | 492 | end |
493 | 493 | ||
494 | local function patch_hunks(srcname, tgtname, hunks) | 494 | local function patch_hunks(srcname, tgtname, hunks) |