From d4d9db71622af582e5f297a27d45741d4e015e76 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
 <41898282+github-actions[bot]@users.noreply.github.com>
Date: Fri, 8 Mar 2024 13:17:37 +0100
Subject: [PATCH] scripts: image_customization_lib.lua: fail build without
 valid customization file (#3220)

image-customization.lua has replaced GLUON_FEATURES and
GLUON_SITE_PACKAGES, so the file is always required to build a useful
Gluon image. In addition, not only 'file not found' errors were ignored,
but also all other Lua load errors, resulting in a build with empty
image customization when the file was not valid.

Closes #3218

(cherry picked from commit 7feaec85bf853252be886c4c20c612b4dfcef182)

Co-authored-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 scripts/image_customization_lib.lua | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/scripts/image_customization_lib.lua b/scripts/image_customization_lib.lua
index 3abe9d69..c39e95d7 100644
--- a/scripts/image_customization_lib.lua
+++ b/scripts/image_customization_lib.lua
@@ -90,26 +90,11 @@ local function evaluate_device(env, dev)
 end
 
 function M.get_selections(dev)
-	local return_object = {
-		features = {},
-		packages = {},
-	}
-
-	if M.customization_file == nil then
-		-- No customization file found
-		return return_object
-	end
-
 	local eval_result = evaluate_device(M.env, dev)
 	return eval_result.selections
 end
 
 function M.device_overrides(dev)
-	if M.customization_file == nil then
-		-- No customization file found
-		return {}
-	end
-
 	local eval_result = evaluate_device(M.env, dev)
 	return eval_result.device_overrides
 end
@@ -118,14 +103,7 @@ function M.init(env)
 	local filename = env.GLUON_SITEDIR .. '/image-customization.lua'
 
 	M.env = env
-
-	local f, _ = loadfile(filename)
-	if not f then
-		-- No customization file found, nothing to do
-		return
-	end
-
-	M.customization_file = f
+	M.customization_file = assert(loadfile(filename))
 end
 
 return M
-- 
GitLab