features: handle all feature files in a single pass of feature_lib.get_packages()

All defined features need to be known at the same time, otherwise handling
a feed-provided feature definition file would add gluon-web-advanced etc.
to the package list when the corresponding feature flags appear in
GLUON_FEATURES.

Fixes: ee5ec5afe5 ("build: rewrite features.sh in Lua")
This commit is contained in:
Matthias Schiffer 2020-08-28 22:20:13 +02:00
parent 13b743d51e
commit a9c2db939a
2 changed files with 12 additions and 16 deletions

View File

@ -16,7 +16,7 @@ local function collect_keys(t)
return ret
end
function M.get_packages(file, features)
function M.get_packages(files, features)
local enabled_features = to_keys(features)
local handled_features = {}
local packages = {}
@ -55,13 +55,15 @@ function M.get_packages(file, features)
end
end
-- Evaluate the feature definition file
-- Evaluate the feature definition files
for _, file in ipairs(files) do
local f, err = loadfile(file)
if not f then
error('Failed to parse feature definition: ' .. err)
end
setfenv(f, funcs)
f()
end
-- Handle default packages
for _, feature in ipairs(features) do

View File

@ -91,21 +91,15 @@ local function site_packages(image)
end
local function feature_packages(features)
local pkgs = {}
local function handle_feature_file(file)
pkgs = concat_list(pkgs, feature_lib.get_packages(file, features))
end
handle_feature_file('package/features')
local files = {'package/features'}
for _, feed in ipairs(feeds) do
local path = string.format('packages/%s/features', feed)
if file_exists(path) then
handle_feature_file(path)
table.insert(files, path)
end
end
return pkgs
return feature_lib.get_packages(files, features)
end
-- This involves running a few processes to evaluate site.mk, so we add a simple cache