From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6655521619015892992 X-Received: by 2002:a7b:c153:: with SMTP id z19mr906537wmi.15.1549611741760; Thu, 07 Feb 2019 23:42:21 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:f70e:: with SMTP id r14ls937613wrp.10.gmail; Thu, 07 Feb 2019 23:42:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IauowkDpIJwEHCzUexJZU88HtrKJWhoSvDWw/SCIfCKEYNZ0silCclOcIGIzS8wC1jfDqEM X-Received: by 2002:adf:fdcd:: with SMTP id i13mr307434wrs.32.1549611741140; Thu, 07 Feb 2019 23:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549611741; cv=none; d=google.com; s=arc-20160816; b=nSzhOTiUKSIVE8lBgyj/mbf4kSRsISvvuzYKqg/oY5MlDayl8mBmb+EzKPZw8YHC23 g/3SXjTkxz4oOJVvz11nBpS7S0OZBNGGK54YIu3lVsiPUpr9UlOFbACwjMJttzDQuJxV TYA2l4XutT/23rMBxI3RS0yUFSDBf6IQ394VzKOH4Ae19+fVFNsgFHVrTvR3cXcn/Lal 2/x1lv2E/rfBuZSoycaldINMcCQ8gj/y91dT00Vtie7rQhabznnh2QBArOpp64ZhzfQB DYI0NlmosDrQUcqRzQm6s3m51nV/vumigWjH4/D2BpG7G/o10fed9vfwMZAXAy2cPGA0 FkhA== 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:to:subject; bh=5xYlVlggKMbd+NEzvSfhp8sFujc662sccY+7pK2+Nrg=; b=guYd1OzrUXy6feVgeT65UjXGBYuYrGbFAfns2vP+J8lMcXIG5Zsd5XNLLrZtOJGFoE 6a4dyeds6TswY5+Qdf8Gi7zISiItnGWUTF//FrDgn8dsMhcG8xlkuiWmhh13iwNuar9h eVfBL1eh/aXmi//6RXVaTvRokGQ4FEZb/8k8S6adx4o+Ljq2kKSUd9cz4OOrAnRHcvqb yYy6g1vKZKMthqlLa/Uvp9aG4AgOdGV3CcqV3nqVQwhPXhUN8l9CEK+T4WFyZvZuJZnK iP6gd1mH0J1v8odLm/H4Pad1A/cLiURmZXadyh5BDFmWf9cBovS1UMnCNkaYQ76R1MDz gadA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id 64si74504wma.1.2019.02.07.23.42.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 23:42:21 -0800 (PST) Received-SPF: pass (google.com: domain of jan.kiszka@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 jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id x187gKBI024152 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Feb 2019 08:42:20 +0100 Received: from [167.87.49.100] ([167.87.49.100]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id x187gJ7q016181; Fri, 8 Feb 2019 08:42:19 +0100 Subject: Re: [PATCH] wic-img: handle variables in .wks files To: Cedric Hombourger , isar-users@googlegroups.com References: <1549609367-1025-1-git-send-email-Cedric_Hombourger@mentor.com> From: Jan Kiszka Message-ID: <91d84a74-fdff-9833-1fd6-031ffebe88c2@siemens.com> Date: Fri, 8 Feb 2019 08:42:20 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <1549609367-1025-1-git-send-email-Cedric_Hombourger@mentor.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: PXi6Q90WI41/ On 08.02.19 08:02, Cedric Hombourger wrote: > Isar will now generate .wks from user-specified templates with variables > such as $ROOTFS_TYPE or $ROOTFS_SIZE replaced with their values. Custom > variables may be substituted by adding them to WKSVARS (WKSVAR += FOO) Isn't that what WICVARS are for? That's at least what OE is doing. I don't see the reason to invent our own interface here. Jan > > Signed-off-by: Cedric Hombourger > --- > doc/user_manual.md | 2 ++ > meta/classes/wic-img.bbclass | 31 ++++++++++++++++++++++++++++++- > 2 files changed, 32 insertions(+), 1 deletion(-) > > diff --git a/doc/user_manual.md b/doc/user_manual.md > index ebc31c6..ea3b4bd 100644 > --- a/doc/user_manual.md > +++ b/doc/user_manual.md > @@ -197,6 +197,8 @@ A bootable disk image is generated if you set IMAGE_TYPE to 'wic-img'. Behind th > $ bitbake multiconfig:qemuamd64-stretch:isar-image-base > ``` > > +Note: `.wks` files may use the ROOTFS_SIZE and ROOTFS_TYPE variables (as well as any other bitbake variables added to WKSVARS). > + > In order to run the EFI images with `qemu`, an EFI firmware is required and available at the following address: > https://github.com/tianocore/edk2/tree/3858b4a1ff09d3243fea8d07bd135478237cb8f7 > > diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass > index 76602d8..16bbc53 100644 > --- a/meta/classes/wic-img.bbclass > +++ b/meta/classes/wic-img.bbclass > @@ -81,6 +81,32 @@ addtask do_rootfs_wicenv after do_copy_boot_files before do_wic_image > do_rootfs_wicenv[vardeps] += "${WICVARS}" > do_rootfs_wicenv[prefuncs] = 'set_image_size' > > +WKSVARS += "ROOTFS_SIZE ROOTFS_TYPE" > + > +python do_rootfs_wksenv () { > + wksvars = d.getVar('WKSVARS', True) > + if not wksvars: > + return > + > + stdir = d.getVar('STAGING_DIR', True) > + outdir = os.path.join(stdir, d.getVar('MACHINE', True), 'imgdata') > + bb.utils.mkdirhier(outdir) > + basename = d.getVar('IMAGE_BASENAME', True) > + with open(os.path.join(outdir, basename) + '-wks.sh', 'w') as envf: > + for var in wksvars.split(): > + value = d.getVar(var, True) > + if value: > + envf.write('%s="%s" \\\n' % (var, value.strip())) > + envf.write("envsubst '") > + for var in wksvars.split(): > + envf.write('$%s ' % var) > + envf.write("'\n") > +} > + > +addtask do_rootfs_wksenv after do_rootfs_wicenv before do_wic_image > +do_rootfs_wksenv[vardeps] += "${WKSVARS}" > +do_rootfs_wksenv[prefuncs] = 'set_image_size' > + > WIC_IMAGE_FILE ="${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic.img" > > do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" > @@ -99,8 +125,11 @@ do_wic_image() { > export BUILDDIR=${BUILDDIR} > export MTOOLS_SKIP_CHECK=1 > > + /bin/sh ${STAGING_DIR}/${MACHINE}/imgdata/${IMAGE_BASENAME}-wks.sh \ > + <${WKS_FULL_PATH} >${BUILDCHROOT_DIR}/tmp/${IMAGE_FULLNAME}.wks > + > sudo -E chroot ${BUILDCHROOT_DIR} \ > - ${ISARROOT}/scripts/wic create ${WKS_FULL_PATH} \ > + ${ISARROOT}/scripts/wic create /tmp/${IMAGE_FULLNAME}.wks \ > --vars "${STAGING_DIR}/${MACHINE}/imgdata/" \ > -o /tmp/${IMAGE_FULLNAME}.wic/ \ > -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS} > -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux