From: Harald Seiler <hws@denx.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 3/5] image: Remove recursion in get_image_name
Date: Tue, 12 Feb 2019 17:56:35 +0100 [thread overview]
Message-ID: <20190212165637.19970-4-hws@denx.de> (raw)
In-Reply-To: <20190212165637.19970-1-hws@denx.de>
The use of recursion in this function is not immediately
obvious. This commit refactors the recursion into a more
visible imperative code style.
Signed-off-by: Harald Seiler <hws@denx.de>
---
meta/classes/image.bbclass | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index a687662..3e3bf0c 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -22,13 +22,24 @@ ROOTFS_EXTRA ?= "64"
def get_image_name(d, name_link):
S = d.getVar("IMAGE_ROOTFS", True)
path_link = os.path.join(S, name_link)
+
+ # If path_link does not exist, it might be a symlink
+ # in the target rootfs. This block attempts to resolve
+ # it relative to the rootfs location.
+ if not os.path.exists(path_link):
+ path_link = os.path.join(
+ S,
+ os.path.relpath(
+ os.path.realpath(path_link),
+ "/",
+ ),
+ )
+
if os.path.exists(path_link):
base = os.path.basename(os.path.realpath(path_link))
full = d.getVar("IMAGE_FULLNAME", True) + "." + base
return [base, full]
- if os.path.islink(path_link):
- return get_image_name(d, os.path.relpath(os.path.realpath(path_link),
- '/'))
+
return ["", ""]
def get_rootfs_size(d):
--
2.14.1
next prev parent reply other threads:[~2019-02-12 16:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 16:56 [PATCH v2 0/5] Python refactoring Harald Seiler
2019-02-12 16:56 ` [PATCH v2 1/5] Remove all uses of subprocess.call(shell=True) Harald Seiler
2019-02-12 16:56 ` [PATCH v2 2/5] Use modern python formatting Harald Seiler
2019-02-12 16:56 ` Harald Seiler [this message]
2019-02-12 16:56 ` [PATCH v2 4/5] wic: Refactor fakeroot script Harald Seiler
2019-02-12 16:56 ` [PATCH v2 5/5] Fix python style Harald Seiler
2019-02-12 17:14 ` [PATCH v2 0/5] Python refactoring Henning Schild
2019-02-18 13:29 ` Maxim Yu. Osipov
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=20190212165637.19970-4-hws@denx.de \
--to=hws@denx.de \
--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