All of lore.kernel.org
 help / color / mirror / Atom feed
* Check IMAGE_FEATURES content in recipe
@ 2018-05-10  7:37 Piotr Piwko
  2018-05-10  8:46 ` ChenQi
  0 siblings, 1 reply; 9+ messages in thread
From: Piotr Piwko @ 2018-05-10  7:37 UTC (permalink / raw)
  To: yocto

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

Hi,

I would like to check in my recipe if created image is read-only or not. In
order to do so, I use the following condition which I would inside poky
sources:

if ${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'true',
'false', d)}; then

However it seems that IMAGE_FEATURES variable is not exported to the higher
recipes. I also confirmed it's content by executing:

bitbake my-image -e | grep IMAGE_FEATURES

Is there any possibility to export this variable to my recipe or somehow
check the particular image feature?

Thank you in advance for help.

-- 
Piotr Piwko
http://www.embedded-engineering.pl/

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

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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10  7:37 Check IMAGE_FEATURES content in recipe Piotr Piwko
@ 2018-05-10  8:46 ` ChenQi
  2018-05-10  8:54   ` André Draszik
  2018-05-10  8:59   ` Piotr Piwko
  0 siblings, 2 replies; 9+ messages in thread
From: ChenQi @ 2018-05-10  8:46 UTC (permalink / raw)
  To: yocto

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

Hi Piotr,

VAR set in recipe A cannot be accessed by recipe B.

For 'read-only-rootfs' image feature, tweaks are done in functions 
executed after generating rootfs.
meta/classes/rootfs-postcommands.bbclass:ROOTFS_POSTPROCESS_COMMAND += 
'${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", 
"read_only_rootfs_hook; ", "",d)}'

Can you use a similar approach to solve your problem?

Best Regards,
Chen Qi

On 05/10/2018 03:37 PM, Piotr Piwko wrote:
> Hi,
>
> I would like to check in my recipe if created image is read-only or 
> not. In order to do so, I use the following condition which I would 
> inside poky sources:
>
> if ${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'true', 
> 'false', d)}; then
>
> However it seems that IMAGE_FEATURES variable is not exported to the 
> higher recipes. I also confirmed it's content by executing:
>
> bitbake my-image -e | grep IMAGE_FEATURES
>
> Is there any possibility to export this variable to my recipe or 
> somehow check the particular image feature?
>
> Thank you in advance for help.
>
> -- 
> Piotr Piwko
> http://www.embedded-engineering.pl/
>
>


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

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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10  8:46 ` ChenQi
@ 2018-05-10  8:54   ` André Draszik
  2018-05-10  8:59   ` Piotr Piwko
  1 sibling, 0 replies; 9+ messages in thread
From: André Draszik @ 2018-05-10  8:54 UTC (permalink / raw)
  To: yocto

Hi,

To expand on that - the idea is that (binary) packages shall not be affected
by the image, meaning that you should be able to install the exact same
(binary) package in different images. If you were able to access image
specific variables inside your package recipe (and change behaviour/contents
of your package based on the image), this wouldn't be possible any more.

In other words, an image is just a collection of a different set / number of
packages to be installed, but each individual package itself is the same for
all images.

Cheers,
Andre'

On Thu, 2018-05-10 at 16:46 +0800, ChenQi wrote:
> Hi Piotr,
> 
> VAR set in recipe A cannot be accessed by recipe B.
> 
> For 'read-only-rootfs' image feature, tweaks are done in functions 
> executed after generating rootfs.
> meta/classes/rootfs-postcommands.bbclass:ROOTFS_POSTPROCESS_COMMAND += 
> '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", 
> "read_only_rootfs_hook; ", "",d)}'
> 
> Can you use a similar approach to solve your problem?
> 
> Best Regards,
> Chen Qi
> 
> On 05/10/2018 03:37 PM, Piotr Piwko wrote:
> > Hi,
> > 
> > I would like to check in my recipe if created image is read-only or 
> > not. In order to do so, I use the following condition which I would 
> > inside poky sources:
> > 
> > if ${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'true', 
> > 'false', d)}; then
> > 
> > However it seems that IMAGE_FEATURES variable is not exported to the 
> > higher recipes. I also confirmed it's content by executing:
> > 
> > bitbake my-image -e | grep IMAGE_FEATURES
> > 
> > Is there any possibility to export this variable to my recipe or 
> > somehow check the particular image feature?
> > 
> > Thank you in advance for help.
> > 
> > -- 
> > Piotr Piwko
> > http://www.embedded-engineering.pl/
> > 
> > 
> 
> 


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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10  8:46 ` ChenQi
  2018-05-10  8:54   ` André Draszik
@ 2018-05-10  8:59   ` Piotr Piwko
  2018-05-10  9:22     ` Burton, Ross
  2018-05-10 10:54     ` Alexander Kanavin
  1 sibling, 2 replies; 9+ messages in thread
From: Piotr Piwko @ 2018-05-10  8:59 UTC (permalink / raw)
  To: Qi.Chen; +Cc: yocto

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

czw., 10 maj 2018 o 10:45 ChenQi <Qi.Chen@windriver.com> napisał(a):

> Hi Piotr,
>
> VAR set in recipe A cannot be accessed by recipe B.
>

All right, but what about DISTRO_FEATURES? It is available everywhere, so
maybe there is some possibility to do so ...


> For 'read-only-rootfs' image feature, tweaks are done in functions
> executed after generating rootfs.
> meta/classes/rootfs-postcommands.bbclass:ROOTFS_POSTPROCESS_COMMAND +=
> '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs",
> "read_only_rootfs_hook; ", "",d)}'
>
> Can you use a similar approach to solve your problem?
>

Unfortunately, I can not. I would like to make a pkg_postinst() function of
my package dependent on the rootfs mount mode. It should be different if
the rootfs is going to be mounted as read-only.

-- 
Piotr Piwko
http://www.embedded-engineering.pl/

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

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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10  8:59   ` Piotr Piwko
@ 2018-05-10  9:22     ` Burton, Ross
  2018-05-10 15:06       ` Marcelo E. Magallon
  2018-05-10 10:54     ` Alexander Kanavin
  1 sibling, 1 reply; 9+ messages in thread
From: Burton, Ross @ 2018-05-10  9:22 UTC (permalink / raw)
  To: Piotr Piwko; +Cc: Yocto-mailing-list

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

On 10 May 2018 at 09:59, Piotr Piwko <piotr.piwko@gmail.com> wrote:

>
>> VAR set in recipe A cannot be accessed by recipe B.
>>
>
> All right, but what about DISTRO_FEATURES? It is available everywhere, so
> maybe there is some possibility to do so ...
>

You need to think about what actually happens.  This is a valid bitbake
call:

$ bitbake image-foo image-bar

image-foo and image-bar both contain recipe-flob.  recipe-flob will be
built *once* to generate the packages, and those packages used to build
both images.  If image-foo is read-only and image-bar is read/write, the
*same packages* will be reused.  recipe-flob has no idea that foo is
read-only and bar is read/write because the IMAGE_FEATURES assignments are
specific to those image recipes.

There are global variables (such as DISTRO_FEATURES) and the *default*
IMAGE_FEATURES is also available globally, but that won't help you here.

Ross

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

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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10  8:59   ` Piotr Piwko
  2018-05-10  9:22     ` Burton, Ross
@ 2018-05-10 10:54     ` Alexander Kanavin
  2018-05-10 11:29       ` Piotr Piwko
  1 sibling, 1 reply; 9+ messages in thread
From: Alexander Kanavin @ 2018-05-10 10:54 UTC (permalink / raw)
  To: Piotr Piwko, Qi.Chen; +Cc: yocto

On 05/10/2018 11:59 AM, Piotr Piwko wrote:
>     For 'read-only-rootfs' image feature, tweaks are done in functions
>     executed after generating rootfs.
>     meta/classes/rootfs-postcommands.bbclass:ROOTFS_POSTPROCESS_COMMAND
>     += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs",
>     "read_only_rootfs_hook; ", "",d)}'
> 
>     Can you use a similar approach to solve your problem?
> 
> 
> Unfortunately, I can not. I would like to make a pkg_postinst() function 
> of my package dependent on the rootfs mount mode. It should be different 
> if the rootfs is going to be mounted as read-only.

You should be able to move the contents of the pkg_postinst to the hook. 
Actually two hooks: one for read only rootfs, another for read-write. 
Add this to your image recipe:

ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "piotrs_ro_rootfs_hook; ", "piotrs_rw_rootfs_hook; 
",d)}'


and implement the hook functions accordingly. By the time the hooks are 
executed, the package is already installed, so you can access its files 
as needed.

Alex


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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10 10:54     ` Alexander Kanavin
@ 2018-05-10 11:29       ` Piotr Piwko
  0 siblings, 0 replies; 9+ messages in thread
From: Piotr Piwko @ 2018-05-10 11:29 UTC (permalink / raw)
  To: alexander.kanavin; +Cc: yocto

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

czw., 10 maj 2018 o 13:02 Alexander Kanavin <
alexander.kanavin@linux.intel.com> napisał(a):

> You should be able to move the contents of the pkg_postinst to the hook.
> Actually two hooks: one for read only rootfs, another for read-write.
> Add this to your image recipe:
>
> ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES",
> "read-only-rootfs", "piotrs_ro_rootfs_hook; ", "piotrs_rw_rootfs_hook;
> ",d)}'
>

Actually, I don't create my own recipe but I try to extend the existing one
(busybox), so your propose may be not so easy as it sounds :). Anyway I
understand the problem and proposed solution.

Thank you all for help!.

-- 
Piotr Piwko
http://www.embedded-engineering.pl/

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

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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10  9:22     ` Burton, Ross
@ 2018-05-10 15:06       ` Marcelo E. Magallon
  2018-05-11  0:04         ` Paul Eggleton
  0 siblings, 1 reply; 9+ messages in thread
From: Marcelo E. Magallon @ 2018-05-10 15:06 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Yocto-mailing-list, Piotr Piwko

On Thu, May 10, 2018 at 10:22:34AM +0100, Burton, Ross wrote:

>$ bitbake image-foo image-bar
>
>image-foo and image-bar both contain recipe-flob.  recipe-flob will be
>built *once* to generate the packages, and those packages used to build
>both images.  If image-foo is read-only and image-bar is read/write, the
>*same packages* will be reused.  recipe-flob has no idea that foo is
>read-only and bar is read/write because the IMAGE_FEATURES assignments are
>specific to those image recipes.

When dealing with a somewhat similar problem, what I've done is 
that my-recipe.bb generates two packages (my-package-a, 
my-package-b) and the images select which of the two packages 
they want to use.

Marcelo


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

* Re: Check IMAGE_FEATURES content in recipe
  2018-05-10 15:06       ` Marcelo E. Magallon
@ 2018-05-11  0:04         ` Paul Eggleton
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2018-05-11  0:04 UTC (permalink / raw)
  To: yocto; +Cc: Piotr Piwko

On Friday, 11 May 2018 3:06:11 AM NZST Marcelo E. Magallon wrote:
> On Thu, May 10, 2018 at 10:22:34AM +0100, Burton, Ross wrote:
> 
> >$ bitbake image-foo image-bar
> >
> >image-foo and image-bar both contain recipe-flob.  recipe-flob will be
> >built *once* to generate the packages, and those packages used to build
> >both images.  If image-foo is read-only and image-bar is read/write, the
> >*same packages* will be reused.  recipe-flob has no idea that foo is
> >read-only and bar is read/write because the IMAGE_FEATURES assignments are
> >specific to those image recipes.
> 
> When dealing with a somewhat similar problem, what I've done is 
> that my-recipe.bb generates two packages (my-package-a, 
> my-package-b) and the images select which of the two packages 
> they want to use.

Right, that's another solution.

FYI I have covered these in the technical FAQ:

  https://wiki.yoctoproject.org/wiki/Technical_FAQ#How_do_I_change_how_my_recipe_is_built_depending_on_what_image_I.27m_building.3F

(One day we'll figure out how to place this somewhere where people can more
easily find it).

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre




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

end of thread, other threads:[~2018-05-11  0:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10  7:37 Check IMAGE_FEATURES content in recipe Piotr Piwko
2018-05-10  8:46 ` ChenQi
2018-05-10  8:54   ` André Draszik
2018-05-10  8:59   ` Piotr Piwko
2018-05-10  9:22     ` Burton, Ross
2018-05-10 15:06       ` Marcelo E. Magallon
2018-05-11  0:04         ` Paul Eggleton
2018-05-10 10:54     ` Alexander Kanavin
2018-05-10 11:29       ` Piotr Piwko

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.