[yocto] Check IMAGE_FEATURES content in recipe

Alexander Kanavin alexander.kanavin at linux.intel.com
Thu May 10 03:54:26 PDT 2018


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


More information about the yocto mailing list