From b974f6d3841b24596c4cbc2c27f9f6572afe52d5 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 9 Apr 2013 13:11:55 +0200 Subject: installer adds information for the registry, including icon and actions for .rockspec files when /R argument is provided. includes the new luarocksw.bat batch file also: made the /P argument of the installer required --- install.bat | 32 +++++++++++++++++++++--- win32/bin/LuaRocks.reg.template | 53 ++++++++++++++++++++++++++++++++++++++++ win32/bin/create_reg_file.lua | 51 ++++++++++++++++++++++++++++++++++++++ win32/bin/lua.ico | Bin 0 -> 22486 bytes win32/bin/luarocksw.bat | 48 ++++++++++++++++++++++++++++++++++++ 5 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 win32/bin/LuaRocks.reg.template create mode 100644 win32/bin/create_reg_file.lua create mode 100644 win32/bin/lua.ico create mode 100644 win32/bin/luarocksw.bat diff --git a/install.bat b/install.bat index 3fdaafa0..1bc58bd0 100644 --- a/install.bat +++ b/install.bat @@ -21,6 +21,8 @@ SET FORCE_CONFIG= SET USE_MINGW= SET MKDIR=.\bin\mkdir -p SET LUA_LIB_NAMES=lua5.1.lib lua51.dll liblua.dll.a +SET REGISTRY=OFF +SET P_SET=FALSE REM *********************************************************** REM Option parser @@ -33,9 +35,9 @@ IF [%1]==[] GOTO DONE_PARSING IF [%1]==[/?] ( ECHO Installs LuaRocks. ECHO. - ECHO /P [dir] Where to install. - ECHO Default is %PREFIX% ^(version; %VERSION%, will be - ECHO appended to this path^) + ECHO /P [dir] ^(REQUIRED^) Where to install. + ECHO Note that version; %VERSION%, will be + ECHO appended to this path. ECHO /CONFIG [dir] Location where the config file should be installed. ECHO Default is same place of installation ECHO /TREE [dir] Root of the local tree of installed rocks. @@ -66,12 +68,16 @@ IF [%1]==[/?] ( ECHO. ECHO /F Remove installation directory if it already exists. ECHO. + ECHO /R Load registry information to register '.rockspec' + ECHO extension with LuaRocks commands ^(right-click^). + ECHO. GOTO QUIT ) IF /I [%1]==[/P] ( SET PREFIX=%~2 SET SYSCONFDIR=%~2 SET ROCKS_TREE=%~2 + SET P_SET=TRUE SHIFT /1 SHIFT /1 GOTO PARSE_LOOP @@ -138,11 +144,20 @@ IF /I [%1]==[/F] ( SHIFT /1 GOTO PARSE_LOOP ) +IF /I [%1]==[/R] ( + SET REGISTRY=ON + SHIFT /1 + GOTO PARSE_LOOP +) ECHO Unrecognized option: %1 GOTO ERROR :DONE_PARSING -REM check for combination flags +REM check for combination/required flags +IF NOT [%P_SET%]==[TRUE] ( + Echo Missing required parameter /P + GOTO ERROR +) IF [%INSTALL_LUA%]==[ON] ( IF NOT [%LUA_INCDIR%%LUA_BINDIR%%LUA_LIBDIR%%LUA_PREFIX%]==[] ( ECHO Cannot combine option /L with any of /LUA /BIN /LIB /INC @@ -424,6 +439,15 @@ IF NOT EXIST "%APPDATA%/luarocks" ( ECHO Rocktree exists: "%APPDATA%\luarocks" ) +REM Load registry information +IF [%REGISTRY%]==[ON] ( + REM expand template with correct path information + ECHO. + ECHO Loading registry information for ".rockspec" files + lua5.1\bin\lua5.1.exe "%FULL_PREFIX%\create_reg_file.lua" "%FULL_PREFIX%\LuaRocks.reg.template" + %FULL_PREFIX%\LuaRocks.reg +) + REM *********************************************************** REM Exit handlers REM *********************************************************** diff --git a/win32/bin/LuaRocks.reg.template b/win32/bin/LuaRocks.reg.template new file mode 100644 index 00000000..3af1ff34 --- /dev/null +++ b/win32/bin/LuaRocks.reg.template @@ -0,0 +1,53 @@ +Windows Registry Editor Version 5.00 + +[HKEY_CLASSES_ROOT\.rockspec] +@="Lua.Rockspec" + +[HKEY_CLASSES_ROOT\.rockspec\Content Type] +@="text/plain" + +[HKEY_CLASSES_ROOT\.rockspec\PerceivedType] +@="text" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.rockspec] +@="Lua.Rockspec" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.rockspec\Content Type] +@="text/plain" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.rockspec\PerceivedType] +@="text" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec] +@="Lua Rockspec File" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\DefaultIcon] +@="lua.ico" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockpsec\Shell] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\Fetch] +@="Fetch and install" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\Fetch\Command] +@="\"luarocksw.bat" install \"%1\" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\Install] +@="Install Lua module" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\Install\Command] +@="\"luarocksw.bat" make \"%1\" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\Uninstall] +@="Install Lua module (this version)" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\Uninstall\Command] +@="\"luarocksw.bat" remove \"%1\" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\UninstallAll] +@="Install Lua module (all versions)" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Lua.Rockspec\Shell\UninstallAll\Command] +@="\"luarocksw.bat" removeall \"%1\" + + diff --git a/win32/bin/create_reg_file.lua b/win32/bin/create_reg_file.lua new file mode 100644 index 00000000..df0b7491 --- /dev/null +++ b/win32/bin/create_reg_file.lua @@ -0,0 +1,51 @@ +-- Call this file using its full path and the template file as a parameter; +-- +-- C:\> lua.exe "create_reg_file.lua" "c:\luarocks\2.0\LuaRocks.reg.template" +-- +-- it will strip the ".template" extension and write to that file the +-- template contents, where "" will be replaced by the path +-- to LuaRocks (including the trailing backslash) + + + +-- Check argument +local f = (arg or {})[1] +if not f then + print("must provide template file on command line") + os.exit(1) +end + +-- cleanup filepath, remove all double backslashes +while f:match("\\\\") do + f:gsub("\\\\", "\\") +end + +-- extract path and name from argument +local p = "" +local ni = f +for i = #f, 1, -1 do + if f:sub(i,i) == "\\" then + ni = f:sub(i+1) + p = f:sub(1, i) + break + end +end + +-- create output name +local no = ni:gsub("%.template","") + +-- create path substitute; escape backslash by doubles +local ps = p:gsub("\\", "\\\\") + +-- read template +local fh = io.open(f) +local content = fh:read("*a") +fh:close() + +-- fill template +content = content:gsub("%", ps) + +-- write destination file +fh = io.open(p..no, "w+") +fh:write(content) +fh:close() diff --git a/win32/bin/lua.ico b/win32/bin/lua.ico new file mode 100644 index 00000000..56dc4fe1 Binary files /dev/null and b/win32/bin/lua.ico differ diff --git a/win32/bin/luarocksw.bat b/win32/bin/luarocksw.bat new file mode 100644 index 00000000..a0144c44 --- /dev/null +++ b/win32/bin/luarocksw.bat @@ -0,0 +1,48 @@ +@echo off +setlocal +SET MYPATH=%~dp0 + + +ECHO Same as 'luarocks' command, except this +ECHO command will pause after completion, allowing for +ECHO examination of output. +ECHO +ECHO For LuaRocks help use: +ECHO LUAROCKS HELP +ECHO +ECHO OPTIONS specific for LUAROCKSW: +ECHO REMOVEALL is a command specific to this batch file +ECHO the option takes a FULL ROCKSPEC filename and then +ECHO it will strip path, version and extension info from +ECHO it before executing the LUAROCKS REMOVE command +ECHO Example: +ECHO luarocksw remove "c:\somedir\modulename-1.0-1.rockspec" +ECHO will execute: +ECHO luarocks remove "c:\somedir\modulename-1.0-1.rockspec" +ECHO and will only remove the specific version 1.0 from the +ECHO system. +ECHO luarocksw removeall "c:\somedir\modulename-1.0-1.rockspec" +ECHO will execute: +ECHO luarocks remove modulename +ECHO and will remove all versions of this package + + + +REM if REMOVEALL command then info must be stripped from the parameter +if [%1]==[removeall] goto REMOVEALL + +REM execute LuaRocks and wait for results +echo executing: luarocks %* +call %MYPATH%luarocks %* +pause +goto END + +:REMOVEALL +for /f "delims=-" %%a in ("%~n2") do ( + echo executing: luarocks remove %%a + %MYPATH%luarocks remove "%%a" + pause + goto END +) + +:END \ No newline at end of file -- cgit v1.2.3-55-g6feb