Re: [OE-core] [PATCH] RFC wic: Support .wks files for multiple machines

2020-05-13 Thread Ricardo Ribalda
Hi

Even if it does not cover all the use cases. Can we consider this patch?

Thanks!

On Sat, Apr 25, 2020 at 11:29 PM Ricardo Ribalda Delgado
 wrote:
>
> Hi Christopher
>
> On Fri, Apr 24, 2020 at 5:56 PM Christopher Larson  wrote:
> >
> > This will only work the way you expect if hte user's local.conf uses ?= or 
> > ??= for MACHINE, otherwise setting it in the environment will do nothing.
> >
>
> Good catch, You are right :(,
>
> Any idea of how could I fix it. I think I would have to change
> site.conf, or local.conf from wic, and I do not want to do that.
>
> Ignoring this bug we are still covering a big number of usecases:
>
> - bibake
> - wic with user provided rootfs-dir
> - wic without userprovided rootfs-dir and ?= or ??=
>
> At the end of the day this is just a RFC ;), so i am open to any
> implementation. I would love to hear your thoughts
>
> Best regards
>
>
>
> > On Fri, Apr 24, 2020 at 6:30 AM Ricardo Ribalda  
> > wrote:
> >>
> >> If you want to make a disk image containing rootfs for different
> >> machines, the only way to do it today is by calling wic and passing the
> >> different rootfs-paths.
> >>
> >> Eg:
> >> combined.wks
> >> part /export --source rootfs --rootfs-dir=target-image
> >> part / --source rootfs
> >>
> >> bitbake multiconfig:arm:target-image
> >> wic create combined --rootfs-dir 
> >> target-image=/workdir/build/tmp/work/arm-poky-linux/target-image/1.0-r0/rootfs/
> >>  -e main
> >>
> >> This has many drawbacks:
> >> 1) You need to know the folder location for the target-image
> >> 2) It is easy to forget updating the target (only running wic and not
> >>bitbake)
> >> 3) It is slow
> >> 4) It does not scale when you have multiple machines
> >>
> >> Instead, wic can be given a hint of what machine to search for:
> >>
> >> combined.wks
> >> part /export --source rootfs --rootfs-dir=arm:target-image
> >> part / --source rootfs
> >>
> >> bitbake main
> >>
> >> If we ensoure the dependency of target-image from main via
> >> do_image[mcdepends], all the dependencies are automatically
> >> handled.
> >>
> >> This patch makes wic aware of the machine to use.
> >>
> >> Signed-off-by: Ricardo Ribalda Delgado 
> >> ---
> >>  scripts/lib/wic/misc.py | 16 +---
> >>  1 file changed, 13 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
> >> index 91975ba151..51b43b49aa 100644
> >> --- a/scripts/lib/wic/misc.py
> >> +++ b/scripts/lib/wic/misc.py
> >> @@ -206,7 +206,12 @@ class BitbakeVars(defaultdict):
> >>
> >>  if image not in self:
> >>  if image and self.vars_dir:
> >> -fname = os.path.join(self.vars_dir, image + '.env')
> >> +if image.find(":") != -1:
> >> +[machine, img] = image.split(":")
> >> +fname = os.path.join(self.vars_dir, "../../",
> >> + machine, "imgdata", img + '.env')
> >> +else:
> >> +fname = os.path.join(self.vars_dir, image + '.env')
> >>  if os.path.isfile(fname):
> >>  # parse .env file
> >>  with open(fname) as varsfile:
> >> @@ -220,11 +225,16 @@ class BitbakeVars(defaultdict):
> >>  # Get bitbake -e output
> >>  cmd = "bitbake -e"
> >>  if image:
> >> -cmd += " %s" % image
> >> +if image.find(":") != -1:
> >> +[machine, img] = image.split(":")
> >> +cmd = "MACHINE=%s %s" % (machine, cmd)
> >> +else:
> >> +img = image
> >> +cmd += " %s" % img
> >>
> >>  log_level = logger.getEffectiveLevel()
> >>  logger.setLevel(logging.INFO)
> >> -ret, lines = _exec_cmd(cmd)
> >> +ret, lines = _exec_cmd(cmd, as_shell=True)
> >>  logger.setLevel(log_level)
> >>
> >>  if ret:
> >> --
> >> 2.26.1
> >>
> >> 
> >
> >
> >
> > --
> > Christopher Larson
> > kergoth at gmail dot com
> > Founder - BitBake, OpenEmbedded, OpenZaurus
> > Senior Software Engineer, Mentor Graphics
>
>
>
> --
> Ricardo Ribalda



-- 
Ricardo Ribalda
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#138205): 
https://lists.openembedded.org/g/openembedded-core/message/138205
Mute This Topic: https://lists.openembedded.org/mt/73241116/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [OE-core] [PATCH] RFC wic: Support .wks files for multiple machines

2020-04-25 Thread Ricardo Ribalda
Hi Christopher

On Fri, Apr 24, 2020 at 5:56 PM Christopher Larson  wrote:
>
> This will only work the way you expect if hte user's local.conf uses ?= or 
> ??= for MACHINE, otherwise setting it in the environment will do nothing.
>

Good catch, You are right :(,

Any idea of how could I fix it. I think I would have to change
site.conf, or local.conf from wic, and I do not want to do that.

Ignoring this bug we are still covering a big number of usecases:

- bibake
- wic with user provided rootfs-dir
- wic without userprovided rootfs-dir and ?= or ??=

At the end of the day this is just a RFC ;), so i am open to any
implementation. I would love to hear your thoughts

Best regards



> On Fri, Apr 24, 2020 at 6:30 AM Ricardo Ribalda  
> wrote:
>>
>> If you want to make a disk image containing rootfs for different
>> machines, the only way to do it today is by calling wic and passing the
>> different rootfs-paths.
>>
>> Eg:
>> combined.wks
>> part /export --source rootfs --rootfs-dir=target-image
>> part / --source rootfs
>>
>> bitbake multiconfig:arm:target-image
>> wic create combined --rootfs-dir 
>> target-image=/workdir/build/tmp/work/arm-poky-linux/target-image/1.0-r0/rootfs/
>>  -e main
>>
>> This has many drawbacks:
>> 1) You need to know the folder location for the target-image
>> 2) It is easy to forget updating the target (only running wic and not
>>bitbake)
>> 3) It is slow
>> 4) It does not scale when you have multiple machines
>>
>> Instead, wic can be given a hint of what machine to search for:
>>
>> combined.wks
>> part /export --source rootfs --rootfs-dir=arm:target-image
>> part / --source rootfs
>>
>> bitbake main
>>
>> If we ensoure the dependency of target-image from main via
>> do_image[mcdepends], all the dependencies are automatically
>> handled.
>>
>> This patch makes wic aware of the machine to use.
>>
>> Signed-off-by: Ricardo Ribalda Delgado 
>> ---
>>  scripts/lib/wic/misc.py | 16 +---
>>  1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
>> index 91975ba151..51b43b49aa 100644
>> --- a/scripts/lib/wic/misc.py
>> +++ b/scripts/lib/wic/misc.py
>> @@ -206,7 +206,12 @@ class BitbakeVars(defaultdict):
>>
>>  if image not in self:
>>  if image and self.vars_dir:
>> -fname = os.path.join(self.vars_dir, image + '.env')
>> +if image.find(":") != -1:
>> +[machine, img] = image.split(":")
>> +fname = os.path.join(self.vars_dir, "../../",
>> + machine, "imgdata", img + '.env')
>> +else:
>> +fname = os.path.join(self.vars_dir, image + '.env')
>>  if os.path.isfile(fname):
>>  # parse .env file
>>  with open(fname) as varsfile:
>> @@ -220,11 +225,16 @@ class BitbakeVars(defaultdict):
>>  # Get bitbake -e output
>>  cmd = "bitbake -e"
>>  if image:
>> -cmd += " %s" % image
>> +if image.find(":") != -1:
>> +[machine, img] = image.split(":")
>> +cmd = "MACHINE=%s %s" % (machine, cmd)
>> +else:
>> +img = image
>> +cmd += " %s" % img
>>
>>  log_level = logger.getEffectiveLevel()
>>  logger.setLevel(logging.INFO)
>> -ret, lines = _exec_cmd(cmd)
>> +ret, lines = _exec_cmd(cmd, as_shell=True)
>>  logger.setLevel(log_level)
>>
>>  if ret:
>> --
>> 2.26.1
>>
>> 
>
>
>
> --
> Christopher Larson
> kergoth at gmail dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Senior Software Engineer, Mentor Graphics



-- 
Ricardo Ribalda
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#137488): 
https://lists.openembedded.org/g/openembedded-core/message/137488
Mute This Topic: https://lists.openembedded.org/mt/73241116/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [OE-core] [PATCH] RFC wic: Support .wks files for multiple machines

2020-04-24 Thread Christopher Larson
This will only work the way you expect if hte user's local.conf uses ?= or
??= for MACHINE, otherwise setting it in the environment will do nothing.

On Fri, Apr 24, 2020 at 6:30 AM Ricardo Ribalda 
wrote:

> If you want to make a disk image containing rootfs for different
> machines, the only way to do it today is by calling wic and passing the
> different rootfs-paths.
>
> Eg:
> combined.wks
> part /export --source rootfs --rootfs-dir=target-image
> part / --source rootfs
>
> bitbake multiconfig:arm:target-image
> wic create combined --rootfs-dir
> target-image=/workdir/build/tmp/work/arm-poky-linux/target-image/1.0-r0/rootfs/
> -e main
>
> This has many drawbacks:
> 1) You need to know the folder location for the target-image
> 2) It is easy to forget updating the target (only running wic and not
>bitbake)
> 3) It is slow
> 4) It does not scale when you have multiple machines
>
> Instead, wic can be given a hint of what machine to search for:
>
> combined.wks
> part /export --source rootfs --rootfs-dir=arm:target-image
> part / --source rootfs
>
> bitbake main
>
> If we ensoure the dependency of target-image from main via
> do_image[mcdepends], all the dependencies are automatically
> handled.
>
> This patch makes wic aware of the machine to use.
>
> Signed-off-by: Ricardo Ribalda Delgado 
> ---
>  scripts/lib/wic/misc.py | 16 +---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
> index 91975ba151..51b43b49aa 100644
> --- a/scripts/lib/wic/misc.py
> +++ b/scripts/lib/wic/misc.py
> @@ -206,7 +206,12 @@ class BitbakeVars(defaultdict):
>
>  if image not in self:
>  if image and self.vars_dir:
> -fname = os.path.join(self.vars_dir, image + '.env')
> +if image.find(":") != -1:
> +[machine, img] = image.split(":")
> +fname = os.path.join(self.vars_dir, "../../",
> + machine, "imgdata", img + '.env')
> +else:
> +fname = os.path.join(self.vars_dir, image + '.env')
>  if os.path.isfile(fname):
>  # parse .env file
>  with open(fname) as varsfile:
> @@ -220,11 +225,16 @@ class BitbakeVars(defaultdict):
>  # Get bitbake -e output
>  cmd = "bitbake -e"
>  if image:
> -cmd += " %s" % image
> +if image.find(":") != -1:
> +[machine, img] = image.split(":")
> +cmd = "MACHINE=%s %s" % (machine, cmd)
> +else:
> +img = image
> +cmd += " %s" % img
>
>  log_level = logger.getEffectiveLevel()
>  logger.setLevel(logging.INFO)
> -ret, lines = _exec_cmd(cmd)
> +ret, lines = _exec_cmd(cmd, as_shell=True)
>  logger.setLevel(log_level)
>
>  if ret:
> --
> 2.26.1
>
> 
>


-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#137452): 
https://lists.openembedded.org/g/openembedded-core/message/137452
Mute This Topic: https://lists.openembedded.org/mt/73241116/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[OE-core] [PATCH] RFC wic: Support .wks files for multiple machines

2020-04-24 Thread Ricardo Ribalda
If you want to make a disk image containing rootfs for different
machines, the only way to do it today is by calling wic and passing the
different rootfs-paths.

Eg:
combined.wks
part /export --source rootfs --rootfs-dir=target-image
part / --source rootfs

bitbake multiconfig:arm:target-image
wic create combined --rootfs-dir 
target-image=/workdir/build/tmp/work/arm-poky-linux/target-image/1.0-r0/rootfs/ 
-e main

This has many drawbacks:
1) You need to know the folder location for the target-image
2) It is easy to forget updating the target (only running wic and not
   bitbake)
3) It is slow
4) It does not scale when you have multiple machines

Instead, wic can be given a hint of what machine to search for:

combined.wks
part /export --source rootfs --rootfs-dir=arm:target-image
part / --source rootfs

bitbake main

If we ensoure the dependency of target-image from main via
do_image[mcdepends], all the dependencies are automatically
handled.

This patch makes wic aware of the machine to use.

Signed-off-by: Ricardo Ribalda Delgado 
---
 scripts/lib/wic/misc.py | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
index 91975ba151..51b43b49aa 100644
--- a/scripts/lib/wic/misc.py
+++ b/scripts/lib/wic/misc.py
@@ -206,7 +206,12 @@ class BitbakeVars(defaultdict):
 
 if image not in self:
 if image and self.vars_dir:
-fname = os.path.join(self.vars_dir, image + '.env')
+if image.find(":") != -1:
+[machine, img] = image.split(":")
+fname = os.path.join(self.vars_dir, "../../",
+ machine, "imgdata", img + '.env')
+else:
+fname = os.path.join(self.vars_dir, image + '.env')
 if os.path.isfile(fname):
 # parse .env file
 with open(fname) as varsfile:
@@ -220,11 +225,16 @@ class BitbakeVars(defaultdict):
 # Get bitbake -e output
 cmd = "bitbake -e"
 if image:
-cmd += " %s" % image
+if image.find(":") != -1:
+[machine, img] = image.split(":")
+cmd = "MACHINE=%s %s" % (machine, cmd)
+else:
+img = image
+cmd += " %s" % img
 
 log_level = logger.getEffectiveLevel()
 logger.setLevel(logging.INFO)
-ret, lines = _exec_cmd(cmd)
+ret, lines = _exec_cmd(cmd, as_shell=True)
 logger.setLevel(log_level)
 
 if ret:
-- 
2.26.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#137446): 
https://lists.openembedded.org/g/openembedded-core/message/137446
Mute This Topic: https://lists.openembedded.org/mt/73241116/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-