Bump buildroot to 2019.02
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
From 961269271134e711bcfffebb0f179ffddcbf3d5a Mon Sep 17 00:00:00 2001
|
||||
From: Francois Perrad <francois.perrad@gadz.org>
|
||||
Date: Sun, 29 Jul 2018 11:17:34 +0200
|
||||
Subject: [PATCH] allow libluajit detection
|
||||
|
||||
This detection was done only if luarocks is runned by luajit.
|
||||
But on Buildroot, luarocks is always runned by lua.
|
||||
|
||||
See https://github.com/luarocks/luarocks/pull/883
|
||||
|
||||
Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
|
||||
---
|
||||
src/luarocks/deps.lua | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
|
||||
index 8403f12..c1c0220 100644
|
||||
--- a/src/luarocks/deps.lua
|
||||
+++ b/src/luarocks/deps.lua
|
||||
@@ -513,10 +513,8 @@ function deps.check_lua(vars)
|
||||
"lua-" .. cfg.lua_version,
|
||||
"lua-" .. shortv,
|
||||
"lua",
|
||||
+ "luajit-" .. cfg.lua_version,
|
||||
}
|
||||
- if cfg.luajit_version then
|
||||
- table.insert(libnames, 1, "luajit-" .. cfg.lua_version)
|
||||
- end
|
||||
for _, libname in ipairs(libnames) do
|
||||
local ok = check_external_dependency("LUA", { library = libname }, vars, "build")
|
||||
if ok then
|
||||
--
|
||||
2.17.1
|
||||
|
||||
326
bsp/buildroot/package/luarocks/buildroot.lua
Normal file
326
bsp/buildroot/package/luarocks/buildroot.lua
Normal file
@@ -0,0 +1,326 @@
|
||||
|
||||
--- Module implementing the LuaRocks "buildroot" command.
|
||||
local buildroot = {}
|
||||
|
||||
local dir = require("luarocks.dir")
|
||||
local fs = require("luarocks.fs")
|
||||
local util = require("luarocks.util")
|
||||
local queries = require("luarocks.queries")
|
||||
local search = require("luarocks.search")
|
||||
local download = require("luarocks.download")
|
||||
local fetch = require("luarocks.fetch")
|
||||
|
||||
buildroot.help_summary = "generate buildroot package files of a rock."
|
||||
buildroot.help_arguments = "rockname [brname]"
|
||||
buildroot.help = [[
|
||||
This addon generates Buildroot package files of a rock.
|
||||
First argument is the name of a rock, the second argument is optional
|
||||
and needed when Buildroot uses another name (usually prefixed by lua-).
|
||||
Files are generated with the source content of the rock and more
|
||||
especially the rockspec. So, the rock is downloaded and unpacked.
|
||||
]]
|
||||
|
||||
local function brname (name)
|
||||
return name:upper():gsub('-', '_')
|
||||
end
|
||||
|
||||
local function brlicense (license)
|
||||
if license:match('MIT/X') then
|
||||
return 'MIT'
|
||||
end
|
||||
return license
|
||||
end
|
||||
|
||||
local function wrap (txt, max)
|
||||
local lines = {}
|
||||
local line = ''
|
||||
for word in txt:gmatch('(%S+)') do
|
||||
if line:len() + word:len() > max - 1 then
|
||||
lines[#lines+1] = line
|
||||
line = ''
|
||||
end
|
||||
if line == '' then
|
||||
line = word
|
||||
else
|
||||
line = line .. ' ' .. word
|
||||
end
|
||||
end
|
||||
lines[#lines+1] = line
|
||||
return lines
|
||||
end
|
||||
|
||||
local function get_external_dependencies (rockspec)
|
||||
local t = {}
|
||||
for k in pairs(rockspec.external_dependencies or {}) do
|
||||
k = k:lower()
|
||||
if fs.is_dir('package/' .. k) then
|
||||
t[#t+1] = k
|
||||
else
|
||||
t[#t+1] = 'lib' .. k
|
||||
if not fs.is_dir('package/lib' .. k) then
|
||||
util.printout('unkwown external dependency: ' .. k)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(t)
|
||||
return t
|
||||
end
|
||||
|
||||
local function get_dependencies (rockspec)
|
||||
local t = {}
|
||||
for i = 1, #rockspec.dependencies do
|
||||
local dep = tostring(rockspec.dependencies[i]):match('^(%S+)')
|
||||
if dep ~= 'lua' then
|
||||
dep = dep:gsub('_', '-')
|
||||
if fs.is_dir('package/lua-' .. dep) then
|
||||
t[#t+1] = 'lua-' .. dep
|
||||
else
|
||||
t[#t+1] = dep
|
||||
if not fs.is_dir('package/' .. dep) then
|
||||
util.printout('unkwown dependency: ' .. dep)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(t)
|
||||
return t
|
||||
end
|
||||
|
||||
function get_digest (file)
|
||||
local absname = fs.absolute_name(file)
|
||||
local pipe = io.popen('sha256sum ' .. fs.Q(absname))
|
||||
local line = pipe:read('*l')
|
||||
pipe:close()
|
||||
local computed = line and line:match('(' .. ('%x'):rep(64) .. ')')
|
||||
if computed then
|
||||
return computed
|
||||
else
|
||||
return nil, "Failed to compute SHA256 hash for file " .. absname
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_config (rockspec, lcname)
|
||||
local ucname = brname(lcname)
|
||||
local only_luajit = rockspec.package:match('^lj')
|
||||
local summary = rockspec.description.summary
|
||||
if not summary then
|
||||
summary = '???'
|
||||
elseif not summary:match('%.%s*$') then
|
||||
summary = summary:gsub('%s*$', '.')
|
||||
end
|
||||
local homepage = rockspec.description.homepage or '???'
|
||||
local external_dependencies = get_external_dependencies(rockspec)
|
||||
local dependencies = get_dependencies(rockspec)
|
||||
local fname = 'package/' .. lcname .. '/Config.in'
|
||||
local f = assert(io.open(fname, 'w'))
|
||||
util.printout('write ' .. fname)
|
||||
f:write('config BR2_PACKAGE_' .. ucname .. '\n')
|
||||
f:write('\tbool "' .. lcname .. '"\n')
|
||||
if only_luajit then
|
||||
f:write('\tdepends on BR2_PACKAGE_LUAJIT\n')
|
||||
end
|
||||
for i = 1, #external_dependencies do
|
||||
f:write('\tselect BR2_PACKAGE_' .. brname(external_dependencies[i]) .. '\n')
|
||||
end
|
||||
for i = 1, #dependencies do
|
||||
f:write('\tselect BR2_PACKAGE_' .. brname(dependencies[i]) .. ' # runtime\n')
|
||||
end
|
||||
f:write('\thelp\n')
|
||||
f:write('\t ' .. table.concat(wrap(summary, 62), '\n\t ') .. '\n')
|
||||
f:write('\n\t ' .. homepage .. '\n')
|
||||
if only_luajit then
|
||||
f:write('\ncomment "' .. lcname .. ' needs LuaJIT"\n')
|
||||
f:write('\tdepends on !BR2_PACKAGE_LUAJIT\n')
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
|
||||
local function generate_mk (rockspec, lcname, licenses)
|
||||
local function escape (s)
|
||||
return s:gsub('-', '%%-'):gsub('%.', '%%.')
|
||||
end
|
||||
|
||||
local ucname = brname(lcname)
|
||||
local need_name_upstream = false
|
||||
local need_version_upstream = false
|
||||
local name_upstream = rockspec.package
|
||||
local version = rockspec.version
|
||||
local version_upstream = version:match('^([^-]+)-')
|
||||
local revision = version:match('-(%d+)$')
|
||||
local license = rockspec.description.license
|
||||
local subdir = rockspec.source.dir
|
||||
if subdir then
|
||||
local root = subdir:match('^(.-)-' .. escape(version) .. '$')
|
||||
if root then
|
||||
subdir = root .. '-$(' .. ucname .. '_VERSION)'
|
||||
end
|
||||
root = subdir:match('^(.--[Vv])' .. escape(version_upstream) .. '$')
|
||||
if root then
|
||||
need_version_upstream = true
|
||||
subdir = root .. '$(' .. ucname .. '_VERSION_UPSTREAM)'
|
||||
end
|
||||
root = subdir:match('^(.-)-' .. escape(version_upstream) .. '$')
|
||||
if root then
|
||||
if root == lcname then
|
||||
subdir = nil
|
||||
elseif root == name_upstream then
|
||||
subdir = nil
|
||||
need_name_upstream = true
|
||||
else
|
||||
need_version_upstream = true
|
||||
subdir = root .. '-$(' .. ucname .. '_VERSION_UPSTREAM)'
|
||||
end
|
||||
end
|
||||
end
|
||||
local external_dependencies = get_external_dependencies(rockspec)
|
||||
local fname = 'package/' .. lcname .. '/' .. lcname .. '.mk'
|
||||
local f = assert(io.open(fname, 'w'))
|
||||
util.printout('write ' .. fname)
|
||||
f:write('################################################################################\n')
|
||||
f:write('#\n')
|
||||
f:write('# ' .. lcname .. '\n')
|
||||
f:write('#\n')
|
||||
f:write('################################################################################\n')
|
||||
f:write('\n')
|
||||
if need_version_upstream then
|
||||
f:write(ucname .. '_VERSION_UPSTREAM = ' .. version_upstream .. '\n')
|
||||
f:write(ucname .. '_VERSION = $(' .. ucname .. '_VERSION_UPSTREAM)-' .. revision .. '\n')
|
||||
else
|
||||
f:write(ucname .. '_VERSION = ' .. version .. '\n')
|
||||
end
|
||||
if lcname ~= name_upstream:lower() or need_name_upstream then
|
||||
f:write(ucname .. '_NAME_UPSTREAM = ' .. name_upstream .. '\n')
|
||||
end
|
||||
if subdir then
|
||||
f:write(ucname .. '_SUBDIR = ' .. subdir .. '\n')
|
||||
end
|
||||
if license then
|
||||
f:write(ucname .. '_LICENSE = ' .. brlicense(license) .. '\n')
|
||||
end
|
||||
if #licenses == 1 then
|
||||
f:write(ucname .. '_LICENSE_FILES = $(' .. ucname .. '_SUBDIR)/' .. licenses[1] .. '\n')
|
||||
elseif #licenses > 1 then
|
||||
f:write(ucname .. '_LICENSE_FILES =')
|
||||
for i = 1, #licenses do
|
||||
local file = licenses[i]
|
||||
f:write(' \\\n\t$(' .. ucname .. '_SUBDIR)/' .. file)
|
||||
end
|
||||
f:write('\n')
|
||||
end
|
||||
if #external_dependencies > 0 then
|
||||
f:write(ucname .. '_DEPENDENCIES = ' .. table.concat(external_dependencies, ' ') .. '\n')
|
||||
end
|
||||
f:write('\n$(eval $(luarocks-package))\n')
|
||||
f:close()
|
||||
end
|
||||
|
||||
local function generate_hash (rockspec, lcname, rock_file, licenses, digest)
|
||||
local subdir = rockspec.source.dir
|
||||
local fname = 'package/' .. lcname .. '/' .. lcname .. '.hash'
|
||||
local f = assert(io.open(fname, 'w'))
|
||||
util.printout('write ' .. fname)
|
||||
f:write('# computed by luarocks/buildroot\n')
|
||||
f:write('sha256 ' .. digest[rock_file] .. ' ' .. rock_file .. '\n')
|
||||
for i = 1, #licenses do
|
||||
local file = licenses[i]
|
||||
f:write('sha256 ' .. digest[file] .. ' ' .. subdir .. '/' .. file .. '\n')
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
|
||||
--- Driver function for the "buildroot" command.
|
||||
-- @param rockname string: the name of a rock to be fetched and unpacked.
|
||||
-- @param brname string: the name used by Buildroot (optional)
|
||||
-- @return boolean: true if successful
|
||||
function buildroot.command(flags, rockname, fsname)
|
||||
if type(rockname) ~= 'string' then
|
||||
return nil, "Argument missing. "..util.see_help('buildroot')
|
||||
end
|
||||
fsname = fsname or rockname
|
||||
assert(type(fsname) == 'string')
|
||||
|
||||
local query = queries.new(rockname:lower(), nil, false, 'src')
|
||||
local url, err = search.find_suitable_rock(query)
|
||||
if not url then
|
||||
return nil, "Could not find a result named " .. tostring(query) .. ": " .. err
|
||||
end
|
||||
local rock_file = dir.base_name(url)
|
||||
|
||||
local temp_dir, err = fs.make_temp_dir(rockname)
|
||||
if not temp_dir then
|
||||
return nil, "Failed creating temporary dir: " .. err
|
||||
end
|
||||
local ok, err = fs.change_dir(temp_dir)
|
||||
if not ok then return nil, err end
|
||||
|
||||
ok = fs.download(url, rock_file, true)
|
||||
if not ok then
|
||||
return nil, "Failed downloading " .. url
|
||||
end
|
||||
|
||||
local digest = {}
|
||||
digest[rock_file], err = get_digest(rock_file)
|
||||
if not digest[rock_file] then return nil, err end
|
||||
ok, err = fs.unzip(rock_file)
|
||||
if not ok then return nil, err end
|
||||
|
||||
local rockspec_file = rock_file:gsub('%.src%.rock$', '.rockspec')
|
||||
local rockspec, err = fetch.load_rockspec(rockspec_file)
|
||||
if not rockspec then
|
||||
return nil, "Error loading rockspec: " .. err
|
||||
end
|
||||
if rockspec.source.file then
|
||||
ok, err = fs.unpack_archive(rockspec.source.file)
|
||||
if not ok then return nil, err end
|
||||
end
|
||||
|
||||
if rockspec.source.dir ~= '.' then
|
||||
fs.copy(rockspec.local_abs_filename, rockspec.source.dir, 'read')
|
||||
end
|
||||
|
||||
local build_type = rockspec.build.type
|
||||
if build_type ~= 'none' and build_type ~= 'builtin' and build_type ~= 'module' then
|
||||
util.printout('[' .. rockspec.package .. "] build_type '" .. build_type .. "' not supported")
|
||||
end
|
||||
|
||||
local licenses = {}
|
||||
ok, err = fs.change_dir(rockspec.source.dir)
|
||||
if not ok then return nil, err end
|
||||
local files = fs.find()
|
||||
for i = 1, #files do
|
||||
local v = files[i]
|
||||
if v == 'COPYING'
|
||||
or v == 'COPYRIGHT'
|
||||
or v:match('^LICENSE') then
|
||||
licenses[#licenses+1] = v
|
||||
digest[v], err = get_digest(v)
|
||||
if not digest[v] then return nil, err end
|
||||
end
|
||||
end
|
||||
if #licenses == 0 then
|
||||
for i = 1, #files do
|
||||
local v = files[i]
|
||||
if v:match('^doc/LICENSE')
|
||||
or v:match('^doc/license')
|
||||
or v:match('^doc/us/license') then
|
||||
licenses[#licenses+1] = v
|
||||
digest[v], err = get_digest(v)
|
||||
if not digest[v] then return nil, err end
|
||||
end
|
||||
end
|
||||
end
|
||||
fs.pop_dir()
|
||||
table.sort(licenses)
|
||||
|
||||
fs.pop_dir()
|
||||
ok, err = fs.make_dir('package/' .. fsname:lower())
|
||||
if not ok then return nil, err end
|
||||
|
||||
generate_config(rockspec, fsname:lower())
|
||||
generate_mk(rockspec, fsname:lower(), licenses)
|
||||
generate_hash(rockspec, fsname:lower(), rock_file, licenses, digest)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return buildroot
|
||||
13
bsp/buildroot/package/luarocks/luarocks-br-config.lua
Normal file
13
bsp/buildroot/package/luarocks/luarocks-br-config.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
-- BR cross-compilation
|
||||
local function getenv (name) return os_getenv(name) or '' end
|
||||
variables.LUA_INCDIR = getenv('STAGING_DIR') .. [[/usr/include]]
|
||||
variables.LUA_LIBDIR = getenv('STAGING_DIR') .. [[/usr/lib]]
|
||||
variables.CC = getenv('TARGET_CC')
|
||||
variables.LD = getenv('TARGET_CC')
|
||||
variables.CFLAGS = getenv('TARGET_CFLAGS')
|
||||
variables.LIBFLAG = [[-shared ]] .. getenv('TARGET_LDFLAGS')
|
||||
external_deps_dirs = { getenv('STAGING_DIR') .. [[/usr]] }
|
||||
gcc_rpath = false
|
||||
rocks_trees = { getenv('TARGET_DIR') .. [[/usr]] }
|
||||
wrap_bin_scripts = false
|
||||
deps_mode = [[none]]
|
||||
@@ -1,2 +1,3 @@
|
||||
# Locally calculated
|
||||
sha256 4d414d32fed5bb121c72d3ff1280b7f2dc9027a9bc012e41dfbffd5b519b362e luarocks-2.4.3.tar.gz
|
||||
sha256 1236a307ca5c556c4fed9fdbd35a7e0e80ccf063024becc8c3bf212f37ff0edf luarocks-3.0.4.tar.gz
|
||||
sha256 542ad0ee9b8ba582437ca7b4d0959c9b9432f25d2067f144d017188a7a84dd2f COPYING
|
||||
|
||||
@@ -4,56 +4,48 @@
|
||||
#
|
||||
################################################################################
|
||||
|
||||
LUAROCKS_VERSION = 2.4.3
|
||||
LUAROCKS_VERSION = 3.0.4
|
||||
LUAROCKS_SITE = http://luarocks.org/releases
|
||||
LUAROCKS_LICENSE = MIT
|
||||
LUAROCKS_LICENSE_FILES = COPYING
|
||||
|
||||
HOST_LUAROCKS_DEPENDENCIES = host-luainterpreter
|
||||
|
||||
LUAROCKS_CONFIG_DIR = $(HOST_DIR)/etc/luarocks
|
||||
LUAROCKS_CONFIG_FILE = $(LUAROCKS_CONFIG_DIR)/config-$(LUAINTERPRETER_ABIVER).lua
|
||||
LUAROCKS_CONFIG_DIR = $(HOST_DIR)/etc
|
||||
LUAROCKS_CONFIG_FILE = $(LUAROCKS_CONFIG_DIR)/luarocks/config-$(LUAINTERPRETER_ABIVER).lua
|
||||
LUAROCKS_CFLAGS = $(TARGET_CFLAGS) -fPIC
|
||||
ifeq ($(BR2_PACKAGE_LUA_5_3),y)
|
||||
LUAROCKS_CFLAGS += -DLUA_COMPAT_5_2
|
||||
endif
|
||||
|
||||
define LUAROCKS_ADDON_EXTRACT
|
||||
mkdir $(@D)/src/luarocks/cmd/external
|
||||
cp package/luarocks/buildroot.lua $(@D)/src/luarocks/cmd/external/buildroot.lua
|
||||
endef
|
||||
HOST_LUAROCKS_POST_EXTRACT_HOOKS += LUAROCKS_ADDON_EXTRACT
|
||||
|
||||
HOST_LUAROCKS_CONF_OPTS = \
|
||||
--prefix=$(HOST_DIR) \
|
||||
--sysconfdir=$(LUAROCKS_CONFIG_DIR) \
|
||||
--with-lua=$(HOST_DIR)
|
||||
|
||||
ifeq ($(BR2_PACKAGE_LUAJIT),y)
|
||||
HOST_LUAROCKS_CONF_OPTS += --lua-suffix=jit
|
||||
endif
|
||||
|
||||
define HOST_LUAROCKS_CONFIGURE_CMDS
|
||||
cd $(@D) && ./configure $(HOST_LUAROCKS_CONF_OPTS)
|
||||
endef
|
||||
|
||||
define HOST_LUAROCKS_INSTALL_CMDS
|
||||
rm -f $(LUAROCKS_CONFIG_FILE)
|
||||
$(MAKE1) -C $(@D) install \
|
||||
PREFIX=$(HOST_DIR)
|
||||
echo "-- BR cross-compilation" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "variables = {" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo " LUA_INCDIR = [[$(STAGING_DIR)/usr/include]]," >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo " LUA_LIBDIR = [[$(STAGING_DIR)/usr/lib]]," >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo " CC = [[$(TARGET_CC)]]," >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo " LD = [[$(TARGET_CC)]]," >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo " CFLAGS = [[$(LUAROCKS_CFLAGS)]]," >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo " LIBFLAG = [[-shared $(TARGET_LDFLAGS)]]," >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "}" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "external_deps_dirs = { [[$(STAGING_DIR)/usr]] }" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "gcc_rpath = false" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "rocks_trees = { [[$(TARGET_DIR)/usr]] }" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "wrap_bin_scripts = false" >> $(LUAROCKS_CONFIG_FILE)
|
||||
echo "deps_mode = [[none]]" >> $(LUAROCKS_CONFIG_FILE)
|
||||
$(MAKE1) -C $(@D) install
|
||||
cat $(HOST_LUAROCKS_PKGDIR)/luarocks-br-config.lua >> $(LUAROCKS_CONFIG_FILE)
|
||||
endef
|
||||
|
||||
$(eval $(host-generic-package))
|
||||
|
||||
LUAROCKS_RUN_ENV = LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua"
|
||||
LUAROCKS_RUN_ENV = \
|
||||
LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua" \
|
||||
TARGET_CC="$(TARGET_CC)" \
|
||||
TARGET_CFLAGS="$(LUAROCKS_CFLAGS)" \
|
||||
TARGET_LDFLAGS="$(TARGET_LDFLAGS)"
|
||||
LUAROCKS_RUN_CMD = $(LUA_RUN) $(HOST_DIR)/bin/luarocks
|
||||
|
||||
define LUAROCKS_FINALIZE_TARGET
|
||||
|
||||
Reference in New Issue
Block a user