aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2013-12-02 09:35:57 +0100
committerThijs Schreijer <thijs@thijsschreijer.nl>2013-12-02 09:35:57 +0100
commitaeff1458076fdefccea990a6d62139084ee605e2 (patch)
tree7e5d7dd0f48fd9b9c6e6d4fadd8db294e992cda0
parentc1342e27bf94e39b095badeb3d91ddd13fc89b59 (diff)
downloadluarocks-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
Diffstat (limited to '')
-rw-r--r--install.bat24
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
7vars.PREFIX = [[C:\LuaRocks]] 7vars.PREFIX = [[C:\LuaRocks]]
8vars.VERSION = "2.1" 8vars.VERSION = "2.1"
9vars.SYSCONFDIR = [[C:\LuaRocks]] 9vars.SYSCONFDIR = nil
10vars.ROCKS_TREE = [[C:\LuaRocks]] 10vars.ROCKS_TREE = nil
11vars.SCRIPTS_DIR = nil 11vars.SCRIPTS_DIR = nil
12vars.LUA_INTERPRETER = nil 12vars.LUA_INTERPRETER = nil
13vars.LUA_PREFIX = nil 13vars.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
426end 424end
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
430local config = {} 432local config = {}
431local with_arg = { -- options followed by an argument, others are flags 433local with_arg = { -- options followed by an argument, others are flags
@@ -466,7 +468,7 @@ end
466for k,v in pairs(oarg) do if k < 1 then arg[k] = v end end -- copy 0 and negative indexes 468for k,v in pairs(oarg) do if k < 1 then arg[k] = v end end -- copy 0 and negative indexes
467oarg = nil 469oarg = nil
468 470
469 471-- build config option table with name and value elements
470local i = 1 472local i = 1
471while i <= #arg do 473while 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")
516end 519end
517 520
521vars.SYSCONFDIR = vars.SYSCONFDIR or vars.PREFIX
522vars.ROCKS_TREE = vars.ROCKS_TREE or vars.PREFIX
518vars.FULL_PREFIX = S"$PREFIX\\$VERSION" 523vars.FULL_PREFIX = S"$PREFIX\\$VERSION"
519vars.BINDIR = vars.FULL_PREFIX 524vars.BINDIR = vars.FULL_PREFIX
520vars.LIBDIR = vars.FULL_PREFIX 525vars.LIBDIR = vars.FULL_PREFIX
@@ -644,8 +649,13 @@ else
644end 649end
645 650
646 651
652-- ***********************************************************
653-- Configure LuaRocks
654-- ***********************************************************
655
647print() 656print()
648print("Configuring LuaRocks...") 657print("Configuring LuaRocks...")
658
649-- Create a site-config file 659-- Create a site-config file
650if exists(S[[$LUADIR\luarocks\site_config.lua]]) then 660if 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]])