From bd0133ad379b977334964edef863fded5ee02732 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sat, 15 Aug 2020 13:59:54 +0200
Subject: [PATCH] scripts/target_lib.lua: print a meaningful error message for
 missing site_code (#2094)

site_code is evaluated early during config generation, so a site.conf
without site_code would hit this assertion that just printed 'Assertion
failed'. Add a proper error message to tell users what went wrong.

The inner assert() is removed, as it should never be hit (as site.conf
syntax will have already been validated when this script runs), and it
doesn't add anything (even without the assert, the attempt to index a
nil value would throw an error).
---
 scripts/target_lib.lua | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/target_lib.lua b/scripts/target_lib.lua
index bb9746592..babec324b 100644
--- a/scripts/target_lib.lua
+++ b/scripts/target_lib.lua
@@ -21,7 +21,9 @@ assert(env.GLUON_RELEASE)
 assert(env.GLUON_DEPRECATED)
 
 
-M.site_code = assert(assert(dofile('scripts/site_config.lua')('site.conf')).site_code)
+M.site_code = assert(
+	dofile('scripts/site_config.lua')('site.conf').site_code, 'site_code missing in site.conf'
+)
 M.target_packages = {}
 M.configs = {}
 M.devices = {}
-- 
GitLab