diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-11-16 15:30:51 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-11-16 15:30:51 -0200 |
| commit | c27d9ace24f4773da4e6d3680d60769aa1f33197 (patch) | |
| tree | 55183e53426dc26de2078dcad119c5bbe6e987d4 /src | |
| parent | 459d1ddf965d532df787d480236237ef8aa17bc1 (diff) | |
| parent | 8d8e36451aae7f5832efe9ff64de4307e6e8b6a6 (diff) | |
| download | luarocks-c27d9ace24f4773da4e6d3680d60769aa1f33197.tar.gz luarocks-c27d9ace24f4773da4e6d3680d60769aa1f33197.tar.bz2 luarocks-c27d9ace24f4773da4e6d3680d60769aa1f33197.zip | |
Merge branch 'master' into luarocks-3
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 25 | ||||
| -rw-r--r-- | src/luarocks/tools/patch.lua | 24 |
2 files changed, 28 insertions, 21 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index ec9a9829..4fb1b23b 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -228,24 +228,31 @@ 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 | 231 | ||
| 232 | local config_env_var = "LUAROCKS_CONFIG_" .. version_suffix | 232 | local config_env_var = "LUAROCKS_CONFIG_" .. version_suffix |
| 233 | local config_env_value = os.getenv(config_env_var) | 233 | local config_env_value = os.getenv(config_env_var) |
| 234 | if not config_env_value then | 234 | if not config_env_value then |
| 235 | config_env_var = "LUAROCKS_CONFIG" | 235 | config_env_var = "LUAROCKS_CONFIG" |
| 236 | config_env_value = os.getenv(config_env_var) | 236 | config_env_value = os.getenv(config_env_var) |
| 237 | end | 237 | end |
| 238 | if config_env_value then | 238 | |
| 239 | home_config_ok = load_config_file({ config_env_value }) | 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) | ||
| 240 | if not home_config_ok then | 244 | if not home_config_ok then |
| 241 | io.stderr:write("Warning: could not load file "..config_env_value.." given in environment variable "..config_env_var) | 245 | io.stderr:write("Warning: could not load configuration file `"..config_env_value.."` given in environment variable "..config_env_var.."\n") |
| 242 | end | 246 | end |
| 243 | home_config_file = config_env_var | 247 | end |
| 244 | else | 248 | |
| 245 | home_config_file = load_config_file({ | 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 = { | ||
| 246 | home_config_file_default, | 252 | home_config_file_default, |
| 247 | home_config_dir.."/config.lua", | 253 | home_config_dir.."/config.lua", |
| 248 | }) | 254 | } |
| 255 | home_config_file = load_config_file(list) | ||
| 249 | home_config_ok = (home_config_file ~= nil) | 256 | home_config_ok = (home_config_file ~= nil) |
| 250 | end | 257 | end |
| 251 | end | 258 | end |
| @@ -385,7 +392,7 @@ local defaults = { | |||
| 385 | } | 392 | } |
| 386 | 393 | ||
| 387 | if cfg.platforms.windows then | 394 | if cfg.platforms.windows then |
| 388 | local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version | 395 | local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])) |
| 389 | extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" | 396 | extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" |
| 390 | 397 | ||
| 391 | home_config_file = home_config_file and home_config_file:gsub("\\","/") | 398 | 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) |
