upgrading-recipes.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Upgrading Recipes
  3. *****************
  4. Over time, upstream developers publish new versions for software built
  5. by layer recipes. It is recommended to keep recipes up-to-date with
  6. upstream version releases.
  7. While there are several methods to upgrade a recipe, you might
  8. consider checking on the upgrade status of a recipe first. You can do so
  9. using the ``devtool check-upgrade-status`` command. See the
  10. ":ref:`devtool-checking-on-the-upgrade-status-of-a-recipe`"
  11. section in the Yocto Project Reference Manual for more information.
  12. The remainder of this section describes three ways you can upgrade a
  13. recipe. You can use the Automated Upgrade Helper (AUH) to set up
  14. automatic version upgrades. Alternatively, you can use
  15. ``devtool upgrade`` to set up semi-automatic version upgrades. Finally,
  16. you can manually upgrade a recipe by editing the recipe itself.
  17. Using the Auto Upgrade Helper (AUH)
  18. ===================================
  19. The AUH utility works in conjunction with the OpenEmbedded build system
  20. in order to automatically generate upgrades for recipes based on new
  21. versions being published upstream. Use AUH when you want to create a
  22. service that performs the upgrades automatically and optionally sends
  23. you an email with the results.
  24. AUH allows you to update several recipes with a single use. You can also
  25. optionally perform build and integration tests using images with the
  26. results saved to your hard drive and emails of results optionally sent
  27. to recipe maintainers. Finally, AUH creates Git commits with appropriate
  28. commit messages in the layer's tree for the changes made to recipes.
  29. .. note::
  30. In some conditions, you should not use AUH to upgrade recipes
  31. and should instead use either ``devtool upgrade`` or upgrade your
  32. recipes manually:
  33. - When AUH cannot complete the upgrade sequence. This situation
  34. usually results because custom patches carried by the recipe
  35. cannot be automatically rebased to the new version. In this case,
  36. ``devtool upgrade`` allows you to manually resolve conflicts.
  37. - When for any reason you want fuller control over the upgrade
  38. process. For example, when you want special arrangements for
  39. testing.
  40. The following steps describe how to set up the AUH utility:
  41. #. *Be Sure the Development Host is Set Up:* You need to be sure that
  42. your development host is set up to use the Yocto Project. For
  43. information on how to set up your host, see the
  44. ":ref:`dev-manual/start:Preparing the Build Host`" section.
  45. #. *Make Sure Git is Configured:* The AUH utility requires Git to be
  46. configured because AUH uses Git to save upgrades. Thus, you must have
  47. Git user and email configured. The following command shows your
  48. configurations::
  49. $ git config --list
  50. If you do not have the user and
  51. email configured, you can use the following commands to do so::
  52. $ git config --global user.name some_name
  53. $ git config --global user.email username@domain.com
  54. #. *Clone the AUH Repository:* To use AUH, you must clone the repository
  55. onto your development host. The following command uses Git to create
  56. a local copy of the repository on your system::
  57. $ git clone git://git.yoctoproject.org/auto-upgrade-helper
  58. Cloning into 'auto-upgrade-helper'... remote: Counting objects: 768, done.
  59. remote: Compressing objects: 100% (300/300), done.
  60. remote: Total 768 (delta 499), reused 703 (delta 434)
  61. Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done.
  62. Resolving deltas: 100% (499/499), done.
  63. Checking connectivity... done.
  64. AUH is not part of the :term:`OpenEmbedded-Core (OE-Core)` or
  65. :term:`Poky` repositories.
  66. #. *Create a Dedicated Build Directory:* Run the :ref:`structure-core-script`
  67. script to create a fresh :term:`Build Directory` that you use exclusively
  68. for running the AUH utility::
  69. $ cd poky
  70. $ source oe-init-build-env your_AUH_build_directory
  71. Re-using an existing :term:`Build Directory` and its configurations is not
  72. recommended as existing settings could cause AUH to fail or behave
  73. undesirably.
  74. #. *Make Configurations in Your Local Configuration File:* Several
  75. settings are needed in the ``local.conf`` file in the build
  76. directory you just created for AUH. Make these following
  77. configurations:
  78. - If you want to enable :ref:`Build
  79. History <dev-manual/build-quality:maintaining build output quality>`,
  80. which is optional, you need the following lines in the
  81. ``conf/local.conf`` file::
  82. INHERIT =+ "buildhistory"
  83. BUILDHISTORY_COMMIT = "1"
  84. With this configuration and a successful
  85. upgrade, a build history "diff" file appears in the
  86. ``upgrade-helper/work/recipe/buildhistory-diff.txt`` file found in
  87. your :term:`Build Directory`.
  88. - If you want to enable testing through the :ref:`ref-classes-testimage`
  89. class, which is optional, you need to have the following set in
  90. your ``conf/local.conf`` file::
  91. IMAGE_CLASSES += "testimage"
  92. .. note::
  93. If your distro does not enable by default ptest, which Poky
  94. does, you need the following in your ``local.conf`` file::
  95. DISTRO_FEATURES:append = " ptest"
  96. #. *Optionally Start a vncserver:* If you are running in a server
  97. without an X11 session, you need to start a vncserver::
  98. $ vncserver :1
  99. $ export DISPLAY=:1
  100. #. *Create and Edit an AUH Configuration File:* You need to have the
  101. ``upgrade-helper/upgrade-helper.conf`` configuration file in your
  102. :term:`Build Directory`. You can find a sample configuration file in the
  103. :yocto_git:`AUH source repository </auto-upgrade-helper/tree/>`.
  104. Read through the sample file and make configurations as needed. For
  105. example, if you enabled build history in your ``local.conf`` as
  106. described earlier, you must enable it in ``upgrade-helper.conf``.
  107. Also, if you are using the default ``maintainers.inc`` file supplied
  108. with Poky and located in ``meta-yocto`` and you do not set a
  109. "maintainers_whitelist" or "global_maintainer_override" in the
  110. ``upgrade-helper.conf`` configuration, and you specify "-e all" on
  111. the AUH command-line, the utility automatically sends out emails to
  112. all the default maintainers. Please avoid this.
  113. This next set of examples describes how to use the AUH:
  114. - *Upgrading a Specific Recipe:* To upgrade a specific recipe, use the
  115. following form::
  116. $ upgrade-helper.py recipe_name
  117. For example, this command upgrades the ``xmodmap`` recipe::
  118. $ upgrade-helper.py xmodmap
  119. - *Upgrading a Specific Recipe to a Particular Version:* To upgrade a
  120. specific recipe to a particular version, use the following form::
  121. $ upgrade-helper.py recipe_name -t version
  122. For example, this command upgrades the ``xmodmap`` recipe to version 1.2.3::
  123. $ upgrade-helper.py xmodmap -t 1.2.3
  124. - *Upgrading all Recipes to the Latest Versions and Suppressing Email
  125. Notifications:* To upgrade all recipes to their most recent versions
  126. and suppress the email notifications, use the following command::
  127. $ upgrade-helper.py all
  128. - *Upgrading all Recipes to the Latest Versions and Send Email
  129. Notifications:* To upgrade all recipes to their most recent versions
  130. and send email messages to maintainers for each attempted recipe as
  131. well as a status email, use the following command::
  132. $ upgrade-helper.py -e all
  133. Once you have run the AUH utility, you can find the results in the AUH
  134. :term:`Build Directory`::
  135. ${BUILDDIR}/upgrade-helper/timestamp
  136. The AUH utility
  137. also creates recipe update commits from successful upgrade attempts in
  138. the layer tree.
  139. You can easily set up to run the AUH utility on a regular basis by using
  140. a cron job. See the
  141. :yocto_git:`weeklyjob.sh </auto-upgrade-helper/tree/weeklyjob.sh>`
  142. file distributed with the utility for an example.
  143. Using ``devtool upgrade``
  144. =========================
  145. As mentioned earlier, an alternative method for upgrading recipes to
  146. newer versions is to use
  147. :doc:`devtool upgrade </ref-manual/devtool-reference>`.
  148. You can read about ``devtool upgrade`` in general in the
  149. ":ref:`dev-manual/devtool:use \`\`devtool upgrade\`\` to create a version of the recipe that supports a newer version of the software`"
  150. section in the Yocto Project Application Development and the Extensible
  151. Software Development Kit (eSDK) Manual.
  152. To see all the command-line options available with ``devtool upgrade``,
  153. use the following help command::
  154. $ devtool upgrade -h
  155. If you want to find out what version a recipe is currently at upstream
  156. without any attempt to upgrade your local version of the recipe, you can
  157. use the following command::
  158. $ devtool latest-version recipe_name
  159. As mentioned in the previous section describing AUH, ``devtool upgrade``
  160. works in a less-automated manner than AUH. Specifically,
  161. ``devtool upgrade`` only works on a single recipe that you name on the
  162. command line, cannot perform build and integration testing using images,
  163. and does not automatically generate commits for changes in the source
  164. tree. Despite all these "limitations", ``devtool upgrade`` updates the
  165. recipe file to the new upstream version and attempts to rebase custom
  166. patches contained by the recipe as needed.
  167. .. note::
  168. AUH uses much of ``devtool upgrade`` behind the scenes making AUH somewhat
  169. of a "wrapper" application for ``devtool upgrade``.
  170. A typical scenario involves having used Git to clone an upstream
  171. repository that you use during build operations. Because you have built the
  172. recipe in the past, the layer is likely added to your
  173. configuration already. If for some reason, the layer is not added, you
  174. could add it easily using the
  175. ":ref:`bitbake-layers <bsp-guide/bsp:creating a new bsp layer using the \`\`bitbake-layers\`\` script>`"
  176. script. For example, suppose you use the ``nano.bb`` recipe from the
  177. ``meta-oe`` layer in the ``meta-openembedded`` repository. For this
  178. example, assume that the layer has been cloned into following area::
  179. /home/scottrif/meta-openembedded
  180. The following command from your :term:`Build Directory` adds the layer to
  181. your build configuration (i.e. ``${BUILDDIR}/conf/bblayers.conf``)::
  182. $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe
  183. NOTE: Starting bitbake server...
  184. Parsing recipes: 100% |##########################################| Time: 0:00:55
  185. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  186. Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00
  187. Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00
  188. Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00
  189. Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00
  190. For this example, assume that the ``nano.bb`` recipe that
  191. is upstream has a 2.9.3 version number. However, the version in the
  192. local repository is 2.7.4. The following command from your build
  193. directory automatically upgrades the recipe for you::
  194. $ devtool upgrade nano -V 2.9.3
  195. NOTE: Starting bitbake server...
  196. NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace
  197. Parsing recipes: 100% |##########################################| Time: 0:00:46
  198. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  199. NOTE: Extracting current version source...
  200. NOTE: Resolving any missing task queue dependencies
  201. .
  202. .
  203. .
  204. NOTE: Executing SetScene Tasks
  205. NOTE: Executing RunQueue Tasks
  206. NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded.
  207. Adding changed files: 100% |#####################################| Time: 0:00:00
  208. NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano
  209. NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb
  210. .. note::
  211. Using the ``-V`` option is not necessary. Omitting the version number causes
  212. ``devtool upgrade`` to upgrade the recipe to the most recent version.
  213. Continuing with this example, you can use ``devtool build`` to build the
  214. newly upgraded recipe::
  215. $ devtool build nano
  216. NOTE: Starting bitbake server...
  217. Loading cache: 100% |################################################################################################| Time: 0:00:01
  218. Loaded 2040 entries from dependency cache.
  219. Parsing recipes: 100% |##############################################################################################| Time: 0:00:00
  220. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  221. NOTE: Resolving any missing task queue dependencies
  222. .
  223. .
  224. .
  225. NOTE: Executing SetScene Tasks
  226. NOTE: Executing RunQueue Tasks
  227. NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano
  228. NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded.
  229. Within the ``devtool upgrade`` workflow, you can
  230. deploy and test your rebuilt software. For this example,
  231. however, running ``devtool finish`` cleans up the workspace once the
  232. source in your workspace is clean. This usually means using Git to stage
  233. and submit commits for the changes generated by the upgrade process.
  234. Once the tree is clean, you can clean things up in this example with the
  235. following command from the ``${BUILDDIR}/workspace/sources/nano``
  236. directory::
  237. $ devtool finish nano meta-oe
  238. NOTE: Starting bitbake server...
  239. Loading cache: 100% |################################################################################################| Time: 0:00:00
  240. Loaded 2040 entries from dependency cache.
  241. Parsing recipes: 100% |##############################################################################################| Time: 0:00:01
  242. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  243. NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch
  244. NOTE: Updating recipe nano_2.9.3.bb
  245. NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb
  246. NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano
  247. NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually
  248. Using the ``devtool finish`` command cleans up the workspace and creates a patch
  249. file based on your commits. The tool puts all patch files back into the
  250. source directory in a sub-directory named ``nano`` in this case.
  251. Manually Upgrading a Recipe
  252. ===========================
  253. If for some reason you choose not to upgrade recipes using
  254. :ref:`dev-manual/upgrading-recipes:Using the Auto Upgrade Helper (AUH)` or
  255. by :ref:`dev-manual/upgrading-recipes:Using ``devtool upgrade```,
  256. you can manually edit the recipe files to upgrade the versions.
  257. .. note::
  258. Manually updating multiple recipes scales poorly and involves many
  259. steps. The recommendation to upgrade recipe versions is through AUH
  260. or ``devtool upgrade``, both of which automate some steps and provide
  261. guidance for others needed for the manual process.
  262. To manually upgrade recipe versions, follow these general steps:
  263. #. *Change the Version:* Rename the recipe such that the version (i.e.
  264. the :term:`PV` part of the recipe name)
  265. changes appropriately. If the version is not part of the recipe name,
  266. change the value as it is set for :term:`PV` within the recipe itself.
  267. #. *Update* :term:`SRCREV` *if Needed*: If the source code your recipe builds
  268. is fetched from Git or some other version control system, update
  269. :term:`SRCREV` to point to the
  270. commit hash that matches the new version.
  271. #. *Build the Software:* Try to build the recipe using BitBake. Typical
  272. build failures include the following:
  273. - License statements were updated for the new version. For this
  274. case, you need to review any changes to the license and update the
  275. values of :term:`LICENSE` and
  276. :term:`LIC_FILES_CHKSUM`
  277. as needed.
  278. .. note::
  279. License changes are often inconsequential. For example, the
  280. license text's copyright year might have changed.
  281. - Custom patches carried by the older version of the recipe might
  282. fail to apply to the new version. For these cases, you need to
  283. review the failures. Patches might not be necessary for the new
  284. version of the software if the upgraded version has fixed those
  285. issues. If a patch is necessary and failing, you need to rebase it
  286. into the new version.
  287. #. *Optionally Attempt to Build for Several Architectures:* Once you
  288. successfully build the new software for a given architecture, you
  289. could test the build for other architectures by changing the
  290. :term:`MACHINE` variable and
  291. rebuilding the software. This optional step is especially important
  292. if the recipe is to be released publicly.
  293. #. *Check the Upstream Change Log or Release Notes:* Checking both these
  294. reveals if there are new features that could break
  295. backwards-compatibility. If so, you need to take steps to mitigate or
  296. eliminate that situation.
  297. #. *Optionally Create a Bootable Image and Test:* If you want, you can
  298. test the new software by booting it onto actual hardware.
  299. #. *Create a Commit with the Change in the Layer Repository:* After all
  300. builds work and any testing is successful, you can create commits for
  301. any changes in the layer holding your upgraded recipe.