Hi Christopher

On Fri, Apr 24, 2020 at 5:56 PM Christopher Larson <kerg...@gmail.com> 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 <ricardo.riba...@gmail.com> 
> 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 <rica...@ribalda.com>
>> ---
>>  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]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to