patch-policy.txt 3.9 KB

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