aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2013-12-12 23:25:29 -0200
committerHisham Muhammad <hisham@gobolinux.org>2013-12-12 23:25:29 -0200
commit58aabb224b4b34779f4df01f4e5265d7d82fac49 (patch)
tree58039e810b74aeb0c18c2e6cd1a2a4add006a351
parente37937d2f7f28d8bdf395ce1ad13df83d6b2b3ae (diff)
parentf154f7e7741fe91850cb0bd4b537ccfaf32e1511 (diff)
downloadluarocks-58aabb224b4b34779f4df01f4e5265d7d82fac49.tar.gz
luarocks-58aabb224b4b34779f4df01f4e5265d7d82fac49.tar.bz2
luarocks-58aabb224b4b34779f4df01f4e5265d7d82fac49.zip
Merge branch 'master' of github.com:keplerproject/luarocks
-rw-r--r--install.bat90
1 files changed, 52 insertions, 38 deletions
diff --git a/install.bat b/install.bat
index 43a2b34f..280d361f 100644
--- a/install.bat
+++ b/install.bat
@@ -4,10 +4,11 @@ rem=rem --[[
4 4
5local vars = {} 5local vars = {}
6 6
7vars.PREFIX = [[C:\LuaRocks]] 7
8vars.PREFIX = os.getenv("PROGRAMFILES")..[[\LuaRocks]]
8vars.VERSION = "2.1" 9vars.VERSION = "2.1"
9vars.SYSCONFDIR = nil 10vars.SYSCONFDIR = (os.getenv("PROGRAMDATA") or (os.getenv("ALLUSERSPROFILE")..[[\Application Data]])) .. [[\LuaRocks]] -- ALLUSERS for WinXP compat
10vars.ROCKS_TREE = nil 11vars.ROCKS_TREE = vars.SYSCONFDIR
11vars.SCRIPTS_DIR = nil 12vars.SCRIPTS_DIR = nil
12vars.LUA_INTERPRETER = nil 13vars.LUA_INTERPRETER = nil
13vars.LUA_PREFIX = nil 14vars.LUA_PREFIX = nil
@@ -21,13 +22,13 @@ vars.LUA_LIB_NAMES = "lua5.1.lib lua51.dll liblua.dll.a"
21vars.LUA_RUNTIME = nil 22vars.LUA_RUNTIME = nil
22vars.UNAME_M = nil 23vars.UNAME_M = nil
23 24
24local P_SET = false
25local FORCE = false 25local FORCE = false
26local FORCE_CONFIG = false 26local FORCE_CONFIG = false
27local INSTALL_LUA = false 27local INSTALL_LUA = false
28local USE_MINGW = false 28local USE_MINGW = false
29local REGISTRY = false 29local REGISTRY = false
30local NOADMIN = false 30local NOADMIN = false
31local PROMPT = true
31 32
32--- 33---
33-- Some helpers 34-- Some helpers
@@ -85,7 +86,7 @@ end
85 86
86-- does the current user have admin priviledges ( = elevated) 87-- does the current user have admin priviledges ( = elevated)
87local function permission() 88local function permission()
88 return exec("net session >nul 2>&1") -- fails if not admin 89 return exec("net session >NUL 2>&1") -- fails if not admin
89end 90end
90 91
91-- rename file (full path) to backup (name only), appending number if required 92-- rename file (full path) to backup (name only), appending number if required
@@ -111,16 +112,17 @@ local function print_help()
111 print(S[[ 112 print(S[[
112Installs LuaRocks. 113Installs LuaRocks.
113 114
114/P [dir] (REQUIRED) Where to install LuaRocks. 115/P [dir] Where to install LuaRocks.
115 Note that version; $VERSION, will be appended to this 116 Note that version; $VERSION, will be appended to this
116 path, so "/P c:\luarocks\" will install in 117 path, so "/P c:\luarocks\" will install in
117 "c:\luarocks\$VERSION\" 118 "c:\luarocks\$VERSION\"
119 Default is %PROGRAMFILES%\LuaRocks
118 120
119Configuring the destinations: 121Configuring the destinations:
120/TREE [dir] Root of the local tree of installed rocks. 122/TREE [dir] Root of the local tree of installed rocks.
121 Default is same place of installation 123 Default is %PROGRAMDATA%\LuaRocks
122/SCRIPTS [dir] Where to install commandline scripts installed by 124/SCRIPTS [dir] Where to install commandline scripts installed by
123 rocks. Default is TREE/bin. 125 rocks. Default is {TREE}/bin.
124 126
125Configuring the Lua interpreter: 127Configuring the Lua interpreter:
126/LV [version] Lua version to use; either 5.1 or 5.2. 128/LV [version] Lua version to use; either 5.1 or 5.2.
@@ -148,7 +150,7 @@ Compiler configuration:
148 150
149Other options: 151Other options:
150/CONFIG [dir] Location where the config file should be installed. 152/CONFIG [dir] Location where the config file should be installed.
151 Default is same place of installation 153 Default is %PROGRAMDATA%\LuaRocks
152/FORCECONFIG Use a single config location. Do not use the 154/FORCECONFIG Use a single config location. Do not use the
153 LUAROCKS_CONFIG variable or the user's home directory. 155 LUAROCKS_CONFIG variable or the user's home directory.
154 Useful to avoid conflicts when LuaRocks 156 Useful to avoid conflicts when LuaRocks
@@ -161,6 +163,11 @@ Other options:
161 switch to prevent elevation, but make sure the 163 switch to prevent elevation, but make sure the
162 destination paths are all accessible for the current 164 destination paths are all accessible for the current
163 user. 165 user.
166/Q Do not prompt for confirmation of settings
167
168Example:
169To create a self contained install use (assuming Lua is in your PATH):
170INSTALL /P c:\LuaRocks /TREE c:\LuaRocks /CONFIG c:\LuaRocks
164 171
165]]) 172]])
166end 173end
@@ -176,7 +183,6 @@ local function parse_options(args)
176 os.exit(0) 183 os.exit(0)
177 elseif name == "/P" then 184 elseif name == "/P" then
178 vars.PREFIX = option.value 185 vars.PREFIX = option.value
179 P_SET = true
180 elseif name == "/CONFIG" then 186 elseif name == "/CONFIG" then
181 vars.SYSCONFDIR = option.value 187 vars.SYSCONFDIR = option.value
182 elseif name == "/TREE" then 188 elseif name == "/TREE" then
@@ -205,6 +211,8 @@ local function parse_options(args)
205 REGISTRY = true 211 REGISTRY = true
206 elseif name == "/NOADMIN" then 212 elseif name == "/NOADMIN" then
207 NOADMIN = true 213 NOADMIN = true
214 elseif name == "/Q" then
215 PROMPT = false
208 else 216 else
209 die("Unrecognized option: " .. name) 217 die("Unrecognized option: " .. name)
210 end 218 end
@@ -213,9 +221,6 @@ end
213 221
214-- check for combination/required flags 222-- check for combination/required flags
215local function check_flags() 223local function check_flags()
216 if not P_SET then
217 die("Missing required parameter /P")
218 end
219 if INSTALL_LUA then 224 if INSTALL_LUA then
220 if vars.LUA_INCDIR or vars.LUA_BINDIR or vars.LUA_LIBDIR or vars.LUA_PREFIX then 225 if vars.LUA_INCDIR or vars.LUA_BINDIR or vars.LUA_LIBDIR or vars.LUA_PREFIX then
221 die("Cannot combine option /L with any of /LUA /BIN /LIB /INC") 226 die("Cannot combine option /L with any of /LUA /BIN /LIB /INC")
@@ -531,8 +536,6 @@ else
531 print("Admin priviledges available for installing") 536 print("Admin priviledges available for installing")
532end 537end
533 538
534vars.SYSCONFDIR = vars.SYSCONFDIR or vars.PREFIX
535vars.ROCKS_TREE = vars.ROCKS_TREE or vars.PREFIX
536vars.FULL_PREFIX = S"$PREFIX\\$VERSION" 539vars.FULL_PREFIX = S"$PREFIX\\$VERSION"
537vars.BINDIR = vars.FULL_PREFIX 540vars.BINDIR = vars.FULL_PREFIX
538vars.LIBDIR = vars.FULL_PREFIX 541vars.LIBDIR = vars.FULL_PREFIX
@@ -563,14 +566,18 @@ print(S[[
563Will configure LuaRocks with the following paths: 566Will configure LuaRocks with the following paths:
564LuaRocks : $FULL_PREFIX 567LuaRocks : $FULL_PREFIX
565Lua interpreter: $LUA_BINDIR\$LUA_INTERPRETER 568Lua interpreter: $LUA_BINDIR\$LUA_INTERPRETER
566Lua binaries : $LUA_BINDIR 569 binaries : $LUA_BINDIR
567Lua libraries : $LUA_LIBDIR 570 libraries : $LUA_LIBDIR
568Lua includes : $LUA_INCDIR 571 includes : $LUA_INCDIR
569Binaries will be linked against: $LUA_LIBNAME with runtime $LUA_RUNTIME 572Binaries will be linked against: $LUA_LIBNAME with runtime $LUA_RUNTIME
570System architecture detected as: $UNAME_M 573System architecture detected as: $UNAME_M
571 574
572]]) 575]])
573 576
577if PROMPT then
578 print("Press <ENTER> to start installing, or press <CTRL>+<C> to abort. Use install /? for installation options.")
579 io.read()
580end
574 581
575-- *********************************************************** 582-- ***********************************************************
576-- Install LuaRocks files 583-- Install LuaRocks files
@@ -644,23 +651,26 @@ ENDLOCAL
644 f:close() 651 f:close()
645 print(S"Created LuaRocks command: $BINDIR\\"..c..".bat") 652 print(S"Created LuaRocks command: $BINDIR\\"..c..".bat")
646end 653end
647-- configure 'scripts' directory
648if vars.SCRIPTS_DIR then
649 mkdir(vars.SCRIPTS_DIR)
650 if not USE_MINGW then
651 -- definitly not for MinGW because of conflicting runtimes
652 -- but is it ok to do it for others???
653 exec(S[[COPY lua5.1\bin\*.dll "$SCRIPTS_DIR" >NUL]])
654 end
655else
656 if not USE_MINGW then
657 mkdir(S[[$ROCKS_TREE\bin]])
658 -- definitly not for MinGW because of conflicting runtimes
659 -- but is it ok to do it for others???
660 exec(S[[COPY lua5.1\bin\*.dll "$ROCKS_TREE"\bin >NUL]])
661 end
662end
663 654
655-- part below was commented out as its purpose was unclear
656-- see https://github.com/keplerproject/luarocks/pull/197#issuecomment-30176548
657
658-- configure 'scripts' directory
659-- if vars.SCRIPTS_DIR then
660-- mkdir(vars.SCRIPTS_DIR)
661-- if not USE_MINGW then
662-- -- definitly not for MinGW because of conflicting runtimes
663-- -- but is it ok to do it for others???
664-- exec(S[[COPY lua5.1\bin\*.dll "$SCRIPTS_DIR" >NUL]])
665-- end
666-- else
667-- if not USE_MINGW then
668-- mkdir(S[[$ROCKS_TREE\bin]])
669-- -- definitly not for MinGW because of conflicting runtimes
670-- -- but is it ok to do it for others???
671-- exec(S[[COPY lua5.1\bin\*.dll "$ROCKS_TREE"\bin >NUL]])
672-- end
673-- end
664 674
665-- *********************************************************** 675-- ***********************************************************
666-- Configure LuaRocks 676-- Configure LuaRocks
@@ -756,7 +766,8 @@ else
756 print(S[[System rocktree exists : "$ROCKS_TREE"]]) 766 print(S[[System rocktree exists : "$ROCKS_TREE"]])
757end 767end
758 768
759vars.LOCAL_TREE = os.getenv("APPDATA")..[[\LuaRocks]] 769vars.APPDATA = os.getenv("APPDATA")
770vars.LOCAL_TREE = vars.APPDATA..[[\LuaRocks]]
760if not exists(vars.LOCAL_TREE) then 771if not exists(vars.LOCAL_TREE) then
761 mkdir(vars.LOCAL_TREE) 772 mkdir(vars.LOCAL_TREE)
762 print(S[[Created local user rocktree: "$LOCAL_TREE"]]) 773 print(S[[Created local user rocktree: "$LOCAL_TREE"]])
@@ -770,16 +781,16 @@ if REGISTRY then
770 print() 781 print()
771 print([[Loading registry information for ".rockspec" files]]) 782 print([[Loading registry information for ".rockspec" files]])
772 exec( S[[lua5.1\bin\lua5.1.exe "$FULL_PREFIX\LuaRocks.reg.lua" "$FULL_PREFIX\LuaRocks.reg.template"]] ) 783 exec( S[[lua5.1\bin\lua5.1.exe "$FULL_PREFIX\LuaRocks.reg.lua" "$FULL_PREFIX\LuaRocks.reg.template"]] )
773 exec( S[["$FULL_PREFIX\\LuaRocks.reg"]] ) 784 exec( S[[regedit /S "$FULL_PREFIX\\LuaRocks.reg"]] )
774end 785end
775 786
776-- *********************************************************** 787-- ***********************************************************
777-- Cleanup 788-- Cleanup
778-- *********************************************************** 789-- ***********************************************************
779-- remove regsitry related files, no longer needed 790-- remove regsitry related files, no longer needed
780exec( S[[del "$FULL_PREFIX\LuaRocks.reg.*" > nul]] ) 791exec( S[[del "$FULL_PREFIX\LuaRocks.reg.*" >NUL]] )
781-- remove pe-parser module 792-- remove pe-parser module
782exec( S[[del "$FULL_PREFIX\pe-parser.lua" > nul]] ) 793exec( S[[del "$FULL_PREFIX\pe-parser.lua" >NUL]] )
783 794
784-- *********************************************************** 795-- ***********************************************************
785-- Exit handlers 796-- Exit handlers
@@ -805,5 +816,8 @@ System rocktree
805 LUA_PATH : $ROCKS_TREE\share\lua\$LUA_VERSION\?.lua;$ROCKS_TREE\share\lua\$LUA_VERSION\?\init.lua 816 LUA_PATH : $ROCKS_TREE\share\lua\$LUA_VERSION\?.lua;$ROCKS_TREE\share\lua\$LUA_VERSION\?\init.lua
806 LUA_CPATH: $ROCKS_TREE\lib\lua\$LUA_VERSION\?.dll 817 LUA_CPATH: $ROCKS_TREE\lib\lua\$LUA_VERSION\?.dll
807 818
819Note that the %APPDATA% element in the paths above is user specific and it MUST be replaced by its actual value.
820For the current user that value is: $APPDATA.
821
808]]) 822]])
809os.exit(0) 823os.exit(0)