From a9c2db939aac2c6123a6f3088fa2aaef42e80696 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 28 Aug 2020 22:20:13 +0200 Subject: [PATCH] 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: ee5ec5afe5ea ("build: rewrite features.sh in Lua") --- scripts/feature_lib.lua | 16 +++++++++------- scripts/target_config_lib.lua | 12 +++--------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/feature_lib.lua b/scripts/feature_lib.lua index 4c575dd4..a5197e0a 100644 --- a/scripts/feature_lib.lua +++ b/scripts/feature_lib.lua @@ -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 - local f, err = loadfile(file) - if not f then - error('Failed to parse feature definition: ' .. err) + -- 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 - setfenv(f, funcs) - f() -- Handle default packages for _, feature in ipairs(features) do diff --git a/scripts/target_config_lib.lua b/scripts/target_config_lib.lua index e91dfb0c..4b107e2b 100644 --- a/scripts/target_config_lib.lua +++ b/scripts/target_config_lib.lua @@ -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