From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6667861012102774784 X-Received: by 2002:a50:97a6:: with SMTP id e35mr1271412edb.4.1552482371596; Wed, 13 Mar 2019 06:06:11 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:ee8a:: with SMTP id f10ls492972edr.6.gmail; Wed, 13 Mar 2019 06:06:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5yb/eXrOTl6h40ozZJ3/vZRYaZUyQsIESpnmCHy4RxgaBPhuCdVgMAsdg+cBwg5ZtuYgF X-Received: by 2002:a50:ba2b:: with SMTP id g40mr1267398edc.1.1552482371078; Wed, 13 Mar 2019 06:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552482371; cv=none; d=google.com; s=arc-20160816; b=w2lmXLJF7rI8xhStmJ4wg3LL6lc1De5/0UBxopQghJN2fFEdkN8eFX6clL2AFRBo9Y Lnphj5JobQ9/Ng+K2F9OfQvLH++1Bwanq2JuQQ3FAFEOkmNOGRXTpEdrR6n3TrjXmPWR D+cGhjaSpCV3hk/vvtteIeuqcRoPLobsl++u/6eRCamzQw2BdOcOjo+U1GQUhat6tAoO 9D4LhNXnSSMjTIq3ZAANsU0Au5UP7xA+95tOsmc0mGUgEY0T2KSYcqWVpcQBp6qD1rFX CkG8fBGFSd+topg8MJmdktTY/cSUbule+4SQchiBL23dwlD+ArRrfu25poHd0FnJSjpf Xpqg== 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=5xgZm7FZGH1ruMK3OKCqwhGAs6mnCXPercrnOBfueao=; b=W/ZSI6cXRQydCyGC/dIAVblsvC0ZotPufda4Sf34kmWIxjso7Nb1+0NJXQH04An1L+ /JBT5tzvrfKj0R9mHcDHYXtYaeQex9EPKrjHOMJGn23BAO1LkTDfz3XOT8SrARj9viaS NIAOLUPazztTU0xPvGZRzDi2hjGfHhLw/MokJuoWFvmV2mtVfv59litg5TK3TPCQBQ6U c8U1czZGYOgmaZVOeULefOG2GG46y9xLfBiXtVUD9A0m84TUztR2+c932FnxZgRtRHxj vNYjY+iJ2ZmZDqV5DpJoB2mEFeDCdrK9weJAGjFCZvsBKB7aQdsIuaPPzjka0I/qcZDl dFZg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id k46si61747eda.4.2019.03.13.06.06.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 06:06:11 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id x2DD6Ado009310 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2019 14:06:10 +0100 Received: from ring.ppmd.siemens.net (linux-ses-ext02.ppmd.siemens.net [139.25.69.232]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id x2DD69ii007054; Wed, 13 Mar 2019 14:06:09 +0100 From: claudius.heine.ext@siemens.com To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH] wic-img: switch over to use the template.bbclass mechanism Date: Wed, 13 Mar 2019 14:05:57 +0100 Message-Id: <20190313130557.22878-1-claudius.heine.ext@siemens.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: hXVos6duV2fO 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. 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 -- 2.20.1