From patchwork Mon Aug 15 15:56:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1666499 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=Us65phhL; dkim-atps=neutral Received: from legolas.ozlabs.org (legolas.ozlabs.org [150.107.73.247]) (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 4M5zRx69Mnz9s2R for ; Tue, 16 Aug 2022 01:57:01 +1000 (AEST) Received: by legolas.ozlabs.org (Postfix) id 4M5zRx1lTmz1ygN; Tue, 16 Aug 2022 01:57:01 +1000 (AEST) Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23b; helo=mail-lj1-x23b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbrgz5glqmgqeb6kk6ua@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=Us65phhL; dkim-atps=neutral Received: from mail-lj1-x23b.google.com (mail-lj1-x23b.google.com [IPv6:2a00:1450:4864:20::23b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M5zRx1frJz1ygF for ; Tue, 16 Aug 2022 01:56:59 +1000 (AEST) Received: by mail-lj1-x23b.google.com with SMTP id q2-20020a05651c054200b0025e77ad1ec6sf2361444ljp.23 for ; Mon, 15 Aug 2022 08:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1660579013; cv=pass; d=google.com; s=arc-20160816; b=J6BZocGyYmlJx/lObxOlt7BnldRgGgpIk659/6chgt6bUBdCv6dwibNfQbiyyeZOf2 pCTyJ4Magje7oOjMh/PsQq4tavyFl80UJJNdx/z4lcog5d+LJNypwPvVboC67vGkJQKs zUvxX4D/EiP1Y9+7xXmO7jUO/nE374XWw/obuhz28pWYiHbWEzm/7hfNjmj9mT4KFHlR VQb28x/6TvOo4mQduTa0LXzybM7eJJHaSy7vhCKiDLCq2CCO2/30yE9N5w35xn40VVah 9/5RviNLYaDH/GRErOf8SfzJRL8XA8tje9nUCYOf4EV3ShDNJpAHRKJJq0AdfxmtyJ94 w+fA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=WL1GA9RwvfB9Y9Qk30DaC1n2idngIlok+vVx8Stzaak=; b=uF5OL9kSxeQFakqbL0VgW5zwJT982RybcU0F/cqqWo6nhn/lcyanV3msKcikNRT3ej MaTg6j+lpaqPPeNl+HpW8WvdhkC6Gp8y3ToIX01NXnNBxFrXsuPOZo2gfk69wmboAA/o w8vP08SM4PzO6zI6cqzVGmabGM2e5q/71Ukg+BJd58bl3e4lnCADvmYlE3F5MseCqKfS nIa81Z/Iz/o7RcHnwhnn0IY8JlAJQuGBGo/uOMNBzGFM4EJ0IPry3Q/nHOO6o6nwvIfi g7lClUZ+pjONPYYNKSD7/V3aB00LSM27RIdmJndSuyZVFe1kc7l48pZhna+wGokWDhBT zq+g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:content-transfer-encoding:mime-version:message-id :date:subject:cc:to:from:sender:from:to:cc; bh=WL1GA9RwvfB9Y9Qk30DaC1n2idngIlok+vVx8Stzaak=; b=Us65phhLbQIsDaS5RRD7RI+g/A8dySd7as8VzIlG2y9J7EYIan5oxAscJiCxKKdNZB 5+gNHu7yBRcAY2um+d5pTeJmfT6VhAZry/IHGaF+ZR5QryObMI7QsiHxuyPTc8TOPpmV 1bJGQRtttPV+gkQ/Tv5++Q2Ikcn6FOHmzJDaHtDXscH+ZYH5YIckYdghnJEbGNzhog7S Po7Ryck4szoVH3FGBE2mbevQ1P0oWvWe86Ib6gGkZuuKlSyrTRGAQVYHeTQf1tNoWK+/ KpgGK79lzKSPcmWW9uMzrxBdd623WG7BuUvrpfgtcUBAKKCSrdEWFi2/xcZy4XekdVqT W/qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:sender:from:to:cc; bh=WL1GA9RwvfB9Y9Qk30DaC1n2idngIlok+vVx8Stzaak=; b=pxnCudpWKuPzaedXKJKo6U1eKN3G1sFoqwIcP6lPTp36hKPZLl77xPpEeuQECEmRUl eC1W9Wdd3FumXyDWQOYWgHcNNSSUcmbu3PuAPMdZEls6EfNgWoHOqJVU7DkM4wtXnzLr 7Ug4ovvimq+qom4e4KNjEjl1nJCNzPD1zvO/N7VHBoRWISxIUdkhL3ZIKTTUE5FuTAup 4/4mbdes671sJZoFC/0REzbC6CLUS9pkgxaGp5CM0SHvXJpFRdunYmdx0A2zY5of2JQ3 C8DJGRntBDoQ6bah3oKwRQFLh47ve28h+VCVKxNijB0XS02f1Y2Oo0BA+Sp4rBtCoElP iUIQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: ACgBeo3/QoBp5Pn4wjhWjCf8F5iSMilOcvnbmrSp+01MHz05E12sYX8B 3sAIrKjgqTL7EA50PNO0oP4= X-Google-Smtp-Source: AA6agR6RSNirYR0bPIRPa2OGwt+gaOrqCi0ZkX2B4kKSoMFUO0du2m2hcFK9dMKgtRb8exuXwMwh2w== X-Received: by 2002:a2e:804c:0:b0:261:806b:b86d with SMTP id p12-20020a2e804c000000b00261806bb86dmr2812550ljg.460.1660579013533; Mon, 15 Aug 2022 08:56:53 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:118:b0:25e:c1fe:11fc with SMTP id a24-20020a05651c011800b0025ec1fe11fcls1723521ljb.11.-pod-prod-gmail; Mon, 15 Aug 2022 08:56:51 -0700 (PDT) X-Received: by 2002:a2e:a7d3:0:b0:25e:7a20:e255 with SMTP id x19-20020a2ea7d3000000b0025e7a20e255mr4856791ljp.426.1660579011827; Mon, 15 Aug 2022 08:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660579011; cv=none; d=google.com; s=arc-20160816; b=siXhvyyy7oF/iV3+V3acD0LxXaVC8ItM/EClX325u5ICFwPqWhQF1XxrIadLUP90gf AGqH2bBqrS0DcfdcQocryIkD5stfzjqp4pZ2/ZLiQHYQ7CLPIwkKSOKIh0ZFjHeHmVRp 9Y8xNxQeS4A719d3JHkJbDfLeV5ooYze3J0hN6NpnQg/X6fhYMdcQN3E9cJK+P25BZsI Eyc4RQw7ogouDPI8YJgiIhITxXfnPyCXjXYR0lnUpL3FDpdQQVqnnJCs4Rb1/ISpsiX5 4qqwGK0Ux3uCHq5MSeQ0/0HJPWX3V4YRPByD2sbxJzEWCWPE6tSMfbRaGAGrz2vDB1U5 1+Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=O/LhYkGkYccYi1HnasGz3Z8gVQOIuZANwGfsphbINIE=; b=HlJ2gLZ2Wt3zujJub+NV/EYFj6fGy9xK+aRcX6dvqHthQlQmbyYYROnQxX3HeS1ir2 XqEolOZjZZc3DfSyyVAwKAwLaPU69oGFR9k9SvxyyC8OC8okfyJDrQgogRUx1gB+LH6v LYvarlLigAMcAiJ/4dzmuhwRpoW0MSZ7HZwOewSvKJhZR0pxJD2b7HT47rbki/t6AjY1 YuiOTjkJDocoe9t8idOTTy2DUXOtGT9tFbkLbEQcLu0a9jmkDJCx6Eus99vpGmq/Vv3X fDGSBWBBpJz1l8o0ACzAargzLCbQS/C7qWKhFEspe4uPiUb4GyTH3qd0x9Y6NQ/5o0BZ i0xw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id h3-20020a2ea483000000b0025ebaef956dsi794547lji.3.2022.08.15.08.56.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Aug 2022 08:56:51 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4M5zRl148Xz1s7tW; Mon, 15 Aug 2022 17:56:51 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4M5zRl09Gbz1qqkD; Mon, 15 Aug 2022 17:56:51 +0200 (CEST) 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 lPVQjzaB0ety; Mon, 15 Aug 2022 17:56:49 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 15 Aug 2022 17:56:49 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id E83664540625; Mon, 15 Aug 2022 17:56:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 9IEivA44e4Ej; Mon, 15 Aug 2022 17:56:46 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 1B6174540609; Mon, 15 Aug 2022 17:56:46 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , =?utf-8?q?Esad_Erg=C3=BCl?= Subject: [swupdate] [SWUgenerator][PATCH] Replace filenames after compression Date: Mon, 15 Aug 2022 17:56:44 +0200 Message-Id: <20220815155644.262055-1-sbabic@denx.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , File is compressed with new name and it replaces the original filename in sw-description. Signed-off-by: Stefano Babic Reported-by: Esad Ergül --- swugenerator/artifact.py | 8 +++----- swugenerator/generator.py | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/swugenerator/artifact.py b/swugenerator/artifact.py index d1f48a0..96482d8 100644 --- a/swugenerator/artifact.py +++ b/swugenerator/artifact.py @@ -10,6 +10,7 @@ import subprocess class Artifact: def __init__(self, filename: "") -> None: self.filename = filename + self.newfilename = filename self.fullfilename = filename self._available = False self.sha256 = "" @@ -18,7 +19,7 @@ class Artifact: def exist(self): return os.path.exists(self.filename) - def computesha256(self): + def getsha256(self): m = hashlib.sha256() with open(os.path.join(self.fullfilename), 'rb') as f: while True: @@ -35,14 +36,11 @@ class Artifact: fname = os.path.join(libdir, self.filename) if os.path.exists(fname): self.fullfilename = fname - self.sha256 = self.computesha256() + self.sha256 = self.getsha256() self.size = os.path.getsize(fname) return True return False - def getsha256(self): - return self.sha256 - def getsize(self): return self.size diff --git a/swugenerator/generator.py b/swugenerator/generator.py index 37a7a7b..c650381 100644 --- a/swugenerator/generator.py +++ b/swugenerator/generator.py @@ -61,6 +61,8 @@ class SWUGenerator: logging.critical("Artifact %s not found" % entry['filename']) exit(22) + new.newfilename = entry['filename'] + # Encrypt if required if 'encrypted' in entry and self.aeskey: iv = self.aesiv @@ -78,9 +80,8 @@ class SWUGenerator: logging.critical("Wrong compression algorithm: %s" % cmp) exit(1) - #new_path = os.path.join(self.temp.name, entry['filename']) + '.' + cmp - new_path = os.path.join(self.temp.name, entry['filename']) - + new_path = os.path.join(self.temp.name, entry['filename']) + '.' + cmp + new.newfilename = entry['filename'] + '.' + cmp if cmp == 'zlib': cmd = ['gzip', '-f', '-9', '-n', '-c', '--rsyncable', new.fullfilename, '>', new_path] else: @@ -97,6 +98,8 @@ class SWUGenerator: self.artifacts.append(new) else: print("Artifact %s already stored" % entry['filename']) + + entry['filename'] = new.newfilename entry['sha256'] = new.getsha256() def find_files_in_swdesc(self, first):