public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Henning Schild <henning.schild@siemens.com>,
	Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: [PATCH] bootstrap: handle python exception for missing sources files more readable
Date: Wed, 20 Apr 2022 13:52:24 +0200	[thread overview]
Message-ID: <20220420115224.27674-1-henning.schild@siemens.com> (raw)

When a file for DISTRO_APT_SOURCES can not be found in any layer, catch
the exception and turn it into a bb.fatal. Which will be much more
readable to users.

Reported-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 .../recipes-core/isar-bootstrap/isar-bootstrap.inc | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index a6e370e3b7db..b4bd2dad87f7 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -147,14 +147,22 @@ def aggregate_aptsources_list(d, file_list, file_out):
             out_fd.write("\n".encode())
 
 def get_aptsources_list(d):
+    import errno
     apt_sources_var = d.getVar("DISTRO_VARS_PREFIX") + "DISTRO_APT_SOURCES"
-    return (d.getVar(apt_sources_var, True) or "").split()
+    list = (d.getVar(apt_sources_var, True) or "").split()
+    ret = []
+    for p in list:
+        try:
+            f = bb.parse.resolve_file(p, d)
+            ret.append(f)
+        except FileNotFoundError as e:
+            bb.fatal(os.strerror(errno.ENOENT) + ' "' + p + '"')
+    return ret
 
 def generate_distro_sources(d):
     apt_sources_list = get_aptsources_list(d)
     for entry in apt_sources_list:
-        entry_real = bb.parse.resolve_file(entry, d)
-        with open(entry_real, "r") as in_fd:
+        with open(entry, "r") as in_fd:
             for line in in_fd:
                 parsed = parse_aptsources_list_line(line)
                 if parsed:
-- 
2.35.1


             reply	other threads:[~2022-04-20 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 11:52 Henning Schild [this message]
2022-05-05 10:17 ` Anton Mikanovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420115224.27674-1-henning.schild@siemens.com \
    --to=henning.schild@siemens.com \
    --cc=florian.bezdeka@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox