From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2A9CC433EF for ; Mon, 10 Jan 2022 03:16:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7852083093; Mon, 10 Jan 2022 04:15:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Ujnog6i7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 552AB82A71; Mon, 10 Jan 2022 04:15:23 +0100 (CET) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 474D281DCC for ; Mon, 10 Jan 2022 04:15:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id i14so15732254ioj.12 for ; Sun, 09 Jan 2022 19:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/xQ3wpg63NMEyiQsAK1utNRqNUS3czJj22z+RfSh32A=; b=Ujnog6i7m5aFfx7Pbgh2slA+sJP8Kus2sAtkv0FfIbx/JKj5nI3f3OAVdcHgL587Lm zBNS6GdmwLsihbak0SasjWR2zg2WXc9M/DTJnLYjOaeKWVsjCDPOfukBqpuiw4YGIO0x a2pNDBd0Qf74cJhMqwgLldfYzY/CXxPjqLeME= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/xQ3wpg63NMEyiQsAK1utNRqNUS3czJj22z+RfSh32A=; b=L0gR6TVX5F5UdeodbZe15vJUwVgHdjZYptqBAnLR2rD6ZcpwKhBXhbaS51Cg8j9NTq /BNW9LtPD1QRxcVD0vOTiW4HQiJshIWmSc+VgDnq8Ho6J0qwzk8VMnV9IbGUvJCwWDZx Nqwe9ujO5hZo9+nxKGgMcS6hZEl45qu3BEoeKiKmz/X/eZKRnprMuTOa5VCbc1JTuYve yQEvHA6pi2+Sh25xgqNO5b8jRJY8+zryMddqLHmbsQLPC5i3lw1zaPtPsDYruzVJ2sja In65iFwT37/D4FzZUApMNL2+qCmRtk33+gCvtkKwhZy7vgPM7NHmT9fmK6qRc3/Ivpxq kDZg== X-Gm-Message-State: AOAM530C6mIQW1T4mT6tDu+NXa9Oib+A6EutFbQQ7qTMqgQ+2eMx5VFP 6L6g9r0bdpHwr4XWtZERMFg8itZNvm/NHA== X-Google-Smtp-Source: ABdhPJy2uiI4/b/e2FAoed0w8T+aNkLNAbuNPKbV5mR/ueCBD9FzpWhU3U22bJkSoxLcqfhAPmYWTw== X-Received: by 2002:a05:6602:17d0:: with SMTP id z16mr10662346iox.204.1641784512757; Sun, 09 Jan 2022 19:15:12 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id d16sm3542182ioy.29.2022.01.09.19.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 19:15:12 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 09/38] binman: Write fake blobs to the output directory Date: Sun, 9 Jan 2022 20:13:44 -0700 Message-Id: <20220110031413.1970836-10-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220110031413.1970836-1-sjg@chromium.org> References: <20220110031413.1970836-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean At present binman writes fake blobs to the current directory. This is not very helpful, since the files serve no useful purpose once binman has finished. They clutter up the source directory and affect future runs, since the files in the current directory are often used in preference to those in the board directory. To avoid these problems, write them to the output directory instead. Move the file-creation code to the Entry base class, so it can be used by any entry type that needs it. This is required since some entry types, such as Entry_blob_ext_list, are not subclasses of Entry_blob. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/control.py | 8 +++++--- tools/binman/entry.py | 20 ++++++++++++++++++++ tools/binman/etype/blob.py | 8 +------- tools/binman/ftest.py | 1 - 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index 4b3ce23fb4c..f4c1fd01568 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -577,9 +577,11 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, faked_list = [] image.CheckFakedBlobs(faked_list) if faked_list: - tout.Warning("Image '%s:%s' has faked external blobs and is non-functional: %s" % - (image.name, image.image_name, - ' '.join([e.GetDefaultFilename() for e in faked_list]))) + tout.Warning( + "Image '%s:%s' has faked external blobs and is non-functional: %s" % + (image.name, image.image_name, + ' '.join([os.path.basename(e.GetDefaultFilename()) + for e in faked_list]))) return bool(missing_list) or bool(faked_list) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 54cc3726b9d..bac90bbbcde 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -7,6 +7,7 @@ from collections import namedtuple import importlib import os +import pathlib import sys from dtoc import fdt_util @@ -972,6 +973,25 @@ features to produce new behaviours. if self.missing: missing_list.append(self) + def check_fake_fname(self, fname): + """If the file is missing and the entry allows fake blobs, fake it + + Sets self.faked to True if faked + + Args: + fname (str): Filename to check + + Returns: + fname (str): Filename of faked file + """ + if self.allow_fake and not pathlib.Path(fname).is_file(): + outfname = tools.GetOutputFilename(os.path.basename(fname)) + with open(outfname, "wb") as out: + out.truncate(1024) + self.faked = True + return outfname + return fname + def CheckFakedBlobs(self, faked_blobs_list): """Check if any entries in this section have faked external blobs diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index 65ebb2ecf4d..59728f368ec 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -5,8 +5,6 @@ # Entry-type module for blobs, which are binary objects read from files # -import pathlib - from binman.entry import Entry from binman import state from dtoc import fdt_util @@ -38,16 +36,12 @@ class Entry_blob(Entry): self._filename = fdt_util.GetString(self._node, 'filename', self.etype) def ObtainContents(self): - if self.allow_fake and not pathlib.Path(self._filename).is_file(): - with open(self._filename, "wb") as out: - out.truncate(1024) - self.faked = True - self._filename = self.GetDefaultFilename() self._pathname = tools.GetInputFilename(self._filename, self.external and self.section.GetAllowMissing()) # Allow the file to be missing if not self._pathname: + self._pathname = self.check_fake_fname(self._filename) self.SetContents(b'') self.missing = True return True diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index f44128de6f3..6a7647311ba 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4981,7 +4981,6 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertRegex( err, "Image '.*' has faked external blobs and is non-functional: .*") - os.remove('binman_faking_test_blob') if __name__ == "__main__": -- 2.34.1.575.g55b058a8bb-goog