patch-policy.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // -*- mode:doc; -*-
  2. [[patch-policy]]
  3. Patch Policy
  4. ------------
  5. While integrating a new package or updating an existing one, it may be
  6. necessary to patch the source of the software to get it built within
  7. Buildroot.
  8. Buildroot offers an infrastructure to automatically handle this during
  9. the builds. It supports several ways of applying patch sets:
  10. Providing patches
  11. ~~~~~~~~~~~~~~~~~
  12. Additional tarball
  13. ^^^^^^^^^^^^^^^^^^
  14. If it is necessary to apply a patch set available as a downloadable
  15. tarball, then add the patch tarball to the +<packagename>_PATCH+
  16. variable.
  17. Note that the patch tarballs are downloaded from the same site as the
  18. sources.
  19. Within Buildroot
  20. ^^^^^^^^^^^^^^^^
  21. Most patches are provided within Buildroot, in the package
  22. directory; these typically aim to fix cross-compilation, +libc+ support,
  23. or other such issues.
  24. These patch files should have the extension +*.patch+.
  25. A +series+ file, as used by +quilt+, may also be added in the
  26. package directory. In that case, the +series+ file defines the patch
  27. application order.
  28. How patches are applied
  29. ~~~~~~~~~~~~~~~~~~~~~~~
  30. . Run the +<packagename>_PRE_PATCH_HOOKS+ commands if defined;
  31. . Cleanup the build directory, removing any existing +*.rej+ files;
  32. . If +<packagename>_PATCH+ is defined, then patches from these
  33. tarballs are applied;
  34. . If there are some +*.patch+ files in the package directory or in the
  35. a package subdirectory named +<packagename>-<packageversion>+, then:
  36. +
  37. * If a +series+ file exists in the package directory, then patches are
  38. applied according to the +series+ file;
  39. +
  40. * Otherwise, patch files matching `<packagename>-*.patch` or
  41. `<packagename>-*.patch.<arch>` (where +<arch>+ is the architecture
  42. name) are applied following the +ls+ command order.
  43. . Run the +<packagename>_POST_PATCH_HOOKS+ commands if defined.
  44. If something goes wrong in the steps _3_ or _4_, then the build fails.
  45. Format and licensing of the package patches
  46. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. Patches are released under the same license as the software that is
  48. modified.
  49. A message explaining what the patch does, and why it is needed, should
  50. be added in the header commentary of the patch.
  51. You should add a +signed-off-by+ statement in the header of the each
  52. patch to help with keeping track of the changes.
  53. If the software is under version control, it is recommended to use the
  54. SCM software to generate the patch set.
  55. Otherwise, concatenate the header with the output of the
  56. +diff -purN source.c.orig source.c+ command.
  57. At the end, the patch should look like:
  58. ---------------
  59. configure.ac: add C++ support test
  60. signed-off-by John Doe <john.doe@noname.org>
  61. --- configure.ac.orig
  62. +++ configure.ac
  63. @@ -40,2 +40,12 @@
  64. AC_PROG_MAKE_SET
  65. +
  66. +AC_CACHE_CHECK([whether the C++ compiler works],
  67. + [rw_cv_prog_cxx_works],
  68. + [AC_LANG_PUSH([C++])
  69. + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  70. + [rw_cv_prog_cxx_works=yes],
  71. + [rw_cv_prog_cxx_works=no])
  72. + AC_LANG_POP([C++])])
  73. +
  74. +AM_CONDITIONAL([CXX_WORKS], [test "x$rw_cv_prog_cxx_works" = "xyes"])
  75. ---------------
  76. Integrating patches found on the Web
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78. When integrating a patch of which you are not the author, you have to
  79. add a few things in the header of the patch itself.
  80. Depending on whether the patch has been obtained from the project
  81. repository itself, or from somewhere on the web, add one of the
  82. following tags:
  83. ---------------
  84. Backported from: <some commit id>
  85. ---------------
  86. or
  87. ---------------
  88. Fetch from: <some url>
  89. ---------------
  90. It is also sensible to add a few words about any changes to the patch
  91. that may have been necessary.