Tieske / luawinmulti

Lua build and installation script for Windows, building multiple Lua versions in parallel, including LuaRocks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please update for LuaRocks 3.0.4

hishamhm opened this issue · comments

This requires some minor changes to the main script since the site_config hack should not be needed anymore (all trees in 3.x are versioned).

Ideally, it should be possible to replace the three LuaRocks installs with a single copy of luarocks.exe, create a config file for each version, and wrap them with luarocks5x.bat scripts that do something like

@echo off
set LUAROCKS_SYSCONFDIR=c:\location\of\your\config-5.x.lua
luarocks --lua-version=5.x %*

for convenience.

there already was a pr; #14 I guess we'll need to adjust that then

If I remove the hack then the config file starts to default to the system directories (eg. no longer self contained)

Old version, with system config in c:/lua/...

CONFIGURATION
        Lua version: 5.1
        Configuration files:
                System: c:/lua/LuaRocks/config-5.1.lua (ok)
                User  : C:/Users/Gebruiker/AppData/Roaming/luarocks/config-5.1.lua (not found)

        Rocks trees in use:
                C:/Users/Gebruiker/AppData/Roaming/luarocks ("user")
                c:/lua ("system")

Gebruiker@MDTWORK-5KGJL7K

With 3.0.4, and the hack removed, it goes into C:/Program Files (x86)/luarocks/...:

CONFIGURATION
        Lua version: 5.1

        Configuration files:
                System  : C:/Program Files (x86)/luarocks/config-5.1.lua (not found)
                User    : C:/Users/Gebruiker/AppData/Roaming/luarocks/config-5.1.lua (not found)

        Rocks trees in use:
                C:/Users/Gebruiker/AppData/Roaming/luarocks ("user")
                C:/Lua/LuaRocks ("system")


Gebruiker@MDTWORK-5KGJL7K

ah, I guess that's why the mention of the additional batch file, I'll give that a try

@hishamhm does the all-in-one binary also do the auto-elevation trick when it is doesn't have enough rights for an install?

So this is harder than expected, since LuaRocks doesn't pick up the defaults properly

C:\test\luawinmulti>luarocks

LuaRocks 3.0.4, the Lua package manager

NAME
        C:\Lua\LuaRocks\luarocks.lua - LuaRocks main command-line interface

SYNOPSIS
        C:\Lua\LuaRocks\luarocks.lua [<flags...>] [VAR=VALUE]... <command> [<argument>]

GENERAL OPTIONS
        These apply to all commands, as appropriate:

        --dev                  Enable the sub-repositories in rocks servers
                               for rockspecs of in-development versions
        --server=<server>      Fetch rocks/rockspecs from this server
                               (takes priority over config file)
        --only-server=<server> Fetch rocks/rockspecs from this server only
                               (overrides any entries in the config file)
        --only-sources=<url>   Restrict downloads to paths matching the
                               given URL.
        --lua-dir=<prefix>     Which Lua installation to use.
        --tree=<tree>          Which tree to operate on.
        --local                Use the tree in the user's home directory.
                               To enable it, see 'C:\Lua\LuaRocks\luarocks.lua help path'.
        --verbose              Display verbose output of commands executed.
        --timeout=<seconds>    Timeout on network operations, in seconds.
                               0 means no timeout (wait forever).
                               Default is 30.

VARIABLES
        Variables from the "variables" table of the configuration file
        can be overriden with VAR=VALUE assignments.

COMMANDS
        build
                build/compile a rock.
        config
                Query information about the LuaRocks configuration.
        doc
                Show documentation for an installed rock.
        download
                Download a specific rock file from a rocks server.
        help
                Help on commands. Type 'C:\Lua\LuaRocks\luarocks.lua help <command>' for more.
        init
                Initialize a directory for a Lua project using LuaRocks.
        install
                Install a rock.
        lint
                Check syntax of a rockspec.
        list
                List currently installed rocks.
        make
                Compile package in current directory using a rockspec.
        new_version
                Auto-write a rockspec for a new version of a rock.
        pack
                Create a rock, packing sources or binaries.
        path
                Return the currently configured package path.
        purge
                Remove all installed rocks from a tree.
        remove
                Uninstall a rock.
        search
                Query the LuaRocks servers.
        show
                Show information about an installed rock.
        test
                Run the test suite in the current directory.
        unpack
                Unpack the contents of a rock.
        upload
                Upload a rockspec to the public rocks repository.
        which
                Tell which file corresponds to a given module name.
        write_rockspec
                Write a template for a rockspec file.

CONFIGURATION
        Lua version: 5.1

        Configuration files:
                System  : C:/Program Files (x86)/luarocks/config-5.1.lua (not found)
                User    : C:/Users/Gebruiker/AppData/Roaming/luarocks/config-5.1.lua (not found)

        Rocks trees in use:
                C:/Users/Gebruiker/AppData/Roaming/luarocks ("user")
                C:/Lua/LuaRocks ("system")


C:\test\luawinmulti>luarocks install busted
Installing https://luarocks.org/busted-2.0.rc13-0.rockspec
Missing dependencies for busted 2.0.rc13-0:
   lua_cliargs 3.0-1 (not installed)
   luafilesystem >= 1.5.0 (not installed)
   luasystem >= 0.2.0-0 (not installed)
   dkjson >= 2.1.0 (not installed)
   say >= 1.3-0 (not installed)
   luassert >= 1.7.8-0 (not installed)
   lua-term >= 0.1-1 (not installed)
   penlight >= 1.3.2-2 (not installed)
   mediator_lua >= 1.1.1-0 (not installed)

busted 2.0.rc13-0 depends on lua_cliargs 3.0-1 (not installed)
Installing https://luarocks.org/lua_cliargs-3.0-1.src.rock

No existing manifest. Attempting to rebuild...
lua_cliargs 3.0-1 is now installed in C:\Lua\LuaRocks (license: MIT <http://opensource.org/licenses/MIT>)

busted 2.0.rc13-0 depends on luafilesystem >= 1.5.0 (not installed)
Installing https://luarocks.org/luafilesystem-1.7.0-2.src.rock

mingw32-gcc -O2 -c -o src/lfs.o -IC:\Lua\include\lua\5.3 src/lfs.c
mingw32-gcc -shared -o lfs.dll src/lfs.o C:\Lua\bin/lua51.dll -lm
src/lfs.o:lfs.c:(.text+0x122e): undefined reference to `luaL_checkversion_'
src/lfs.o:lfs.c:(.text+0x125e): undefined reference to `luaL_setfuncs'
src/lfs.o:lfs.c:(.text+0x127e): undefined reference to `lua_setglobal'
collect2.exe: error: ld returned 1 exit status

Error: Failed installing dependency: https://luarocks.org/luafilesystem-1.7.0-2.src.rock - Build error: Failed compiling module lfs.dll

C:\test\luawinmulti>

The top shows LuaRocks is running on Lua 5.1. Yet the LFS dependency is being compiled using the 5.3 headers. So seems LuaRocks is taking a wrong turn here somewhere,

Any ideas @hishamhm ?

it doesn't. isn't it possible to do the equivalent of "setuid the binary" to make it privileged?

it doesn't. isn't it possible to do the equivalent of "setuid the binary" to make it privileged?

not that I know of (but not too much into priviledges on Windows these days), usually the access is validated at runtime, and the user is prompted for extra credentials. Would make more sense to loosen up restrictions on the LuaRocks tree probably. But it goes against the security model.

We've had lengthy discussions on this in the past, when we treated rocks as data, and not as executable code. Hence we implemented the auto-elevation code in the batch files, so it would honor the Windows security model.

just noticed this, which is concerning:

mingw32-gcc -O2 -c -o src/lfs.o -IC:\Lua\include\lua\5.3 src/lfs.c
mingw32-gcc -shared -o lfs.dll src/lfs.o C:\Lua\bin/lua51.dll -lm

it does pick lua51.dll for the library, but then does \include\lua\5.3 for the header... What happens if you run luarocks --lua-version=5.1 install busted in that same setup?

getting weirder all the time:

> luarocks --lua-version=5.1 install busted                          
Access is denied.                                                    
Access is denied.                                                    
Access is denied.                                                    
Access is denied.                                                    
Access is denied.                                                    
Access is denied.                                                    
                                                                     
Error: Could not find a Lua interpreter for version 5.1 in your PATH 
                                                                     
Gebruiker@MDTWORK-5KGJL7K C:\test\luawinmulti                        
>                                                                    

adding the --verbose flag yields the exact same result.

The access denied errors are probably because of the script trying folders in the system path it doesn't have access to.

This folder is in the path:

> dir c:\lua\bin
 Volume in drive C is OSDisk
 Volume Serial Number is 8CCF-02F6

 Directory of c:\lua\bin

08-Jan-19  11:00    <DIR>          .
08-Jan-19  11:00    <DIR>          ..
04-Jan-19  18:20            49,664 lua.exe
04-Jan-19  18:19           170,202 lua51.dll
04-Jan-19  18:19            49,152 lua51.exe
04-Jan-19  18:20           192,035 lua52.dll
04-Jan-19  18:20            49,664 lua52.exe
04-Jan-19  18:20           249,760 lua53.dll
04-Jan-19  18:20            49,664 lua53.exe
04-Jan-19  18:19           197,312 luac51.exe
04-Jan-19  18:20           216,051 luac52.exe
04-Jan-19  18:20           234,390 luac53.exe
08-Jan-19  11:07               144 luarocks.bat
08-Jan-19  11:00             1,699 luarocks51.bat
08-Jan-19  11:00             1,699 luarocks52.bat
08-Jan-19  11:00             1,699 luarocks53.bat
04-Jan-19  16:22             3,230 setlua.bat
              15 File(s)      1,466,365 bytes
               2 Dir(s)  26,615,173,120 bytes free

Gebruiker@MDTWORK-5KGJL7K C:\test\luawinmulti
>