diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-12-02 09:35:57 +0100 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-12-02 09:35:57 +0100 |
| commit | aeff1458076fdefccea990a6d62139084ee605e2 (patch) | |
| tree | 7e5d7dd0f48fd9b9c6e6d4fadd8db294e992cda0 | |
| parent | c1342e27bf94e39b095badeb3d91ddd13fc89b59 (diff) | |
| download | luarocks-aeff1458076fdefccea990a6d62139084ee605e2.tar.gz luarocks-aeff1458076fdefccea990a6d62139084ee605e2.tar.bz2 luarocks-aeff1458076fdefccea990a6d62139084ee605e2.zip | |
Windows installer required /P argument to be first or would overwrite other values
cleanup temp batch file in case of elevation
| -rw-r--r-- | install.bat | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/install.bat b/install.bat index 11558f7f..1e4763fc 100644 --- a/install.bat +++ b/install.bat | |||
| @@ -6,8 +6,8 @@ local vars = {} | |||
| 6 | 6 | ||
| 7 | vars.PREFIX = [[C:\LuaRocks]] | 7 | vars.PREFIX = [[C:\LuaRocks]] |
| 8 | vars.VERSION = "2.1" | 8 | vars.VERSION = "2.1" |
| 9 | vars.SYSCONFDIR = [[C:\LuaRocks]] | 9 | vars.SYSCONFDIR = nil |
| 10 | vars.ROCKS_TREE = [[C:\LuaRocks]] | 10 | vars.ROCKS_TREE = nil |
| 11 | vars.SCRIPTS_DIR = nil | 11 | vars.SCRIPTS_DIR = nil |
| 12 | vars.LUA_INTERPRETER = nil | 12 | vars.LUA_INTERPRETER = nil |
| 13 | vars.LUA_PREFIX = nil | 13 | vars.LUA_PREFIX = nil |
| @@ -163,8 +163,6 @@ local function parse_options(args) | |||
| 163 | os.exit(0) | 163 | os.exit(0) |
| 164 | elseif name == "/P" then | 164 | elseif name == "/P" then |
| 165 | vars.PREFIX = option.value | 165 | vars.PREFIX = option.value |
| 166 | vars.SYSCONFDIR = option.value | ||
| 167 | vars.ROCKS_TREE = option.value | ||
| 168 | P_SET = true | 166 | P_SET = true |
| 169 | elseif name == "/CONFIG" then | 167 | elseif name == "/CONFIG" then |
| 170 | vars.SYSCONFDIR = option.value | 168 | vars.SYSCONFDIR = option.value |
| @@ -425,7 +423,11 @@ local function look_for_lua_install () | |||
| 425 | return false | 423 | return false |
| 426 | end | 424 | end |
| 427 | 425 | ||
| 428 | --- | 426 | |
| 427 | -- *********************************************************** | ||
| 428 | -- Installer script start | ||
| 429 | -- *********************************************************** | ||
| 430 | |||
| 429 | -- Poor man's command-line parsing | 431 | -- Poor man's command-line parsing |
| 430 | local config = {} | 432 | local config = {} |
| 431 | local with_arg = { -- options followed by an argument, others are flags | 433 | local with_arg = { -- options followed by an argument, others are flags |
| @@ -466,7 +468,7 @@ end | |||
| 466 | for k,v in pairs(oarg) do if k < 1 then arg[k] = v end end -- copy 0 and negative indexes | 468 | for k,v in pairs(oarg) do if k < 1 then arg[k] = v end end -- copy 0 and negative indexes |
| 467 | oarg = nil | 469 | oarg = nil |
| 468 | 470 | ||
| 469 | 471 | -- build config option table with name and value elements | |
| 470 | local i = 1 | 472 | local i = 1 |
| 471 | while i <= #arg do | 473 | while i <= #arg do |
| 472 | local opt = arg[i] | 474 | local opt = arg[i] |
| @@ -499,10 +501,11 @@ if not permission() then | |||
| 499 | local runner = os.getenv("TEMP").."\\".."LuaRocks_Installer.bat" | 501 | local runner = os.getenv("TEMP").."\\".."LuaRocks_Installer.bat" |
| 500 | local f = io.open(runner, "w") | 502 | local f = io.open(runner, "w") |
| 501 | f:write("@echo off\n") | 503 | f:write("@echo off\n") |
| 502 | f:write("CHDIR /D "..arg[0]:match("(.+)%\\.-$").."\n") -- return to current die, elevation changes current path | 504 | f:write("CHDIR /D "..arg[0]:match("(.+)%\\.-$").."\n") -- return to current dir, elevation changes current path |
| 503 | f:write('"'..arg[-1]..'" "'..table.concat(arg, '" "', 0)..'"\n') | 505 | f:write('"'..arg[-1]..'" "'..table.concat(arg, '" "', 0)..'"\n') |
| 504 | f:write("ECHO Press any key to close this window...\n") | 506 | f:write("ECHO Press any key to close this window...\n") |
| 505 | f:write("PAUSE > NUL\n") | 507 | f:write("PAUSE > NUL\n") |
| 508 | f:write('DEL "'..runner..'"') -- temp batch file deletes itself | ||
| 506 | f:close() | 509 | f:close() |
| 507 | -- run the created temp batch file in elevated mode | 510 | -- run the created temp batch file in elevated mode |
| 508 | exec("PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('"..runner.."', '', '', 'runas')\n") | 511 | exec("PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('"..runner.."', '', '', 'runas')\n") |
| @@ -515,6 +518,8 @@ else | |||
| 515 | print("Admin priviledges available for installing") | 518 | print("Admin priviledges available for installing") |
| 516 | end | 519 | end |
| 517 | 520 | ||
| 521 | vars.SYSCONFDIR = vars.SYSCONFDIR or vars.PREFIX | ||
| 522 | vars.ROCKS_TREE = vars.ROCKS_TREE or vars.PREFIX | ||
| 518 | vars.FULL_PREFIX = S"$PREFIX\\$VERSION" | 523 | vars.FULL_PREFIX = S"$PREFIX\\$VERSION" |
| 519 | vars.BINDIR = vars.FULL_PREFIX | 524 | vars.BINDIR = vars.FULL_PREFIX |
| 520 | vars.LIBDIR = vars.FULL_PREFIX | 525 | vars.LIBDIR = vars.FULL_PREFIX |
| @@ -644,8 +649,13 @@ else | |||
| 644 | end | 649 | end |
| 645 | 650 | ||
| 646 | 651 | ||
| 652 | -- *********************************************************** | ||
| 653 | -- Configure LuaRocks | ||
| 654 | -- *********************************************************** | ||
| 655 | |||
| 647 | print() | 656 | print() |
| 648 | print("Configuring LuaRocks...") | 657 | print("Configuring LuaRocks...") |
| 658 | |||
| 649 | -- Create a site-config file | 659 | -- Create a site-config file |
| 650 | if exists(S[[$LUADIR\luarocks\site_config.lua]]) then | 660 | if exists(S[[$LUADIR\luarocks\site_config.lua]]) then |
| 651 | exec(S[[RENAME "$LUADIR\luarocks\site_config.lua" site_config.lua.bak]]) | 661 | exec(S[[RENAME "$LUADIR\luarocks\site_config.lua" site_config.lua.bak]]) |
