Re: [OE-core] [PATCH 1/4] image_types_wic.bbclass: Copy the .wks and .env files to deploy image dir

2019-08-08 Thread Jason Wessel

On 8/8/19 1:42 PM, Richard Purdie wrote:

On Thu, 2019-08-08 at 05:55 -0700, Jason Wessel wrote:

When using a .wks.in file, the only place that the generated .wks file
exists in the tmp/work area.  A copy should be left behind in the
deploy directory so that you can easily run the wic tool to
re-generate or modify a new image without running bitbake.  Custom
.wks.in files can reference any number of bitbake variables, so it is
important to save the result.

below is an example of using the generated .wks file in the deploy
area.  The full name of my generated .wks file was
core-image-minimal-ostree-uboot-ab.wks, but since you usually only
have a single .wks file per image you can use a wild card like:

   cd tmp*/deploy/images/*
   wic create --vars . -e core-image-minimal -s -m core-image-minimal-*.wks

Signed-off-by: Jason Wessel 
---
  meta/classes/image_types_wic.bbclass | 9 +
  1 file changed, 9 insertions(+)

diff --git a/meta/classes/image_types_wic.bbclass 
b/meta/classes/image_types_wic.bbclass
index 519aeb1b04..ce94138b3c 100644
--- a/meta/classes/image_types_wic.bbclass
+++ b/meta/classes/image_types_wic.bbclass
@@ -77,6 +77,11 @@ python do_write_wks_template () {
  wks_file = d.getVar('WKS_FULL_PATH')
  with open(wks_file, 'w') as f:
  f.write(template_body)
+f.close()
+# Copy the finalized wks file to the deploy directory for later use
+depdir = d.getVar('DEPLOY_DIR_IMAGE')
+basename = d.getVar('IMAGE_BASENAME')
+bb.utils.copyfile(wks_file, "%s/%s" % (depdir, basename + '-' + 
os.path.basename(wks_file)))
  }


Nothing should be writing to DEPLOY_DIR_IMAGE directly as it means its
not being managed by sstate and won't restore in a build from sstate.
There is an intermediate directory it should be written to and the
sstate code will put it into DEPLOY_DIR_IMAGE. For image classes it
might be IMGDEPLOYDIR but you'd have to check this task/code runs
between do_image and do_image_complete.




Thank you for the pointer.  It works exactly as intended so long as the 
dependency
is changed properly, and the correct staging directory is used.
There is no directory creation required because the do_image() takes care of all
that.

I'll send v2 of the series, but this this the only patch that changed.

Jason.
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/4] image_types_wic.bbclass: Copy the .wks and .env files to deploy image dir

2019-08-08 Thread Richard Purdie
On Thu, 2019-08-08 at 05:55 -0700, Jason Wessel wrote:
> When using a .wks.in file, the only place that the generated .wks file
> exists in the tmp/work area.  A copy should be left behind in the
> deploy directory so that you can easily run the wic tool to
> re-generate or modify a new image without running bitbake.  Custom
> .wks.in files can reference any number of bitbake variables, so it is
> important to save the result.
> 
> below is an example of using the generated .wks file in the deploy
> area.  The full name of my generated .wks file was
> core-image-minimal-ostree-uboot-ab.wks, but since you usually only
> have a single .wks file per image you can use a wild card like:
> 
>   cd tmp*/deploy/images/*
>   wic create --vars . -e core-image-minimal -s -m core-image-minimal-*.wks
> 
> Signed-off-by: Jason Wessel 
> ---
>  meta/classes/image_types_wic.bbclass | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/meta/classes/image_types_wic.bbclass 
> b/meta/classes/image_types_wic.bbclass
> index 519aeb1b04..ce94138b3c 100644
> --- a/meta/classes/image_types_wic.bbclass
> +++ b/meta/classes/image_types_wic.bbclass
> @@ -77,6 +77,11 @@ python do_write_wks_template () {
>  wks_file = d.getVar('WKS_FULL_PATH')
>  with open(wks_file, 'w') as f:
>  f.write(template_body)
> +f.close()
> +# Copy the finalized wks file to the deploy directory for later use
> +depdir = d.getVar('DEPLOY_DIR_IMAGE')
> +basename = d.getVar('IMAGE_BASENAME')
> +bb.utils.copyfile(wks_file, "%s/%s" % (depdir, basename + '-' + 
> os.path.basename(wks_file)))
>  }

Nothing should be writing to DEPLOY_DIR_IMAGE directly as it means its
not being managed by sstate and won't restore in a build from sstate.
There is an intermediate directory it should be written to and the
sstate code will put it into DEPLOY_DIR_IMAGE. For image classes it
might be IMGDEPLOYDIR but you'd have to check this task/code runs
between do_image and do_image_complete.

>  python () {
> @@ -127,6 +132,10 @@ python do_rootfs_wicenv () {
>  value = d.getVar(var)
>  if value:
>  envf.write('%s="%s"\n' % (var, value.strip()))
> +envf.close()
> +# Copy to deploy directory for later use with stand alone wic
> +depdir = d.getVar('DEPLOY_DIR_IMAGE')
> +bb.utils.copyfile(os.path.join(outdir, basename) + '.env', 
> os.path.join(depdir, basename) + '.env')
>  }

Same here.

Cheers,

Richard

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/4] image_types_wic.bbclass: Copy the .wks and .env files to deploy image dir

2019-08-08 Thread Jason Wessel

On 8/8/19 7:55 AM, Jason Wessel wrote:

When using a .wks.in file, the only place that the generated .wks file
exists in the tmp/work area.  A copy should be left behind in the
deploy directory so that you can easily run the wic tool to
re-generate or modify a new image without running bitbake.  Custom
.wks.in files can reference any number of bitbake variables, so it is
important to save the result.

below is an example of using the generated .wks file in the deploy
area.  The full name of my generated .wks file was
core-image-minimal-ostree-uboot-ab.wks, but since you usually only
have a single .wks file per image you can use a wild card like:

   cd tmp*/deploy/images/*
   wic create --vars . -e core-image-minimal -s -m core-image-minimal-*.wks

Signed-off-by: Jason Wessel 
---
  meta/classes/image_types_wic.bbclass | 9 +
  1 file changed, 9 insertions(+)

diff --git a/meta/classes/image_types_wic.bbclass 
b/meta/classes/image_types_wic.bbclass
index 519aeb1b04..ce94138b3c 100644
--- a/meta/classes/image_types_wic.bbclass
+++ b/meta/classes/image_types_wic.bbclass
@@ -77,6 +77,11 @@ python do_write_wks_template () {
  wks_file = d.getVar('WKS_FULL_PATH')
  with open(wks_file, 'w') as f:
  f.write(template_body)
+f.close()
+# Copy the finalized wks file to the deploy directory for later use
+depdir = d.getVar('DEPLOY_DIR_IMAGE')


This needs a call to "bb.utils.mkdirhier(depdir)" in order to work properly.

I didn't find the problem until using a higher degree of parallelism where the 
deploy directory might not actually be there to write out the file.  I'll send 
a v2 after more tests with the rest of the series.  It was all well tested 
originally on a single server, extended testing found the problem.


Cheers,
Jason.


+basename = d.getVar('IMAGE_BASENAME')
+bb.utils.copyfile(wks_file, "%s/%s" % (depdir, basename + '-' + 
os.path.basename(wks_file)))
  }
  
  python () {

@@ -127,6 +132,10 @@ python do_rootfs_wicenv () {
  value = d.getVar(var)
  if value:
  envf.write('%s="%s"\n' % (var, value.strip()))
+envf.close()
+# Copy to deploy directory for later use with stand alone wic
+depdir = d.getVar('DEPLOY_DIR_IMAGE')
+bb.utils.copyfile(os.path.join(outdir, basename) + '.env', 
os.path.join(depdir, basename) + '.env')
  }
  addtask do_rootfs_wicenv after do_image before do_image_wic
  do_rootfs_wicenv[vardeps] += "${WICVARS}"



--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/4] image_types_wic.bbclass: Copy the .wks and .env files to deploy image dir

2019-08-08 Thread Jason Wessel
When using a .wks.in file, the only place that the generated .wks file
exists in the tmp/work area.  A copy should be left behind in the
deploy directory so that you can easily run the wic tool to
re-generate or modify a new image without running bitbake.  Custom
.wks.in files can reference any number of bitbake variables, so it is
important to save the result.

below is an example of using the generated .wks file in the deploy
area.  The full name of my generated .wks file was
core-image-minimal-ostree-uboot-ab.wks, but since you usually only
have a single .wks file per image you can use a wild card like:

  cd tmp*/deploy/images/*
  wic create --vars . -e core-image-minimal -s -m core-image-minimal-*.wks

Signed-off-by: Jason Wessel 
---
 meta/classes/image_types_wic.bbclass | 9 +
 1 file changed, 9 insertions(+)

diff --git a/meta/classes/image_types_wic.bbclass 
b/meta/classes/image_types_wic.bbclass
index 519aeb1b04..ce94138b3c 100644
--- a/meta/classes/image_types_wic.bbclass
+++ b/meta/classes/image_types_wic.bbclass
@@ -77,6 +77,11 @@ python do_write_wks_template () {
 wks_file = d.getVar('WKS_FULL_PATH')
 with open(wks_file, 'w') as f:
 f.write(template_body)
+f.close()
+# Copy the finalized wks file to the deploy directory for later use
+depdir = d.getVar('DEPLOY_DIR_IMAGE')
+basename = d.getVar('IMAGE_BASENAME')
+bb.utils.copyfile(wks_file, "%s/%s" % (depdir, basename + '-' + 
os.path.basename(wks_file)))
 }
 
 python () {
@@ -127,6 +132,10 @@ python do_rootfs_wicenv () {
 value = d.getVar(var)
 if value:
 envf.write('%s="%s"\n' % (var, value.strip()))
+envf.close()
+# Copy to deploy directory for later use with stand alone wic
+depdir = d.getVar('DEPLOY_DIR_IMAGE')
+bb.utils.copyfile(os.path.join(outdir, basename) + '.env', 
os.path.join(depdir, basename) + '.env')
 }
 addtask do_rootfs_wicenv after do_image before do_image_wic
 do_rootfs_wicenv[vardeps] += "${WICVARS}"
-- 
2.21.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core