# Create a Recipe ## Creation It may be better to use already existing recipes and customize them. A recipe file must be named `_.bb` (lowercase only) To be enabled, the recipe must be available in the `BBFILES` variable located in the `conf/layer.conf` file Recipe skeleton ```sh 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 # 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 `-.*`| |`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](http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#new-recipe-configuring-the-recipe)| |`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_()`|__Replace `` with the recipe name__
Contains 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`| [Full class list](http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#ref-classes) ## 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. [Details](http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#new-recipe-enabling-system-services) ### SysVinit You must add to the recipe: ```sh 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 `