special.sgml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <chapter id="gbp.special">
  2. <title>Special use cases</title>
  3. <sect1 id="gbp.special.dfsgfree">
  4. <title>Handling non-DFSG clean upstream sources</title>
  5. <para>If you have to handle non-DFSG clean upstream sources, you can use a
  6. different branch which you have to create once:
  7. </para>
  8. <programlisting>
  9. &gitcmd; branch dfsg_clean upstream
  10. </programlisting>
  11. <para>
  12. This creates the <emphasis>dfsg_clean</emphasis> branch from the tip of a
  13. branch called <emphasis>upstream</emphasis>. Then, when importing a new
  14. upstream version, you import the new version on the
  15. <option>upstream-branch</option> (by default named
  16. <emphasis>upstream</emphasis>) as usual and just don't merge to the
  17. <emphasis>debian-branch</emphasis> (by default named
  18. <emphasis>master</emphasis>):
  19. </para>
  20. <programlisting>
  21. &gbp-import-orig; --no-merge <filename>/path/to/nondfsg-clean-package_10.4.orig.tar.gz</filename>
  22. &gitcmd; <option>tag</option> 10.4
  23. </programlisting>
  24. <para>
  25. After the import, you can switch to the <emphasis>dfsg_clean</emphasis>
  26. branch and get the newly imported changes from the upstream branch:
  27. </para>
  28. <programlisting>
  29. &gitcmd; <option>checkout</option> dfsg_clean
  30. &gitcmd; <option>pull</option> <filename>.</filename> upstream
  31. </programlisting>
  32. <para>Now make this checkout dfsg clean (preferably by a cleanup script), commit
  33. your changes and merge to your <option>debian-branch</option>:</para>
  34. <programlisting>
  35. cleanup-script.sh
  36. &gitcmd; commit -a -m "Make source dfsg clean"
  37. &gitcmd; tag <replaceable>10.4.dfsg</replaceable>
  38. &gitcmd; checkout <replaceable>master</replaceable>
  39. &gitcmd; pull <replaceable>.</replaceable> <replaceable>dfsg_clean</replaceable>
  40. </programlisting>
  41. </sect1>
  42. <sect1 id="gbp.special.nmus">
  43. <title>Importing NMUs</title>
  44. <para>
  45. First, create a branch that holds the NMUs from the tip of your
  46. <option>debian-branch</option> (default is <emphasis>master</emphasis>) once:
  47. </para>
  48. <programlisting>
  49. &gitcmd; <option>branch</option> <replaceable>nmu</replaceable> <replaceable>master</replaceable>
  50. </programlisting>
  51. <para>
  52. To import an NMU, change into the git repository and use &gbp-import-dsc;:
  53. </para>
  54. <programlisting>
  55. &gitcmd; checkout <replaceable>master</replaceable>
  56. &gbp-import-dsc; <option>--debian-branch</option>=<replaceable>nmu</replaceable> <filename>/path/to/package_1.0-1nmu0.dsc</filename>
  57. </programlisting>
  58. <para>
  59. This will import the NMU onto the branched named <emphasis>nmu</emphasis>
  60. instead of the default <option>master</option>. This method can also
  61. be used to import "old" releases into the &git; repository when migrating
  62. to &git; from another VCS.
  63. </para>
  64. </sect1>
  65. <sect1 id="gbp.special.pbuilder">
  66. <title>Building with &cowbuilder;</title>
  67. <para>
  68. &cowbuilder; is nice tool to build Debian packages in a defined
  69. environment. It makes sure all build-dependencies are specified
  70. correctly by building the package in a clean chroot. As its
  71. cousin &pbuilder; it can be extended via hooks to (e.g. run
  72. autopkg tests) but doesn't need a tarball unpacked but uses copy
  73. on write tree to speed up the build.
  74. </para>
  75. <para>
  76. Since &cowbuilder; uses different command line arguments than
  77. &debuild; and &dpkg-buildpackage;, we can't simply pass the
  78. options to run it on the command line. To simplifiy the
  79. integration we use a separate helper named &git-pbuilder;.
  80. &gbp; has it's own command line option for this:
  81. </para>
  82. <programlisting>
  83. &gbp-buildpackage; <option>--git-pbuilder</option>
  84. </programlisting>
  85. <para>
  86. This will set the build command to run &git-pbuilder; (which
  87. invokes &cowbuilder; by default) and the clean command
  88. to <command>/bin/true</command>. It also activates the parsing
  89. of several &git-pbuilder; related options
  90. like <option>--git-dist</option>, <option>--git-arch</option> and
  91. <option>--git-pbuilder-options</option>.
  92. </para>
  93. <para>
  94. We can make &git-pbuilder; usage the default by adding it to
  95. <filename>~/.gbp.conf</filename>:
  96. </para>
  97. <programlisting>
  98. cat &lt;&lt;EOF &gt; <filename>~/.gbp.conf</filename>
  99. [DEFAULT]
  100. # We invoke cowbuilder via git-pbuilder. Arguments passed to &gbp-buildpackage;
  101. # will be passed to dpkg-buildpackage in the chroot
  102. pbuilder = True
  103. EOF
  104. </programlisting>
  105. <para>
  106. <command>git-pbuilder</command> defaults to building a package for the
  107. <envar>sid</envar> distribution. If you want to build for another
  108. distribution, pass this in the <option>--git-dist</option> option:
  109. <programlisting>
  110. &gbp-buildpackage; --git-pbuilder --git-dist=jessie
  111. </programlisting>
  112. If you want to use <command>debuild</command> again (without
  113. modifying <filename>~/.gbp.conf</filename>), you can use:
  114. </para>
  115. <programlisting>
  116. &gbp-buildpackage; --git-no-pbuilder
  117. </programlisting>
  118. <para>
  119. In order for all of the above to work you have to create a
  120. base chroot first using &git-pbuilder;
  121. </para>
  122. <programlisting>
  123. <command>git-pbuilder</command> create
  124. </programlisting>
  125. <para>
  126. This can later be updated using
  127. </para>
  128. <programlisting>
  129. <command>git-pbuilder</command> update
  130. </programlisting>
  131. </sect1>
  132. <sect1 id="gbp.special.hacking">
  133. <title>Working on random packages</title>
  134. <para>
  135. Whenever you need to work on an arbitrary &debian; package, you can check it
  136. right into &git; with one command:
  137. <programlisting>
  138. &gbp-import-dsc --download <filename>package</filename>
  139. cd <filename>package</filename>
  140. &gitcmd; branch debian
  141. </programlisting>
  142. </para>
  143. <para>
  144. This uses <command>apt-get</command> to download the source package,
  145. puts the orig tarball on the <option>upstream-branch</option> and the
  146. &debian; changes on the <option>debian-branch</option> (by default
  147. <emphasis>master</emphasis>). The second command
  148. creates a branch called <emphasis>debian</emphasis>. Now you can easily
  149. modify the package, revert changes you made, create other branches for
  150. testing, see what changes you made, etc. When finished, just do</para>
  151. <programlisting>
  152. &gitcmd; commit -a
  153. &gitcmd; diff debian --
  154. </programlisting>
  155. <para>
  156. to get a nice patch that can be submitted to the &debian; BTS. You can also
  157. fetch the source package from a URL:
  158. <programlisting>
  159. &gbp-import-dsc --download <filename>http://mentors.debian.net/debian/pool/main/i/ipsec-tools/ipsec-tools_0.7.3-9.dsc</filename>
  160. </programlisting>
  161. The import works incrementally; you can import new versions on top of
  162. already imported ones for e.g. easy review of changes.
  163. </para>
  164. </sect1>
  165. </chapter>