extendpoky.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  3. <chapter id='extendpoky'>
  4. <title>Extending Poky</title>
  5. <para>
  6. This section gives information about how to extend the functionality
  7. already present in Poky, documenting standard tasks such as adding new
  8. software packages, extending or customising images or porting poky to
  9. new hardware (adding a new machine). It also contains advice about how
  10. to manage the process of making changes to Poky to achieve best results.
  11. </para>
  12. <section id='usingpoky-extend-addpkg'>
  13. <title>Adding a Package</title>
  14. <para>
  15. To add package into Poky you need to write a recipe for it.
  16. Writing a recipe means creating a .bb file which sets various
  17. variables. The variables
  18. useful for recipes are detailed in the <link linkend='ref-varlocality-recipe-required'>
  19. recipe reference</link> section along with more detailed information
  20. about issues such as recipe naming.
  21. </para>
  22. <para>
  23. Before writing a recipe from scratch it is often useful to check
  24. someone else hasn't written one already. OpenEmbedded is a good place
  25. to look as it has a wider scope and hence a wider range of packages.
  26. Poky aims to be compatible with OpenEmbedded so most recipes should
  27. just work in Poky.
  28. </para>
  29. <para>
  30. For new packages, the simplest way to add a recipe is to base it on a similar
  31. pre-existing recipe. There are some examples below of how to add
  32. standard types of packages:
  33. </para>
  34. <section id='usingpoky-extend-addpkg-singlec'>
  35. <title>Single .c File Package (Hello World!)</title>
  36. <para>
  37. To build an application from a single file stored locally requires a
  38. recipe which has the file listed in the <glossterm><link
  39. linkend='var-SRC_URI'>SRC_URI</link></glossterm> variable. In addition
  40. the <function>do_compile</function> and <function>do_install</function>
  41. tasks need to be manually written. The <glossterm><link linkend='var-S'>
  42. S</link></glossterm> variable defines the directory containing the source
  43. code which in this case is set equal to <glossterm><link linkend='var-WORKDIR'>
  44. WORKDIR</link></glossterm>, the directory BitBake uses for the build.
  45. </para>
  46. <programlisting>
  47. DESCRIPTION = "Simple helloworld application"
  48. SECTION = "examples"
  49. LICENSE = "MIT"
  50. SRC_URI = "file://helloworld.c"
  51. S = "${WORKDIR}"
  52. do_compile() {
  53. ${CC} helloworld.c -o helloworld
  54. }
  55. do_install() {
  56. install -d ${D}${bindir}
  57. install -m 0755 helloworld ${D}${bindir}
  58. }
  59. </programlisting>
  60. <para>
  61. As a result of the build process "helloworld" and "helloworld-dbg"
  62. packages will be built.
  63. </para>
  64. </section>
  65. <section id='usingpoky-extend-addpkg-autotools'>
  66. <title>Autotooled Package</title>
  67. <para>
  68. Applications which use autotools (autoconf, automake)
  69. require a recipe which has a source archive listed in
  70. <glossterm><link
  71. linkend='var-SRC_URI'>SRC_URI</link></glossterm> and
  72. <command>inherit autotools</command> to instruct BitBake to use the
  73. <filename>autotools.bbclass</filename> which has
  74. definitions of all the steps
  75. needed to build an autotooled application.
  76. The result of the build will be automatically packaged and if
  77. the application uses NLS to localise then packages with
  78. locale information will be generated (one package per
  79. language).
  80. </para>
  81. <programlisting>
  82. DESCRIPTION = "GNU Helloworld application"
  83. SECTION = "examples"
  84. LICENSE = "GPLv2"
  85. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.bz2"
  86. inherit autotools
  87. </programlisting>
  88. </section>
  89. <section id='usingpoky-extend-addpkg-makefile'>
  90. <title>Makefile-Based Package</title>
  91. <para>
  92. Applications which use GNU make require a recipe which has
  93. the source archive listed in <glossterm><link
  94. linkend='var-SRC_URI'>SRC_URI</link></glossterm>.
  95. Adding a <function>do_compile</function> step
  96. is not needed as by default BitBake will start the "make"
  97. command to compile the application. If there is a need for
  98. additional options to make then they should be stored in the
  99. <glossterm><link
  100. linkend='var-EXTRA_OEMAKE'>EXTRA_OEMAKE</link></glossterm> variable - BitBake
  101. will pass them into the GNU
  102. make invocation. A <function>do_install</function> task is required
  103. - otherwise BitBake will run an empty <function>do_install</function>
  104. task by default.
  105. </para>
  106. <para>
  107. Some applications may require extra parameters to be passed to
  108. the compiler, for example an additional header path. This can
  109. be done buy adding to the <glossterm><link
  110. linkend='var-CFLAGS'>CFLAGS</link></glossterm> variable, as in the example below.
  111. </para>
  112. <programlisting>
  113. DESCRIPTION = "Tools for managing memory technology devices."
  114. SECTION = "base"
  115. DEPENDS = "zlib"
  116. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  117. LICENSE = "GPLv2"
  118. SRC_URI = "ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-${PV}.tar.gz"
  119. CFLAGS_prepend = "-I ${S}/include "
  120. do_install() {
  121. oe_runmake install DESTDIR=${D}
  122. }
  123. </programlisting>
  124. </section>
  125. <section id='usingpoky-extend-addpkg-files'>
  126. <title>Controlling packages content</title>
  127. <para>
  128. The variables <glossterm><link
  129. linkend='var-PACKAGES'>PACKAGES</link></glossterm> and
  130. <glossterm><link linkend='var-FILES'>FILES</link></glossterm> are used to split an
  131. application into multiple packages.
  132. </para>
  133. <para>
  134. Below the "libXpm" recipe is used as an example. By
  135. default the "libXpm" recipe generates one package
  136. which contains the library
  137. and also a few binaries. The recipe can be adapted to
  138. split the binaries into separate packages.
  139. </para>
  140. <programlisting>
  141. require xorg-lib-common.inc
  142. DESCRIPTION = "X11 Pixmap library"
  143. LICENSE = "X-BSD"
  144. DEPENDS += "libxext"
  145. XORG_PN = "libXpm"
  146. PACKAGES =+ "sxpm cxpm"
  147. FILES_cxpm = "${bindir}/cxpm"
  148. FILES_sxpm = "${bindir}/sxpm"
  149. </programlisting>
  150. <para>
  151. In this example we want to ship the "sxpm" and "cxpm" binaries
  152. in separate packages. Since "bindir" would be packaged into the
  153. main <glossterm><link linkend='var-PN'>PN</link></glossterm>
  154. package as standard we prepend the <glossterm><link
  155. linkend='var-PACKAGES'>PACKAGES</link></glossterm> variable so
  156. additional package names are added to the start of list. The
  157. extra <glossterm><link linkend='var-PN'>FILES</link></glossterm>_*
  158. variables then contain information to specify which files and
  159. directories goes into which package.
  160. </para>
  161. </section>
  162. <section id='usingpoky-extend-addpkg-postinstalls'>
  163. <title>Post Install Scripts</title>
  164. <para>
  165. To add a post-installation script to a package, add
  166. a <function>pkg_postinst_PACKAGENAME()</function>
  167. function to the .bb file
  168. where PACKAGENAME is the name of the package to attach
  169. the postinst script to. A post-installation function has the following structure:
  170. </para>
  171. <programlisting>
  172. pkg_postinst_PACKAGENAME () {
  173. #!/bin/sh -e
  174. # Commands to carry out
  175. }
  176. </programlisting>
  177. <para>
  178. The script defined in the post installation function
  179. gets called when the rootfs is made. If the script succeeds,
  180. the package is marked as installed. If the script fails,
  181. the package is marked as unpacked and the script will be
  182. executed again on the first boot of the image.
  183. </para>
  184. <para>
  185. Sometimes it is necessary that the execution of a post-installation
  186. script is delayed until the first boot, because the script
  187. needs to be executed on the device itself. To delay script execution
  188. until boot time, the post-installation function should have the
  189. following structure:
  190. </para>
  191. <programlisting>
  192. pkg_postinst_PACKAGENAME () {
  193. #!/bin/sh -e
  194. if [ x"$D" = "x" ]; then
  195. # Actions to carry out on the device go here
  196. else
  197. exit 1
  198. fi
  199. }
  200. </programlisting>
  201. <para>
  202. The structure above delays execution until first boot
  203. because the <glossterm><link
  204. linkend='var-D'>D</link></glossterm> variable points
  205. to the 'image'
  206. directory when the rootfs is being made at build time but
  207. is unset when executed on the first boot.
  208. </para>
  209. </section>
  210. </section>
  211. <section id='usingpoky-extend-customimage'>
  212. <title>Customising Images</title>
  213. <para>
  214. Poky images can be customised to satisfy
  215. particular requirements. Several methods are detailed below
  216. along with guidelines of when to use them.
  217. </para>
  218. <section id='usingpoky-extend-customimage-custombb'>
  219. <title>Customising Images through a custom image .bb files</title>
  220. <para>
  221. One way to get additional software into an image is by creating a
  222. custom image. The recipe will contain two lines:
  223. </para>
  224. <programlisting>
  225. IMAGE_INSTALL = "task-poky-x11-base package1 package2"
  226. inherit poky-image
  227. </programlisting>
  228. <para>
  229. By creating a custom image, a developer has total control
  230. over the contents of the image. It is important to use
  231. the correct names of packages in the <glossterm><link
  232. linkend='var-IMAGE_INSTALL'>IMAGE_INSTALL</link></glossterm> variable.
  233. The names must be in
  234. the OpenEmbedded notation instead of Debian notation, for example
  235. "glibc-dev" instead of "libc6-dev" etc.
  236. </para>
  237. <para>
  238. The other method of creating a new image is by modifying
  239. an existing image. For example if a developer wants to add
  240. "strace" into "poky-image-sato" the following recipe can
  241. be used:
  242. </para>
  243. <programlisting>
  244. require poky-image-sato.bb
  245. IMAGE_INSTALL += "strace"
  246. </programlisting>
  247. </section>
  248. <section id='usingpoky-extend-customimage-customtasks'>
  249. <title>Customising Images through custom tasks</title>
  250. <para>
  251. For complex custom images, the best approach is to create a custom
  252. task package which is then used to build the image (or images). A good
  253. example of a tasks package is <filename>meta/packages/tasks/task-poky.bb
  254. </filename>. The <glossterm><link linkend='var-PACKAGES'>PACKAGES</link></glossterm>
  255. variable lists the task packages to build (along with the complementary
  256. -dbg and -dev packages). For each package added,
  257. <glossterm><link linkend='var-PACKAGES'>RDEPENDS</link></glossterm> and
  258. <glossterm><link linkend='var-PACKAGES'>RRECOMMENDS</link></glossterm>
  259. entries can then be added each containing a list of packages the parent
  260. task package should contain. An example would be:
  261. </para>
  262. <para>
  263. <programlisting>
  264. DESCRIPTION = "My Custom Tasks"
  265. PACKAGES = "\
  266. task-custom-apps \
  267. task-custom-apps-dbg \
  268. task-custom-apps-dev \
  269. task-custom-tools \
  270. task-custom-tools-dbg \
  271. task-custom-tools-dev \
  272. "
  273. RDEPENDS_task-custom-apps = "\
  274. dropbear \
  275. portmap \
  276. psplash"
  277. RDEPENDS_task-custom-tools = "\
  278. oprofile \
  279. oprofileui-server \
  280. lttng-control \
  281. lttng-viewer"
  282. RRECOMMENDS_task-custom-tools = "\
  283. kernel-module-oprofile"
  284. </programlisting>
  285. </para>
  286. <para>
  287. In this example, two tasks packages are created, task-custom-apps and
  288. task-custom-tools with the dependencies and recommended package dependencies
  289. listed. To build an image using these task packages, you would then add
  290. "task-custom-apps" and/or "task-custom-tools" to <glossterm><link
  291. linkend='var-IMAGE_INSTALL'>IMAGE_INSTALL</link></glossterm> or other forms
  292. of image dependencies as described in other areas of this section.
  293. </para>
  294. </section>
  295. <section id='usingpoky-extend-customimage-imagefeatures'>
  296. <title>Customising Images through custom <glossterm><link linkend='var-IMAGE_FEATURES'>IMAGE_FEATURES</link></glossterm></title>
  297. <para>
  298. Ultimately users may want to add extra image "features" as used by Poky with the
  299. <glossterm><link linkend='var-IMAGE_FEATURES'>IMAGE_FEATURES</link></glossterm>
  300. variable. To create these, the best reference is <filename>meta/classes/poky-image.bbclass</filename>
  301. which illustrates how poky achieves this. In summary, the file looks at the contents of the
  302. <glossterm><link linkend='var-IMAGE_FEATURES'>IMAGE_FEATURES</link></glossterm>
  303. variable and based on this generates the <glossterm><link linkend='var-IMAGE_INSTALL'>
  304. IMAGE_INSTALL</link></glossterm> variable automatically. Extra features can be added by
  305. extending the class or creating a custom class for use with specialised image .bb files.
  306. </para>
  307. </section>
  308. <section id='usingpoky-extend-customimage-localconf'>
  309. <title>Customising Images through local.conf</title>
  310. <para>
  311. It is possible to customise image contents by abusing
  312. variables used by distribution maintainers in local.conf.
  313. This method only allows the addition of packages and
  314. is not recommended.
  315. </para>
  316. <para>
  317. To add an "strace" package into the image the following is
  318. added to local.conf:
  319. </para>
  320. <programlisting>
  321. DISTRO_EXTRA_RDEPENDS += "strace"
  322. </programlisting>
  323. <para>
  324. However, since the <glossterm><link linkend='var-DISTRO_EXTRA_RDEPENDS'>
  325. DISTRO_EXTRA_RDEPENDS</link></glossterm> variable is for
  326. distribution maintainers this method does not make
  327. adding packages as simple as a custom .bb file. Using
  328. this method, a few packages will need to be recreated
  329. and the the image built.
  330. </para>
  331. <programlisting>
  332. bitbake -cclean task-boot task-base task-poky
  333. bitbake poky-image-sato
  334. </programlisting>
  335. <para>
  336. Cleaning task-* packages is required because they use the
  337. <glossterm><link linkend='var-DISTRO_EXTRA_RDEPENDS'>
  338. DISTRO_EXTRA_RDEPENDS</link></glossterm> variable. There is no need to
  339. build them by hand as Poky images depend on the packages they contain so
  340. dependencies will be built automatically. For this reason we don't use the
  341. "rebuild" task in this case since "rebuild" does not care about
  342. dependencies - it only rebuilds the specified package.
  343. </para>
  344. </section>
  345. </section>
  346. <section id="platdev-newmachine">
  347. <title>Porting Poky to a new machine</title>
  348. <para>
  349. Adding a new machine to Poky is a straightforward process and
  350. this section gives an idea of the changes that are needed. This guide is
  351. meant to cover adding machines similar to those Poky already supports.
  352. Adding a totally new architecture might require gcc/glibc changes as
  353. well as updates to the site information and, whilst well within Poky's
  354. capabilities, is outside the scope of this section.
  355. </para>
  356. <section id="platdev-newmachine-conffile">
  357. <title>Adding the machine configuration file</title>
  358. <para>
  359. A .conf file needs to be added to conf/machine/ with details of the
  360. device being added. The name of the file determines the name Poky will
  361. use to reference this machine.
  362. </para>
  363. <para>
  364. The most important variables to set in this file are <glossterm>
  365. <link linkend='var-TARGET_ARCH'>TARGET_ARCH</link></glossterm>
  366. (e.g. "arm"), <glossterm><link linkend='var-PREFERRED_PROVIDER'>
  367. PREFERRED_PROVIDER</link></glossterm>_virtual/kernel (see below) and
  368. <glossterm><link linkend='var-MACHINE_FEATURES'>MACHINE_FEATURES
  369. </link></glossterm> (e.g. "kernel26 apm screen wifi"). Other variables
  370. like <glossterm><link linkend='var-SERIAL_CONSOLE'>SERIAL_CONSOLE
  371. </link></glossterm> (e.g. "115200 ttyS0"), <glossterm>
  372. <link linkend='var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</link>
  373. </glossterm> (e.g. "zImage") and <glossterm><link linkend='var-IMAGE_FSTYPES'>
  374. IMAGE_FSTYPES</link></glossterm> (e.g. "tar.gz jffs2") might also be
  375. needed. Full details on what these variables do and the meaning of
  376. their contents is available through the links.
  377. </para>
  378. </section>
  379. <section id="platdev-newmachine-kernel">
  380. <title>Adding a kernel for the machine</title>
  381. <para>
  382. Poky needs to be able to build a kernel for the machine. You need
  383. to either create a new kernel recipe for this machine or extend an
  384. existing recipe. There are plenty of kernel examples in the
  385. packages/linux directory which can be used as references.
  386. </para>
  387. <para>
  388. If creating a new recipe the "normal" recipe writing rules apply
  389. for setting up a <glossterm><link linkend='var-SRC_URI'>SRC_URI
  390. </link></glossterm> including any patches and setting <glossterm>
  391. <link linkend='var-S'>S</link></glossterm> to point at the source
  392. code. You will need to create a configure task which configures the
  393. unpacked kernel with a defconfig be that through a "make defconfig"
  394. command or more usually though copying in a suitable defconfig and
  395. running "make oldconfig". By making use of "inherit kernel" and also
  396. maybe some of the linux-*.inc files, most other functionality is
  397. centralised and the the defaults of the class normally work well.
  398. </para>
  399. <para>
  400. If extending an existing kernel it is usually a case of adding a
  401. suitable defconfig file in a location similar to that used by other
  402. machine's defconfig files in a given kernel, possibly listing it in
  403. the SRC_URI and adding the machine to the expression in <glossterm>
  404. <link linkend='var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</link>
  405. </glossterm>.
  406. </para>
  407. </section>
  408. <section id="platdev-newmachine-formfactor">
  409. <title>Adding a formfactor configuration file</title>
  410. <para>
  411. A formfactor configuration file provides information about the
  412. target hardware on which Poky is running, and that Poky cannot
  413. obtain from other sources such as the kernel. Some examples of
  414. information contained in a formfactor configuration file include
  415. framebuffer orientation, whether or not the system has a keyboard,
  416. the positioning of the keyboard in relation to the screen, and
  417. screen resolution.
  418. </para>
  419. <para>
  420. Sane defaults should be used in most cases, but if customisation is
  421. necessary you need to create a <filename>machconfig</filename> file
  422. under <filename>meta/packages/formfactor/files/MACHINENAME/</filename>
  423. where <literal>MACHINENAME</literal> is the name for which this infomation
  424. applies. For information about the settings available and the defaults, please see
  425. <filename>meta/packages/formfactor/files/config</filename>.
  426. </para>
  427. </section>
  428. </section>
  429. <section id='usingpoky-changes'>
  430. <title>Making and Maintaining Changes</title>
  431. <para>
  432. We recognise that people will want to extend/configure/optimise Poky for
  433. their specific uses, especially due to the extreme configurability and
  434. flexibility Poky offers. To ensure ease of keeping pace with future
  435. changes in Poky we recommend making changes to Poky in a controlled way.
  436. </para>
  437. <para>
  438. Poky supports the idea of <link
  439. linkend='usingpoky-changes-collections'>"collections"</link> which when used
  440. properly can massively ease future upgrades and allow segregation
  441. between the Poky core and a given developer's changes. Some other advice on
  442. managing changes to Poky is also given in the following section.
  443. </para>
  444. <section id="usingpoky-changes-collections">
  445. <title>Bitbake Collections</title>
  446. <para>
  447. Often, people want to extend Poky either through adding packages
  448. or overriding files contained within Poky to add their own
  449. functionality. Bitbake has a powerful mechanism called
  450. collections which provide a way to handle this which is fully
  451. supported and actively encouraged within Poky.
  452. </para>
  453. <para>
  454. In the standard tree, meta-extras is an example of how you can
  455. do this. As standard the data in meta-extras is not used on a
  456. Poky build but local.conf.sample shows how to enable it:
  457. </para>
  458. <para>
  459. <literallayout class='monospaced'>
  460. BBFILES := "${OEROOT}/meta/packages/*/*.bb ${OEROOT}/meta-extras/packages/*/*.bb"
  461. BBFILE_COLLECTIONS = "normal extras"
  462. BBFILE_PATTERN_normal = "^${OEROOT}/meta/"
  463. BBFILE_PATTERN_extras = "^${OEROOT}/meta-extras/"
  464. BBFILE_PRIORITY_normal = "5"
  465. BBFILE_PRIORITY_extras = "5"</literallayout>
  466. </para>
  467. <para>
  468. As can be seen, the extra recipes are added to BBFILES. The
  469. BBFILE_COLLECTIONS variable is then set to contain a list of
  470. collection names. The BBFILE_PATTERN variables are regular
  471. expressions used to match files from BBFILES into a particular
  472. collection in this case by using the base pathname.
  473. The BBFILE_PRIORITY variable then assigns the different
  474. priorities to the files in different collections. This is useful
  475. in situations where the same package might appear in both
  476. repositories and allows you to choose which collection should
  477. 'win'.
  478. </para>
  479. <para>
  480. This works well for recipes. For bbclasses and configuration
  481. files, you can use the BBPATH environment variable. In this
  482. case, the first file with the matching name found in BBPATH is
  483. the one that is used, just like the PATH variable for binaries.
  484. </para>
  485. </section>
  486. <section id="usingpoky-changes-supplement">
  487. <title>Supplementry Metadata Repositories</title>
  488. <para>
  489. Often when developing a project based on Poky there will be components
  490. that are not ready for public consumption for whatever reason. By making
  491. use of the collections mechanism and other functionality within Poky, it
  492. is possible to have a public repository which is supplemented by a private
  493. one just containing the pieces that need to be kept private.
  494. </para>
  495. <para>
  496. The usual approach with these is to create a separate git repository called
  497. "meta-prvt-XXX" which is checked out alongside the other meta-*
  498. directories included in Poky. Under this directory there can be several
  499. different directories such as classes, conf and packages which all
  500. function as per the usual Poky directory structure.
  501. </para>
  502. <para>
  503. If extra meta-* directories are found, Poky will automatically add them
  504. into the BBPATH variable so the conf and class files contained there
  505. are found. If a file called poky-extra-environment is found within the
  506. meta-* directory, this will be sourced as the environment is setup,
  507. allowing certain configuration to be overridden such as the location of the
  508. local.conf.sample file that is used.
  509. </para>
  510. <para>
  511. Note that at present, BBFILES is not automatically changed and this needs
  512. to be adjusted to find files in the packages/ directory. Usually a custom
  513. local.conf.sample file will be used to handle this instead.
  514. </para>
  515. </section>
  516. <section id='usingpoky-changes-commits'>
  517. <title>Committing Changes</title>
  518. <para>
  519. Modifications to Poky are often managed under some kind of source
  520. revision control system. The policy for committing to such systems
  521. is important as some simple policy can significantly improve
  522. usability. The tips below are based on the policy followed for the
  523. Poky core.
  524. </para>
  525. <para>
  526. It helps to use a consistent style for commit messages when committing
  527. changes. We've found a style where the first line of a commit message
  528. summarises the change and starts with the name of any package affected
  529. work well. Not all changes are to specific packages so the prefix could
  530. also be a machine name or class name instead. If a change needs a longer
  531. description this should follow the summary.
  532. </para>
  533. <para>
  534. Any commit should be self contained in that it should leave the
  535. metadata in a consistent state, buildable before and after the
  536. commit. This helps ensure the autobuilder test results are valid
  537. but is good practice regardless.
  538. </para>
  539. </section>
  540. <section id='usingpoky-changes-prbump'>
  541. <title>Package Revision Incrementing</title>
  542. <para>
  543. If a committed change will result in changing the package output
  544. then the value of the <glossterm><link linkend='var-PR'>PR</link>
  545. </glossterm> variable needs to be increased (commonly referred to
  546. as 'bumped') as part of that commit. Only integer values are used
  547. and <glossterm><link linkend='var-PR'>PR</link></glossterm> =
  548. "r0" should not be added into new recipes as this is default value.
  549. When upgrading the version of a package (<glossterm><link
  550. linkend='var-PV'>PV</link></glossterm>), the <glossterm><link
  551. linkend='var-PR'>PR</link></glossterm> variable should be removed.
  552. </para>
  553. <para>
  554. The aim is that the package version will only ever increase. If
  555. for some reason <glossterm><link linkend='var-PV'>PV</link></glossterm>
  556. will change and but not increase, the <glossterm><link
  557. linkend='var-PE'>PE</link></glossterm> (Package Epoch) can
  558. be increased (it defaults to '0'). The version numbers aim to
  559. follow the <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  560. Debian Version Field Policy Guidelines</ulink> which define how
  561. versions are compared and hence what "increasing" means.
  562. </para>
  563. <para>
  564. There are two reasons for doing this, the first is to ensure that
  565. when a developer updates and rebuilds, they get all the changes to
  566. the repository and don't have to remember to rebuild any sections.
  567. The second is to ensure that target users are able to upgrade their
  568. devices via their package manager such as with the <command>
  569. opkg update;opkg upgrade</command> commands (or similar for
  570. dpkg/apt or rpm based systems). The aim is to ensure Poky has
  571. upgradable packages in all cases.
  572. </para>
  573. </section>
  574. <section id='usingpoky-changes-collaborate'>
  575. <title>Using Poky in a Team Environment</title>
  576. <para>
  577. It may not be immediately clear how Poky can work in a team environment,
  578. or scale to a large team of developers. The specifics of any situation
  579. will determine the best solution and poky offers immense flexibility in
  580. that aspect but there are some practises that experience has shown to work
  581. well.
  582. </para>
  583. <para>
  584. The core component of any development effort with Poky is often an
  585. automated build testing framework and image generation process. This
  586. can be used to check that the metadata is buildable, highlight when
  587. commits break the builds and provide up to date images allowing people
  588. to test the end result and use them as a base platform for further
  589. development. Experience shows that buildbot is a good fit for this role
  590. and that it works well to configure it to make two types of build -
  591. incremental builds and 'from scratch'/full builds. The incremental builds
  592. can be tied to a commit hook which triggers them each time a commit is
  593. made to the metadata and are a useful acid test of whether a given commit
  594. breaks the build in some serious way. They catch lots of simple errors
  595. and whilst they won't catch 100% of failures, the tests are fast so
  596. developers can get feedback on their changes quickly. The full builds
  597. are builds that build everything from the ground up and test everything.
  598. They usually happen at preset times such as at night when the machine
  599. load isn't high from the incremental builds.
  600. </para>
  601. <para>
  602. Most teams have pieces of software undergoing active development. It is of
  603. significant benefit to put these under control of a source control system
  604. compatible with Poky such as git or svn. The autobuilder can then be set to
  605. pull the latest revisions of these packages so the latest commits get tested
  606. by the builds allowing any issues to be highlighted quickly. Poky easily
  607. supports configurations where there is both a stable known good revision
  608. and a floating revision to test. Poky can also only take changes from specific
  609. source control branches giving another way it can be used to track/test only
  610. specified changes.
  611. </para>
  612. <para>
  613. Perhaps the hardest part of setting this up is the policy that surrounds
  614. the different source control systems, be them software projects or the Poky
  615. metadata itself. The circumstances will be different in each case but this is
  616. one of Poky's advantages - the system itself doesn't force any particular policy
  617. unlike a lot of build systems, allowing the best policy to be chosen for the
  618. circumstances.
  619. </para>
  620. </section>
  621. </section>
  622. <section id='usingpoky-modifing-packages'>
  623. <title>Modifying Package Source Code</title>
  624. <para>
  625. Poky is usually used to build software rather than modifying
  626. it. However, there are ways Poky can be used to modify software.
  627. </para>
  628. <para>
  629. During building, the sources are available in <glossterm><link
  630. linkend='var-WORKDIR'>WORKDIR</link></glossterm> directory.
  631. Where exactly this is depends on the type of package and the
  632. architecture of target device. For a standard recipe not
  633. related to <glossterm><link
  634. linkend='var-MACHINE'>MACHINE</link></glossterm> it will be
  635. <filename>tmp/work/PACKAGE_ARCH-poky-TARGET_OS/PN-PV-PR/</filename>.
  636. Target device dependent packages use <glossterm><link
  637. linkend='var-MACHINE'>MACHINE
  638. </link></glossterm>
  639. instead of <glossterm><link linkend='var-PACKAGE_ARCH'>PACKAGE_ARCH
  640. </link></glossterm>
  641. in the directory name.
  642. </para>
  643. <tip>
  644. <para>
  645. Check the package recipe sets the <glossterm><link
  646. linkend='var-S'>S</link></glossterm> variable to something
  647. other than standard <filename>WORKDIR/PN-PV/</filename> value.
  648. </para>
  649. </tip>
  650. <para>
  651. After building a package, a user can modify the package source code
  652. without problem. The easiest way to test changes is by calling the
  653. "compile" task:
  654. </para>
  655. <programlisting>
  656. bitbake --cmd compile --force NAME_OF_PACKAGE
  657. </programlisting>
  658. <para>
  659. Other tasks may also be called this way.
  660. </para>
  661. <section id='usingpoky-modifying-packages-quilt'>
  662. <title>Modifying Package Source Code with quilt</title>
  663. <para>
  664. By default Poky uses <ulink
  665. url='http://savannah.nongnu.org/projects/quilt'>quilt</ulink>
  666. to manage patches in <function>do_patch</function> task.
  667. It is a powerful tool which can be used to track all
  668. modifications done to package sources.
  669. </para>
  670. <para>
  671. Before modifying source code it is important to
  672. notify quilt so it will track changes into new patch
  673. file:
  674. <programlisting>
  675. quilt new NAME-OF-PATCH.patch
  676. </programlisting>
  677. Then add all files which will be modified into that
  678. patch:
  679. <programlisting>
  680. quilt add file1 file2 file3
  681. </programlisting>
  682. Now start editing. At the end quilt needs to be used
  683. to generate final patch which will contain all
  684. modifications:
  685. <programlisting>
  686. quilt refresh
  687. </programlisting>
  688. The resulting patch file can be found in the
  689. <filename class="directory">patches/</filename> subdirectory of the source
  690. (<glossterm><link linkend='var-S'>S</link></glossterm>) directory. For future builds it
  691. should be copied into
  692. Poky metadata and added into <glossterm><link
  693. linkend='var-SRC_URI'>SRC_URI</link></glossterm> of a recipe:
  694. <programlisting>
  695. SRC_URI += "file://NAME-OF-PATCH.patch;patch=1"
  696. </programlisting>
  697. This also requires a bump of <glossterm><link
  698. linkend='var-PR'>PR</link></glossterm> value in the same recipe as we changed resulting packages.
  699. </para>
  700. </section>
  701. </section>
  702. </chapter>
  703. <!--
  704. vim: expandtab tw=80 ts=4
  705. -->