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 E1F6FC433EF for ; Mon, 10 Jan 2022 03:20:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9BDD383325; Mon, 10 Jan 2022 04:16:42 +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="BorRz2eO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03A06830D0; Mon, 10 Jan 2022 04:15:55 +0100 (CET) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 819B881E04 for ; Mon, 10 Jan 2022 04:15:28 +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-xd31.google.com with SMTP id s6so15821005ioj.0 for ; Sun, 09 Jan 2022 19:15:28 -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=n1Uc8wCPYlAVDv5PNmyfZfaBUXWuQD/o0pe0Nv57LGU=; b=BorRz2eOahzjmKpA+Hv8l21hNWZlxu7Fc99N48bmzeo95d+jHMSrQIx0Yjk1FSw1Ig H5Z1Ke1Bq9LGzgPHYJyCiJ/n5spz8WqwwYlXfrIypEHSpL+w5IoRvI386IRcH5dkqk99 IxTsehKwtL1Q2S1JrMhHuWm+nK/jGTiMSMAA4= 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=n1Uc8wCPYlAVDv5PNmyfZfaBUXWuQD/o0pe0Nv57LGU=; b=cUD07jVS6iNq6pJCSZbT+cXYfKNMBhzptw9HRGM9/dMrBeBw8KV65nES7d6AKXLTK5 itQcLg3JG+BEST/Ff2MXcKQOW2uRssI69BaZgL+ODmGqZXwDISr3litwWv1VyHsasu7G CZC9Iuz2zafyT4t2MerjNaDaU67w6yZWcMMoHeMK2bc1CV9a+QzlSg1RA6T+osSTXsQs n0XzvSrp49l6/DqTtWdyHA0pPYcH5HvstFSX3UI4M9gBxDuiai88Xwc0K7lmTSdzu9VX WomL/9vpV4Hon+3O7lwfhokNvm8Huttr/ACfCWN23aXF8MXeOrdXTQfZqBTbXCQ0bzSi qubg== X-Gm-Message-State: AOAM533AIa+DuvGnUatoZH7KPX9aZVgMbGRcI8Yd6ltaNfSU1CDuXw7a 9IeCfd82HNGorTwIzcwdfiIABlX65zInkQ== X-Google-Smtp-Source: ABdhPJwKbl7dFeiCJGZZkti17hb0bruoaoFKXKOT+iyJuo5YPERZAO2cQn8D3MtMSMpFhHQOCGIeKA== X-Received: by 2002:a05:6602:1490:: with SMTP id a16mr7107029iow.30.1641784527145; Sun, 09 Jan 2022 19:15:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 19:15:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 31/38] binman: Convert to using the lz4 bintool Date: Sun, 9 Jan 2022 20:14:06 -0700 Message-Id: <20220110031413.1970836-32-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 Update the code to use this bintool, instead of running lz4 directly. This simplifies the code and provides more consistency. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/cbfs_util_test.py | 8 ++------ tools/binman/comp_util.py | 10 +++++++--- tools/binman/ftest.py | 8 +------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py index 70b42795bfd..494f6145edb 100755 --- a/tools/binman/cbfs_util_test.py +++ b/tools/binman/cbfs_util_test.py @@ -19,6 +19,7 @@ import unittest from binman import bintool from binman import cbfs_util from binman.cbfs_util import CbfsWriter +from binman import comp_util from binman import elf from patman import test_util from patman import tools @@ -49,12 +50,7 @@ class TestCbfs(unittest.TestCase): cls.cbfstool = bintool.Bintool.create('cbfstool') cls.have_cbfstool = cls.cbfstool.is_present() - cls.have_lz4 = True - try: - tools.Run('lz4', '--no-frame-crc', '-c', - tools.GetInputFilename('u-boot.bin'), binary=True) - except: - cls.have_lz4 = False + cls.have_lz4 = comp_util.HAVE_LZ4 @classmethod def tearDownClass(cls): diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py index 7e741cb62cc..baa29798bed 100644 --- a/tools/binman/comp_util.py +++ b/tools/binman/comp_util.py @@ -6,8 +6,13 @@ import struct import tempfile +from binman import bintool from patman import tools +LZ4 = bintool.Bintool.create('lz4') +HAVE_LZ4 = LZ4.is_present() + + def compress(indata, algo, with_header=True): """Compress some data using a given algorithm @@ -33,8 +38,7 @@ def compress(indata, algo, with_header=True): dir=tools.GetOutputDir()).name tools.WriteFile(fname, indata) if algo == 'lz4': - data = tools.Run('lz4', '--no-frame-crc', '-B4', '-5', '-c', fname, - binary=True) + data = LZ4.compress(indata) # cbfstool uses a very old version of lzma elif algo == 'lzma': outfname = tempfile.NamedTemporaryFile(prefix='%s.comp.otmp' % algo, @@ -75,7 +79,7 @@ def decompress(indata, algo, with_header=True): fname = tools.GetOutputFilename('%s.decomp.tmp' % algo) tools.WriteFile(fname, indata) if algo == 'lz4': - data = tools.Run('lz4', '-dc', fname, binary=True) + data = LZ4.decompress(indata) elif algo == 'lzma': outfname = tools.GetOutputFilename('%s.decomp.otmp' % algo) tools.Run('lzma_alone', 'd', fname, outfname) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 779b8997ab0..19461c927c3 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -197,13 +197,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('env.txt', ENV_DATA) - # Travis-CI may have an old lz4 - cls.have_lz4 = True - try: - tools.Run('lz4', '--no-frame-crc', '-c', - os.path.join(cls._indir, 'u-boot.bin'), binary=True) - except: - cls.have_lz4 = False + cls.have_lz4 = comp_util.HAVE_LZ4 @classmethod def tearDownClass(cls): -- 2.34.1.575.g55b058a8bb-goog