3.1 KiB
3.1 KiB
Create a Recipe
Creation
It may be better to use already existing recipes and customize them.
A recipe file must be named <name>_<version>.bb
(lowercase only)
To be enabled, the recipe must be available in the BBFILES
variable located in the conf/layer.conf
file
Recipe skeleton
SUMMARY = ""
HOMEPAGE = ""
LICENSE = ""
LIC_FILES_CHKSUM = ""
# Source download URI
SRC_URI = ""
SRC_URI[md5sum] = ""
SRC_URI[sha256sum] = ""
# Source folder
S = "${WORKDIR}/${PN}-${PV}"
# Classes to use
inherit <classname>
# Task definition
do_compile() {
${CC} helloworld.c -o helloworld
}
Configuration
Variable list
Variable | Content |
---|---|
PN |
Recipe name |
PV |
Recipe version |
PR |
Recipe revision |
WORKDIR |
Directory where sources are extracted and the recipe is built |
SRCREV |
Commit hash, Tag or branch to checkout if the sources are a repository |
SRC_URI |
Files to download (new-line separated list) |
DEPENDS |
Recipe build-time dependency list |
RDEPENDS_${PN} |
Recipe run-time dependency list |
Function list
Task/Function | Role |
---|---|
do_unpack() |
Unpacks the downloaded source code to ${S} .Automatically generated if the downloaded package is named <recipe_name>-<recipe_version>.* |
do_patch() |
Applies patches to source code. If SRC_URI contains a .patch or .diff file, it will automatically apply it to source code. |
do_configure() |
Configures the project (ie ./configure for Autotools).Automatically generated if the project uses Autotools or CMake. More |
do_compile() |
Commands to build the recipe Automatically generated for Autotools or CMake |
do_install() |
Commands to install on the system (into ${D}${bindir} )Automatically generated for Autotools or CMake |
pkg_postinst_<RECIPENAME>() |
Replace <RECIPENAME> with the recipe nameContains the commands to execute after the package installation. pkg_postinst_yolo(){ #!/bin/sh -e cp A B } |
Useful classes
To use some Yocto tools in recipes, you may need to inherit some packages:
Tool | Inheritance |
---|---|
Autotools | inherit autotools gettext |
SysVInit | inherit update-rc.d |
Enabling services
If do_install()
exists in the recipe add code to the end of the function, else write a do_install_append()
function that will contain the service initialization code.
SysVinit
You must add to the recipe:
inherit update-rc.d
# List of packages that contains initscripts
# Optional, default: ${PN}
#INITSCRIPT_PACKAGES
# Name of the init script installed in /etc/init.d
# Mandatory
INITSCRIPT_NAME = "${PN}"
# Parameters to pass to the init command
# Mandatory
INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ."
Build the recipe
bitbake <recipe_name>