From patchwork Sat May 8 04:43:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 485 Return-Path: Delivered-To: ilbers.mnt@gmail.com Received: by 2002:a4a:df46:0:0:0:0:0 with SMTP id j6csp1241868oou; Sat, 8 May 2021 05:43:34 -0700 (PDT) X-Received: by 2002:a17:907:1c98:: with SMTP id nb24mr15602928ejc.206.1620477814262; Sat, 08 May 2021 05:43:34 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1620477814; cv=pass; d=google.com; s=arc-20160816; b=H0Qr5IPEB+ir7R7pU/EGmGok3vJ9SjmetUtxQdzuncmW/xM4KtVGGO1MDW3eAtOw6u b0UnPWxDnj98dcBfQdTuZxFqbnFRWsMWYNRHZbW8BNQrlp3HiJMteyHbUYq0imqZJgjm ReEk+Z/tgbAG+fJKGM/PYi29Xaq72M73ydVTgxfndMuiSTXHA36TXTzsP43U83YORok4 ak2Zqd9/Rrjb5VFt3eKyDBSVoqtXlQ4YLPYh6D8/me70pE1jE1Eze6USAvGoIIXU/lbZ 4cuCYIV+FJDhZ0NJPE/NIo8Cx7txdoOnfiy1NF9eZdRumJ7+3wVjc7vY21ZEosS37sdR 99iA== ARC-Message-Signature: i=3; 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-language:mime-version :user-agent:date:message-id:to:subject:from:sender:dkim-signature; bh=+832MKUbtsNcJ/WVufthCa2ZnjNUVg7aH2ztPC6O9z8=; b=zHYEAYr76k1ZvTXnnj3rQ9brx5kI83fNpgrKcCgP8gM+CM2YobuxF0Ht3PZErvCCNC udQeFCCrX0egf+lGMQ0UvOlLPnuxQkp/c8WdSruPuZr0J2ThIgKlsW3MbOSVtttEVo8w gm1ZY+RaNA6brpNXqNKk0OgVMrDMk9n8kdzwMBsujZgzaEnDt3q4QtgL45EqM4T0KzN3 +qekncEQlUjiZuDUB+uXXM4PqRFmFxJ5T+Xh9X73hWJ6k50vG8hTfoewYTsaQlytr3SP sR3dqQyWno3uxWDMC1yVzr7/HPCLVv+g38Uir4Xd7pmFbcNYTLl9Mopzl3RlOi0dbM4K 0F5w== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=bv5bUuVL; arc=pass (i=2 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of isar-users+bncbcji7smnv4nbb5mo3kcamgqeusaoazq@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCJI7SMNV4NBB5MO3KCAMGQEUSAOAZQ@googlegroups.com; dmarc=fail (p=NONE sp=NONE dis=NONE arc=pass) header.from=siemens.com Received: from mail-sor-f55.google.com (mail-sor-f55.google.com. [209.85.220.55]) by mx.google.com with SMTPS id k25sor5224076ejc.89.2021.05.08.05.43.33 (Google Transport Security); Sat, 08 May 2021 05:43:34 -0700 (PDT) Received-SPF: pass (google.com: domain of isar-users+bncbcji7smnv4nbb5mo3kcamgqeusaoazq@googlegroups.com designates 209.85.220.55 as permitted sender) client-ip=209.85.220.55; Authentication-Results: mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=bv5bUuVL; arc=pass (i=2 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of isar-users+bncbcji7smnv4nbb5mo3kcamgqeusaoazq@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCJI7SMNV4NBB5MO3KCAMGQEUSAOAZQ@googlegroups.com; dmarc=fail (p=NONE sp=NONE dis=NONE arc=pass) header.from=siemens.com ARC-Seal: i=2; a=rsa-sha256; t=1620477813; cv=pass; d=google.com; s=arc-20160816; b=UDGqzWbDFHFUxGmA5VbG2EpEBkI9ql96LLyW3zA9uPEIrRDzps4FfLFGmukEuLOCA1 XAKOdJ/9wk25oXhw5zEhKU3EKp+00THdEqPImpgizUNXnzL1bYmqwfAm7eUvbXmpoR5w HmaKP5xDJQMmhwA7iY1F5wP81BxrWnbRCDa2WqhmL5HUd+ADfQzI4okrL6SlbjihHm7q 8U45NTpW/hThyscuouGC32sHZNV8ne4+4WmX9CQR01i/PDtd+HmBeKKx87l1MeipM7FD Mf7dIOvsnMkXBBL0lCbWU20kLhegJLQctVpFJsEiWbpZbkuWSRr1T14/8h8e41G1zex4 2BDQ== 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-language:mime-version :user-agent:date:message-id:to:subject:from:sender:dkim-signature; bh=+832MKUbtsNcJ/WVufthCa2ZnjNUVg7aH2ztPC6O9z8=; b=DPF5GhaEKfV7gaHO4CMiAfwTDremlZ3GiGbcP4yH0SxC66gR/k3+PB5Ps/b/NAiD2y l8c9PdSDxg2jw6IJHQ0FkbpfKieg9s1tCR4QseWi4k1Zhq+joqOftdbsMvgzsWSwGwWn +ba7hk6ssmflejASKqCNVRHPV0ksqa0bampQODbjQKz8ZGz87AGBqEWAPAYpp+joer/Q AZVx/Y0GG6Fuf5/V0HXqdtUYwSy3Mb4Myy1vTiiJpsvWzVnwRTrMq5F0bNHTE8d4HhR5 8M+dV8FaZuIBo2KlaXHh79UGM46FlL2S7LHeSMifRvY1DY8oAjy4L7PqCxufefHltBvn tORg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:subject:to:message-id:date:user-agent:mime-version :content-language:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=+832MKUbtsNcJ/WVufthCa2ZnjNUVg7aH2ztPC6O9z8=; b=bv5bUuVLqQ3RGGeUW34Q2LLxitF8SRITp80W/kbgNtRv4IiDQjfA2jLswSvagLEUck 6+dRPbGKaImZqkNf0pdlfURGfl4vkzDQUKY2ozcIgnTu6AQUTjk1tVTKsyacvOFnnx9j oyETU7YFCWCQccOIbz7yr0DWnowrX5s+XgBRTJwyTv3nfKCYvsCt2XfY4z6bWZQxEftK k2/8P6Q0Leqeom+LMIGsLNT7ZL2sGcj1QBF1X4FJHgWMJ7JxzY+iBMmzPPx5cEmSzfk9 rwUlX1OCqma0/z/MQ7h/pOExMeL5fKSUgdb/4qCiLJVcZcZ7Hwi7rbMK36QD0sE9bmef I+MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:subject:to:message-id:date :user-agent:mime-version:content-language: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=+832MKUbtsNcJ/WVufthCa2ZnjNUVg7aH2ztPC6O9z8=; b=eoJzgxjd+tTrDxoCHQl8Skf3WdZe1QparXj8F13AZB0G2M0heFQskJ8wTmq76rLT5L u0dvdSLXx+FJ6LM9FRtdO7XLe9C0o6KWb6ji5od0UmhBX0CpvL57/3S2Mn9rgpbGuAAs HZrjLvGlfiotY2ciHR5HzAMzNUqAsfF8vdmXt0xgEcA5t3u5tLvEcm9lMmY4vvem9OHi mxPygZqahVuef8wZClPxpfaABvoDRk/UGqbkI+GbQ5qFPX0aXskJs9e5tAQZ7GX1BMOs xvkWWz5rvb4Wf5g9CZyYBW8b4o3xwuhEouWl+fY0W+5dj6JM79G8j+EzPUKBWZidO1TD ZsiA== Sender: isar-users@googlegroups.com X-Gm-Message-State: AOAM530V9Z9aZZRY7TfVKZqMAP9NH3AtHNfHVizB+4xOk67SHv8+Q23L qVX2ydK2dyl0VeUmHoPe5Pk= X-Google-Smtp-Source: ABdhPJzNAFBXXYTPt852k5wwosnDnQeWuNbI2GKXB2P6kHnLZae6+EgLe2YWtIubfu6x15QiHVwDOQ== X-Received: by 2002:a17:906:1147:: with SMTP id i7mr9259275eja.20.1620477813364; Sat, 08 May 2021 05:43:33 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:aa7:cdcb:: with SMTP id h11ls1121103edw.2.gmail; Sat, 08 May 2021 05:43:32 -0700 (PDT) X-Received: by 2002:aa7:d917:: with SMTP id a23mr17307176edr.260.1620477812460; Sat, 08 May 2021 05:43:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620477812; cv=none; d=google.com; s=arc-20160816; b=m7CMStrXEYpIE3me9J4QWRxjQMMHnsf6mueb2dI4LDh/fz/T4ytT9CGzho1pKnEFaJ +KwJGIHEonbLgvMYIgizaVQtN1IxXa4KtEU1+g+Be4djyao7RI0chtH6K4cfXixUCHCr Lc66sBwA1GgkVu+5W23VG05trH29RWrcZKOlNtxkPCicl6pCrIKATkQ/Onvz3Ya1GFmR aIxMzxedr7nv9y/UWuFsCo1vuRRxjyhUm0L7gS9fZKpOl7uniSVgRpFJ3iECBBi5YkIW CwJ9cQROpnbZSshWCirFBn5DzdJmp3tRAU/15RdkIs1EPE/iieSNhjS8tZ7Yv5QuzRwq /1jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:to:subject:from; bh=fGVbltvC85ijlbEojc87o65pKjEOLpvqD01d+xKcLWE=; b=hidHWVktrLOGrgNo+v/+7fj+D6VPWAA9ZTqgKECNnT+b4kGP6N3vprLTA/fgfvDzdA RD77mivdtVZp5mud3cqobp/Uk2iNb7QWTzYH2n70P9UEaKHd4eZ5ERhYatc+z+QoD/Kq IL69e99e436snhiKKbz/veZ4dVx5ACNa46N4FcUr8dR1LsUBNDXLsGk31XotzgbeR+fi o/J+wIbHfTMOPgwdbCoRge7+4n1zkTidmj4U3WPFPrFOsYs8g23/PQzpuYsdQl3cBw2O hvVUjJjz5cCKvD7I8IOT+KvYIjyK+B5lnEdtWwTuK8wi9jmEVTk6mD+Ewfooo8Umrva6 Ow4g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id di23si246861edb.0.2021.05.08.05.43.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 May 2021 05:43:32 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 148ChV5t010126 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 8 May 2021 14:43:32 +0200 Received: from [167.87.32.109] ([167.87.32.109]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 148ChVfD026273 for ; Sat, 8 May 2021 14:43:31 +0200 From: Jan Kiszka Subject: [PATCH] wic: plugins: Improve rootfs-u-boot script_prepend passing To: isar-users Message-ID: <185f97a0-6755-1344-43cd-7df51040ba65@siemens.com> Date: Sat, 8 May 2021 14:43:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 Content-Language: en-US X-Original-Sender: jan.kiszka@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1699194144072212549?= X-GMAIL-MSGID: =?utf-8?q?1699194144072212549?= From: Jan Kiszka Passing a script_prepend value down to the generated boot.scr currently requires double escaping: once for the wks file when being parsed by wic and a second time for /etc/default/u-boot-script when being parsed by the u-boot-script tool. This removes the need for double escaping by detecting if the " or $ characters are already escaped after the wic parsing step. If not, the plugin injects the required escape character. In addition, this provides a way to avoid the wic warning about an unknown (bitbake) variable when injecting ${some_var} into the script: do_wic_image: WARNING: cannot expand variable some_var The user can now simply escape the curly braces as well: $\{some_var\}. The plugin will remove these escapes before generating the u-boot-script configuration file. This also resolves the more theoretical case of a naming clash between a WICVAR and a U-Boot script variable. Signed-off-by: Jan Kiszka --- meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py b/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py index 3ac0aa0..15acb57 100644 --- a/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py +++ b/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py @@ -14,6 +14,7 @@ import glob import logging +import re import os from wic import WicError @@ -75,6 +76,12 @@ class RootfsUBootPlugin(RootfsPlugin): overlays = source_params.get('overlays') or '' cfg.write('OVERLAYS="%s"\n' % overlays) script_prepend = source_params.get('script_prepend') or '' + # remove escapes from $\{var\} that are needed to avoid expansion by wic + script_prepend = re.sub(r'\$\\{([^\\]+)\\}', r'${\1}', script_prepend) + # escape any quotes that aren't escaped yet + script_prepend = re.sub(r'([^\\])"', r'\1\\"', script_prepend) + # escape any dollars that aren't escaped yet + script_prepend = re.sub(r'([^\\])\$', r'\1\\$', script_prepend) cfg.write('SCRIPT_PREPEND="%s"\n' % script_prepend) # Run update-u-boot-script in the target rootfs