[yocto] Image specific configuration files

Iván Castell icastell at nayarsystems.com
Wed Jun 13 03:22:52 PDT 2018


Very useful information!
This is the first time I understand this bbclass and BBCLASSEXTEND
mechanism (I was unable to understand it after reading documentation again
and again).
I managed implementing a custom but working solution.
Thanks a lot for sharing Mr Ulf! :)


2018-06-01 13:44 GMT+02:00 Ulf Samuelsson <
ulf.samuelsson at external.atlascopco.com>:

> Here is the idea developed at Atlas Copco.
>
> Not my code, but I thought it useful for this problem
>
>
> define three bbclasses.
>
> production.bbclass, rnd.bbclass, release.bbclass containing:
>
> ==========================
>
> # Class for use in BBCLASSEXTEND to make it easier to have a single recipe
> that
> # build and generate packages separately for release and normal images.
> #
> # Usage:
> # BBCLASSEXTEND = "release"
>
> CLASSOVERRIDE .= ":class-release"
>
> python release_virtclass_handler () {
>     # Do nothing if this is inherited, as it's for BBCLASSEXTEND
>     if "release" not in (d.getVar('BBCLASSEXTEND') or ""):
>         bb.error("Don't inherit release, use BBCLASSEXTEND")
>         return
>
>     # Restore BPN
>     bpn = d.getVar('BPN')
>     newbpn = bpn.replace('-release', '')
>     d.setVar('BPN', newbpn)
>
>     # Use default FILESPATH searching for patches and files
>     filespath = d.getVar('FILESPATH', True)
>     newfilespath = filespath.replace('-release', '')
>     d.setVar('FILESPATH', newfilespath)
> }
>
> addhandler release_virtclass_handler
> release_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
>
> ==========================
> In a bbappend you use the classes:
>
>
> ==========================
>
> SRC_URI_append_class-production = " \
>     file://rcS.production \
> "
>
> SRC_URI_append_class-rnd = " \
>     file://rcS.rnd \
> "
>
> SRC_URI_append_class-release = " \
>     file://rcS.release \
> "
>
> do_install_append_class-production () {
>     install -m 755 ${WORKDIR}/rcS.production ${D}${sysconfdir}/init.d/rcS
> }
>
> do_install_append_class-rnd () {
>     install -m 755 ${WORKDIR}/rcS.rnd ${D}${sysconfdir}/init.d/rcS
> }
>
> do_install_append_class-release () {
>     install -m 755 ${WORKDIR}/rcS.release ${D}${sysconfdir}/init.d/rcS
> }
>
> BBCLASSEXTEND = "production rnd release"
>
> ==========================
>
> In your production image you add
>
> IMAGE_INSTALL_append = "busybox-production"
>
>
> Do something similar for the other two.
>
> BR
>
> Ulf Samuelsson
> ------------------------------
> *Från:* yocto-bounces at yoctoproject.org <yocto-bounces at yoctoproject.org>
> för Damien LEFEVRE <lefevre.da at gmail.com>
> *Skickat:* den 1 juni 2018 13:17:53
> *Till:* Iván Castell
> *Kopia:* Yocto discussion list
> *Ämne:* Re: [yocto] Image specific configuration files
>
> Thanks a lot everyone, this is very helpful =)
>
> On Fri, Jun 1, 2018 at 2:14 PM, Iván Castell <icastell at nayarsystems.com>
> wrote:
>
>
>
> 2018-06-01 11:24 GMT+02:00 Alexander Kanavin <alex.kanavin at gmail.com>:
>
> I have to say defining multiple distros and then tweaking recipes
> according to those definitions is not a good practice, as recipes should
> generally only access DISTRO_FEATURES and otherwise be distro-agnostic. The
> above iptables scenario should be handled with different image recipes,
> which pull in (via packages) or create different configurations.
>
>
>
> That has sense. We will refactorize our Yocto repo as suggested. Always
> very helpfull with all your comments Mr Alexander. Thank you very much! :)
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180613/b7862095/attachment-0001.html>


More information about the yocto mailing list