From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6667861012102774784 X-Received: by 2002:a2e:6309:: with SMTP id x9mr13539384ljb.75.1553531766027; Mon, 25 Mar 2019 09:36:06 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ac2:5085:: with SMTP id f5ls1618209lfm.13.gmail; Mon, 25 Mar 2019 09:36:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCkjuBQyEAITo0znVH2XmnwmbGL6y9MClcUMB6BvoN9KD3PLsjzUs8g9TUaVZtxKrAmJzw X-Received: by 2002:ac2:4421:: with SMTP id w1mr4966910lfl.97.1553531765540; Mon, 25 Mar 2019 09:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553531765; cv=none; d=google.com; s=arc-20160816; b=hZUQr5egLN18T1GeUi8kRS3twr83bNwyqEY3GYusXBjujMEAt3ujHStv7Fyr4twN83 SG8YR+CNpXFu+eC2R49zy8saFDQcTb2kprQXs3qAZuw0VNKL6QHV2A/5Bb+n+kx/DDEz HVK5GHZDWs7cTFv0YOVGBpqYdwwEpUgbi7Iiv7DcUxkt4XLS0kc03T7WqoUXlua5l1oU C5oNpUoGZvP7fL5G3lKV8O2FZ7TSYBcOfFDR79cxgFQcBb3L49rndZhbAqILc0EIXwBi X7etRzyVfc0e0NE7JSn94RJCUcHmGIwLppAaGlLHm69P3ipBnqQgBX6X2gkuSzSyolMi vj2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:references:cc:to :subject; bh=A2BF6djQT+9BddSS1u0J0sYzGW10NO8dZgGcAo0H6vo=; b=Ezs+VGc7XuLIhZZ1aykQBsxvK16OE5GBQ5mxwplzSEs2QFtIGP9B8N2ROn99z4rnkC VDs9T2IlbNYnt00poPdsStPyInqV23roy6EPQ2qDKPEZAO+9aJZYxUC3qC7G4vGVVOit fR9NuxSPkeKcJaFPhv5W13NRyQmNwW7y+OBBoa0wA9fMhWK54uV5itsrQ4rpQf6w0m5T QTcX+Rtm4HuAyUMYEi9g9zaD1vPnBZJJazbqKHQMopm/sZ66WplInJ5HGSfMycNKX+gB +22Ag9GBksiO8e+vYaiRN4WSoK2DkkOGXirdHB4k+Aw1u4eHjdqTklsDl8pLXuhwgUBW FGCg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of mosipov@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id h21si182144lfm.4.2019.03.25.09.36.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 09:36:05 -0700 (PDT) Received-SPF: pass (google.com: domain of mosipov@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of mosipov@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.164] (d51A48A80.access.telenet.be [81.164.138.128]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8) with ESMTPSA id x2PGa0eN019029 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Mar 2019 17:36:01 +0100 Subject: Re: [PATCH] wic-img: switch over to use the template.bbclass mechanism To: claudius.heine.ext@siemens.com, isar-users@googlegroups.com Cc: Claudius Heine References: <20190313130557.22878-1-claudius.heine.ext@siemens.com> From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: <719e152d-29c9-af15-822a-90e32515f2ad@ilbers.de> Date: Mon, 25 Mar 2019 17:35:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190313130557.22878-1-claudius.heine.ext@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: 5ZNGb5lN33oV On 3/13/19 2:05 PM, claudius.heine.ext@siemens.com wrote: > From: Claudius Heine > > We don't need to have two template mechanism implemented in Isar. This > patch switches the very specific one in wic-img to use the generic one > from template.bbclass. Applied to the 'next'. > Signed-off-by: Claudius Heine > --- > meta/classes/wic-img.bbclass | 40 +++++++++++++----------------------- > 1 file changed, 14 insertions(+), 26 deletions(-) > > diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass > index 5a451a0..09d9f2e 100644 > --- a/meta/classes/wic-img.bbclass > +++ b/meta/classes/wic-img.bbclass > @@ -6,29 +6,14 @@ > > WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}')}" > > -python do_write_wks_template () { > - """Write out expanded template contents to WKS_FULL_PATH.""" > - import re > - > - template_body = d.getVar('_WKS_TEMPLATE') > - > - # Remove any remnant variable references left behind by the expansion > - # due to undefined variables > - expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}") > - while True: > - new_body = re.sub(expand_var_regexp, '', template_body) > - if new_body == template_body: > - break > - else: > - template_body = new_body > - > - wks_file = d.getVar('WKS_FULL_PATH') > - with open(wks_file, 'w') as f: > - f.write(template_body) > +do_copy_wks_template[file-checksums] += "${WKS_FILE_CHECKSUM}" > +do_copy_wks_template () { > + cp -f '${WKS_TEMPLATE_PATH}' '${WORKDIR}/${WKS_TEMPLATE_FILE}' > } > > python () { > import itertools > + import re > > wks_full_path = None > > @@ -70,22 +55,25 @@ python () { > d.setVar('WKS_TEMPLATE_PATH', wks_file_u) > d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True') > > + wks_template_file = os.path.basename(base) + '.tmpl' > + d.setVar('WKS_TEMPLATE_FILE', wks_template_file) > + d.appendVar('TEMPLATE_FILES', " {}".format(wks_template_file)) > + > # We need to re-parse each time the file changes, and bitbake > # needs to be told about that explicitly. > bb.parse.mark_dependency(d, wks_file) > > + expand_var_regexp = re.compile(r"\${(?P[^{}@\n\t :]+)}") > + > try: > with open(wks_file, 'r') as f: > - body = f.read() > + d.appendVar("TEMPLATE_VARS", " {}".format( > + " ".join(expand_var_regexp.findall(f.read())))) > except (IOError, OSError) as exc: > pass > else: > - # Previously, I used expandWithRefs to get the dependency list > - # and add it to WICVARS, but there's no point re-parsing the > - # file in process_wks_template as well, so just put it in > - # a variable and let the metadata deal with the deps. > - d.setVar('_WKS_TEMPLATE', body) > - bb.build.addtask('do_write_wks_template', 'do_wic_image', None, d) > + bb.build.addtask('do_copy_wks_template', 'do_transform_template do_wic_image', None, d) > + bb.build.addtask('do_transform_template', 'do_wic_image', None, d) > } > > inherit buildchroot > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov