From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6657041487194226688 X-Received: by 2002:a1c:9cc2:: with SMTP id f185mr173138wme.10.1549963258836; Tue, 12 Feb 2019 01:20:58 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:e919:: with SMTP id q25ls286250wmc.6.gmail; Tue, 12 Feb 2019 01:20:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IZIJp29Fb1rlbZrHoIhIAaVJc9aMSOPJX6bpy0PdRq0pGkehipdIH6Gl15idhYhtK2qendc X-Received: by 2002:a1c:e357:: with SMTP id a84mr189826wmh.13.1549963258273; Tue, 12 Feb 2019 01:20:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549963258; cv=none; d=google.com; s=arc-20160816; b=FJOn7zMRVpIcRE0Fm6YfunRiVlIBJ4sTPdyxtr8hTSa/8Pg125l2hFnLPlGZNm2x2p yUp6Gmn4a5ZBXRM3gQoiMbgIlLy/iugOckxqZjFJTd9L+gAhJ6U1VxszPUb7e87COMit 37ivaWHZDrroNsfylU1Qy9NfobJDXH1nlCUfAn+FENHNmb5HK619w7HeBOTXY3Si25AE cwWLeoWmf0KVUarym85C+vWxGXXl+3QD122aY6y5QTZy/oZtWUfaT1hXbeHUqJrauYT7 TICPCwWvSTzKYINPyh5nZ/d7U1hYl5hgSVsGuabWenJC5U+QZ4GPhgbRRwek0ml0NGg0 w8jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=ZCCS5mPwMjA/7Ydzf6IqB3Oi50Pd1r50dG1KiWOg4+c=; b=D0QPfuIbsLaCAWKs1N75GnrGp6N+imLZrtyiU9FHAbMq30pMYwdGhWgMV5qVLig93u FcKhzPf+1R5w2IgVZ4eNyGvE4h8qC6Ed3ccTpJfmQPoRAaGjN6nlY3rFCiq4chyn/QN5 kooeIW5RAWDouKEboUn8ihgBfB6NO6E+XwgLaVnOSf/2jOu5uBlgol1qhBOXxO/ElVzU z3c+ZPAETxZjZhZRJM9IL7q4awwYDEy8zHrxQHHEdTmrh78ZLJ/8B7l+fiXXq96MPQGU nci76ImkbBLZaIr+IBkO9AHV0ImpnJmHQHEF1sF1ifCiyDg8mLKdV46rJ7RTkDDh8D5g C1jg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id y6si107691wmd.1.2019.02.12.01.20.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 01:20:58 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of hws@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43zHFk0qGLz1r0hB for ; Tue, 12 Feb 2019 10:20:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43zHFk0gk2z1qvWm for ; Tue, 12 Feb 2019 10:20:58 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Gx9x9KsgJcKk for ; Tue, 12 Feb 2019 10:20:57 +0100 (CET) X-Auth-Info: uQbD15NuClUHhqhEhPuG5LPP0rYPHvhA1MW64c7ubL4= Received: from sandvich.fritz.box (p578a821c.dip0.t-ipconnect.de [87.138.130.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Tue, 12 Feb 2019 10:20:57 +0100 (CET) From: Harald Seiler To: isar-users@googlegroups.com Subject: [PATCH 3/4] image: Remove recursion in get_image_name Date: Tue, 12 Feb 2019 10:20:45 +0100 Message-Id: <20190212092046.6508-4-hws@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212092046.6508-1-hws@denx.de> References: <20190212092046.6508-1-hws@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: eAm96w4rI2CP 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 --- meta/classes/image.bbclass | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 930c245..8a2c152 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -22,12 +22,23 @@ 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 ["", ""] -- 2.14.1