2
1

adding-packages-tips.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Tips and tricks
  4. [[package-name-variable-relation]]
  5. ==== Package name, config entry name and makefile variable relationship
  6. In Buildroot, there is some relationship between:
  7. * the _package name_, which is the package directory name (and the
  8. name of the +*.mk+ file);
  9. * the config entry name that is declared in the +Config.in+ file;
  10. * the makefile variable prefix.
  11. It is mandatory to maintain consistency between these elements,
  12. using the following rules:
  13. * the package directory and the +*.mk+ name are the _package name_
  14. itself (e.g.: +package/foo-bar_boo/foo-bar_boo.mk+);
  15. * the _make_ target name is the _package name_ itself (e.g.:
  16. +foo-bar_boo+);
  17. * the config entry is the upper case _package name_ with `.` and `-`
  18. characters substituted with `_`, prefixed with +BR2_PACKAGE_+ (e.g.:
  19. +BR2_PACKAGE_FOO_BAR_BOO+);
  20. * the +*.mk+ file variable prefix is the upper case _package name_
  21. with `.` and `-` characters substituted with `_` (e.g.:
  22. +FOO_BAR_BOO_VERSION+).
  23. [[testing-package]]
  24. ==== How to test your package
  25. Once you have added your new package, it is important that you test it
  26. under various conditions: does it build for all architectures? Does it
  27. build with the different C libraries? Does it need threads, NPTL? And
  28. so on...
  29. Buildroot runs http://autobuild.buildroot.org/[autobuilders] which
  30. continuously test random configurations. However, these only build the
  31. `master` branch of the git tree, and your new fancy package is not yet
  32. there.
  33. Buildroot provides a script in +utils/test-pkg+ that uses the same base
  34. configurations as used by the autobuilders so you can test your package
  35. in the same conditions.
  36. First, create a config snippet that contains all the necessary options
  37. needed to enable your package, but without any architecture or toolchain
  38. option. For example, let's create a config snippet that just enables
  39. +libcurl+, without any TLS backend:
  40. ----
  41. $ cat libcurl.config
  42. BR2_PACKAGE_LIBCURL=y
  43. ----
  44. If your package needs more configuration options, you can add them to the
  45. config snippet. For example, here's how you would test +libcurl+ with
  46. +openssl+ as a TLS backend and the +curl+ program:
  47. ----
  48. $ cat libcurl.config
  49. BR2_PACKAGE_LIBCURL=y
  50. BR2_PACKAGE_CURL=y
  51. BR2_PACKAGE_OPENSSL=y
  52. ----
  53. Then run the +test-pkg+ script, by telling it what config snippet to use
  54. and what package to test:
  55. ----
  56. $ ./utils/test-pkg -c libcurl.config -p libcurl
  57. ----
  58. This will try to build your package against all the toolchains used
  59. by the autobuilders (except for the internal toolchains, because it takes
  60. too long to do so). The output lists all toolchains and the corresponding
  61. result (excerpt, results are fake):
  62. ----
  63. $ ./utils/test-pkg -c libcurl.config -p libcurl
  64. armv5-ctng-linux-gnueabi [ 1/11]: OK
  65. armv7-ctng-linux-gnueabihf [ 2/11]: OK
  66. br-aarch64-glibc [ 3/11]: SKIPPED
  67. br-arcle-hs38 [ 4/11]: SKIPPED
  68. br-arm-basic [ 5/11]: FAILED
  69. br-arm-cortex-a9-glibc [ 6/11]: OK
  70. br-arm-cortex-a9-musl [ 7/11]: FAILED
  71. br-arm-cortex-m4-full [ 8/11]: OK
  72. br-arm-full [ 9/11]: OK
  73. br-arm-full-nothread [10/11]: FAILED
  74. br-arm-full-static [11/11]: OK
  75. 11 builds, 2 skipped, 2 build failed, 1 legal-info failed
  76. ----
  77. The results mean:
  78. * `OK`: the build was successful.
  79. * `SKIPPED`: one or more configuration options listed in the config
  80. snippet were not present in the final configuration. This is due to
  81. options having dependencies not satisfied by the toolchain, such as
  82. for example a package that +depends on BR2_USE_MMU+ with a noMMU
  83. toolchain. The missing options are reported in +missing.config+ in
  84. the output build directory (+~/br-test-pkg/TOOLCHAIN_NAME/+ by
  85. default).
  86. * `FAILED`: the build failed. Inspect the +logfile+ file in the output
  87. build directory to see what went wrong:
  88. ** the actual build failed,
  89. ** the legal-info failed,
  90. ** one of the preliminary steps (downloading the config file, applying
  91. the configuration, running `dirclean` for the package) failed.
  92. When there are failures, you can just re-run the script with the same
  93. options (after you fixed your package); the script will attempt to
  94. re-build the package specified with +-p+ for all toolchains, without
  95. the need to re-build all the dependencies of that package.
  96. The +test-pkg+ script accepts a few options, for which you can get some
  97. help by running:
  98. ----
  99. $ ./utils/test-pkg -h
  100. ----
  101. [[github-download-url]]
  102. ==== How to add a package from GitHub
  103. Packages on GitHub often don't have a download area with release tarballs.
  104. However, it is possible to download tarballs directly from the repository
  105. on GitHub. As GitHub is known to have changed download mechanisms in the
  106. past, the 'github' helper function should be used as shown below.
  107. ------------------------
  108. # Use a tag or a full commit ID
  109. FOO_VERSION = v1.0
  110. FOO_SITE = $(call github,<user>,<package>,$(FOO_VERSION))
  111. ------------------------
  112. .Notes
  113. - The FOO_VERSION can either be a tag or a commit ID.
  114. - The tarball name generated by github matches the default one from
  115. Buildroot (e.g.: +foo-f6fb6654af62045239caed5950bc6c7971965e60.tar.gz+),
  116. so it is not necessary to specify it in the +.mk+ file.
  117. - When using a commit ID as version, you should use the full 40 hex characters.
  118. If the package you wish to add does have a release section on GitHub, the
  119. maintainer may have uploaded a release tarball, or the release may just point
  120. to the automatically generated tarball from the git tag. If there is a
  121. release tarball uploaded by the maintainer, we prefer to use that since it
  122. may be slightly different (e.g. it contains a configure script so we don't
  123. need to do AUTORECONF).
  124. You can see on the release page if it's an uploaded tarball or a git tag:
  125. image::github_hash_mongrel2.png[]
  126. - If it looks like the image above then it was uploaded by the
  127. maintainer and you should use that link (in that example:
  128. 'mongrel2-v1.9.2.tar.bz2') to specify +FOO_SITE+, and not use the
  129. 'github' helper.
  130. - On the other hand, if there's is *only* the "Source code" link, then
  131. it's an automatically generated tarball and you should use the
  132. 'github' helper function.