From patchwork Mon Aug 8 10:51:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1664528 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-weidmueller-onmicrosoft-com header.b=YosLA2+7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M1Y314GNmz9s2R for ; Mon, 8 Aug 2022 20:53:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CAF4F848A4; Mon, 8 Aug 2022 12:52:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=weidmueller.com 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=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.b="YosLA2+7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E46A984180; Mon, 8 Aug 2022 12:51:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80054.outbound.protection.outlook.com [40.107.8.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 089D58419C for ; Mon, 8 Aug 2022 12:51:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan.herbrechtsmeier-oss@weidmueller.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WMSZNek8OGHG8z8pxNelllwwhD4O7/HEk/b9KpnkmRNef6QYn2rAXCQqltaBfkTygF69QZv3WRUiTEOEDwhIDY5pQ2tAMWrOmTHJJuWJuFchUSIMMccd0xtXLrZWw0mKXqtoTuOBv1JuBZaL3pZdIb+Yftxi1H78mNQBo5p1OfRWRKNSTz/8DvzSSoNmThWDRvAd+62et7PFlHONnCqQVp0ygW6LTQSJz27LUDHzwGlraSY6PXTrcLZ47GPHcnnd5SZlS63JhE522iGr7sLo4xHt8GQ/YvXnPV6xLFH9jHoKFUyn8XQqTmigXL87++XbTZvMfntTk+3EBTYZBERYLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h2MJwAItko9jKXhdgRwNeG8ua+Nmr6sdn0KZIvj0BPc=; b=SMT2wHFbqOgHyJMIpv/LGk3qqMj1AgVb9CflSAkjc5dfkta8vEXjMWUkKtX0RTxJBMz5gJjRv9+rsa0pVzW1O5Sb/tnLcmNw2zu+ht2Ig9+7UhlNQo19MHRxne88n6PC2UxCUdAODfWgEU+4oJg1XO4eTuVif2+GsjR/5DM9rbK7mng715WS2OPrmBwcqkpp1aQ83oAuqltTBPOmFw+ZGKzZvZgQK+LRgYHmyd/b8bc6fD34CMXutBTIMRTEZ5hkn0ybGw49IkuTXJ0EpSde6oelZlDgOXzrbQpEJp6ok29Ke0mQ8MlWUcz0bw5PYk7NguyCkzwMzgCYDcJS/yKXfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h2MJwAItko9jKXhdgRwNeG8ua+Nmr6sdn0KZIvj0BPc=; b=YosLA2+72pvlrjFbzkNit2Z5lUw140sDVHztg65RHU5hDi4vFs94ffVK3LlI5qf6NsMne7n4O2psP87j0zRyzxoRW5AFlojvbBbcqwLkWf3E3it2Juj8ZCtYS+RTO3w3IiSl8636MtnY5OVtpWZpfToGlTOrNVxv6aut9+XQm6E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by DB6PR0802MB2487.eurprd08.prod.outlook.com (2603:10a6:4:9e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Mon, 8 Aug 2022 10:51:53 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f95b:2e64:9ee6:4d44]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f95b:2e64:9ee6:4d44%3]) with mapi id 15.20.5504.020; Mon, 8 Aug 2022 10:51:53 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 09/10] binman: Add xz bintool Date: Mon, 8 Aug 2022 12:51:24 +0200 Message-Id: <20220808105125.21356-9-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220808105125.21356-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220808105125.21356-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: FR0P281CA0058.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::19) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f8995a3-a354-4788-832e-08da792c0108 X-MS-TrafficTypeDiagnostic: DB6PR0802MB2487:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bLxAlKhKfxGuD2bi8+6QIWkdMBcCQgKbhD3rJxovecupWyU/RKPOBc8RZ9BegtEtfE3Q++mGlteEDKZBfciY48Npv2iMvY30GcKxNbhfzj/anmQM7DCmBdFSD1IGxRWPgKs6j7ofqecjTwDv9ANfUv+tiNowjYc1qX23N9r7UlbtLNHwY/I42OXTW5Kwk7z9/4/uQqsIMfLOzQlVSks8Vo1+SvlJB7DceOE2zJavMKGtWYZvCGT3w2LZ9AO9m2JcAmL3apT72GOvjJgn6G4Yu1WoQa2e65jpHL3lNs2yI1nTaxfKM4fxcQf5DAnmrd35ZFAT+HSoWUNhElyV6gLvaNMg2sDGKfKo052vQKGIxgNmwDrjesbh0QnVrIX2bvN26sxrmgiKcJugb4XCDL5uwCSANwQmwBpAdC9ndjSiGeiB4yKzXqS7Vt7N2XEW1k3SX3sJUSnaLBuBqowQXoLj0tcsboG5YkBgDfF4kIVqszBkiAigfoglzy5WBXnh1QjO/u6V52QKjBlBTDWItdVLhikU6fHNzCbCxqQWvAsWq/YvYVi9dJ3LvdNfKAMkN3miv3oHSQAAbaamXuHMFaan4kWje0TKaWEMTfJD+s5k0v0lKE1Eq3v/tJkaYU5QbnYZRMQVBO/kWen+3P4EAwmzunfuIV7pi9P2Z9hFhLyFdMjF93pLg0QBRCRDEodk1JM8XGt+zUzufbJfN1DLPJDaw2Y3oNWCM8lIwvCSyEGvawo7wTgUdCgP9MrX564D2mpgS8jEZAU4Oi+JPU6SqHA/BIOTzp3efa5E0dr7AvxEkJ8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB6969.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(6666004)(2906002)(6512007)(26005)(41300700001)(52116002)(6506007)(83380400001)(38100700002)(38350700002)(2616005)(186003)(1076003)(478600001)(36756003)(4326008)(8676002)(66476007)(66556008)(8936002)(86362001)(6486002)(66946007)(6916009)(316002)(54906003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?KAwU6aIi4q0/r1uPBi1RllKcar0T?= =?utf-8?q?lAe8ONenGnlx2hRkSlaUxqnIpwPW1yrOp/9tfz7GyBrGmem5sFLUC4tjcf/olhjie?= =?utf-8?q?7ZuRffAhg9PDu0pT+DAEuRxn8WAJYsXmlu1kGBdM+QjyQ1Szt0HCg/wNajcUTpzaY?= =?utf-8?q?1pqM3nTfu5WZQatyV2z4Q+EjKnjhp9WU/SdFVEOz5wxINXFBAsXY+/lLxE5n27g4E?= =?utf-8?q?RVjHSHxzmISEVwzlHELCdldhiu3jxz80xY8+YhM9/8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mffM7yWgSW68yMoS8FlTGRKLte+i0oOv0wFEK?= =?utf-8?q?7QBFQSDnSwMNF8xORZsYaHYzNR44N84c65afmzpuTrtIU/fV/kkr71ThBbi9N+JPY?= =?utf-8?q?wJ0L8M3HWJ1D7Pd7uSxUmwmZKs45r9fjpRb7pnuWilHWziza6l7XVXDqu/PKfhFE1?= =?utf-8?q?CeUQ8KDVl312rl5mMkyAHHqyxLKxYbnwnsHbTs5ETSXhdj9JRbvxPSgqxVoDZ4V91?= =?utf-8?q?FtrXtnK1DqGXfu8CeFNUClcM/R/IC9oOOPWqxoJkchRLE+khmkPMKxAhgbwaG/2yS?= =?utf-8?q?ny0/B5FZ6Mmx1Xldyhbe9Kt1mSBkB6YjCYJbZR2EQ/h1mWPW4P+SbLiKNzKVabuT7?= =?utf-8?q?/t9vOM2PJk1ChBgwikvKFfLPYov4nJ5T5HzoYaklyuCpx9N/VkNd+edtGxzJRNY0N?= =?utf-8?q?Vr71Hn2M1k4qCX8nW9GKCL6xyhNlCgXcXA=3D=3D?= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f8995a3-a354-4788-832e-08da792c0108 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 10:51:53.0297 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8GPhTmid+zp0TuQ0o9upAdpUbwyP2DfIB9HBcS8Ce5QCNZi2m4486K54t2p7QeVnw7jFThgj6RvZYlm/zZm6Ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2487 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.6 at phobos.denx.de X-Virus-Status: Clean From: Stefan Herbrechtsmeier Add xz bintool to binman to support on-the-fly compression. Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Simon Glass --- Changes in v2: - Added tools/binman/btool/xz.py | 31 +++++++++++++++++++++++++++++++ tools/binman/comp_util.py | 18 +++++++++--------- 2 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 tools/binman/btool/xz.py diff --git a/tools/binman/btool/xz.py b/tools/binman/btool/xz.py new file mode 100644 index 0000000000..e2b413d18b --- /dev/null +++ b/tools/binman/btool/xz.py @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (C) 2022 Weidmüller Interface GmbH & Co. KG +# Stefan Herbrechtsmeier +# +"""Bintool implementation for xz + +xz allows compression and decompression of files. + +Documentation is available via:: + + man xz +""" + +from binman import bintool + +# pylint: disable=C0103 +class Bintoolxz(bintool.BintoolPacker): + """Compression/decompression using the xz algorithm + + This bintool supports running `xz` to compress and decompress data, as + used by binman. + + It is also possible to fetch the tool, which uses `apt` to install it. + + Documentation is available via:: + + man xz + """ + def __init__(self, name): + super().__init__(name, fetch_package='xz-utils', + version_regex=r'xz \(XZ Utils\) ([0-9.]+)') diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py index e7cba23aa8..35835450e2 100644 --- a/tools/binman/comp_util.py +++ b/tools/binman/comp_util.py @@ -11,7 +11,7 @@ from binman import bintool from patman import tools # Supported compressions -COMPRESSIONS = ['bzip2', 'gzip', 'lz4', 'lzma', 'lzo'] +COMPRESSIONS = ['bzip2', 'gzip', 'lz4', 'lzma', 'lzo', 'xz'] bintools = {} @@ -34,14 +34,14 @@ def compress(indata, algo): Note that for lzma this uses an old version of the algorithm, not that provided by xz. - This requires 'bzip2', 'gzip', 'lz4', 'lzma_alone' and 'lzop' tools. It - also requires an output directory to be previously set up, by calling + This requires 'bzip2', 'gzip', 'lz4', 'lzma_alone' 'lzop' and 'xz' tools. + It also requires an output directory to be previously set up, by calling PrepareOutputDir(). Args: indata (bytes): Input data to compress - algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4', 'lzma' or - 'lzo') + algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4', 'lzma', + 'lzo' or 'xz') Returns: bytes: Compressed data @@ -62,14 +62,14 @@ def decompress(indata, algo): Note that for lzma this uses an old version of the algorithm, not that provided by xz. - This requires 'bzip2', 'gzip', 'lz4', 'lzma_alone' and 'lzop' tools. It - also requires an output directory to be previously set up, by calling + This requires 'bzip2', 'gzip', 'lz4', 'lzma_alone', 'lzop' and 'xz' tools. + It also requires an output directory to be previously set up, by calling PrepareOutputDir(). Args: indata (bytes): Input data to decompress - algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4', 'lzma' or - 'lzo') + algo (str): Algorithm to use ('none', 'bzip2', 'gzip', 'lz4', 'lzma', + 'lzo' or 'xz') Returns: (bytes) Compressed data