lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 13.11.2016 um 14:02 schröbte Lorenzo Donati:
On 07/11/2016 02:50, Martin wrote:
On 16-11-04 12:00 AM, Philipp Janda wrote:
 ["GNU GPL v3"] = 4,
 ["GPL-3"] = 214,
 ["GNU/GPL 3"] = 2,
 ["GNU GPLv3"] = 3,
 ["GPL v3"] = 9,
 ["GPLv3"] = 14,

Ugh. Looks like some license name canonization wouldn't hurt.


+1.

Exactly what I thought when I saw that list.

This could also avoid misunderstandings: although the ones you cite are
clearly the same license, there could be well cases (TL;DR) where a
different spelling could actually mean a license variant (e.g. "generic"
MIT vs. MIT/X11 vs. whatever).

There is a *lot* of confusion about MIT vs MIT/X11, and many Lua libraries claim MIT/X11 in their rockspecs, but the LICENSE files themselves are plain MIT (aka MIT/Expat).


Sadly I fear this could mean building a repository of
"LuaRocks-approved" license IDs, so more work for the LuaRocks team.

It's not that simple. Many Lua libraries are bindings to C or C++ libraries, and the license for the binding (often MIT) could differ from the license for the C or C++ library. And of course you can release your library under multiple alternative licenses. So it's not just IDs, but probably a little DSL ...

Anyway, currently the license field in the rockspec is a free-form string field, and that probably won't change for LuaRocks 2.x for compatibility reasons, but there is still time for improvements for LuaRocks 3.0 ...


Philipp


p.s. Since there was interest in the script I'll attach it, but it requires a local mirror of all rockspec files of LuaRocks.org (about 4000 of them, ATM). I'll add a script for downloading those as well.


#!/usr/bin/lua

-- get manifest from
-- http://luarocks.org/repositories/rocks/manifest

local base = "http://luarocks.org/repositories/rocks/";
local outdir = "rockspecs"


local function load_manifest( fname )
  local env = {}
  local f = assert( loadfile( fname, "t", env ) )
  if setfenv then setfenv( f, env ) end
  f()
  return env
end

local function not_exists( fname )
  local f = io.open( fname )
  if f then
    f:close()
  end
  return not f
end

local function download( url, outname )
  os.execute( "wget -q -O '"..outname.."' '"..url.."'" )
end


local data = load_manifest( arg[ 1 ] or "manifest" )

for module,vset in pairs( data.repository ) do
  for version,list in pairs( vset ) do
    local p = "^[%w_+-.]"
    if module:match( p ) and version:match( p ) then
      for _,v in ipairs( list ) do
        if type( v ) == "table" and
           v.arch == "rockspec" then
          local name = module.."-"..version..".rockspec"
          local outname = outdir.."/"..name
          if not_exists( outname ) then
            print( name )
            download( base..name, outname )
          end
          break
        end
      end
    end
  end
end

#!/usr/bin/lua

local rockspecdir = "rockspecs"
local lfs = require( "lfs" )


local function load_rockspec( fname )
  local env = {}
  local f = assert( loadfile( fname, "t", env ) )
  if setfenv then setfenv( f, env ) end
  f()
  return env
end


local dir = arg[ 1 ] or rockspecdir
local data = {}

for rs in lfs.dir( dir ) do
  if rs:match( "%.rockspec$" ) then
    local env = load_rockspec( dir.."/"..rs )
    if type( env.description ) == "table" and
       type( env.description.license ) == "string" then
      data[ env.description.license ] = (data[ env.description.license ] or 0)+1
    end
  end
end

local f = assert( io.open( "lualicenses.data", "w" ) )
f:write( "return {\n" )
for k,v in pairs( data ) do
  f:write( ('  [%q] = %d,\n'):format( k, v ) )
end
f:write( "}\n\n" )
f:close()