All of lore.kernel.org
 help / color / mirror / Atom feed
* setting SRC_URI runtime - possible options
@ 2019-05-21  6:09 Belisko Marek
  2019-05-21 10:00 ` Alexander Kanavin
  0 siblings, 1 reply; 8+ messages in thread
From: Belisko Marek @ 2019-05-21  6:09 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 1498 bytes --]

Hi,

I have special need to fetch repo which is defined in config file in form
(repo and branch):
git@testrepo.com/myrepo mysuperbranch

Config file is placed in recipe directory. I've tried to add some bits and
pieces but it seems it's not doing right. Snippet from recipe:

LICENSE = "CLOSED"

SRCREV = "${AUTOREV}"
PV = "${SRCPV}"

do_fetch_prepend () {

    src_uri = d.getVar('SRC_URI')

    p = d.getVar("FILE")
    idx = p.rfind("/")
    p = p[:idx]
    p += "/config.txt"

    with open(p) as f:
        read_data = f.readline().strip().split(" ")
        d.setVar('SRC_URI', read_data[0])
}

SRC_URI = ""

S = "${WORKDIR}/git"

It looks like that repo is fetched but unpack doesn't put git directory in
$WORKDIR and in build directory I get strange directories like:

!=
bitbake-cookerdaemon.log
cache
conf
${@d.getVar('S')
else
if
os.path.join('
os.path.normpath(d.getVar('S'))
os.path.normpath(d.getVar('WORKDIR'))
'patches')}
tmp

so there is obviously I'm doing something wrong :). My question is if this
is the way or should I stick to some variables set in local.conf and then
use it in recipe? Thanks a lot for any pointers.

BR,

marek
-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com

[-- Attachment #2: Type: text/html, Size: 2444 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-21  6:09 setting SRC_URI runtime - possible options Belisko Marek
@ 2019-05-21 10:00 ` Alexander Kanavin
  2019-05-21 10:10   ` Belisko Marek
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Kanavin @ 2019-05-21 10:00 UTC (permalink / raw)
  To: Belisko Marek; +Cc: yocto

If you provide some context for why you want this, we might be able to
suggest a different way.

Alex

On Tue, 21 May 2019 at 08:11, Belisko Marek <marek.belisko@gmail.com> wrote:
>
> Hi,
>
> I have special need to fetch repo which is defined in config file in form (repo and branch):
> git@testrepo.com/myrepo mysuperbranch
>
> Config file is placed in recipe directory. I've tried to add some bits and pieces but it seems it's not doing right. Snippet from recipe:
>
> LICENSE = "CLOSED"
>
> SRCREV = "${AUTOREV}"
> PV = "${SRCPV}"
>
> do_fetch_prepend () {
>
>     src_uri = d.getVar('SRC_URI')
>
>     p = d.getVar("FILE")
>     idx = p.rfind("/")
>     p = p[:idx]
>     p += "/config.txt"
>
>     with open(p) as f:
>         read_data = f.readline().strip().split(" ")
>         d.setVar('SRC_URI', read_data[0])
> }
>
> SRC_URI = ""
>
> S = "${WORKDIR}/git"
>
> It looks like that repo is fetched but unpack doesn't put git directory in $WORKDIR and in build directory I get strange directories like:
>
> !=
> bitbake-cookerdaemon.log
> cache
> conf
> ${@d.getVar('S')
> else
> if
> os.path.join('
> os.path.normpath(d.getVar('S'))
> os.path.normpath(d.getVar('WORKDIR'))
> 'patches')}
> tmp
>
> so there is obviously I'm doing something wrong :). My question is if this is the way or should I stick to some variables set in local.conf and then use it in recipe? Thanks a lot for any pointers.
>
> BR,
>
> marek
> --
> as simple and primitive as possible
> -------------------------------------------------
> Marek Belisko - OPEN-NANDRA
> Freelance Developer
>
> Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
> Tel: +421 915 052 184
> skype: marekwhite
> twitter: #opennandra
> web: http://open-nandra.com
> --
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-21 10:00 ` Alexander Kanavin
@ 2019-05-21 10:10   ` Belisko Marek
  2019-05-21 10:14     ` Alexander Kanavin
  0 siblings, 1 reply; 8+ messages in thread
From: Belisko Marek @ 2019-05-21 10:10 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 2436 bytes --]

Hi,

On Tue, May 21, 2019 at 12:00 PM Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> If you provide some context for why you want this, we might be able to
> suggest a different way.
>
Customer wants to have kind of base-os (build in yocto) and then on top of
that different flavor python application which should be fetch and added
during build based on configuration file. This is only need. Thanks.

>
> Alex
>
> On Tue, 21 May 2019 at 08:11, Belisko Marek <marek.belisko@gmail.com>
> wrote:
> >
> > Hi,
> >
> > I have special need to fetch repo which is defined in config file in
> form (repo and branch):
> > git@testrepo.com/myrepo mysuperbranch
> >
> > Config file is placed in recipe directory. I've tried to add some bits
> and pieces but it seems it's not doing right. Snippet from recipe:
> >
> > LICENSE = "CLOSED"
> >
> > SRCREV = "${AUTOREV}"
> > PV = "${SRCPV}"
> >
> > do_fetch_prepend () {
> >
> >     src_uri = d.getVar('SRC_URI')
> >
> >     p = d.getVar("FILE")
> >     idx = p.rfind("/")
> >     p = p[:idx]
> >     p += "/config.txt"
> >
> >     with open(p) as f:
> >         read_data = f.readline().strip().split(" ")
> >         d.setVar('SRC_URI', read_data[0])
> > }
> >
> > SRC_URI = ""
> >
> > S = "${WORKDIR}/git"
> >
> > It looks like that repo is fetched but unpack doesn't put git directory
> in $WORKDIR and in build directory I get strange directories like:
> >
> > !=
> > bitbake-cookerdaemon.log
> > cache
> > conf
> > ${@d.getVar('S')
> > else
> > if
> > os.path.join('
> > os.path.normpath(d.getVar('S'))
> > os.path.normpath(d.getVar('WORKDIR'))
> > 'patches')}
> > tmp
> >
> > so there is obviously I'm doing something wrong :). My question is if
> this is the way or should I stick to some variables set in local.conf and
> then use it in recipe? Thanks a lot for any pointers.
> >
> > BR,
> >
> > marek
> > --
> > as simple and primitive as possible
> > -------------------------------------------------
> > Marek Belisko - OPEN-NANDRA
> > Freelance Developer
> >
> > Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
> > Tel: +421 915 052 184
> > skype: marekwhite
> > twitter: #opennandra
> > web: http://open-nandra.com
> > --
> > _______________________________________________
> > yocto mailing list
> > yocto@yoctoproject.org
> > https://lists.yoctoproject.org/listinfo/yocto
>


marek

[-- Attachment #2: Type: text/html, Size: 3812 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-21 10:10   ` Belisko Marek
@ 2019-05-21 10:14     ` Alexander Kanavin
  2019-05-21 10:22       ` Belisko Marek
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Kanavin @ 2019-05-21 10:14 UTC (permalink / raw)
  To: Belisko Marek; +Cc: yocto

You can write a class which sets the template for SRC_URI and then a
series of recipes that inherit the class, and define the variable that
would turn the template into the actual URI.

Alex

On Tue, 21 May 2019 at 12:10, Belisko Marek <marek.belisko@gmail.com> wrote:
>
> Hi,
>
> On Tue, May 21, 2019 at 12:00 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>>
>> If you provide some context for why you want this, we might be able to
>> suggest a different way.
>
> Customer wants to have kind of base-os (build in yocto) and then on top of that different flavor python application which should be fetch and added during build based on configuration file. This is only need. Thanks.
>>
>>
>> Alex
>>
>> On Tue, 21 May 2019 at 08:11, Belisko Marek <marek.belisko@gmail.com> wrote:
>> >
>> > Hi,
>> >
>> > I have special need to fetch repo which is defined in config file in form (repo and branch):
>> > git@testrepo.com/myrepo mysuperbranch
>> >
>> > Config file is placed in recipe directory. I've tried to add some bits and pieces but it seems it's not doing right. Snippet from recipe:
>> >
>> > LICENSE = "CLOSED"
>> >
>> > SRCREV = "${AUTOREV}"
>> > PV = "${SRCPV}"
>> >
>> > do_fetch_prepend () {
>> >
>> >     src_uri = d.getVar('SRC_URI')
>> >
>> >     p = d.getVar("FILE")
>> >     idx = p.rfind("/")
>> >     p = p[:idx]
>> >     p += "/config.txt"
>> >
>> >     with open(p) as f:
>> >         read_data = f.readline().strip().split(" ")
>> >         d.setVar('SRC_URI', read_data[0])
>> > }
>> >
>> > SRC_URI = ""
>> >
>> > S = "${WORKDIR}/git"
>> >
>> > It looks like that repo is fetched but unpack doesn't put git directory in $WORKDIR and in build directory I get strange directories like:
>> >
>> > !=
>> > bitbake-cookerdaemon.log
>> > cache
>> > conf
>> > ${@d.getVar('S')
>> > else
>> > if
>> > os.path.join('
>> > os.path.normpath(d.getVar('S'))
>> > os.path.normpath(d.getVar('WORKDIR'))
>> > 'patches')}
>> > tmp
>> >
>> > so there is obviously I'm doing something wrong :). My question is if this is the way or should I stick to some variables set in local.conf and then use it in recipe? Thanks a lot for any pointers.
>> >
>> > BR,
>> >
>> > marek
>> > --
>> > as simple and primitive as possible
>> > -------------------------------------------------
>> > Marek Belisko - OPEN-NANDRA
>> > Freelance Developer
>> >
>> > Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
>> > Tel: +421 915 052 184
>> > skype: marekwhite
>> > twitter: #opennandra
>> > web: http://open-nandra.com
>> > --
>> > _______________________________________________
>> > yocto mailing list
>> > yocto@yoctoproject.org
>> > https://lists.yoctoproject.org/listinfo/yocto
>
>
>
> marek


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-21 10:14     ` Alexander Kanavin
@ 2019-05-21 10:22       ` Belisko Marek
  2019-05-21 10:33         ` Alexander Kanavin
  2019-05-22  7:50         ` Paul Barker
  0 siblings, 2 replies; 8+ messages in thread
From: Belisko Marek @ 2019-05-21 10:22 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 3349 bytes --]

On Tue, May 21, 2019 at 12:14 PM Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> You can write a class which sets the template for SRC_URI and then a
> series of recipes that inherit the class, and define the variable that
> would turn the template into the actual URI.
>
OK I think it make sense. So parsing of config file will be done in class
and then class will be used in recipes to set correct SRU_URI.
Do you have any idea what is wrong with actual code I posted? Why it is
doing some strange things? Thanks.

>
> Alex
>
> On Tue, 21 May 2019 at 12:10, Belisko Marek <marek.belisko@gmail.com>
> wrote:
> >
> > Hi,
> >
> > On Tue, May 21, 2019 at 12:00 PM Alexander Kanavin <
> alex.kanavin@gmail.com> wrote:
> >>
> >> If you provide some context for why you want this, we might be able to
> >> suggest a different way.
> >
> > Customer wants to have kind of base-os (build in yocto) and then on top
> of that different flavor python application which should be fetch and added
> during build based on configuration file. This is only need. Thanks.
> >>
> >>
> >> Alex
> >>
> >> On Tue, 21 May 2019 at 08:11, Belisko Marek <marek.belisko@gmail.com>
> wrote:
> >> >
> >> > Hi,
> >> >
> >> > I have special need to fetch repo which is defined in config file in
> form (repo and branch):
> >> > git@testrepo.com/myrepo mysuperbranch
> >> >
> >> > Config file is placed in recipe directory. I've tried to add some
> bits and pieces but it seems it's not doing right. Snippet from recipe:
> >> >
> >> > LICENSE = "CLOSED"
> >> >
> >> > SRCREV = "${AUTOREV}"
> >> > PV = "${SRCPV}"
> >> >
> >> > do_fetch_prepend () {
> >> >
> >> >     src_uri = d.getVar('SRC_URI')
> >> >
> >> >     p = d.getVar("FILE")
> >> >     idx = p.rfind("/")
> >> >     p = p[:idx]
> >> >     p += "/config.txt"
> >> >
> >> >     with open(p) as f:
> >> >         read_data = f.readline().strip().split(" ")
> >> >         d.setVar('SRC_URI', read_data[0])
> >> > }
> >> >
> >> > SRC_URI = ""
> >> >
> >> > S = "${WORKDIR}/git"
> >> >
> >> > It looks like that repo is fetched but unpack doesn't put git
> directory in $WORKDIR and in build directory I get strange directories like:
> >> >
> >> > !=
> >> > bitbake-cookerdaemon.log
> >> > cache
> >> > conf
> >> > ${@d.getVar('S')
> >> > else
> >> > if
> >> > os.path.join('
> >> > os.path.normpath(d.getVar('S'))
> >> > os.path.normpath(d.getVar('WORKDIR'))
> >> > 'patches')}
> >> > tmp
> >> >
> >> > so there is obviously I'm doing something wrong :). My question is if
> this is the way or should I stick to some variables set in local.conf and
> then use it in recipe? Thanks a lot for any pointers.
> >> >
> >> > BR,
> >> >
> >> > marek
> >> > --
> >> > as simple and primitive as possible
> >> > -------------------------------------------------
> >> > Marek Belisko - OPEN-NANDRA
> >> > Freelance Developer
> >> >
> >> > Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
> >> > Tel: +421 915 052 184
> >> > skype: marekwhite
> >> > twitter: #opennandra
> >> > web: http://open-nandra.com
> >> > --
> >> > _______________________________________________
> >> > yocto mailing list
> >> > yocto@yoctoproject.org
> >> > https://lists.yoctoproject.org/listinfo/yocto
> >
> >
> >
> > marek
>


marek

[-- Attachment #2: Type: text/html, Size: 5297 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-21 10:22       ` Belisko Marek
@ 2019-05-21 10:33         ` Alexander Kanavin
  2019-05-22  7:50         ` Paul Barker
  1 sibling, 0 replies; 8+ messages in thread
From: Alexander Kanavin @ 2019-05-21 10:33 UTC (permalink / raw)
  To: Belisko Marek; +Cc: yocto

Don't use the config file at all. Just create as many recipes as you
need, put the common bits into the class, and the bits that differ
into the recipes directly.

Example:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/pypi.bbclass

Alex

On Tue, 21 May 2019 at 12:22, Belisko Marek <marek.belisko@gmail.com> wrote:
>
> On Tue, May 21, 2019 at 12:14 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>>
>> You can write a class which sets the template for SRC_URI and then a
>> series of recipes that inherit the class, and define the variable that
>> would turn the template into the actual URI.
>
> OK I think it make sense. So parsing of config file will be done in class and then class will be used in recipes to set correct SRU_URI.
> Do you have any idea what is wrong with actual code I posted? Why it is doing some strange things? Thanks.
>>
>>
>> Alex
>>
>> On Tue, 21 May 2019 at 12:10, Belisko Marek <marek.belisko@gmail.com> wrote:
>> >
>> > Hi,
>> >
>> > On Tue, May 21, 2019 at 12:00 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>> >>
>> >> If you provide some context for why you want this, we might be able to
>> >> suggest a different way.
>> >
>> > Customer wants to have kind of base-os (build in yocto) and then on top of that different flavor python application which should be fetch and added during build based on configuration file. This is only need. Thanks.
>> >>
>> >>
>> >> Alex
>> >>
>> >> On Tue, 21 May 2019 at 08:11, Belisko Marek <marek.belisko@gmail.com> wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > I have special need to fetch repo which is defined in config file in form (repo and branch):
>> >> > git@testrepo.com/myrepo mysuperbranch
>> >> >
>> >> > Config file is placed in recipe directory. I've tried to add some bits and pieces but it seems it's not doing right. Snippet from recipe:
>> >> >
>> >> > LICENSE = "CLOSED"
>> >> >
>> >> > SRCREV = "${AUTOREV}"
>> >> > PV = "${SRCPV}"
>> >> >
>> >> > do_fetch_prepend () {
>> >> >
>> >> >     src_uri = d.getVar('SRC_URI')
>> >> >
>> >> >     p = d.getVar("FILE")
>> >> >     idx = p.rfind("/")
>> >> >     p = p[:idx]
>> >> >     p += "/config.txt"
>> >> >
>> >> >     with open(p) as f:
>> >> >         read_data = f.readline().strip().split(" ")
>> >> >         d.setVar('SRC_URI', read_data[0])
>> >> > }
>> >> >
>> >> > SRC_URI = ""
>> >> >
>> >> > S = "${WORKDIR}/git"
>> >> >
>> >> > It looks like that repo is fetched but unpack doesn't put git directory in $WORKDIR and in build directory I get strange directories like:
>> >> >
>> >> > !=
>> >> > bitbake-cookerdaemon.log
>> >> > cache
>> >> > conf
>> >> > ${@d.getVar('S')
>> >> > else
>> >> > if
>> >> > os.path.join('
>> >> > os.path.normpath(d.getVar('S'))
>> >> > os.path.normpath(d.getVar('WORKDIR'))
>> >> > 'patches')}
>> >> > tmp
>> >> >
>> >> > so there is obviously I'm doing something wrong :). My question is if this is the way or should I stick to some variables set in local.conf and then use it in recipe? Thanks a lot for any pointers.
>> >> >
>> >> > BR,
>> >> >
>> >> > marek
>> >> > --
>> >> > as simple and primitive as possible
>> >> > -------------------------------------------------
>> >> > Marek Belisko - OPEN-NANDRA
>> >> > Freelance Developer
>> >> >
>> >> > Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
>> >> > Tel: +421 915 052 184
>> >> > skype: marekwhite
>> >> > twitter: #opennandra
>> >> > web: http://open-nandra.com
>> >> > --
>> >> > _______________________________________________
>> >> > yocto mailing list
>> >> > yocto@yoctoproject.org
>> >> > https://lists.yoctoproject.org/listinfo/yocto
>> >
>> >
>> >
>> > marek
>
>
>
> marek


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-22  7:50         ` Paul Barker
@ 2019-05-22  5:55           ` Belisko Marek
  0 siblings, 0 replies; 8+ messages in thread
From: Belisko Marek @ 2019-05-22  5:55 UTC (permalink / raw)
  To: Paul Barker; +Cc: Yocto discussion list

[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]

On Wed, May 22, 2019 at 9:50 AM Paul Barker <paul@betafive.co.uk> wrote:

> On Tue, 21 May 2019, at 11:23, Belisko Marek wrote:
> > On Tue, May 21, 2019 at 12:14 PM Alexander Kanavin
> > <alex.kanavin@gmail.com> wrote:
> > > You can write a class which sets the template for SRC_URI and then a
> > >  series of recipes that inherit the class, and define the variable that
> > >  would turn the template into the actual URI.
> > OK I think it make sense. So parsing of config file will be done in
> > class and then class will be used in recipes to set correct SRU_URI.
> > Do you have any idea what is wrong with actual code I posted? Why it is
> > doing some strange things? Thanks.
>
> You're setting the SRC_URI value only in the do_fetch task. It's needed in
> at least the do_unpack task as well and possibly other tasks.
>
> You could look at setting this in an anonymous python function instead if
> you really need to parse a config file.
>
Yes I was using anonymous python function before but  then when project was
unpacked the SRCPV + SRCREV was somehow not updated.
I'll try to look more on it and debug. Thanks.

>
> --
> Paul Barker
> Managing Director & Principal Engineer
> Beta Five Ltd
>

BR,

marek
-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com

[-- Attachment #2: Type: text/html, Size: 2262 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: setting SRC_URI runtime - possible options
  2019-05-21 10:22       ` Belisko Marek
  2019-05-21 10:33         ` Alexander Kanavin
@ 2019-05-22  7:50         ` Paul Barker
  2019-05-22  5:55           ` Belisko Marek
  1 sibling, 1 reply; 8+ messages in thread
From: Paul Barker @ 2019-05-22  7:50 UTC (permalink / raw)
  To: Belisko Marek, Alexander Kanavin; +Cc: Yocto discussion list

On Tue, 21 May 2019, at 11:23, Belisko Marek wrote:
> On Tue, May 21, 2019 at 12:14 PM Alexander Kanavin 
> <alex.kanavin@gmail.com> wrote:
> > You can write a class which sets the template for SRC_URI and then a
> >  series of recipes that inherit the class, and define the variable that
> >  would turn the template into the actual URI.
> OK I think it make sense. So parsing of config file will be done in 
> class and then class will be used in recipes to set correct SRU_URI.
> Do you have any idea what is wrong with actual code I posted? Why it is 
> doing some strange things? Thanks.

You're setting the SRC_URI value only in the do_fetch task. It's needed in at least the do_unpack task as well and possibly other tasks.

You could look at setting this in an anonymous python function instead if you really need to parse a config file.

-- 
Paul Barker
Managing Director & Principal Engineer
Beta Five Ltd


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-05-22  7:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21  6:09 setting SRC_URI runtime - possible options Belisko Marek
2019-05-21 10:00 ` Alexander Kanavin
2019-05-21 10:10   ` Belisko Marek
2019-05-21 10:14     ` Alexander Kanavin
2019-05-21 10:22       ` Belisko Marek
2019-05-21 10:33         ` Alexander Kanavin
2019-05-22  7:50         ` Paul Barker
2019-05-22  5:55           ` Belisko Marek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.