From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6667861012102774784 X-Received: by 2002:a50:aa70:: with SMTP id p45mr1278585edc.6.1552483136733; Wed, 13 Mar 2019 06:18:56 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:9fad:: with SMTP id c42ls507263edf.1.gmail; Wed, 13 Mar 2019 06:18:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxFujxGjOqGd/PTqs8R0s33AfzzXek+Ju0ihBEt35uV0u8xAFpkha97fnTEWtsGAaoAZb8 X-Received: by 2002:a50:97a6:: with SMTP id e35mr1279821edb.4.1552483136299; Wed, 13 Mar 2019 06:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552483136; cv=none; d=google.com; s=arc-20160816; b=qu2zpjxcNVgvmeqTEdbBj2qKxQCIgc22e1d7ycYh1UhC7CsiwgzL73hDyqozqRO4tL bcCq+oBxnc+nAIialwPNyb6YXHG8CTdzlJRncmHL1uJJQUhkFxOMGJFElip0lLC1naPL UtRiAeDoeOLIZ3S092nEkzuBzDhBtv8gGkpH43W5ioV/h3GVV71xg2mVzmZo3YEu80Ej YIvhOhppfVelxkYPk6df9jx+SkiU06PIQb9FcjmUQGFrsi7/5Gf9ViDFdioiao9eUFxT z127MgBzrGmFXbtHoTjMqM/Yyue9N2ScA6iHEghO6vgWfXYWk+ZlzETKbFlXeFPagxwu Bb5Q== 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:from:references:cc:to:subject; bh=UQFj+FzmwUH1H8oogVnJhUYYrsctgi75xSSpohuJk54=; b=NSzPvN6D65U6dKqx8Pb0HDGLUVYQke2puUNG/GpoVtsJqYSsCO6umBbG+4OyMCf7hK H502kBwYvDqV6tGTtGwbdphgaAJ2etMo0j8OM8022fVu5QRAORMzjQE6EOOrQ3ro4iOe av9TLg1QuIm6ohB3Sc4if9pFVtmCH4kyaNEKs40ycNFonNAz3doipsj5Mtc+iDylUeSw +0+MR2hZLBHlwu8rU1QvDiqgl1FEkdicSal8ZqeNIgfdJYQLIEP5fF5+BwrylKGBFhoI nVW3Yb4b4pV0LXF2OlDyDRFoW6fVFrCBzx1hC4Xwd6iLHRvz5vvBBWxg1k7DsdBDLEpL Sbtw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id q1si48546edd.5.2019.03.13.06.18.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 06:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id x2DDItUF018051 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2019 14:18:55 +0100 Received: from [139.25.69.232] (linux-ses-ext02.ppmd.siemens.net [139.25.69.232]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id x2DDIt5x015988; Wed, 13 Mar 2019 14:18:55 +0100 Subject: Re: [PATCH] wic-img: switch over to use the template.bbclass mechanism To: Henning Schild , Cedric Hombourger Cc: isar-users@googlegroups.com, Claudius Heine References: <20190313130557.22878-1-claudius.heine.ext@siemens.com> <20190313141636.7ba20187@md1za8fc.ad001.siemens.net> From: Claudius Heine Message-ID: <90b49582-5ecd-1dac-2979-05bbd900f1de@siemens.com> Date: Wed, 13 Mar 2019 14:18:55 +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: <20190313141636.7ba20187@md1za8fc.ad001.siemens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: GIBoFE+/Nz5r On 13/03/2019 14.16, Henning Schild wrote: > Cedric you might want to test that on more than just the example we > have inside Isar. Regarding testing. I tested this patch locally with the 'multiconfig:de0-nano-soc-stretch:isar-image-base' target, but since the isar-build.org seems to be currently down, I could not test it there. Claudius > > Henning > > Am Wed, 13 Mar 2019 14:05:57 +0100 > schrieb "[ext] claudius.heine.ext@siemens.com" > : > >> 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 > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de