From 57c4c60f352c0bbecdb28b0f5c27831b48f653a2 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 26 Dec 2013 09:31:09 +0100 Subject: updated comments for exitcodes batch wrapper script (luarocks.bat) updated to auto-elevate if permission was denied --- install.bat | 54 +++++++++++++++++++++++++++++++++++++++++++++++- src/luarocks/build.lua | 4 ++-- src/luarocks/install.lua | 4 ++-- src/luarocks/make.lua | 4 ++-- src/luarocks/remove.lua | 4 ++-- 5 files changed, 61 insertions(+), 9 deletions(-) diff --git a/install.bat b/install.bat index ed2a49ff..03ec7c94 100644 --- a/install.bat +++ b/install.bat @@ -519,6 +519,14 @@ end print(S"LuaRocks $VERSION.x installer.\n") +print([[ + +======================== +== Checking system... == +======================== + +]]) + parse_options(config) check_flags() @@ -593,6 +601,10 @@ end print(S[[ +========================== +== System check results == +========================== + Will configure LuaRocks with the following paths: LuaRocks : $FULL_PREFIX Config file : $SYSCONFDIR\config.lua @@ -613,6 +625,14 @@ if PROMPT then io.read() end +print([[ + +============================ +== Installing LuaRocks... == +============================ + +]]) + -- *********************************************************** -- Install LuaRocks files -- *********************************************************** @@ -680,6 +700,35 @@ IF NOT "%LUA_PATH_5_2%"=="" ( ) SET "PATH=$BINDIR;%PATH%" "$LUA_INTERPRETER" "$BINDIR\]]..c..[[.lua" %* +IF NOT "%ERRORLEVEL%"=="2" GOTO EXITLR + +REM Permission denied error, try and auto elevate... +REM already an admin? (checking to prevent loops) +NET SESSION >NUL 2>&1 +IF "%ERRORLEVEL%"=="0" GOTO EXITLR + +REM Do we have PowerShell available? +PowerShell /? >NUL 2>&1 +IF NOT "%ERRORLEVEL%"=="0" GOTO EXITLR + +:GETTEMPNAME +SET TMPFILE=%TEMP%\LuaRocks-Elevator-%RANDOM%.bat +IF EXIST "%TMPFILE%" GOTO :GETTEMPNAME + +ECHO @ECHO OFF > "%TMPFILE%" +ECHO CHDIR /D %CD% >> "%TMPFILE%" +ECHO ECHO %0 %* >> "%TMPFILE%" +ECHO ECHO. >> "%TMPFILE%" +ECHO CALL %0 %* >> "%TMPFILE%" +ECHO ECHO. >> "%TMPFILE%" +ECHO ECHO Press any key to close this window... >> "%TMPFILE%" +ECHO PAUSE ^> NUL >> "%TMPFILE%" +ECHO DEL "%TMPFILE%" >> "%TMPFILE%" + +ECHO Now trying to run again elevated... +PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('%TMPFILE%', '', '', 'runas') + +:EXITLR ENDLOCAL ]]) f:close() @@ -833,7 +882,10 @@ exec( S[[del "$FULL_PREFIX\pe-parser.lua" >NUL]] ) print(S[[ -*** LuaRocks is installed! *** +============================ +== LuaRocks is installed! == +============================ + You may want to add the following elements to your paths; Lua interpreter; diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index cee65781..ec269023 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -351,8 +351,8 @@ end -- if returned a result, installs the matching rock. -- @param version string: When passing a package name, a version number may -- also be given. --- @return boolean or (nil, string): True if build was successful; nil and an --- error message otherwise. +-- @return boolean or (nil, string, exitcode): True if build was successful; nil and an +-- error message otherwise. exitcode is optionally returned. function run(...) local flags, name, version = util.parse_flags(...) if type(name) ~= "string" then diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index 041d8ca2..b28e6282 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua @@ -120,8 +120,8 @@ end -- if returned a result, installs the matching rock. -- @param version string: When passing a package name, a version number -- may also be given. --- @return boolean or (nil, string): True if installation was --- successful, nil and an error message otherwise. +-- @return boolean or (nil, string, exitcode): True if installation was +-- successful, nil and an error message otherwise. exitcode is optionally returned. function run(...) local flags, name, version = util.parse_flags(...) if type(name) ~= "string" then diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua index aff4f93c..3999e39f 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua @@ -40,8 +40,8 @@ To install rocks, you'll normally want to use the "install" and --- Driver function for "make" command. -- @param name string: A local rockspec. --- @return boolean or (nil, string): True if build was successful; nil and an --- error message otherwise. +-- @return boolean or (nil, string, exitcode): True if build was successful; nil and an +-- error message otherwise. exitcode is optionally returned. function run(...) local flags, rockspec = util.parse_flags(...) assert(type(rockspec) == "string" or not rockspec) diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index 9ab6d11f..f2f6997b 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua @@ -132,8 +132,8 @@ end -- a specific version; otherwise, try to remove all versions. -- @param version string: When passing a package name, a version number -- may also be given. --- @return boolean or (nil, string): True if removal was --- successful, nil and an error message otherwise. +-- @return boolean or (nil, string, exitcode): True if removal was +-- successful, nil and an error message otherwise. exitcode is optionally returned. function run(...) local flags, name, version = util.parse_flags(...) -- cgit v1.2.3-55-g6feb