diff mbox series

[meta-swupdate,v2,2/2] use sstate staging to copy update image to deploy directory

Message ID 1505882880-8304-2-git-send-email-c.andersen@kostal.com
State Accepted
Headers show
Series [meta-swupdate,v2,1/2] fix image generation when signing is enabled | expand

Commit Message

Andersen, Christian Sept. 20, 2017, 4:48 a.m. UTC
Since morty YP uses the sstate also for the deploy directory. Using
this approach old images will be removed from deploy on a new build.
The same process is now used for updates images. As with normal images
the update images won't be cached in the sstate to reduce disk usage.

This change also resolves the issue, that update images are not
recreated after deleting the tmp directory and let bitbake regenerate
all unchanged recipes from sstate.

This is based on the original implementation in image.bbclass.

Signed-off-by: Christian Andersen <c.andersen@kostal.com>
---
 classes/swupdate.bbclass | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

Comments

Stefano Babic Sept. 20, 2017, 7:52 a.m. UTC | #1
Hi Christian,

On 20/09/2017 06:48, Christian Andersen wrote:
> Since morty YP uses the sstate also for the deploy directory. Using
> this approach old images will be removed from deploy on a new build.
> The same process is now used for updates images. As with normal images
> the update images won't be cached in the sstate to reduce disk usage.
> 
> This change also resolves the issue, that update images are not
> recreated after deleting the tmp directory and let bitbake regenerate
> all unchanged recipes from sstate.
> 
> This is based on the original implementation in image.bbclass.
> 
> Signed-off-by: Christian Andersen <c.andersen@kostal.com>
> ---
>  classes/swupdate.bbclass | 32 +++++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
> index 5a2d963..02db631 100644
> --- a/classes/swupdate.bbclass
> +++ b/classes/swupdate.bbclass
> @@ -64,15 +64,23 @@ def swupdate_getdepends(d):
>          depstr += " " + dep + ":do_build"
>      return depstr
>  
> +IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-swuimage"
> +
>  do_swuimage[dirs] = "${TOPDIR}"
> -do_swuimage[cleandirs] += "${S}"
> +do_swuimage[cleandirs] += "${S} ${IMGDEPLOYDIR}"
>  do_swuimage[umask] = "022"
> +SSTATETASKS += "do_swuimage"
> +SSTATE_SKIP_CREATION_task-swuimage = '1'
> +do_swuimage[sstate-inputdirs] = "${IMGDEPLOYDIR}"
> +do_swuimage[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
> +do_swuimage[stamp-extra-info] = "${MACHINE}"
>  
>  do_configure[noexec] = "1"
>  do_compile[noexec] = "1"
>  do_install[noexec] = "1"
> +deltask do_populate_sysroot
>  do_package[noexec] = "1"
> -do_package_qa[noexec] = "1"
> +deltask do_package_qa
>  do_packagedata[noexec] = "1"
>  do_package_write_ipk[noexec] = "1"
>  do_package_write_deb[noexec] = "1"
> @@ -83,14 +91,6 @@ python () {
>      d.appendVarFlag('do_swuimage', 'depends', deps)
>  }
>  
> -do_install () {
> -}
> -
> -do_createlink () {
> -    cd ${DEPLOY_DIR_IMAGE}
> -    ln -sf ${IMAGE_NAME}.swu ${IMAGE_LINK_NAME}.swu
> -}
> -
>  python do_swuimage () {
>      import shutil
>  
> @@ -115,6 +115,7 @@ python do_swuimage () {
>  # If they are not there, additional file can be added
>  # by fetching from URLs
>      deploydir = d.getVar('DEPLOY_DIR_IMAGE', True)
> +    imgdeploydir = d.getVar('IMGDEPLOYDIR', True)
>  
>      for image in images:
>          fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split()
> @@ -192,12 +193,17 @@ python do_swuimage () {
>          else:
>              bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism.");
>  
> -    line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(deploydir,d.getVar('IMAGE_NAME', True) + '.swu')
> +    line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(imgdeploydir,d.getVar('IMAGE_NAME', True) + '.swu')
>      os.system("cd " + s + ";" + line)
> +
> +    line = 'ln -sf ' + d.getVar('IMAGE_NAME', True) + '.swu ' + d.getVar('IMAGE_LINK_NAME', True) + '.swu'
> +    os.system("cd " + imgdeploydir + "; " + line)
>  }
>  
>  COMPRESSIONTYPES = ""
>  PACKAGE_ARCH = "${MACHINE_ARCH}"
>  
> -addtask do_swuimage after do_unpack after do_prepare_recipe_sysroot before do_install
> -addtask do_createlink after do_swuimage before do_install
> +INHIBIT_DEFAULT_DEPS = "1"
> +EXCLUDE_FROM_WORLD = "1"
> +
> +addtask do_swuimage after do_unpack after do_prepare_recipe_sysroot before do_build
> 


Reviewed-by: Stefano Babic <sbabic@denx.de>

Thanks for patch - I assume that this should applied (as 1/2) just to
-pyro, -master. Do you agree ?

Best regards,
Stefano Babic
Andersen, Christian Sept. 20, 2017, 9:30 a.m. UTC | #2
Hi Stefano,

> -----Ursprüngliche Nachricht-----
> Von: swupdate@googlegroups.com [mailto:swupdate@googlegroups.com] Im
> Gesendet: Mittwoch, 20. September 2017 09:52
> 
> Hi Christian,
> 
> On 20/09/2017 06:48, Christian Andersen wrote:
> > Since morty YP uses the sstate also for the deploy directory. Using 
> > this approach old images will be removed from deploy on a new build.
> > The same process is now used for updates images. As with normal 
> > images the update images won't be cached in the sstate to reduce disk usage.
> >
> > This change also resolves the issue, that update images are not 
> > recreated after deleting the tmp directory and let bitbake 
> > regenerate all unchanged recipes from sstate.
> >
> > This is based on the original implementation in image.bbclass.
> >
> > Signed-off-by: Christian Andersen <c.andersen@kostal.com>
> >
> > (...)
> >
> >> 
> Reviewed-by: Stefano Babic <sbabic@denx.de>
> 
> Thanks for patch - I assume that this should applied (as 1/2) just to -pyro, -master.
> Do you agree ?

I am currently using this on pyro.

Patch 1/2 is only needed for pyro and newer (because per-recipe-sysroots were implemented with pyro).
Patch 2/2 might be interesting for morty as well, because sstate for deploy dir was introduced in morty. But I did not test it on morty and I did not check if there were any changes in the sstate deployment implementation in images.bbclass between morty and pyro.

So for the moment: I would also say that pyro and master should be sufficient.

Regards
Christian

--
KOSTAL Industrie Elektrik GmbH
www.kostal-industrie-elektrik.com


KOSTAL Industrie Elektrik GmbH - Sitz Lüdenscheid, Registergericht Iserlohn HRB 3924 - USt-Id-Nr./Vat No.: DE 813742170
Postanschrift: An der Bellmerei 10, D-58513 Lüdenscheid * Telefon: +49  2351 16-0 * Telefax: +49  2351 16-2400
Werksanschrift: Lange Eck 11, D-58099 Hagen * Tel. +49 2331 8040-601 * Fax +49 2331 8040-602
Geschäftsführung: Dr.-Ing. Dipl.-Wirt.Ing. Manfred Gerhard, Dipl.-Ing. Marwin Kinzl, Dipl.-Oec. Andreas Kostal
Stefano Babic Sept. 20, 2017, 11:25 a.m. UTC | #3
Hi Christian,

On 20/09/2017 11:30, Andersen, Christian wrote:
> Hi Stefano,
> 
>> -----Ursprüngliche Nachricht-----
>> Von: swupdate@googlegroups.com [mailto:swupdate@googlegroups.com] Im
>> Gesendet: Mittwoch, 20. September 2017 09:52
>>
>> Hi Christian,
>>
>> On 20/09/2017 06:48, Christian Andersen wrote:
>>> Since morty YP uses the sstate also for the deploy directory. Using 
>>> this approach old images will be removed from deploy on a new build.
>>> The same process is now used for updates images. As with normal 
>>> images the update images won't be cached in the sstate to reduce disk usage.
>>>
>>> This change also resolves the issue, that update images are not 
>>> recreated after deleting the tmp directory and let bitbake 
>>> regenerate all unchanged recipes from sstate.
>>>
>>> This is based on the original implementation in image.bbclass.
>>>
>>> Signed-off-by: Christian Andersen <c.andersen@kostal.com>
>>>
>>> (...)
>>>
>>>>
>> Reviewed-by: Stefano Babic <sbabic@denx.de>
>>
>> Thanks for patch - I assume that this should applied (as 1/2) just to -pyro, -master.
>> Do you agree ?
> 
> I am currently using this on pyro.
> 
> Patch 1/2 is only needed for pyro and newer (because per-recipe-sysroots were implemented with pyro).

Right.

> Patch 2/2 might be interesting for morty as well, because sstate for deploy dir was introduced in morty. But I did not test it on morty and I did not check if there were any changes in the sstate deployment implementation in images.bbclass between morty and pyro.

Agree. I wanted just to mention this on ML. I have also no time to test
it or fix it in -morty. Maybe someone will test and / or fix on -morty.

> 
> So for the moment: I would also say that pyro and master should be sufficient.
> 

Agree.

Best regards,
Stefano
diff mbox series

Patch

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index 5a2d963..02db631 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -64,15 +64,23 @@  def swupdate_getdepends(d):
         depstr += " " + dep + ":do_build"
     return depstr
 
+IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-swuimage"
+
 do_swuimage[dirs] = "${TOPDIR}"
-do_swuimage[cleandirs] += "${S}"
+do_swuimage[cleandirs] += "${S} ${IMGDEPLOYDIR}"
 do_swuimage[umask] = "022"
+SSTATETASKS += "do_swuimage"
+SSTATE_SKIP_CREATION_task-swuimage = '1'
+do_swuimage[sstate-inputdirs] = "${IMGDEPLOYDIR}"
+do_swuimage[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
+do_swuimage[stamp-extra-info] = "${MACHINE}"
 
 do_configure[noexec] = "1"
 do_compile[noexec] = "1"
 do_install[noexec] = "1"
+deltask do_populate_sysroot
 do_package[noexec] = "1"
-do_package_qa[noexec] = "1"
+deltask do_package_qa
 do_packagedata[noexec] = "1"
 do_package_write_ipk[noexec] = "1"
 do_package_write_deb[noexec] = "1"
@@ -83,14 +91,6 @@  python () {
     d.appendVarFlag('do_swuimage', 'depends', deps)
 }
 
-do_install () {
-}
-
-do_createlink () {
-    cd ${DEPLOY_DIR_IMAGE}
-    ln -sf ${IMAGE_NAME}.swu ${IMAGE_LINK_NAME}.swu
-}
-
 python do_swuimage () {
     import shutil
 
@@ -115,6 +115,7 @@  python do_swuimage () {
 # If they are not there, additional file can be added
 # by fetching from URLs
     deploydir = d.getVar('DEPLOY_DIR_IMAGE', True)
+    imgdeploydir = d.getVar('IMGDEPLOYDIR', True)
 
     for image in images:
         fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split()
@@ -192,12 +193,17 @@  python do_swuimage () {
         else:
             bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism.");
 
-    line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(deploydir,d.getVar('IMAGE_NAME', True) + '.swu')
+    line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(imgdeploydir,d.getVar('IMAGE_NAME', True) + '.swu')
     os.system("cd " + s + ";" + line)
+
+    line = 'ln -sf ' + d.getVar('IMAGE_NAME', True) + '.swu ' + d.getVar('IMAGE_LINK_NAME', True) + '.swu'
+    os.system("cd " + imgdeploydir + "; " + line)
 }
 
 COMPRESSIONTYPES = ""
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-addtask do_swuimage after do_unpack after do_prepare_recipe_sysroot before do_install
-addtask do_createlink after do_swuimage before do_install
+INHIBIT_DEFAULT_DEPS = "1"
+EXCLUDE_FROM_WORLD = "1"
+
+addtask do_swuimage after do_unpack after do_prepare_recipe_sysroot before do_build