wic: move out all files ending on "direct*"

Message ID 20210408080521.32000-1-henning.schild@siemens.com
State Accepted, archived
Headers show
Series wic: move out all files ending on "direct*" | expand

Commit Message

Henning Schild April 8, 2021, 12:05 a.m. UTC
wic can compress images, in which case they would have a suffix
plus our new version of wic keeps individual partitions that might be
valuable to some, they also have a suffix we used to not move out

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta/classes/wic-img.bbclass | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Jan Kiszka April 8, 2021, 12:32 a.m. UTC | #1
On 08.04.21 10:05, [ext] Henning Schild wrote:
> wic can compress images, in which case they would have a suffix
> plus our new version of wic keeps individual partitions that might be
> valuable to some, they also have a suffix we used to not move out
> 

I vaguely recall some partition extraction classes for SWUpdate
scenarios - room for improvements, Quirin? Or are we using that feature
already?

Jan

> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta/classes/wic-img.bbclass | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
> index 59dcd2b7c124..76606f882e79 100644
> --- a/meta/classes/wic-img.bbclass
> +++ b/meta/classes/wic-img.bbclass
> @@ -193,10 +193,11 @@ EOSUDO
>                ${WIC_CREATE_EXTRA_ARGS}
>  
>      sudo chown -R $(stat -c "%U" ${LAYERDIR_core}) ${LAYERDIR_core} ${LAYERDIR_isar} ${SCRIPTSDIR} || true
> -    WIC_DIRECT=$(ls -t -1 ${BUILDCHROOT_DIR}/$WICTMP/${IMAGE_FULLNAME}.wic/*.direct | head -1)
>      sudo chown -R $(id -u):$(id -g) ${BUILDCHROOT_DIR}/${WICTMP}
> -    mv -f ${WIC_DIRECT} ${WIC_IMAGE_FILE}
> -    mv -f ${WIC_DIRECT}.bmap ${WIC_IMAGE_FILE}.bmap
> +    find ${BUILDCHROOT_DIR}/${WICTMP} -type f -name "*.direct*" | while read f; do
> +        suffix=$(basename $f | sed 's/\(.*\)\(\.direct\)\(.*\)/\3/')
> +        mv -f ${f} ${WIC_IMAGE_FILE}${suffix}
> +    done
>      rm -rf ${BUILDCHROOT_DIR}/${WICTMP}
>      rm -rf ${IMAGE_ROOTFS}/../pseudo
>  }
>
Henning Schild April 8, 2021, 12:44 a.m. UTC | #2
Am Thu, 8 Apr 2021 10:32:32 +0200
schrieb Jan Kiszka <jan.kiszka@siemens.com>:

> On 08.04.21 10:05, [ext] Henning Schild wrote:
> > wic can compress images, in which case they would have a suffix
> > plus our new version of wic keeps individual partitions that might
> > be valuable to some, they also have a suffix we used to not move out
> >   
> 
> I vaguely recall some partition extraction classes for SWUpdate
> scenarios - room for improvements, Quirin? Or are we using that
> feature already?

I know, with swupdate we often wanted those single partitions but did
not have them because wic did not keep them. Now wic seems to keep
them, which might make later extraction not needed anymore.

I have compression as a separate task in some layers, when i wanted to
finally upstream it i found that wic supports it already.
i.e. bz2 compression is really good to shrink artifacts in CI, and
https://www.balena.io/etcher/ can uncompress that. Which means Mac and
Windows users can flash with a mouse what comes out of CI.

Henning

> Jan
> 
> > Signed-off-by: Henning Schild <henning.schild@siemens.com>
> > ---
> >  meta/classes/wic-img.bbclass | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/meta/classes/wic-img.bbclass
> > b/meta/classes/wic-img.bbclass index 59dcd2b7c124..76606f882e79
> > 100644 --- a/meta/classes/wic-img.bbclass
> > +++ b/meta/classes/wic-img.bbclass
> > @@ -193,10 +193,11 @@ EOSUDO
> >                ${WIC_CREATE_EXTRA_ARGS}
> >  
> >      sudo chown -R $(stat -c "%U" ${LAYERDIR_core})
> > ${LAYERDIR_core} ${LAYERDIR_isar} ${SCRIPTSDIR} || true
> > -    WIC_DIRECT=$(ls -t -1
> > ${BUILDCHROOT_DIR}/$WICTMP/${IMAGE_FULLNAME}.wic/*.direct | head
> > -1) sudo chown -R $(id -u):$(id -g) ${BUILDCHROOT_DIR}/${WICTMP}
> > -    mv -f ${WIC_DIRECT} ${WIC_IMAGE_FILE}
> > -    mv -f ${WIC_DIRECT}.bmap ${WIC_IMAGE_FILE}.bmap
> > +    find ${BUILDCHROOT_DIR}/${WICTMP} -type f -name "*.direct*" |
> > while read f; do
> > +        suffix=$(basename $f | sed
> > 's/\(.*\)\(\.direct\)\(.*\)/\3/')
> > +        mv -f ${f} ${WIC_IMAGE_FILE}${suffix}
> > +    done
> >      rm -rf ${BUILDCHROOT_DIR}/${WICTMP}
> >      rm -rf ${IMAGE_ROOTFS}/../pseudo
> >  }
> >   
>
Jan Kiszka April 8, 2021, 12:49 a.m. UTC | #3
On 08.04.21 10:44, Henning Schild wrote:
> Am Thu, 8 Apr 2021 10:32:32 +0200
> schrieb Jan Kiszka <jan.kiszka@siemens.com>:
> 
>> On 08.04.21 10:05, [ext] Henning Schild wrote:
>>> wic can compress images, in which case they would have a suffix
>>> plus our new version of wic keeps individual partitions that might
>>> be valuable to some, they also have a suffix we used to not move out
>>>   
>>
>> I vaguely recall some partition extraction classes for SWUpdate
>> scenarios - room for improvements, Quirin? Or are we using that
>> feature already?
> 
> I know, with swupdate we often wanted those single partitions but did
> not have them because wic did not keep them. Now wic seems to keep
> them, which might make later extraction not needed anymore.
> 
> I have compression as a separate task in some layers, when i wanted to
> finally upstream it i found that wic supports it already.
> i.e. bz2 compression is really good to shrink artifacts in CI, and
> https://www.balena.io/etcher/ can uncompress that. Which means Mac and
> Windows users can flash with a mouse what comes out of CI.

That's even greater to hear: I was recently asked for such a flashing
tool internally ("Does Isar have something like
https://www.raspberrypi.org/blog/raspberry-pi-imager-imaging-utility/?")
and also pointed to Etcher as one option. The smoother things work with
it, the better. Maybe worth to add a section to the user manual?

Jan
Anton Mikanovich April 16, 2021, 6:21 a.m. UTC | #4
08.04.2021 11:05, Henning Schild wrote:
> wic can compress images, in which case they would have a suffix
> plus our new version of wic keeps individual partitions that might be
> valuable to some, they also have a suffix we used to not move out
>
> Signed-off-by: Henning Schild <henning.schild@siemens.com>

Applied to next, thanks.

Patch

diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 59dcd2b7c124..76606f882e79 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -193,10 +193,11 @@  EOSUDO
               ${WIC_CREATE_EXTRA_ARGS}
 
     sudo chown -R $(stat -c "%U" ${LAYERDIR_core}) ${LAYERDIR_core} ${LAYERDIR_isar} ${SCRIPTSDIR} || true
-    WIC_DIRECT=$(ls -t -1 ${BUILDCHROOT_DIR}/$WICTMP/${IMAGE_FULLNAME}.wic/*.direct | head -1)
     sudo chown -R $(id -u):$(id -g) ${BUILDCHROOT_DIR}/${WICTMP}
-    mv -f ${WIC_DIRECT} ${WIC_IMAGE_FILE}
-    mv -f ${WIC_DIRECT}.bmap ${WIC_IMAGE_FILE}.bmap
+    find ${BUILDCHROOT_DIR}/${WICTMP} -type f -name "*.direct*" | while read f; do
+        suffix=$(basename $f | sed 's/\(.*\)\(\.direct\)\(.*\)/\3/')
+        mv -f ${f} ${WIC_IMAGE_FILE}${suffix}
+    done
     rm -rf ${BUILDCHROOT_DIR}/${WICTMP}
     rm -rf ${IMAGE_ROOTFS}/../pseudo
 }