diff --git a/documentation/dev-manual/dev-manual-common-tasks.xml b/documentation/dev-manual/dev-manual-common-tasks.xml index c8aec0702c..1f552d8d3b 100644 --- a/documentation/dev-manual/dev-manual-common-tasks.xml +++ b/documentation/dev-manual/dev-manual-common-tasks.xml @@ -2142,6 +2142,87 @@ +
+ Post-Installation Scripts + + + Post-installation scripts run immediately after installing + a package on the target, or during image creation when a + package is included in an image. + To add a post-installation script to a package, add a + pkg_postinst_PACKAGENAME() function to + the .bb file and use + PACKAGENAME as the name of the package + you want to attach to the postinst + script. + To apply the post-installation script to the main package + for the recipe, which is usually what is required, specify + ${PN} + in place of PACKAGENAME. + + + + A post-installation function has the following structure: + + pkg_postinst_PACKAGENAME () { + #!/bin/sh -e + # Commands to carry out + } + + + + + The script defined in the post-installation function is + called when the root filesystem is created. + If the script succeeds, the package is marked as installed. + If the script fails, the package is marked as unpacked and + the script is executed when the image boots again. + + + + Sometimes it is necessary for the execution of a + post-installation script to be delayed until the first boot. + For example, the script might need to be executed on the + device itself. + To delay script execution until boot time, use the following + structure in the post-installation script: + + pkg_postinst_PACKAGENAME () { + #!/bin/sh -e + if [ x"$D" = "x" ]; then + # Actions to carry out on the device go here + else + exit 1 + fi + } + + + + + The previous example delays execution until the image boots + again because the + D + variable points to the directory containing the image when + the root filesystem is created at build time but is unset + when executed on the first boot. + + + + Equivalent support for pre-install, + pre-uninstall, and + post-uninstall scripts exist + by way of pkg_preinst, + pkg_prerm, and + pkg_postrm, respectively. + These scrips work in exactly the same way as does + pkg_postinst with the exception that they + run at different times. + Also, because of when they run, they are not applicable to + being run at image creation time like + pkg_postinst. + +
+
Testing @@ -2171,7 +2252,6 @@ Using an Autotooled package Using a Makefile-based package Splitting an application into multiple packages - Installing a post-initialization script @@ -2193,11 +2273,10 @@ WORKDIR in this case - the directory BitBake uses for the build. - DESCRIPTION = "Simple helloworld application" + SUMMARY = "Simple helloworld application" SECTION = "examples" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" - PR = "r0" SRC_URI = "file://helloworld.c" @@ -2240,11 +2319,10 @@ generated (one package per language). Following is one example: (hello_2.3.bb) - DESCRIPTION = "GNU Helloworld application" + SUMMARY = "GNU Helloworld application" SECTION = "examples" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" - PR = "r0" SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz" @@ -2292,7 +2370,7 @@ In the following example, mtd-utils is a makefile-based package: - DESCRIPTION = "Tools for managing memory technology devices." + SUMMARY = "Tools for managing memory technology devices." SECTION = "base" DEPENDS = "zlib lzo e2fsprogs util-linux" HOMEPAGE = "http://www.linux-mtd.infradead.org/" @@ -2324,26 +2402,6 @@ BBCLASSEXTEND = "native" - - - If your sources are available as a tarball instead of a Git repository, you - will need to provide the URL to the tarball as well as an - md5 or sha256 sum of - the download. - Here is an example: - - SRC_URI="ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.4.9.tar.bz2" - SRC_URI[md5sum]="82b8e714b90674896570968f70ca778b" - - You can generate the md5 or sha256 sums - by using the md5sum or sha256sum commands - with the target file as the only argument. - Here is an example: - - $ md5sum mtd-utils-1.4.9.tar.bz2 - 82b8e714b90674896570968f70ca778b mtd-utils-1.4.9.tar.bz2 - -
@@ -2357,21 +2415,21 @@ - Following is an example that uses the libXpm recipe. + Following is an example that uses the libxpm recipe. By default, this recipe generates a single package that contains the library along with a few binaries. You can modify the recipe to split the binaries into separate packages: require xorg-lib-common.inc - DESCRIPTION = "X11 Pixmap library" + SUMMARY = "X11 Pixmap library" LICENSE = "X-BSD" LIC_FILES_CHKSUM = "file://COPYING;md5=3e07763d16963c3af12db271a31abaa5" DEPENDS += "libxext libsm libxt" PR = "r3" PE = "1" - XORG_PN = "libXpm" + XORG_PN = "libxpm" PACKAGES =+ "sxpm cxpm" FILES_cxpm = "${bindir}/cxpm" @@ -2394,62 +2452,6 @@ does not include the above listed files.
- -
- Post-Installation Scripts - - - To add a post-installation script to a package, add a - pkg_postinst_PACKAGENAME() function to the - .bb file and use - PACKAGENAME as the name of the package you want to attach to the - postinst script. - Normally, - PN - can be used, which automatically expands to PACKAGENAME. - A post-installation function has the following structure: - - pkg_postinst_PACKAGENAME () { - #!/bin/sh -e - # Commands to carry out - } - - - - - The script defined in the post-installation function is called when the - root filesystem is created. - If the script succeeds, the package is marked as installed. - If the script fails, the package is marked as unpacked and the script is - executed when the image boots again. - - - - Sometimes it is necessary for the execution of a post-installation - script to be delayed until the first boot. - For example, the script might need to be executed on the device itself. - To delay script execution until boot time, use the following structure in the - post-installation script: - - pkg_postinst_PACKAGENAME () { - #!/bin/sh -e - if [ x"$D" = "x" ]; then - # Actions to carry out on the device go here - else - exit 1 - fi - } - - - - - The previous example delays execution until the image boots again because the - D - variable points - to the directory containing the image when the root filesystem is created at build time but - is unset when executed on the first boot. - -