From patchwork Tue Apr 5 07:09:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1613253 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=fpPnmgXB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::140; helo=mail-lf1-x140.google.com; envelope-from=swupdate+bncbcxploxj6ikrbvgwv6jamgqedqswf7y@googlegroups.com; receiver=) Received: from mail-lf1-x140.google.com (mail-lf1-x140.google.com [IPv6:2a00:1450:4864:20::140]) (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 4KXf173rFmz9sFq for ; Tue, 5 Apr 2022 17:10:18 +1000 (AEST) Received: by mail-lf1-x140.google.com with SMTP id g20-20020a056512119400b0044ada577e3dsf4390444lfr.1 for ; Tue, 05 Apr 2022 00:10:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1649142612; cv=pass; d=google.com; s=arc-20160816; b=0NiLSgGAXH181vSg6bWMR1OE30JJ3s1T5k1aMMFvDSziYASkYlKW4snh+nKi9SLtmS Zvp9HCaIN216CeXkCNC216jY3Hn4g+ErV/R9K6drj5ow9TyC+MIHrt1qpS5Kl1BA1Fb8 gE2Z+umIvNBLmTCI0otQVKUdmutre0MMmU5q61rprv/P+n5nD/Nk2vd1eS1L12DzpLGa 9lbV37O825acscy5ML7rudeTSNpjUC/SHkxDFLTIYgNPX5R9rLfVmGWgDF2tpQO0Ms6X S6nzbEpOjq5ELxAn4iv85LUtmrHN5t9cf7XB58JRAb82QwFQE3ryvd9OSEvXmTFI3DLZ FvXA== 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; bh=S1ihZeDQjbZ6WkvKG45G37me7rsE/ITtOcWzUnjIdVw=; b=c09OEVwrlm/Jl+KWYvvQ0l/OkEhnrmxXII9w1c5ohoYMKlNWGAwlYjS7+y+58g+CIk kj8VTzCRdWTb126BwGsF/2uKLNSeonQo+JY3/V9IMBAxnuYgHS5w5t8OwBQrZD4tsUN9 BTYEHYH0aWGe8qhZ2N6JIMN5j+acNZbTVFnsfHXKY+5PNEkAhIT3jXFGWX1wbdpb7avN m294qbWgvrPWfslpFSkDlGrz++Rsg2QaXocDu04UpjFulGzQnNdQf7pJ0DPIX7rx/Py4 0msgvbAGT7ZVCK02xPSmhGtEmUm//xg3xDW3oK0KBoTG3JA1+2HFBK/8NS3Hv/HlPQ/T 2R6Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=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=S1ihZeDQjbZ6WkvKG45G37me7rsE/ITtOcWzUnjIdVw=; b=fpPnmgXBXxn+Qz8hUGychcPK+g+MkMZlwD2j/KL13B5RETKajObWTpFKrk9rWnks0a RXGEkfzlmMjY8UZ7Bw/zwz1p6usS1TPMbkO841mIDnRBqX2BwMN1Uzx05vi/9DL9B1mj u1ddBVaev5u4qAoHBPK/V14DklpfVi5w/TwyhZQrS6d56PPAqbQL7U1z4ZWJnircvOO0 HEwZK1aIWKa+Q6oK7yEtyrYFIUfJAXytCg+5O1dGV4v0JAwIte19H9OuYuessFoq8bz7 J9Li2IJ03j2jakUqMQ5pjtUnG8a47tD72+YGB630bR7wal9Q4fOgyXf/9cZpuhJ4sVpH i7Pg== 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=S1ihZeDQjbZ6WkvKG45G37me7rsE/ITtOcWzUnjIdVw=; b=WUDPmrZeIwNdzWewd7uHVo+9sP/mWBd/Q1mfCFztUcLQR9+lfhD31b+Ck6m2ShFgMo 2sUWQoVTDAVoaLOrUa1FeD+V6ytBDTcfjeq/PUdppHMNoRZLJAR1HwlCQtKwJXXfFDEr t8CqNQbUiX8uSK2kpnOg9F9jF7NiX1FCCR0Qhab2vlPdlCaiyQAxyy43ZAUR+TSb/h2K Ni2BY+l/mskIAMPQTWyF50GsnrpMOWnWSMdOuk50MC2xTUc7YhuZkqQZLEMmLGy5DJWN yARay7yRERlM+MJA2r37+YUldCJjKxs8q2aWQdVtlImtb6k26tdCLRMufZ2RIu7ICwqR ektw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5338NZ+sup01+2i8jnMziTaGrUKZ0d+Sye9CNBqb/vnq9hcMr5d5 KjdOxZ4jHryEhxUzPzkbVjo= X-Google-Smtp-Source: ABdhPJxeXFLZM9qYdZJxkJjS9K4iNSJkGS4sYVHJmeQOZqt0QNN8D4Jr7h8S7wx1GPBs1aPIo7fC/w== X-Received: by 2002:a2e:a28d:0:b0:247:dce8:cecd with SMTP id k13-20020a2ea28d000000b00247dce8cecdmr1222707lja.415.1649142612518; Tue, 05 Apr 2022 00:10:12 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:bc1d:0:b0:24b:852:f14f with SMTP id b29-20020a2ebc1d000000b0024b0852f14fls1937673ljf.5.gmail; Tue, 05 Apr 2022 00:10:11 -0700 (PDT) X-Received: by 2002:a2e:9101:0:b0:24b:27c:c210 with SMTP id m1-20020a2e9101000000b0024b027cc210mr1233861ljg.134.1649142611471; Tue, 05 Apr 2022 00:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649142611; cv=none; d=google.com; s=arc-20160816; b=Oe6WgcsZ33aonK+l3mkwXy9kypjkAz5UZhmwSTFMjIXLzNeuWuBuJGNMlesDV/qF9W x70Kx5OVWr4LNO3SGOpFLBQuNws3iGs+NRLg+iuSUpz+mDxLb+vWV1A2Mf5b7BAOJMVU zYqDvDvzkMBKFC8h+qn0sj3a2zevgwnDcSbP+3125PkQJTB10FtUF02l7TU5jGGjXygP lk19T/QibUiGcMuV3Ozm2/vX3xfX2jx/YEkmQlCt2qfubf7Adzj+91Kt1tF+4A99IVLF 4854fKFsucuUqm6X6AaLBffy2EbpHVngb7Q5s8Nn0wP8MsolJ3h44xSSjjWK2gaUqKJT rBcg== 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; bh=M3tAtMzQL762eG2szQWh8n/rwWzEaZrd3y/PrrzvDbE=; b=W8in08ke2LzlktwVRQY3c9PqicVn2OVa28Cg1JQV02t4uJ5eeoLVXf4mljSEr3Wx/E YPmTgE35q4gC2/2IRD7G+2wPNZudp4+efbA6iOnVFjqQcfsMY4bNgW6auAH7k/WETmSG h6HX+LMLU9LTN4mVX9R0Rxh9FU7a5Kcox6srJnxNBdzsujwsHGZvQpWS+9+DN2khTK3l Xrn/HDNF06nEK76T5qy3H/nMpTZokt4ffsk+4q58xmGUlaVqaK1PFhF2SUa1CUZ/rjWR GRz4i6n2n1Qna2JAGkVgiAdaz6zbeN3h4wfgSSPhdU/qgAWxWCLZVEB4cpnQH9pJfAzh PqXw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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.9]) by gmr-mx.google.com with ESMTPS id i36-20020a0565123e2400b0044ada59207csi503654lfv.10.2022.04.05.00.10.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2022 00:10:11 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4KXf0y6vjqz1qyJG; Tue, 5 Apr 2022 09:10:10 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4KXf0y6lVVz1qqkD; Tue, 5 Apr 2022 09:10:10 +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 T_n8PnyEWsKd; Tue, 5 Apr 2022 09:10:09 +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; Tue, 5 Apr 2022 09:10:09 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 217754542B2E; Tue, 5 Apr 2022 09:10:09 +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 BFtW-64p_OqD; Tue, 5 Apr 2022 09:10:06 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id BA1C84540BD2; Tue, 5 Apr 2022 09:10:06 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [meta swupdate] [ 01/12] Evaluate functions inside sw-description Date: Tue, 5 Apr 2022 09:09:54 +0200 Message-Id: <20220405071005.3855186-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220405071005.3855186-1-sbabic@denx.de> References: <20220405071005.3855186-1-sbabic@denx.de> 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.9 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: , Instead to add new rules to parse sw-description to generate data, create a generic method to let the class to call a function. It is then enough to create a list / libraries of these function instead to find new ways to extend sw-description's syntax. Signed-off-by: Stefano Babic --- classes/swupdate-common.bbclass | 34 +++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass index 53aa48e..556ab8d 100644 --- a/classes/swupdate-common.bbclass +++ b/classes/swupdate-common.bbclass @@ -38,7 +38,7 @@ def swupdate_getdepends(d): return depstr -def swupdate_get_sha256(s, filename): +def swupdate_get_sha256(d, s, filename): import hashlib m = hashlib.sha256() @@ -84,7 +84,7 @@ def swupdate_write_sha256(s): m = re.match(r"^(?P.+)(sha256|version).+[=:].*(?P[\'\"])@(?P.*)(?P=quote)", line) if m: filename = m.group('filename') - hash = swupdate_get_sha256(s, filename) + hash = swupdate_get_sha256(None, s, filename) write_lines.append(line.replace("@%s" % (filename), hash)) else: write_lines.append(line) @@ -93,6 +93,34 @@ def swupdate_write_sha256(s): for line in write_lines: f.write(line) +def swupdate_create_func_line(s, function, parms): + parmlist = parms.split(',') + cmd = "'" + s + "'" + for parm in parmlist: + if len(cmd): + cmd = cmd + ',' + cmd = cmd + "'" + parm + "'" + cmd = function + '(' + cmd + ')' + return cmd + +def swupdate_exec_functions(d, s, write_lines): + import re + for index, line in enumerate(write_lines): + m = re.match(r"^(?P.+)\$(?P\w+)\((?P.+)\)(?P.+)$", line) + if m: + bb.warn("Found function") + fun = m.group('bitbake_function_name') + "(d, \"" + s + "\", \"" + m.group('parms') + "\")" + ret = eval(fun) + bb.warn("Fun : %s" % fun) + bb.warn ("%s return %s " % (m.group('bitbake_function_name'), ret)) + cmd = swupdate_create_func_line(s, m.group('bitbake_function_name'), m.group('parms') ) + bb.warn ("Returned command %s" % cmd) + line = m.group('before_placeholder') + ret + m.group('after_placeholder') + "\n" + #ret = eval(cmd) + bb.warn ("==> Returned command %s : %s" % (cmd, ret)) + write_lines[index] = line + + def swupdate_expand_bitbake_variables(d, s): write_lines = [] @@ -125,6 +153,8 @@ def swupdate_expand_bitbake_variables(d, s): write_lines.append(line) + swupdate_exec_functions(d, s, write_lines) + with open(os.path.join(s, "sw-description"), 'w+') as f: for line in write_lines: f.write(line)