diff options
Diffstat (limited to 'documentation/dev-manual/new-recipe.rst')
-rw-r--r-- | documentation/dev-manual/new-recipe.rst | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/documentation/dev-manual/new-recipe.rst b/documentation/dev-manual/new-recipe.rst index 9792bd4c1f..832aa300e1 100644 --- a/documentation/dev-manual/new-recipe.rst +++ b/documentation/dev-manual/new-recipe.rst | |||
@@ -188,13 +188,14 @@ the recipe. | |||
188 | Use lower-cased characters and do not include the reserved suffixes | 188 | Use lower-cased characters and do not include the reserved suffixes |
189 | ``-native``, ``-cross``, ``-initial``, or ``-dev`` casually (i.e. do not use | 189 | ``-native``, ``-cross``, ``-initial``, or ``-dev`` casually (i.e. do not use |
190 | them as part of your recipe name unless the string applies). Here are some | 190 | them as part of your recipe name unless the string applies). Here are some |
191 | examples: | 191 | examples (which includes the use of the string "git" as a special case of a |
192 | version identifier): | ||
192 | 193 | ||
193 | .. code-block:: none | 194 | .. code-block:: none |
194 | 195 | ||
195 | cups_1.7.0.bb | 196 | cups_2.4.12.bb |
196 | gawk_4.0.2.bb | 197 | gawk_5.3.2.bb |
197 | irssi_0.8.16-rc1.bb | 198 | psplash_git.bb |
198 | 199 | ||
199 | Running a Build on the Recipe | 200 | Running a Build on the Recipe |
200 | ============================= | 201 | ============================= |
@@ -276,11 +277,11 @@ upgrading the recipe to a future version is as simple as renaming the | |||
276 | recipe to match the new version. | 277 | recipe to match the new version. |
277 | 278 | ||
278 | Here is a simple example from the | 279 | Here is a simple example from the |
279 | ``meta/recipes-devtools/strace/strace_5.5.bb`` recipe where the source | 280 | :oe_git:`strace recipe </openembedded-core/tree/meta/recipes-devtools/strace>` |
280 | comes from a single tarball. Notice the use of the | 281 | where the source comes from a single tarball. Notice the use of the |
281 | :term:`PV` variable:: | 282 | :term:`PV` variable:: |
282 | 283 | ||
283 | SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \ | 284 | SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/strace-${PV}.tar.xz \ |
284 | 285 | ||
285 | Files mentioned in :term:`SRC_URI` whose names end in a typical archive | 286 | Files mentioned in :term:`SRC_URI` whose names end in a typical archive |
286 | extension (e.g. ``.tar``, ``.tar.gz``, ``.tar.bz2``, ``.zip``, and so | 287 | extension (e.g. ``.tar``, ``.tar.gz``, ``.tar.bz2``, ``.zip``, and so |
@@ -292,7 +293,7 @@ another example that specifies these types of files, see the | |||
292 | Another way of specifying source is from an SCM. For Git repositories, | 293 | Another way of specifying source is from an SCM. For Git repositories, |
293 | you must specify :term:`SRCREV` and you should specify :term:`PV` to include | 294 | you must specify :term:`SRCREV` and you should specify :term:`PV` to include |
294 | a ``+`` sign in its definition. Here is an example from the recipe | 295 | a ``+`` sign in its definition. Here is an example from the recipe |
295 | :oe_git:`meta/recipes-sato/l3afpad/l3afpad_git.bb </openembedded-core/tree/meta/recipes-sato/l3afpad/l3afpad_git.bb>`:: | 296 | :oe_git:`l3afpad_git.bb </openembedded-core/tree/meta/recipes-sato/l3afpad/l3afpad_git.bb>`:: |
296 | 297 | ||
297 | SRC_URI = "git://github.com/stevenhoneyman/l3afpad.git;branch=master;protocol=https" | 298 | SRC_URI = "git://github.com/stevenhoneyman/l3afpad.git;branch=master;protocol=https" |
298 | 299 | ||
@@ -347,8 +348,8 @@ paste them into your recipe and then run the build again to continue. | |||
347 | continuing with the build. | 348 | continuing with the build. |
348 | 349 | ||
349 | This final example is a bit more complicated and is from the | 350 | This final example is a bit more complicated and is from the |
350 | ``meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb`` recipe. The | 351 | :oe_git:`rxvt-unicode </openembedded-core/tree/meta/recipes-sato/rxvt-unicode>` |
351 | example's :term:`SRC_URI` statement identifies multiple files as the source | 352 | recipe. The example's :term:`SRC_URI` statement identifies multiple files as the source |
352 | files for the recipe: a tarball, a patch file, a desktop file, and an icon:: | 353 | files for the recipe: a tarball, a patch file, a desktop file, and an icon:: |
353 | 354 | ||
354 | SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \ | 355 | SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \ |
@@ -706,7 +707,7 @@ hierarchy to locations that would mirror their locations on the target | |||
706 | device. The installation process copies files from the | 707 | device. The installation process copies files from the |
707 | ``${``\ :term:`S`\ ``}``, | 708 | ``${``\ :term:`S`\ ``}``, |
708 | ``${``\ :term:`B`\ ``}``, and | 709 | ``${``\ :term:`B`\ ``}``, and |
709 | ``${``\ :term:`WORKDIR`\ ``}`` | 710 | ``${``\ :term:`UNPACKDIR`\ ``}`` |
710 | directories to the ``${``\ :term:`D`\ ``}`` | 711 | directories to the ``${``\ :term:`D`\ ``}`` |
711 | directory to create the structure as it should appear on the target | 712 | directory to create the structure as it should appear on the target |
712 | system. | 713 | system. |
@@ -1145,7 +1146,7 @@ Building an application from a single file that is stored locally (e.g. under | |||
1145 | ``files``) requires a recipe that has the file listed in the :term:`SRC_URI` | 1146 | ``files``) requires a recipe that has the file listed in the :term:`SRC_URI` |
1146 | variable. Additionally, you need to manually write the :ref:`ref-tasks-compile` | 1147 | variable. Additionally, you need to manually write the :ref:`ref-tasks-compile` |
1147 | and :ref:`ref-tasks-install` tasks. The :term:`S` variable defines the | 1148 | and :ref:`ref-tasks-install` tasks. The :term:`S` variable defines the |
1148 | directory containing the source code, which is set to :term:`WORKDIR` in this | 1149 | directory containing the source code, which is set to :term:`UNPACKDIR` in this |
1149 | case --- the directory BitBake uses for the build:: | 1150 | case --- the directory BitBake uses for the build:: |
1150 | 1151 | ||
1151 | SUMMARY = "Simple helloworld application" | 1152 | SUMMARY = "Simple helloworld application" |
@@ -1155,7 +1156,7 @@ case --- the directory BitBake uses for the build:: | |||
1155 | 1156 | ||
1156 | SRC_URI = "file://helloworld.c" | 1157 | SRC_URI = "file://helloworld.c" |
1157 | 1158 | ||
1158 | S = "${WORKDIR}" | 1159 | S = "${UNPACKDIR}" |
1159 | 1160 | ||
1160 | do_compile() { | 1161 | do_compile() { |
1161 | ${CC} ${LDFLAGS} helloworld.c -o helloworld | 1162 | ${CC} ${LDFLAGS} helloworld.c -o helloworld |
@@ -1211,8 +1212,6 @@ In the following example, ``lz4`` is a makefile-based package:: | |||
1211 | " | 1212 | " |
1212 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>.*)" | 1213 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>.*)" |
1213 | 1214 | ||
1214 | S = "${WORKDIR}/git" | ||
1215 | |||
1216 | CVE_STATUS[CVE-2014-4715] = "fixed-version: Fixed in r118, which is larger than the current version" | 1215 | CVE_STATUS[CVE-2014-4715] = "fixed-version: Fixed in r118, which is larger than the current version" |
1217 | 1216 | ||
1218 | EXTRA_OEMAKE = "PREFIX=${prefix} CC='${CC}' CFLAGS='${CFLAGS}' DESTDIR=${D} LIBDIR=${libdir} INCLUDEDIR=${includedir} BUILD_STATIC=no" | 1217 | EXTRA_OEMAKE = "PREFIX=${prefix} CC='${CC}' CFLAGS='${CFLAGS}' DESTDIR=${D} LIBDIR=${libdir} INCLUDEDIR=${includedir} BUILD_STATIC=no" |
@@ -1271,8 +1270,6 @@ is a simple example of an application without dependencies:: | |||
1271 | SRC_URI = "git://gitlab.com/ipcalc/ipcalc.git;protocol=https;branch=master" | 1270 | SRC_URI = "git://gitlab.com/ipcalc/ipcalc.git;protocol=https;branch=master" |
1272 | SRCREV = "4c4261a47f355946ee74013d4f5d0494487cc2d6" | 1271 | SRCREV = "4c4261a47f355946ee74013d4f5d0494487cc2d6" |
1273 | 1272 | ||
1274 | S = "${WORKDIR}/git" | ||
1275 | |||
1276 | inherit meson | 1273 | inherit meson |
1277 | 1274 | ||
1278 | Applications with dependencies are likely to inherit the | 1275 | Applications with dependencies are likely to inherit the |
@@ -1397,11 +1394,31 @@ doing the following: | |||
1397 | where you have installed them and whether those files are in | 1394 | where you have installed them and whether those files are in |
1398 | different locations than the defaults. | 1395 | different locations than the defaults. |
1399 | 1396 | ||
1397 | As a basic example of a :ref:`ref-classes-bin-package`-style recipe, consider | ||
1398 | this snippet from the | ||
1399 | :oe_git:`wireless-regdb </openembedded-core/tree/meta/recipes-kernel/wireless-regdb>` | ||
1400 | recipe file, which fetches a single tarball of binary content and manually | ||
1401 | installs with no need for any configuration or compilation:: | ||
1402 | |||
1403 | SRC_URI = "https://www.kernel.org/pub/software/network/${BPN}/${BP}.tar.xz" | ||
1404 | SRC_URI[sha256sum] = "57f8e7721cf5a880c13ae0c202edbb21092a060d45f9e9c59bcd2a8272bfa456" | ||
1405 | |||
1406 | inherit bin_package allarch | ||
1407 | |||
1408 | do_install() { | ||
1409 | install -d -m0755 ${D}${nonarch_libdir}/crda | ||
1410 | install -d -m0755 ${D}${sysconfdir}/wireless-regdb/pubkeys | ||
1411 | install -m 0644 regulatory.bin ${D}${nonarch_libdir}/crda/regulatory.bin | ||
1412 | install -m 0644 wens.key.pub.pem ${D}${sysconfdir}/wireless-regdb/pubkeys/wens.key.pub.pem | ||
1413 | install -m 0644 -D regulatory.db ${D}${nonarch_base_libdir}/firmware/regulatory.db | ||
1414 | install -m 0644 regulatory.db.p7s ${D}${nonarch_base_libdir}/firmware/regulatory.db.p7s | ||
1415 | } | ||
1416 | |||
1400 | Following Recipe Style Guidelines | 1417 | Following Recipe Style Guidelines |
1401 | ================================= | 1418 | ================================= |
1402 | 1419 | ||
1403 | When writing recipes, it is good to conform to existing style guidelines. | 1420 | When writing recipes, it is good to conform to existing style guidelines. |
1404 | See the ":doc:`../contributor-guide/recipe-style-guide`" in the Yocto Project | 1421 | See the ":doc:`/contributor-guide/recipe-style-guide`" in the Yocto Project |
1405 | and OpenEmbedded Contributor Guide for reference. | 1422 | and OpenEmbedded Contributor Guide for reference. |
1406 | 1423 | ||
1407 | It is common for existing recipes to deviate a bit from this style. | 1424 | It is common for existing recipes to deviate a bit from this style. |
@@ -1428,7 +1445,7 @@ chapter of the BitBake User Manual. | |||
1428 | The following example shows some of the ways you can use variables in | 1445 | The following example shows some of the ways you can use variables in |
1429 | recipes:: | 1446 | recipes:: |
1430 | 1447 | ||
1431 | S = "${WORKDIR}/postfix-${PV}" | 1448 | S = "${UNPACKDIR}/postfix-${PV}" |
1432 | CFLAGS += "-DNO_ASM" | 1449 | CFLAGS += "-DNO_ASM" |
1433 | CFLAGS:append = " --enable-important-feature" | 1450 | CFLAGS:append = " --enable-important-feature" |
1434 | 1451 | ||