patch-policy.txt 3.9 KB

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