From patchwork Mon Aug 8 10:51:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1664524 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=PtS8jQbb; 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 4M1Y2J6HhCz9s2R for ; Mon, 8 Aug 2022 20:52:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4C308455E; Mon, 8 Aug 2022 12:52:08 +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="PtS8jQbb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D3C784164; Mon, 8 Aug 2022 12:51:58 +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-eopbgr80052.outbound.protection.outlook.com [40.107.8.52]) (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 A33088418E for ; Mon, 8 Aug 2022 12:51:52 +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=fnimDS2GD9Q4F6YIADIQZFapY6GmBTLF3Khoekw/AWAjghwUv3nOdDdPMhYrIl/U0hofqwAkJZMxN7ywd3gLoIkNsSnOjZV+MMUD6qCwtjLhTDUjd+vuGlhVg1XGST4cpU2EilOmiJLW9nB7R+X7tIcVhBIEqa8mnAYoS2JsL8/r52hJ0zr6uPfdJ4j6VPDYwoxzymmKshMTcJM+V2E1+DPGgkpzaoy9IpbDY8SC/hXyoV/NPoJ/DqSGRIId8sTkE2ZCdr2UI7rCmfJu0xfL1L6XlbD9ORkzT1K2Qi5HbVO3wcSuR3W4IJf0Fv3AwGn7KuzHj6OiKM33J4YJ628IkA== 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=CX/PI8PUGdjA5by6ThQ+nBCWJo7qIHmQJMk/TlwUHW8=; b=la33GJO+j9qspoQFKv9OwJCN84KE9gYLXF1y+Vc7UwDpG4S94wp0N+SvNaN1gRhF/pXdB5TTAYowKdeU/VxzxsJ1JB0HEq4kcc5t2DN2bTLCqO/pgM8Lp64a0QNT/hxWxc3TJCTT91NRn/cij9K6kOq1DV6+Pucjontvj4JmdoWRnNSmoTHe1PTyUm2Fh3Ashq2zU5lpvi+2wXuBQSEEJkmIz7cTXc/187A2ejfibzrXv3Fmns0FxZHTxN5VnEFCYqI19MJ35PEUdcTZZrAJNjzIXLPcVYAG5Z7I8qH5hcagT7VINMuG0DRqDWUpPWxqwHIz0VUmMOUiCCeuhc6PcA== 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=CX/PI8PUGdjA5by6ThQ+nBCWJo7qIHmQJMk/TlwUHW8=; b=PtS8jQbbHviNP9PzA1ikb9CoGEn2PM7rL3YmqtuRzJeFVD6hpsnky6F1Z+Fi2dq/j8dj2qTV52U+hGpIOSeCOUtsyzMLJLcnINSz4bnSCPMrzripwTLaSXD2yOhjCQh3AkOG2L74cGR4peNEUvykWZCD6t4wC/KHPiCJ6fTcWFc= 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:51 +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:51 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 06/10] binman: Add bzip2 bintool Date: Mon, 8 Aug 2022 12:51:21 +0200 Message-Id: <20220808105125.21356-6-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: b62cc8e7-686d-4291-5f85-08da792c0036 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: B4+32sQiXvI25YfEqN69pri3czeAvBL9oJ5C4gYh2+IXJdNdHRwOoVRU+mv4XDm/1gNqhmBXWic1tBuXKq6tx66syshpLmWmgqA5Sc4QwySWVJKBsqJT3JHjQYBNVec/inpuUx68hkzA/1DiSMaNHAHXKDz6UPSIlkmop2WxjAJTg7/dWhMgi/UTcM6mUv3YdDYztyfh9ZzU/pd3OIzBRgSxG788Da67GJrzi0UpDLXS8d/rY4arwEcVLd7C8t/OYsQnN4SRotpfG/tqbHLmbBgL/SZGliPw9kha4lV0hmN1C+v4ll62F3Av209VwbaKlldgrWvrPYU9mijdHiWzPS7e67bT0hXttnSk0gvYWPUafq5r61uZoR3Cu+2bCqxW/qW5XfsSzUq/z9LGCradd275iWz4ca1kwsBtZearYnE2EKSV7JrGMc8gTH52WkjA0XqYrd4xTiA2F8TwmEAMCp3S0S4+muGSDAZjt5MJn9ShEjC8W0R1rpTZ3Mf3o7gNct1byxd8XFsW5RjIIGzgZwJyyFwEI191HG2oJjs4iW+mhrwMNRtUCi68ua6L4Yj3HihFEuEYbfe+2EuubpOq7RNLnGwA2WaEpga+/5Y+bCvrF+FdwyLxkFFY2jWMdth+JAoOZ3a03oSQ6IR1pPJXNCRUHlx7Jtw7hO5U7AQpIqcbV03TZoz/TUlgjsgTzGMCuqQNFKfrcj7IQZWJd5SLQ7W1h2FZEv7aRHxN/BmzvD4a3PhqUUd/L5aoXg3AhLYbMwkootrMIcw45OiMf/mLnvKHxCi0bYv1UOowFEE1wCg= 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?qEnQGXSJfiZk786cUEecGce8bF2N?= =?utf-8?q?+eCy3dCCJfj+UuiqD1Wu1OvfiiJmAyA+X5qbW5qSHCaDEzq5ORGF8ueLGYf/wmDGH?= =?utf-8?q?hkA99EBXJgrQCQIlkwhTJ4ino5N/kt9UBqqlGYmUoNMe8XPzQxpYXDVShapIYtiWs?= =?utf-8?q?quDdP8zFWWAaWP62KkgueCP0vMJ2YqPvHJa3Nw0VRevwRot8Ih3ZceobnH7PZ+Usn?= =?utf-8?q?JocSKp0OwpqHZM8G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VvHOMrjUWPCaSDPBq1v8iYr0qBlPW4y2?= =?utf-8?q?57iwbRuZ6dutVBWSvBqBFElmwA0stw1SGXzLpzh+mHUYllxyyd+8Tz5fd9Ll6BAoG?= =?utf-8?q?ZNkD7fL6qlB6OU+y+E99Rkzr9MAmXRVHerPuEc9+J0LXnS8wifYz9fT9hccGt9SFv?= =?utf-8?q?BKEXgu5Y4BD33tAGYb8r9hQRtrBkbbIV9sUQI9tD0vpK3pIeXOW3XhMocYPTZAp+w?= =?utf-8?q?+aWIivLe1a+vlHn2qCyTDTGzcrraHiwlgkvcpalOXp14axb8Ej9ddmatJ5qqppmMe?= =?utf-8?q?qsBQC7OXIB/3DWohSDVRUGLnPN/dkpyv2eQYmBk5PMw9q43/bDs+Z6ereIJAHy9Ms?= =?utf-8?q?jLME9x6DYaQC1tbCq+AsHAJol9Temt8jnOAnTix+XHqJi1/YJtMnmWsv0+pdvOxOZ?= =?utf-8?q?ZtmnlGRIwtbcP9Qs9Y6Z4o9s4FzCAqPuoQ=3D=3D?= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: b62cc8e7-686d-4291-5f85-08da792c0036 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:51.6368 (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: mVFRigiih4KnCebt2GG/CT7LLDAE+adrGCJqoXgrkPdkfURyA6sTsenkCVJAQxKkpo2o9dUbYs5BqYhRddn80w== 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 bzip2 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/bzip2.py | 30 ++++++++++++++++++++++++++++++ tools/binman/comp_util.py | 14 +++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 tools/binman/btool/bzip2.py diff --git a/tools/binman/btool/bzip2.py b/tools/binman/btool/bzip2.py new file mode 100644 index 0000000000..9be87a621f --- /dev/null +++ b/tools/binman/btool/bzip2.py @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (C) 2022 Weidmüller Interface GmbH & Co. KG +# Stefan Herbrechtsmeier +# +"""Bintool implementation for bzip2 + +bzip2 allows compression and decompression of files. + +Documentation is available via:: + + man bzip2 +""" + +from binman import bintool + +# pylint: disable=C0103 +class Bintoolbzip2(bintool.BintoolPacker): + """Compression/decompression using the bzip2 algorithm + + This bintool supports running `bzip2` 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 bzip2 + """ + def __init__(self, name): + super().__init__(name, version_regex=r'bzip2.*Version ([0-9.]+)') diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py index faa08a7f8a..fa75911e58 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 = ['lz4', 'lzma'] +COMPRESSIONS = ['bzip2', 'lz4', 'lzma'] bintools = {} @@ -34,12 +34,12 @@ def compress(indata, algo): Note that for lzma this uses an old version of the algorithm, not that provided by xz. - This requires 'lz4' and 'lzma_alone' tools. It also requires an output - directory to be previously set up, by calling PrepareOutputDir(). + This requires 'bzip2', 'lz4' and 'lzma_alone' 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', 'lz4' or 'lzma') + algo (str): Algorithm to use ('none', 'bzip2', 'lz4' or 'lzma') Returns: bytes: Compressed data @@ -60,12 +60,12 @@ def decompress(indata, algo): Note that for lzma this uses an old version of the algorithm, not that provided by xz. - This requires 'lz4' and 'lzma_alone' tools. It also requires an output - directory to be previously set up, by calling PrepareOutputDir(). + This requires 'bzip2', 'lz4' and 'lzma_alone' 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', 'lz4' or 'lzma') + algo (str): Algorithm to use ('none', 'bzip2', 'lz4' or 'lzma') Returns: (bytes) Compressed data