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 /src | |
| 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
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 36 | ||||
| -rw-r--r-- | src/luarocks/tools/patch.lua | 24 |
2 files changed, 38 insertions, 22 deletions
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) |
