From patchwork Wed Dec 22 14:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Van Den Berge X-Patchwork-Id: 1572202 Return-Path: X-Original-To: incoming@patchwork.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=cxsqX3OU; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=j74PtTTI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13b; helo=mail-lf1-x13b.google.com; envelope-from=swupdate+bncbcmixzeahiiolyemrydbubhou2pzs@googlegroups.com; receiver=) Received: from mail-lf1-x13b.google.com (mail-lf1-x13b.google.com [IPv6:2a00:1450:4864:20::13b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JJw705nwtz9sCD for ; Thu, 23 Dec 2021 01:04:27 +1100 (AEDT) Received: by mail-lf1-x13b.google.com with SMTP id r21-20020ac25f95000000b004259e6ab262sf1289174lfe.6 for ; Wed, 22 Dec 2021 06:04:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1640181861; cv=pass; d=google.com; s=arc-20160816; b=Q77po7Ea693/R4/EEJLUZZDylEB+W3r0CRequG6DNoEtbHgMnbDrCPE0hsuCt00FoK nsEPwToYPPJ7BLCGE9SW5a4S1eKLXwqpbbkhOUENPDNKYay9hieHt3FXoaGE0bgo6YyA exc7WqkOgBXfEKkxs1ubfNWowW41HVTHw5d73FcguOLXDJ4EYTweMHipvdghmrhmo83O JJF0raX3FaLohM4W8+60AbT0/pcgfw1bAvUSNMxxhtKLtCrs0DrCGmfAvSPZP8YNG8v2 R9ttC58Wu18sQNRwBnaJwu9CbkD4wjaDt0Euw0GH/3uBCPKH2WeJkPobvGrUfMwi3oeR g4yQ== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature :dkim-signature; bh=8DCdypbqGC6JtyktauyHFh51nuUEUFFPCI32nkJlKUA=; b=GmGi7iV2O6v22jJJDdvRsKFCpUiiCJYkz/7XEOmvCXkQ57Kc+AbF2NSwC4/9dp35My q5aQNLZ00zAWHFu6ZM8GFZHbc2eQr7cuq/N/23BsAry7ih7j04a+ilKk8d+uRMbVV5m+ lELVswLyZKUt2EzYkLwwfd5rl+WkNsBgUBZA6hm2AjCMmFcEOXwlAjSH79TvxcZt4195 WtMu2LzEd7d6UzWkVVa6Y3Crhidu5/YU/SR6Vu6PJVDv5QLBvK5i93twshwAAXI0Z4BZ pfKuNajcUHz+/8pq69hujnjQzBLcYwlqWOBvsRAjP0WLDVXUwzwad43YGFH8CSl4jlik DE9Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DSVfF4jm; spf=pass (google.com: domain of sam.van.den.berge@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) smtp.mailfrom=sam.van.den.berge@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=8DCdypbqGC6JtyktauyHFh51nuUEUFFPCI32nkJlKUA=; b=cxsqX3OU+aXRjk0U1fszESB2MKDpjFXrlRsrEzIUVsbelacIvrfNIRePDZv91i5zFn x/rE3obzNUop94bTO7hCbNVZ7bEAR+MbaiayxA1+yS1KqLrYYxxLiYwV/Yn85f02OaS8 kf7zSpWgEAcijRDJ1C3/WxM1pJadHbI7eL2IjcPjKw1meeU7YdmTwwyQrAPe2eeAOtxx oZXPaF8C3+CTkua99/1mFr+1nr6BwiSPkRuInXcxXyb73VB16I757/oiEhNEvIwGdXTM k0GkK4anRiYNdLgNuMmjs9plAyKBYZ7jk9anVRW5d/hHJ79hAbmdvsx0yBvjsM6Ui5Gp b7OA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=8DCdypbqGC6JtyktauyHFh51nuUEUFFPCI32nkJlKUA=; b=j74PtTTI9ocn7NDh4cEfHpxS7uWIGLLq1sujgvzJZinOmENo0dylpV4YpWniTVFXeV nlOZugn1jw93Kf3oaasLuBzrvHVhT+LYiV/nW7LJB58EYK/0hPdGEJVgWVIY0GrUji5D EK8GZUoocTT/2ifOpHoUtTS5esxMduYgIF1/vgqoH/IYIQzBdkXRPw30sgOv3RBxN9R/ u7lHGCVUVMwGaCKSMNGfD6Ksiotp09mjhLosPuCg4byWI2Brr2kuai/mU3+tli4/j7Of aAgUfv8eDqJl/jCRhUsAFTBS7JXPtBOsnyPXlyMb29ewVE+LWfowlzeGUafV8pK0tzR5 3pPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=8DCdypbqGC6JtyktauyHFh51nuUEUFFPCI32nkJlKUA=; b=V4KxPA5Np1mvO9439BxA3K4c9Zvdl/RnfH9K3rYbyVwZ5WU/Sj8boe8NSdP6N09eNL LN4xYK7hZaN2cfqd7slsIzS28XN2fD+f7IGhIMViwvipgwP4vvhkjllA8506SwDoSEyA i7DTqnT4F8+7Cjjmi4ljpMZKb7ly751UqCEL6ZCFuPoZqtjB5yKer/Xp/rg8iQrSfE0/ brplKSgLD+9uph38tY9g/SlOdODcCAkodiQFuKIbLrgv1M8BAx3F7rlxm/HE5m4LBoCe 7582ilCsND2xt6+QuzdIrXpwrD/QXlTTfyoRom/QS1LMA7i5NXJHt71VZnyvyBhQXr7X 84hQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533DGz1I37lb0eo0pz35t2VQuZ6dWuOocowphdF107qBL9xqHhVK uRE92DeM43fthkp97p0MU9o= X-Google-Smtp-Source: ABdhPJzJ4HfeLqUKZFavVLgUPsDD+rsFIPxJYHEIUM0x/+fsgN1OVPpaO67eHQ5NPS9iSpJL7Gok3A== X-Received: by 2002:a2e:80c3:: with SMTP id r3mr2313017ljg.4.1640181861603; Wed, 22 Dec 2021 06:04:21 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:234c:: with SMTP id p12ls1496403lfu.0.gmail; Wed, 22 Dec 2021 06:04:20 -0800 (PST) X-Received: by 2002:ac2:5547:: with SMTP id l7mr2513200lfk.324.1640181860592; Wed, 22 Dec 2021 06:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640181860; cv=none; d=google.com; s=arc-20160816; b=rIhOEla/i8hD/lu+rEVnNOAfFRlcK1GC/H6vvVLajpAgLG8iwerO/HV0Uf4u+04G1q evRIzR7pwUsLoklSvNTAmwEpZp5ZLKQ16FygkAEIRm544bXx2RTRVMwOfb0baBJ5e7Qg yx9gbnarJKwBUmXVyygvQMUkfQ1BogPVvWzEyM0L6oYc7QgQw4ZmSCkTQPQLWHoR/sf7 UzdUGQkOisEdl1U8m6aIiDmw9a8MtHUKpAfP7HKqdC11SVz0Tes1zkOf+fkdNmaHO/L5 BywNKANKK+x31vHuQgBUA7qtsZqjjwwxRxm3lmH/vFIlYhvdEooY8hpir6Qdw1QwLreB dMZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=W9Y3kCQeDXh5mEWxbrV9oIHhGMYc5hES62mjN5mqN6c=; b=HYhNRdBf9jQ8hJTmb6igpgzm6UmRhn+q3WdAfpNU1tHCXZqXA1qJytlKjL+2iEjDIA oRL2hrWCq5QzWO5Zxk0Gley3pO8LPkzZiq8VmRT3EQbBcX1kkpDIL1VbATbjXqhHW4WH hBcvFkoIm19kqrZD/131HpgSRdSh7dCTMyobgJVkM1e7pF4PSKUGBr2Z8hjRrd9NHncr BbF39DG/D3qAi9Rjz+kyIOn2qWzTjjCDJqMqviwG3rUrroFubs6C2H0BS6pjsOwICWkb Z0XpYE/LsV14pA6r18W24rwhIsv3sExNMLWFFHNz6V7jyY/kHIrx4VoBMBA3pk6TcUuf Smww== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DSVfF4jm; spf=pass (google.com: domain of sam.van.den.berge@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) smtp.mailfrom=sam.van.den.berge@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com. [2a00:1450:4864:20::535]) by gmr-mx.google.com with ESMTPS id i21si128891lfv.10.2021.12.22.06.04.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Dec 2021 06:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of sam.van.den.berge@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) client-ip=2a00:1450:4864:20::535; Received: by mail-ed1-x535.google.com with SMTP id b13so9075882edd.8 for ; Wed, 22 Dec 2021 06:04:20 -0800 (PST) X-Received: by 2002:a17:907:60c8:: with SMTP id hv8mr2569213ejc.192.1640181859729; Wed, 22 Dec 2021 06:04:19 -0800 (PST) Received: from localhost.localdomain (ptr-fhlh8ucqzuc6aa54tvk.18120a2.ip6.access.telenet.be. [2a02:1812:434:bc00:5c6c:c0c5:542e:1d40]) by smtp.gmail.com with ESMTPSA id u14sm922029edv.92.2021.12.22.06.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 06:04:19 -0800 (PST) From: Sam Van Den Berge To: swupdate@googlegroups.com Cc: Sam Van Den Berge Subject: [swupdate] [meta-swupdate][PATCH 2/2] Add support for automatic decrypted size in sw-description Date: Wed, 22 Dec 2021 15:04:00 +0100 Message-Id: <20211222140401.780-2-sam.van.den.berge@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222140401.780-1-sam.van.den.berge@gmail.com> References: <20211222140401.780-1-sam.van.den.berge@gmail.com> MIME-Version: 1.0 X-Original-Sender: sam.van.den.berge@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DSVfF4jm; spf=pass (google.com: domain of sam.van.den.berge@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) smtp.mailfrom=sam.van.den.berge@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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: , The same principle from automatic sha256 insertion is applied for automatic decrypted-size insertion: images: ( { filename = "image.ubifs"; volume = "root_r"; sha256 = "@image.ubifs"; encrypted = true; properties: { decrypted-size = "@image.ubifs"; } }, ); This is usefull especially for *encrypted* UBI images which need the "decrypted-size" property when the image is installed. Signed-off-by: Sam Van Den Berge --- classes/swupdate-common.bbclass | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass index e6e5a5f..79f81df 100644 --- a/classes/swupdate-common.bbclass +++ b/classes/swupdate-common.bbclass @@ -91,6 +91,29 @@ def swupdate_write_sha256(s): for line in write_lines: f.write(line) +def swupdate_write_decrypted_size(s, src): + import re + write_lines = [] + + decrypted_size = os.path.getsize(src) + + with open(os.path.join(s, "sw-description"), 'r') as f: + for line in f: + m = re.match(r"^\s*(decrypted-size).+[=:].*[\'\"]@(?P.*)[\'\"]", line) + if m: + filename = m.group('filename') + if os.path.basename(src) == filename: + bb.note("decrypted-size of %s (%s) is %s" % (filename, src, decrypted_size)) + write_lines.append(line.replace("@%s" % (filename), str(decrypted_size))) + else: + write_lines.append(line) + else: + write_lines.append(line) + + with open(os.path.join(s, "sw-description"), 'w+') as f: + for line in write_lines: + f.write(line) + def swupdate_expand_bitbake_variables(d, s): write_lines = [] @@ -313,6 +336,7 @@ def swupdate_add_src_uri(d, list_for_cpio): if not key or not iv: bb.fatal("Encryption required, but no key found") swupdate_encrypt_file(local, dst, key, iv) + swupdate_write_decrypted_size(s, local) else: shutil.copyfile(local, dst) list_for_cpio.append(filename) @@ -329,6 +353,7 @@ def add_image_to_swu(d, deploydir, imagename, s, encrypt, list_for_cpio): key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) bb.note("Encryption requested for %s" %(imagename)) swupdate_encrypt_file(src, dst, key, iv) + swupdate_write_decrypted_size(s, src) else: shutil.copyfile(src, dst) list_for_cpio.append(target_imagename)