/[ddp]/manuals/trunk/maint-guide/maint-guide.sgml
ViewVC logotype

Contents of /manuals/trunk/maint-guide/maint-guide.sgml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2819 - (hide annotations) (download) (as text)
Thu Jan 20 19:56:58 2005 UTC (8 years, 4 months ago) by osamu
File MIME type: text/x-sgml
File size: 98796 byte(s)
no debconf per mpalmer and virlon reflected
1 osamu 2666 <!DOCTYPE debiandoc PUBLIC "-//DebianDoc//DTD DebianDoc//EN" [
2 aph 743
3 osamu 2666 <!-- textual data entities -->
4     <!-- first definition wins in SGML -->
5     <!ENTITY % default SYSTEM "default.ent"> %default;
6    
7     ]>
8 osamu 2819 <!-- CVS revision of this document "$Revision: 1.89 $" -->
9 osamu 2666 <!-- CVS revision of original english document "*.**" -->
10    
11 aph 743 <debiandoc>
12    
13     <book>
14    
15     <titlepag>
16    
17 joy 773 <title>Debian New Maintainers' Guide</title>
18 aph 743
19 joy 2365 <author>Josip Rodin <email/joy-mg@debian.org/
20 aph 743 </author>
21 joy 887 <!--
22     <author>Translated by: [put your name here] <email/[put your e-mail here]/
23     </author>
24     -->
25 aph 743
26 osamu 2818 <version>version 1.2.3, 18 January 2005.</version>
27 aph 743
28     <copyright>
29 joy 1529 <copyrightsummary>Copyright &copy; 1998-2002 Josip Rodin.</copyrightsummary>
30 aph 743
31 joy 1566 <p>This document may be used under the terms the GNU General Public License
32 joy 893 version 2 or higher.
33 aph 743
34 joy 893 <p>This document was made using with these two documents as examples:
35 joy 773
36 joy 797 <p>Making a Debian Package (AKA the Debmake Manual), copyright &copy;
37 joy 1552 1997 Jaldhar Vyas.
38 joy 797
39 aph 743 <p>The New-Maintainer's Debian Packaging Howto, copyright &copy; 1997
40 joy 1552 Will Lowe.
41 aph 743 </copyright>
42    
43     </titlepag>
44    
45     <toc sect>
46    
47 joy 1523 <chapt id="start">Getting started The Right Way
48 aph 743
49 joy 1520 <p>This document tries to describe building of a Debian package to the
50 osamu 2690 common Debian user, and prospectus developer. It uses pretty common language,
51 joy 1520 and it's well covered with working examples.
52     There is an old Roman saying, <em>Longum
53 aph 743 iter est per preaecepta, breve et efficax per exempla!</em> (It's a long way
54     by the rules, but short and efficient with examples!).
55    
56     <p>One of the things that makes Debian such a top-notch Linux distribution
57     is its package system. While there is a vast quantity of software already
58     in the Debian format, sometimes you need to install software that isn't.
59     You may be wondering how you can make your own packages and perhaps you
60 joy 896 think it is a very difficult task. Well, if you are a real novice on Linux,
61 joy 770 it is hard, but if you were rookie, you wouldn't be reading this doc now. :-)
62 aph 743 You do need to know a little about Unix programming but you certainly
63     don't need to be a wizard.
64    
65 joy 1520 <p>One thing is certain, though: to properly create and maintain Debian
66     packages you need man hours. Make no mistake, for our system to work the
67 joy 2396 maintainers need to be both technically competent and diligent.
68 joy 1520
69 joy 1522 <p>This document will explain every little (at first maybe irrelevant)
70     step, and help you create that first package, and to gain some experience
71     in building next releases of that and maybe other packages later on.
72    
73 joy 896 <p>Newer versions of this document should always be available online at
74 joy 1422 <url name="http://www.debian.org/doc/maint-guide/" id="http://www.debian.org/doc/maint-guide/">
75 joy 1520 and in the `<package/maint-guide/' package.
76     <!-- Translation in <this language> is also available in the
77     `<package/maint-guide-xy/' package. -->
78 joy 896
79 aph 743 <sect id="needprogs">Programs you need for development
80    
81 joy 896 <p>Before you start anything, you should make sure that you have properly
82     installed some additional packages needed for development. Note that the
83     list doesn't contain any packages marked `essential' or `required' - we
84     expect that you have those installed already.
85 joy 770
86 joy 1520 <p>This revision of this document has been updated for the packages in
87     Debian 2.2 (`potato') and 3.0 (`woody').
88 joy 893
89 joy 1520 <p>The following packages come with the standard Debian installation,
90     so you probably have them already (along with any additional packages
91     they depend on).
92 joy 896 Still, you should check with `dpkg -s &lt;package&gt;`.
93 aph 743
94     <list>
95 joy 1521 <item><package/dpkg-dev/ - this package contains the tools needed to unpack,
96 joy 896 build and upload Debian source packages. (see
97     <manref name="dpkg-source" section="1">)
98 aph 743
99 joy 1521 <item><package/file/ - this handy program can determine what type a file is.
100 joy 770 (see <manref name="file" section="1">)
101 aph 743
102 joy 1521 <item><package/gcc/ - the GNU C compiler, necessary if your program like
103 joy 1520 most others is written in the C programming language.
104     (see <manref name="gcc" section="1">)
105     This package will also "pull in" several other packages such as
106 joy 1521 <package/binutils/ which includes programs used to assemble and link
107 joy 1520 object files (see `info binutils` in the <package/binutils-doc/ package)
108 joy 1521 and <package/cpp/, the C preprocessor. (see <manref name="cpp" section="1">)
109 aph 743
110 joy 1521 <item><package/g++/ - the GNU C++ compiler, necessary if your program
111 joy 1520 is written in C++. (see <manref name="g++" section="1">)
112    
113 joy 1521 <item><package/libc6-dev/ - the C libraries and header files gcc needs to
114 joy 1520 link with to create object files. (see `info libc` in the
115     <package/glibc-doc/ package)
116 aph 743
117 joy 1521 <item><package/make/ - usually creation of a program takes several steps,
118 joy 1520 so rather than having to type out the same commands over and over again,
119     you can use this program to automate the process, creating `Makefile's.
120     (see `info make`)
121 aph 743
122 joy 2146 <item><package/patch/ - this very useful utility will take a file containing
123 aph 743 a difference listing (produced by the diff program) and apply it to the
124 joy 770 original file, producing a patched version. (see <manref name="patch" section="1">)
125 aph 743
126 joy 1521 <item><package/perl/ - Perl is one of the most used interpreted scripting
127 joy 1520 languages on today's Unix-like systems, often referred to as "Unix's Swiss Army
128 joy 770 Chainsaw". (see <manref name="perl" section="1">)
129 aph 743 </list>
130    
131 joy 1520 <p>You'll probably want to install the following packages, too:
132 aph 743
133     <list>
134 joy 1521 <item><package/autoconf/ and <package/automake/ - many newer programs use
135 joy 1520 configure scripts and Makefiles preprocessed with help of programs like
136     these. (see `info autoconf`, `info automake`)
137    
138 joy 1521 <item><package/dh-make/ and <package/debhelper/ - dh-make is necessary to
139 joy 2146 create the skeleton of our example package, and it will use some of the
140 aph 743 debhelper tools for creating packages. They are not essential for creation
141 joy 2366 of packages, but are <strong>highly</strong> recommended for new
142 joy 797 maintainers. It makes the whole process very much easier to start, and
143     control afterwards. (see <manref name="dh_make" section="1">,
144 joy 838 <manref name="debhelper" section="1">, /usr/share/doc/debhelper/README)
145 aph 743
146 joy 2146 <item><package/devscripts/ - this package contains some nice and useful
147 joy 773 scripts that can be helpful to the maintainers, but they are also not
148 joy 838 necessary for building packages. (see /usr/share/doc/devscripts/README.gz)
149 joy 773
150 joy 1521 <item><package/fakeroot/ - this utility lets you emulate being root which
151 joy 838 is necessary for some parts of the build process. (see
152     <manref name="fakeroot" section="1">)
153    
154 joy 1521 <item><package/gnupg/ - a tool that enables you to digitally <em>sign</em>
155 joy 1520 packages. This is especially important if you want to distribute it to
156     other people, and you will certainly be doing that when your work gets
157     included in the Debian distribution. (see <manref name="gpg" section="1">)
158    
159 joy 1521 <item><package/g77/ - the GNU Fortran 77 compiler, necessary if your
160 joy 1520 program is written in Fortran. (see <manref name="g77" section="1">)
161    
162 joy 1521 <item><package/gpc/ - the GNU Pascal compiler, necessary if your
163     program is written in Pascal. Worthy of note here is <package/fp-compiler/,
164 joy 1520 the Free Pascal Compiler, which is also good at this task.
165     (see <manref name="gpc" section="1">, <manref name="ppc386" section="1">)
166    
167 osamu 2665 <item><package/xutils/ - some programs, usually those
168 joy 1520 made for X11, also use these programs to generate Makefiles from sets of
169     macro functions. (see <manref name="imake" section="1">,
170     <manref name="xmkmf" section="1">)
171    
172 joy 1521 <item><package/lintian/ - this is the Debian package checker that can let
173 joy 893 you know of any common mistakes after you build the package, and explain
174     the errors found. (see <manref name="lintian" section="1">,
175 joy 838 /usr/share/doc/lintian/lintian.html/index.html)
176 osamu 2669
177     <item><package/linda/ - this is the alternative Debian package checker.
178     (see <manref name="linda" section="1">)
179    
180     <item><package/pbuilder/ - this package contains programs which is used
181     for creating and maintaining chroot environment. Building Debian
182     package in this chroot environment verifies the proper build dependency
183     and avoid FTBFS bugs. (see <manref name="pbuilder" section="8"> and
184     <manref name="pdebuild" section="1">)
185 aph 743 </list>
186    
187 joy 1520 <p>The following is the <em>very important</em> documentation which you
188     should read along with this document:
189 aph 743
190     <list>
191 joy 1521 <item><package/debian-policy/ - the Policy includes explanations of the
192 joy 1520 structure and contents of the Debian archive, several OS design issues,
193     the Filesystem Hierarchy Standard (which says where each file and
194     directory should be) etc.
195     For you, the most important thing is that it describes requirements that
196 joy 838 each package must satisfy to be included in the distribution.
197 osamu 2666 (see &debian-policy;)
198 aph 743
199 joy 1521 <item><package/developers-reference/ - for all matters not specifically
200 aph 743 about the technical details of packaging, like the structure of the
201     archive, how to rename, orphan, pick up packages, how to do NMUs, how to
202 osamu 2781 manage bugs, best packaging practices, when and where to upload etc.
203 osamu 2669 (see &developers-reference;)
204 aph 743 </list>
205    
206     <p>The short descriptions that are given above only serve to introduce
207     you to what each package does. Before continuing please thoroughly read
208 joy 1520 the documentation of each program, at least the standard usage.
209 joy 770 It may seem like heavy going now, but later on you'll be <em>very</em>
210     glad you read it.
211 aph 743
212 joy 1521 <p>Note: <package/debmake/ is a package that contains some programs that
213 joy 896 function similar to dh-make, but its specific use is <strong>not</strong>
214 joy 1520 covered in this document, because it is <em>deprecated</em>. Please refer
215     to <url name="the Debmake manual" id="http://www.debian.org/~jaldhar/">
216     for more information.
217 joy 838
218 joy 770 <sect id="otherinfo">Other information
219 aph 743
220     <p>There are two types of packages you can make, source and binary.
221     A source package contains code which you can compile into a program.
222     A binary package contains just the finished program. Don't mix terms
223     like source of the program and the source package of the program!
224     Please read the other manuals if you need more details on terminology.
225    
226 joy 896 <p>In Debian, the term `maintainer' is used for the person who makes
227     packages, `upstream author' for the person that made the program, and
228     `upstream maintainer' for the person who currently maintains that program,
229     outside of Debian. Usually author and the upstream maintainer are the
230     same person - and sometimes even the maintainer is the same person.
231     If you made a program, and want it to get in Debian, feel free to submit
232     your application to become a maintainer.
233 aph 743
234     <p>After you build your package (or while doing that), you will have
235     to become an official Debian maintainer if you wish your program to get
236     into the next distribution (if the program is useful, why not?).
237 joy 770 That process is explained in Developer's Reference. Please read it.
238 aph 743
239     <chapt id="first">First steps
240    
241 joy 1522 <sect id="choose">Choose your program
242 aph 743
243 joy 1531 <p>You have probably chosen the package you want to create. The first
244     thing you need to do is check if the package is in the distribution already.
245     If you use the `stable' distribution, maybe it's best that you go to the
246 joy 1523 <url name="package search page" id="http://www.debian.org/distrib/packages">.
247 joy 896 If you use <strong>current</strong> `unstable' distribution, check it out
248 joy 838 with these commands:
249 aph 743 <example>
250     dpkg -s program
251     dpkg -l '*program*'
252     </example>
253    
254 joy 1531 <p>If the package already exists, well, install it! :-) If it happens to
255     be orphaned -- if its maintainer is set to "Debian QA Group", you should
256     be able to pick it up. Consult
257     <url name="the list of orphaned packages" id="http://www.debian.org/devel/wnpp/orphaned">
258     and
259     <url name="the list of packages up for adoption" id="http://www.debian.org/devel/wnpp/rfa_bypackage">
260     to verify that the package is indeed up for grabs.
261    
262     <p>If you are able to adopt the package, get the sources (with something
263     like <tt/apt-get source packagename/) and examine them. This document
264     unfortunately doesn't include comprehensive information about adopting
265     packages. Thankfully you shouldn't have a hard time figuring out how the
266     package works since someone has already done the initial set up for you.
267     Keep reading, though, a lot of the advice below will still be applicable
268     for your case.
269    
270     <p>If the package is new, and you decide you'd like to see it in Debian,
271     proceed as follows:
272    
273     <list>
274     <item>check if no one else is working on the package already at
275     <url name="the list of packages being worked on" id="http://www.de.debian.org/devel/wnpp/being_packaged">.
276     If someone's already on it, contact them if you feel you need to.
277     If not - find another interesting program that nobody maintains.
278 joy 838 </item>
279 aph 743
280 joy 797 <item>program <strong>must</strong> have a license, if possible free as
281 joy 1523 according to the <url name="Debian Free Software Guidelines" id="http://www.debian.org/social_contract#guidelines">.
282     If it doesn't conform to some of these rules but it can be distributed
283     anyway, it could still can be included in the `contrib' or `non-free'
284 joy 2366 sections. If you are unsure about where it should go, post the license
285 joy 1523 text on <email/debian-legal@lists.debian.org/ and ask for advice.
286 aph 743 </item>
287    
288 joy 797 <item>program certainly should <strong>not</strong> run setuid root, or
289     even better - it shouldn't need to be setuid or setgid to anything.</item>
290 aph 743
291 joy 770 <item>program should not be a daemon, or something that goes in */sbin
292 joy 1523 directories, or open a port as root.</item>
293 aph 743
294 joy 1523 <item>program should result in binary executable form, libraries are
295     harder to handle.</item>
296 aph 743
297 joy 1523 <item>it should be well documented, or and the code needs to be
298     understandable (i.e. not obfuscated).</item>
299 aph 743
300 joy 770 <item>you should contact program's author(s) to check if they agree
301     with packaging it. It is important to be able to consult with author(s)
302     about the program in case of any program specific problems, so don't
303     try to package unmaintained pieces of software.</item>
304    
305 aph 743 <item>and last but not the least, you must know that it works, and
306     have it tried for some time.</item>
307     </list>
308    
309     <p>Of course, these things are just safety measures, and intended to save
310 joy 896 you from raging users if you do something wrong in some setuid daemon...
311 aph 743 When you gain some more experience in packaging, you'll be able to do such
312 joy 1523 packages, but even the experienced developers consult the debian-mentors
313 aph 743 mailing list when they are in doubt. And people there will gladly help.
314    
315 joy 770 <p>For more help about these, check in Developer's Reference.
316    
317 joy 1522 <sect id="getit">Get the program, and try it out
318 aph 743
319     <p>So the first thing to do is to find and download the original package.
320     I presume that you already have the source file that you picked up at
321 joy 1523 the author's homepage. Sources for free Unix programs usually come in
322 joy 893 tar/gzip format, with extension .tar.gz, and usually contain the
323     subdirectory called program-version and all the sources in it. If your
324     program's source comes as some other sort of archive (for instance, the
325 joy 896 filename ends in ".Z" or ".zip"), unpack it with appropriate
326 joy 1523 tools, or ask on the debian-mentors mailing list if you're not sure how to unpack it
327 joy 893 correctly (hint: issue `file archive.extension`).
328 aph 743
329 joy 2366 <p>As an example, I'll use a program called `gentoo', an X GTK+ file
330 joy 838 manager. Note that the program is already packaged, and has changed
331     substantially from the version while this text was first written.
332 aph 743
333 joy 896 <p>Create a subdirectory under your home directory named 'debian' or 'deb'
334 osamu 2689 or anything you find appropriate (e.g. just <file>~/gentoo/</file> would do fine in
335 joy 896 this case). Place the downloaded archive in it, and uncompress it (with
336     `tar xzf gentoo-0.9.12.tar.gz`). Make sure there are no errors, even some
337     "irrelevant" ones, because there will most probably be problems unpacking
338     on other people's systems, whose unpacking tools may or may not ignore
339     those anomalies.
340 aph 743
341 joy 893 <p>Now you have another subdirectory, called 'gentoo-0.9.12'. Change to
342     that directory and <strong>thoroughly</strong> read the provided
343     documentation. Usually there exist files named README*, INSTALL*, *.lsm
344     or *.html. You must find instructions on how to correctly compile and
345     install the program (most probably they'll assume you want to install to
346 joy 896 /usr/local/bin directory; you won't be doing that, but more on that later
347     in <ref id="destdir">).
348 aph 743
349     <p>The process varies from program to program, but a lot of modern
350 joy 770 programs come with a `configure' script that configures the source under
351 aph 743 your system and makes sure that your system is in condition to compile it.
352 joy 1523 After configuring with `./configure`, programs are usually compiled
353 joy 896 with `make`. Some of them support `make check`, to run included
354     self-checks. Installation in destination directories is usually done with
355 joy 770 `make install`.
356 aph 743
357 joy 1198 <p>Now try to compile and run your program, to make sure it works properly
358 aph 743 and doesn't break something else while it's installing or running.
359    
360 joy 1523 <p>Also, you can usually run `make clean` (or better `make distclean`) to
361     clean up the build directory. Sometimes there's even a `make uninstall`
362     which can be used to remove all the installed files.
363 aph 743
364 joy 1523 <sect id="namever">Package name and version
365 aph 743
366 joy 896 <p>You should start packaging with a completely clean (pristine) source
367     directory, or simply with freshly unpacked sources.
368    
369     <p>For the package to be built correctly, you must make the program's
370     original name lowercase (if it isn't already), and you should move the
371     source directory to &lt;packagename&gt;-&lt;version&gt;.
372    
373     <p>If the program name consists of more than one word, contract them to one
374     word, or make an abbreviation. For example, program "John's little editor
375     for X" package would be named johnledx, or jle4x, or whatever you decide,
376     as long as it's under some reasonable limit, e.g. 20 characters.
377    
378 joy 887 <p>Also check for the exact version of the program (to be included in the
379     package version). If that piece of software is not numbered with versions
380     like X.Y.Z, but with some kind of date, feel free to use that date as the
381     version number, prepended with a "0.0." (just in case upstream people one
382     day decide to release a nice version like 1.0). So, if the release or
383     snapshot date was 19th of December, 1998, you can use the version string
384 joy 1523 of 0.0.19981219.
385    
386     <p>Some programs won't be numbered at all, in which case you
387 joy 887 should contact the upstream maintainer to see if they've got some other
388     revision-tracking method.
389 aph 743
390 joy 1523 <sect id="dh_make">Initial "debianization"
391 aph 743
392 joy 770 <p>Make sure you're in the program source directory, and issue this:
393 aph 743
394 joy 770 <p><example>
395 joy 952 dh_make -e your.maintainer@address -f ../gentoo-0.9.12.tar.gz
396 joy 770 </example>
397 joy 838
398     <p>Of course, replace the string "your.maintainer@address" with your
399 joy 893 e-mail address for inclusion in the changelog entry and other files,
400     and the filename with the name of your original source archive. See
401     <manref name="dh_make" section="1"> for details.
402 joy 838
403 joy 770 <p>Some information will come up. It will ask you what sort of package you
404     want to create. Gentoo is a single binary package - it creates only one
405     binary, and thus one .deb file - so we will select the first option, with
406 joy 896 the `s' key, check the information on the screen and confirm with pressing
407 joy 1523 &lt;enter&gt;.
408    
409 osamu 2769 <p>After this execution of <prgn>dh_make</prgn>, a copy of the
410     upstream tarball is created as <file>gentoo_0.9.12.orig.tar.gz</file>
411     in the parent directory to accommodate the creation of the non-native
412     Debian source package with the <file>diff.gz</file>.
413     Please note 2 key features in this file name:
414     <list compact>
415     <item>Package name and version are separated by the "<tt>_</tt>" .
416     <item>There is the "<tt>orig.</tt>" before the "<tt>tar.gz</tt>" .
417     </list>
418    
419 joy 1523 <p>Once again, as a new maintainer you are discouraged from creating
420 osamu 2769 complicated packages, e.g.,
421     <list compact>
422     <item>multiple binary packages,
423     <item>library packages,
424     <item>the source file format being neither in <tt>tar.gz.</tt> nor
425     <tt>tar.bz2</tt>, or
426     <item>the source tarball containing undistributable contents.
427     </list>
428     It's not too hard, but it does require a bit more knowledge, so we
429     won't describe all of it here.
430 joy 770
431 osamu 2769 <p>Please note that you should run <prgn>dh_make</prgn> <strong>only once</strong>,
432 joy 797 and that it won't behave correctly if you run it again in the same,
433 osamu 2769 already "debianized", directory. That also means that you will use a
434 joy 797 different method to release a new revision or a new version of your
435 joy 896 package in the future. Read more about that later in <ref id="update">
436 joy 797
437 aph 743 <chapt id="modify">Modifying the source
438    
439 joy 893 <p>Normally, programs install themselves in the /usr/local subdirectories.
440 aph 743 But, Debian packages must not use that directory, since it is reserved for
441 joy 893 system administrator's (or user's) private use. This means that you have
442     to take a look at your program's build system, usually starting with the
443     Makefile. This is the script <manref name="make" section="1"> will use to
444     automate building this program. For more details on Makefiles, look in
445     <ref id="rules">.
446 aph 743
447 joy 903 <p>Note that if your program uses GNU <manref name="automake" section="1">
448     and/or <manref name="autoconf" section="1">, meaning the source includes
449     Makefile.am and/or Makefile.in files, respectively, you will need to
450 joy 1198 modify those files. This is because each automake invocation will rewrite
451 joy 903 Makefile.in's with information generated from Makefile.am's, and each
452     ./configure invocation will do the same with Makefile's, with data from
453     Makefile.in's. Editing Makefile.am files requires some knowledge of
454 joy 1198 automake, which you can read about in the automake info entry, whereas editing
455 joy 903 Makefile.in files is pretty much the same as editing Makefile files, just
456     pay attention on the variables, i.e. any strings surrounded with `@'s, for
457     example @CFLAGS@ or @LN_S@, which are replaced with actual stuff on each
458 osamu 2788 ./configure invocation. Please make sure to read
459     <file>&autotools-dev;</file> before proceeding.
460 aph 743
461 joy 903 <p>Also note that there isn't space here to go into <em>all</em> the
462 joy 1198 details of fixing upstream sources, but here are a few problems people
463     often run across.
464 joy 903
465 joy 838 <sect id="destdir">Installation in a subdirectory
466 aph 743
467 joy 838 <p>Most of the programs have some way of installing themselves in the
468     existing directory structure of your system, so that their binaries get
469     included in your $PATH, and that you find their documentation and manual
470 joy 1523 pages in common places. However, if you do that, the program will be
471     installed among everything else already on your system. This would make
472     it hard for the packaging tools to figure out which files belong to your
473     package and which don't.
474    
475     <p>Therefore you need to do something else: install the program into a
476     temporary subdirectory from which the maintainer tools will build a working
477 joy 838 .deb package. Everything that is contained in this directory will be
478 joy 2366 installed on a user's system when they install your package, the only
479 joy 838 difference is that dpkg will be installing the files in the root
480     directory.
481    
482 joy 1523 <p>This temporary directory is usually created under your debian/
483     directory in the unpacked source tree. It is usually called
484     <file>debian/tmp</file> or <file>debian/packagename</file>.
485    
486     <p>Bear in mind that even though you need to make the program install in
487 joy 1526 debian/packagename, it still needs to behave correctly when placed in the
488     root directory, i.e. when installed from the .deb package. So you mustn't
489 joy 1523 allow the build system to hardcode strings like
490     <tt>/home/me/deb/gentoo-0.9.12/usr/share/gentoo</tt> into the package
491     files.
492    
493     <p>With programs that use GNU autoconf, this will be quite easy. Most such
494     programs have makefiles that are by default set up to allow installation
495     into a random subdirectory while keeping in mind that /usr (for example)
496     is the canonical prefix. When it detects your program uses autoconf,
497     dh_make will set up commands for doing all this
498 joy 838 automatically, so you might as well skip reading this section. But with
499     other programs, you will most probably have to examine and edit the
500     Makefiles.
501    
502     <p>Here's the relevant part of gentoo's Makefile:
503    
504 aph 743 <p><example>
505     # Where to put binary on 'make install'?
506     BIN = /usr/local/bin
507 joy 1523
508     # Where to put icons on 'make install'?
509     ICONS = /usr/local/share/gentoo
510 aph 743 </example>
511    
512 joy 1523 <p>We see that the files are set to install under <file>/usr/local</file>.
513     Change those paths to:
514 aph 743
515     <p><example>
516 joy 1523 # Where to put binary on 'make install'?
517     BIN = $(DESTDIR)/usr/bin
518 aph 743
519 joy 1523 # Where to put icons on 'make install'?
520     ICONS = $(DESTDIR)/usr/share/gentoo
521 aph 743 </example>
522    
523 joy 1523 <p>But why in that directory, and not some other? Because Debian packages
524     never install files beneath <file>/usr/local</file> -- that tree is
525     reserved for the system administrator's use. Such files on Debian
526     systems go under <file>/usr</file> instead.
527 aph 743
528 joy 1523 <p>The more exact locations for binaries, icons, documentation etc are
529     specified in the Filesystem Hierarchy Standard
530     (see /usr/share/doc/debian-policy/fhs/). I recommend you browse it and read
531     the sections that might concern your package.
532 aph 743
533 joy 1523 <p>So, we should install the binary in /usr/bin instead of /usr/local/bin,
534     the manual page in /usr/share/man/man1 instead of /usr/local/man/man1 etc.
535     Notice how there's no manual page mentioned in gentoo's makefile, but
536     since the Debian Policy requires that every program has one, we'll make
537     one later and install it in /usr/share/man/man1.
538    
539     <p>Some programs don't use makefile variables to define paths such as
540     these. This means you might have to edit some real C sources in order to
541     fix them to use the right locations.
542 joy 2366 But where to search, and exactly what for? You can find this out by issuing:
543 joy 1523
544 joy 770 <p><example>
545 joy 1523 grep -rn usr/local/lib *.[ch]
546 joy 770 </example>
547 joy 1523
548     <p>Grep will run recursively through the source tree and tell
549 joy 1199 you the name of the file and the line in it, when it finds an occurrence.
550 aph 743
551 joy 1523 <p>Edit those files and in those lines replace /usr/local/* with usr/*
552     -- and that's about it. Be careful that you don't mess up the rest of
553     the code! :-)
554    
555 joy 896 <p>After that you should find the install target (search for line that
556 joy 1523 starts with `install:', that will usually work) and rename all references
557     to directories other than ones defined at the top of the Makefile.
558     Previously, gentoo's install target said:
559 aph 743
560     <p><example>
561 joy 887 install: gentoo
562 aph 743 install ./gentoo $(BIN)
563 joy 1523 install icons/* $(ICONS)
564 aph 743 install gentoorc-example $(HOME)/.gentoorc
565     </example>
566    
567 joy 770 <p>After our change it says:
568 aph 743 <example>
569     install: gentoo-target
570     install -d $(BIN) $(ICONS) $(DESTDIR)/etc
571     install ./gentoo $(BIN)
572     install -m644 icons/* $(ICONS)
573     install -m644 gentoorc-example $(DESTDIR)/etc/gentoorc
574 joy 1523 </example>
575    
576     <p>You've surely noticed that there's now a <tt>install -d</tt> command
577     before the other commands in the rule. The original makefile didn't have
578     it because usually the /usr/local/bin and other directories already exist
579     on the system where one runs `make install`. However, since we will
580     install into our own empty (or even nonexistent) directory, we will have
581     to create each and every one of those directories.
582    
583     <p>We can also add in other things at the end of the rule, like the
584     installation of additional documentation that the upstream authors
585     sometimes omit:
586    
587     <p><example>
588 joy 838 install -d $(DESTDIR)/usr/share/doc/gentoo/html
589     cp -a docs/* $(DESTDIR)/usr/share/doc/gentoo/html
590 aph 743 </example>
591    
592 joy 896 <p>A careful reader will notice that I changed `gentoo' to `gentoo-target'
593 joy 1523 in the `install:' line. That is called an unrelated bug fix :-)
594 aph 743
595     <p>Whenever you make changes that are not specifically related to Debian
596     package, be sure to send them to the upstream maintainer so they can be
597 joy 1523 included in the next program revision and be useful to everyone else.
598     Also remember to make your fixes not specific to Debian or Linux (or even
599     Unix!) prior to sending them -- make them portable. This will make your
600     fixes much easier to apply.
601 aph 743
602 joy 1523 <p>Note that you don't have to send the debian/* files upstream.
603    
604 joy 896 <sect id="difflibs">Differing libraries
605 aph 743
606     <p>There is one other common problem: libraries are often different from
607 joy 2366 platform to platform. For example, a Makefile can contain a reference to a
608 joy 1523 library which doesn't exist on Debian systems. In that case, we
609 joy 893 need to change it to a library which does exist in Debian, and serves the
610 joy 1523 same purpose.
611 aph 743
612 joy 903 <p>So, if there is a line in your program's Makefile (or Makefile.in) that
613     says something like this (and your program doesn't compile):
614 aph 743
615     <p><example>
616 joy 770 LIBS = -lcurses -lsomething -lsomethingelse
617 aph 743 </example>
618    
619     <p>Change it to this, and it will most probably work:
620     <p><example>
621 joy 770 LIBS = -lncurses -lsomething -lsomethingelse
622 aph 743 </example>
623    
624 joy 1523 <p>(The author realizes that this is not the best example considering our
625     libncurses package now ships with a libcurses.so symlink, but he couldn't
626     think of a better one. Suggestions very welcome :-)
627    
628 joy 896 <chapt id="dreq">Required stuff under debian/
629 aph 743
630 joy 1525 <p>There is a new subdirectory under the program's source directory,
631     it's called `debian'. There are a number of files in this directory that
632     we should edit in order to customize
633 joy 893 the behavior of the package. The most important of them are `control',
634     `changelog', `copyright' and 'rules', which are required for all packages.
635 aph 743
636 joy 893 <sect id="control">`control' file
637 aph 743
638 joy 1525 <p>This file contains various values which <prgn/dpkg/, <prgn/dselect/ and
639     other package management tools will use to manage the package.
640 aph 743
641 joy 2366 <p>Here is the control file dh_make created for us:
642 joy 1525
643 joy 893 <p><example>
644     1 Source: gentoo
645 joy 838 2 Section: unknown
646     3 Priority: optional
647 joy 2365 4 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
648 joy 1525 5 Build-Depends: debhelper (>> 3.0.0)
649     6 Standards-Version: 3.5.2
650     7
651     8 Package: gentoo
652     9 Architecture: any
653     10 Depends: ${shlibs:Depends}
654     11 Description: &lt;insert up to 60 chars description&gt;
655     12 &lt;insert long description, indented with spaces&gt;
656 aph 743 </example>
657     (I've added the line numbers.)
658    
659 joy 1525 <p>Lines 1-6 are the control information for the source package.
660 aph 743
661 joy 1525 <p>Line 1 is the name of the source package.
662    
663     <p>Line 2 is the section of the distribution the source package goes into.
664    
665     <p>As you may have noticed, Debian is divided in sections: main (the free
666 joy 797 software), non-free (the not really free software) and contrib (free
667     software that depends on non-free software). Under those, there are
668     logical subsections that describe in short what packages are in.
669 joy 896 So we have `admin' for administrator-only programs, `base' for the
670     basic tools, `devel' for programmer tools, `doc' for documentation,
671     `libs' for libraries, `mail' for e-mail readers and daemons, `net' for
672 joy 1525 network apps and daemons, `x11' for X11 programs that don't fit anywhere
673     else, and many more.
674 aph 743
675 joy 1525 <p>Let's change it then to x11. (A "main/" prefix is implied so we can
676     omit it.)
677 joy 797
678 joy 1525 <p>Line 3 describes how important it is that the user installs this package.
679     See the Policy manual for guidance on what to set this field to. The
680     "optional" priority will usually work for new packages.
681    
682     <p>Section and priority are used by frontends like <prgn/dselect/ when
683     they sort packages and select defaults. Once you upload the package to
684     Debian, the value of these two fields can be overridden by the archive
685     maintainers, in which case you will be notified by email.
686 joy 797
687 joy 1525 <p>As this is a normal priority package and doesn't conflict with anything
688     else, we'll leave it as "optional".
689 aph 743
690 joy 1525 <p>Line 4 is the name and email address of the maintainer. Make sure that
691     this field includes a valid "To: " header for an email, because after you
692     upload it, the bug tracking system will use it to deliver bug emails to
693     you. Avoid using commas, ampersands and parenthesis.
694 aph 743
695 joy 1555 <p>The 5th line includes the list of packages required to build your
696 joy 1525 package. Some packages like gcc and make are implied, see the
697     <package/build-essential/ package for details. If some non-standard
698     compiler or other tool is needed to build your package, you should add
699     it to the `Build-Depends' line. Multiple entries are separated with
700     commas; read on for the explanation of binary dependencies to find out
701     more about the syntax of this field.
702 joy 896
703 joy 1525 <p>You can also have Build-Depends-Indep, Build-Conflicts and other fields
704     here. This data will be used by the Debian automatic package building
705     software in order to create binary packages for other computer platforms.
706     See the Policy manual for more information about the build-dependencies
707     and the Developers' Reference for more information about these other
708     platforms (architectures) and how to port software to them.
709 aph 743
710 joy 1525 <p>Here's a hack you can use to find out which packages your package needs
711     to be built:
712     <example>
713     strace -f -o /tmp/log ./configure
714 joy 2366 # or make instead of ./configure, if the package doesn't use autoconf
715 osamu 2702 for x in `dpkg -S $(grep open /tmp/log|\
716     perl -pe 's!.* open\(\"([^\"]*).*!$1!' |\
717     grep "^/"| sort | uniq|\
718     grep -v "^\(/tmp\|/dev\|/proc\)" ) 2>/dev/null|\
719     cut -f1 -d":"| sort | uniq`; \
720     do \
721     echo -n "$x (>=" `dpkg -s $x|grep ^Version|cut -f2 -d":"` "), "; \
722     done
723 joy 1525 </example>
724    
725 osamu 2677 <p>To manually find exact build dependency for
726     <prgn><var>/usr/bin/foo</var></prgn>, you execute
727     <example>
728     objdump -p <var>/usr/bin/foo</var> | grep NEEDED
729     </example>
730     and for each library listed, e.g., <prgn>libfoo.so.6</prgn>, execute
731     <example>
732     dpkg -S libfoo.so.6
733     </example>
734     Then you just take -dev version of every package as
735     `Build-deps' entry. If you use <prgn>ldd</prgn> for this
736     purpose, it will report indirect lib dependencies as well, resulting
737     in the problem of excessive build deps.
738    
739 joy 1525 <p>Gentoo also happens to require <package/xlibs-dev/,
740     <package/libgtk1.2-dev/ and <package/libglib1.2-dev/ to build, so we'll
741     add them here next to <package/debhelper/.
742    
743 joy 1555 <p>Line 6 is the version of the Debian Policy standards this package
744     follows, the versions of the Policy manual you read while making your
745     package.
746    
747     <p>Line 8 is the name of the binary package. This is usually the same as
748 joy 1525 the name of the source package, but it doesn't necessarily have to be that
749     way.
750    
751 joy 1555 <p>Line 9 describes the CPU architecture the binary package can be compiled
752 joy 1525 for. We'll leave this as "any" because <manref name="dpkg-gencontrol"
753 joy 838 section="1"> will fill in the appropriate value for any machine this
754 joy 1525 package gets compiled on.
755    
756     <p>If your package is architecture independent
757 joy 896 (for example, a shell or Perl script, or a document), change this to
758 joy 1525 "all", and read later in <ref id="rules"> about using the `binary-indep'
759 joy 896 rule instead of `binary-arch' for building the package.
760 aph 743
761 joy 1555 <p>Line 10 shows one of the most powerful features of the Debian packaging
762 aph 743 system. Packages can relate to each other in various ways. Apart from
763 joy 838 Depends:, other relationship fields are Recommends:, Suggests:,
764 joy 1525 Pre-Depends:, Conflicts:, Provides:, and Replaces:.
765 aph 743
766 joy 1525 <p>The package management tools usually behave the same way when dealing
767     with these relations; if not, it will be explained.
768 joy 838 (see <manref name="dpkg" section="8">, <manref name="dselect" section="8">,
769 joy 1525 <manref name="apt" section="8">, <manref name="aptitude" section="1"> etc.)
770 joy 838
771 joy 1525 <p>This is what the dependencies mean:
772 joy 838
773 aph 743 <p><list>
774     <item>Depends:
775 joy 838 <p>The package will not be installed unless the packages it depends on
776     are installed. Use this if your program absolutely will not run (or will
777     cause severe breakage) unless a particular package is present.</item>
778 aph 743
779     <item>Recommends:
780 joy 1525 <p>Frontends such as dselect or aptitude will prompt you to install the
781     recommended packages along with your package; dselect will even insist.
782     dpkg and apt-get will ignore this field, though. Use this for packages
783     that are not strictly necessary but are typically used with your
784 joy 838 program.</item>
785 aph 743
786     <item>Suggests:
787 joy 1525 <p>When a user installs your program, all frontends will likely prompt
788     them to install the suggested packages. dpkg and apt-get won't care. Use
789     this for packages which will work nicely with your program but are not at
790     all necessary.</item>
791 aph 743
792 joy 770 <item>Pre-Depends:
793 joy 838 <p>This is stronger than Depends:. The package will not be installed
794     unless the packages it pre-depends on are installed <em>and correctly
795     configured</em>. Use this <strong>very</strong> sparingly and only after
796     discussing it on the debian-devel mailing list. Read: don't use it at
797     all. :-)</item>
798 aph 743
799     <item>Conflicts:
800 joy 838 <p>The package will not be installed until all the packages it conflicts
801 joy 893 with have been removed. Use this if your program absolutely will not run
802 joy 1525 or will cause severe problems if a particular package is present.</item>
803 aph 743
804     <item>Provides:
805 joy 838 <p>For some types of packages where there are multiple alternatives
806 joy 1525 virtual names have been defined. You can get the full list in the
807     /usr/share/doc/debian-policy/virtual-package-names-list.txt.gz file.
808 joy 838 Use this if your program provides a function of an existing virtual
809     package.</item>
810 aph 743
811     <item>Replaces:
812 joy 838 <p>Use this when your program replaces files from another package, or
813 joy 896 completely replaces another package (used in conjunction with Conflicts:).
814 joy 1525 Files from the named packages will be overwritten with the files from your
815     package.
816 joy 838 </item>
817 aph 743 </list>
818    
819     <p>All these fields have uniform syntax. They are a list of package names
820     separated by commas. These package names may also be lists of alternative
821 joy 1525 package names, separated by vertical bar symbols `<tt>|</tt>' (pipe symbols).
822    
823     <p>The fields may restrict their applicability to particular versions of
824     each named package. These versions are listed in parentheses after each
825 joy 838 individual package name, and they should contain a relation from the list
826     below followed by the version number. The relations allowed are:
827     <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>, <tt>=</tt>, <tt>&gt;=</tt> and
828     <tt>&gt;&gt;</tt> for strictly earlier, earlier or equal, exactly equal,
829 joy 1525 later or equal and strictly later, respectively. For example,
830    
831     <p><example>
832     Depends: foo (>= 1.2), libbar1 (= 1.3.4)
833     Conflicts: baz
834     Recommends: libbaz4 (>> 4.0.7)
835     Suggests: quux
836     Replaces: quux (<< 5), quux-foo (<= 7.6)
837     </example>
838 aph 743
839 joy 1525 <p>The last feature you need to know about is ${shlibs:Depends}.
840     After your package has been built and installed into the temporary
841     directory, <manref name="dh_shlibdeps" section="1"> will scan it for
842     binaries and libraries, determine their shared library dependencies and
843     detect which packages they are in, such as libc6 or xlib6g. It'll pass
844     on the list to <manref name="dh_gencontrol" section="1"> which will fill
845     it in the right place, and you won't have to worry about this yourself.
846 aph 743
847 joy 1589 <p>Having said all that, we can leave the Depends: line exactly as it is
848     now, and insert another line after it saying <tt>Suggests: file</tt>,
849 joy 896 because gentoo can use some features provided by that program/package.
850 aph 743
851     <p>Line 11 is the short description. Most people screens are 80 columns
852 joy 838 wide so this shouldn't be longer than about 60 characters. I'll change
853 joy 1525 it to "A fully GUI configurable X file manager using GTK+".
854 aph 743
855     <p>Line 12 is where the long description goes. This should be a paragraph
856 joy 1525 which gives more details about the package. Column 1 of each line should
857     be empty. There must be no blank lines, but you can put a single . (dot)
858 joy 2366 in a column to simulate that. Also, there must be no more than one blank
859 joy 1525 line after the long description.
860 aph 743
861 joy 1525 <p>Finally, here is the updated control file:
862 aph 743
863     <p><example>
864     1 Source: gentoo
865     2 Section: x11
866     3 Priority: optional
867 joy 2365 4 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
868 joy 1525 5 Build-Depends: debhelper (>> 3.0.0), xlibs-dev, libgtk1.2-dev, libglib1.2-dev
869     6 Standards-Version: 3.5.2
870     7
871     8 Package: gentoo
872     9 Architecture: any
873     10 Depends: ${shlibs:Depends}
874     11 Suggests: file
875 joy 1589 12 Description: A fully GUI configurable X file manager using GTK+
876 joy 1525 13 gentoo is a file manager for Linux written from scratch in pure C. It
877     14 uses the GTK+ toolkit for all of its interface needs. gentoo provides
878     15 100% GUI configurability; no need to edit config files by hand and re-
879     16 start the program. gentoo supports identifying the type of various
880     17 files (using extension, regular expressions, or the 'file' command),
881     18 and can display files of different types with different colors and icons.
882     19 .
883     20 gentoo borrows some of its look and feel from the classic Amiga file
884     21 manager "Directory OPUS" (written by Jonathan Potter).
885 aph 743 </example>
886 joy 838 (I've added the line numbers.)
887 aph 743
888 joy 893 <sect id="copyright">`copyright' file
889 aph 743
890 joy 896 <p>This file contains the information about package upstream resources,
891     copyright and license information. Its format is not dictated by the
892 joy 1526 Policy, but the contents is (section 13.6 "Copyright information").
893 aph 743
894 joy 1526 <p>dh_make created a default one, this is what it looks like:
895    
896 aph 743 <p><example>
897 joy 2365 1 This package was debianized by Josip Rodin &lt;joy-mg@debian.org&gt; on
898 aph 743 2 Wed, 11 Nov 1998 21:02:14 +0100.
899     3
900     4 It was downloaded from &lt;fill in ftp site&gt;
901     5
902     6 Upstream Author(s): &lt;put author(s) name and email here&gt;
903     7
904     8 Copyright:
905     9
906     10 &lt;Must follow here&gt;
907     </example>
908 joy 838 (I've added the line numbers.)
909 aph 743
910     <p>The important things to add to this file are the place you got the
911 joy 896 package from and the actual copyright notice and license. You must
912     include the complete license, unless it's one of the common free software
913     licenses such as GNU GPL or LGPL, BSD or the Artistic license, when you
914     can just refer to the appropriate file in /usr/share/common-licenses/
915 joy 1526 directory that exists on every Debian system.
916 aph 743
917 joy 1526 <p>In short, here's how gentoo's copyright file should look like:
918    
919 aph 743 <p><example>
920 joy 2365 1 This package was debianized by Josip Rodin &lt;joy-mg@debian.org&gt; on
921 aph 743 2 Wed, 11 Nov 1998 21:02:14 +0100.
922     3
923 joy 838 4 It was downloaded from: ftp://ftp.obsession.se/gentoo/
924 aph 743 5
925 joy 838 6 Upstream author: Emil Brink &lt;emil@obsession.se&gt;
926 aph 743 7
927 joy 838 8 This software is copyright (c) 1998-99 by Emil Brink, Obsession
928     9 Development.
929     10
930     11 You are free to distribute this software under the terms of
931     12 the GNU General Public License.
932     13 On Debian systems, the complete text of the GNU General Public
933 joy 1526 14 License can be found in the file `/usr/share/common-licenses/GPL'.
934 aph 743 </example>
935 joy 838 (I've added the line numbers.)
936 aph 743
937 joy 893 <sect id="changelog">`changelog' file
938 aph 743
939 joy 797 <p>This is a required file, which has a special format described in
940 osamu 2664 the Policy section 4.4 "debian/changelog". This format is used by dpkg and
941 joy 797 other programs to obtain the version number, revision, distribution and
942     urgency of your package.
943 aph 743
944 joy 797 <p>For you, it is also important, since it is good to have documented
945     all changes you have done. It will help people downloading your package
946 joy 1526 to see whether there are issues with the package that they should know
947     about. It will be saved as
948 joy 896 `/usr/share/doc/gentoo/changelog.Debian.gz' in the binary package.
949 joy 797
950 joy 2366 <p>dh_make created a default one, and this is how it looks like:
951 joy 797
952 aph 743 <p><example>
953     1 gentoo (0.9.12-1) unstable; urgency=low
954     2
955     3 * Initial Release.
956     4
957 joy 2365 5 -- Josip Rodin &lt;joy-mg@debian.org&gt; Wed, 11 Nov 1998 21:02:14 +0100
958 aph 743 6
959     </example>
960 joy 838 (I've added the line numbers.)
961 aph 743
962     <p>Line 1 is the package name, version, distribution, and urgency.
963 joy 896 The name must match the source package name, distribution should be
964 joy 1526 either `unstable' (or even `experimental'), and urgency shouldn't
965 joy 896 be changed to anything higher than `low'. :-)
966 aph 743
967     <p>Lines 3-5 are a log entry, where you document changes made in this
968     package revision (not the upstream changes - there is special file for
969 joy 1526 that purpose, created by the upstream authors, which you will later install as
970 joy 838 /usr/share/doc/gentoo/changelog.gz). New lines must be inserted just
971 joy 896 before the uppermost line that begins with asterisk (`*'). You can do
972 joy 1526 it with <manref name="dch" section="1">, or manually with a text editor.
973 aph 743
974 joy 1526 <p>You will end up with something like this:
975    
976 aph 743 <p><example>
977     1 gentoo (0.9.12-1) unstable; urgency=low
978     2
979     3 * Initial Release.
980     4 * This is my first Debian package.
981 joy 838 5 * Adjusted the Makefile to fix $DESTDIR problems.
982     6
983 joy 2365 7 -- Josip Rodin &lt;joy-mg@debian.org&gt; Wed, 11 Nov 1998 21:02:14 +0100
984 joy 838 8
985 aph 743 </example>
986 joy 838 (I've added the line numbers.)
987 aph 743
988 joy 1526 <p>You can read more about updating the changelog file later in
989 joy 896 <ref id="update">.
990    
991 joy 893 <sect id="rules">`rules' file
992    
993 joy 896 <p>Now we need to take a look at the exact rules which
994     <manref name="dpkg-buildpackage" section="1"> will use to actually create
995 joy 1526 the package. This file is actually another Makefile, but different than
996     the one(s) in the upstream source. Unlike other files in debian/, this one
997     is marked as executable.
998 joy 893
999 joy 896 <p>Every `rules' file, as any other Makefile, consists of several rules
1000     specifying how to handle the source. Each rule consists of targets,
1001     filenames or names of actions that should be carried out (e.g. `build:'
1002     or `install:'). Rules that you want to execute are invoked as command
1003     line arguments (for example, `./debian/rules build` or `make -f rules
1004     install`). After the target name, you can name the dependency, program
1005 joy 2366 or file that the rule depends on. After that, there can be any number
1006 joy 1526 of commands, indented with &lt;tab&gt;. A new rule begins with the target
1007     declaration in the first column. Empty lines and lines beginning
1008 joy 896 with `#' (hash) are treated as comments and ignored.
1009 joy 893
1010     <p>You are probably confused now, but it will all be clear upon examination
1011 joy 896 of the `rules' file that dh_make gives us as a default. You should also
1012     read the `make' entry in info for more information.
1013 joy 893
1014     <p>The important part to know about the rules file created by dh_make, is
1015     that it is just a suggestion. It will work for simple packages but for
1016     more complicated ones, don't be afraid to add and subtract from it to fit
1017     your needs. Only thing that you must not change are the names of the
1018 joy 1526 rules, because all the tools use these names, as mandated by the Policy.
1019 joy 893
1020 joy 1526 <p>Here's (approximately) how the default debian/rules file that dh_make
1021     generated for us looks like:
1022    
1023 joy 893 <p><example>
1024     1 #!/usr/bin/make -f
1025 joy 1526 2 # Sample debian/rules that uses debhelper.
1026     3 # GNU copyright 1997 to 1999 by Joey Hess.
1027     4
1028     5 # Uncomment this to turn on verbose mode.
1029     6 #export DH_VERBOSE=1
1030     7
1031     8 # This is the debhelper compatibility version to use.
1032 osamu 2668 9 export DH_COMPAT=4
1033     10
1034     11 CFLAGS = -g
1035     12 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
1036     13 CFLAGS += -O0
1037     14 else
1038     15 CFLAGS += -O2
1039 joy 1526 16 endif
1040     17
1041     18 build: build-stamp
1042     19 build-stamp:
1043     20 dh_testdir
1044     21
1045     22 # Add here commands to compile the package.
1046     23 $(MAKE)
1047     24 #/usr/bin/docbook-to-man debian/gentoo.sgml > gentoo.1
1048 joy 893 25
1049 joy 1526 26 touch build-stamp
1050     27
1051     28 clean:
1052     29 dh_testdir
1053     30 dh_testroot
1054     31 rm -f build-stamp
1055     32
1056     33 # Add here commands to clean up after the build process.
1057     34 -$(MAKE) clean
1058     35
1059     36 dh_clean
1060     37
1061     38 install: build
1062     39 dh_testdir
1063     40 dh_testroot
1064     41 dh_clean -k
1065     42 dh_installdirs
1066 joy 893 43
1067 joy 1526 44 # Add here commands to install the package into debian/gentoo.
1068     45 $(MAKE) install DESTDIR=$(CURDIR)/debian/gentoo
1069     46
1070     47 # Build architecture-independent files here.
1071     48 binary-indep: build install
1072     49 # We have nothing to do by default.
1073     50
1074     51 # Build architecture-dependent files here.
1075     52 binary-arch: build install
1076     53 dh_testdir
1077     54 dh_testroot
1078     55 # dh_installdebconf
1079     56 dh_installdocs
1080     57 dh_installexamples
1081     58 dh_installmenu
1082     59 # dh_installlogrotate
1083     60 # dh_installemacsen
1084     61 # dh_installpam
1085     62 # dh_installmime
1086     63 # dh_installinit
1087     64 dh_installcron
1088     65 dh_installman
1089     66 dh_installinfo
1090     67 # dh_undocumented
1091     68 dh_installchangelogs ChangeLog
1092     69 dh_link
1093     70 dh_strip
1094     71 dh_compress
1095     72 dh_fixperms
1096     73 # dh_makeshlibs
1097     74 dh_installdeb
1098     75 # dh_perl
1099     76 dh_shlibdeps
1100     77 dh_gencontrol
1101     78 dh_md5sums
1102     79 dh_builddeb
1103     80
1104     81 binary: binary-indep binary-arch
1105     82 .PHONY: build clean binary-indep binary-arch binary install
1106 joy 893 </example>
1107     (I've added the line numbers.)
1108    
1109 joy 896 <p>You are probably familiar with lines like line 1 from shell and Perl
1110     scripts. It tells the operating system that this file is to be processed
1111     with /usr/bin/make.
1112 joy 893
1113 joy 1526 <p>The meaning of DH_* variables mentioned on lines 6 and 9 should be
1114     evident from the short description. For more information on DH_COMPAT
1115     read the "Debhelper compatibility levels" section of the
1116     <manref name="debhelper" section="1"> manual page.
1117 joy 893
1118 joy 1526 <p>The lines 11 through 16 are a skeleton of support for DEB_BUILD_OPTIONS
1119     parameters, described in the Policy section 11.1 "Binaries". Basically,
1120     these things control if the binaries are to be built with the debugging
1121     symbols, and if they should be stripped upon installation. Again, this is
1122     just a skeleton, a hint that you should do it. You should check into how
1123     the upstream build system handles the inclusion of debugging symbols and
1124     stripping on installation and implement this yourself.
1125    
1126     <p>Usually you can tell gcc to compile with "-g" using the CFLAGS variable
1127     -- if that's the case for your package, propagate the variable by
1128     <em>appending</em> <tt>CFLAGS="$(CFLAGS)"</tt> to the $(MAKE) invocation
1129     in the build rule (see below). Alternatively, if your package uses an
1130     autoconf configure script, you can pass it to configure by
1131     <em>prepending</em> the above string to the ./configure invocation in the
1132     build rule.
1133    
1134     <p>As for the stripping, programs are commonly configured to install
1135     themselves unstripped, and often without an option to change this.
1136     Fortunately, you still have <manref name="dh_strip" section="1"> which
1137     will detect when the DEB_BUILD_OPTIONS=nostrip flag is set and silently
1138     exit.
1139    
1140     <p>Lines 18 through 26 describe the `build' (and its child `build-stamp')
1141     rule, which runs make with the application's own Makefile to compile the
1142 osamu 2700 program. If your package uses GNU configure utilities to build binaries,
1143     please make absolutely sure to read <file>&autotools-dev;</file> .
1144     We'll talk about the commented out docbook-to-man example later
1145 joy 1526 in <ref id="manpage">.
1146    
1147     <p>The `clean' rule, as specified in lines 28-36, cleans up any unneeded
1148 joy 893 binary or auto-generated stuff, left over from building the package.
1149     This rule must be working at all times (even when the source tree <em/is/
1150     cleaned up!), so please use the forcing options (e.g. for rm, that is
1151 joy 1526 `-f'), or have make ignore return values (failures) using a `-' in front
1152     of the command name.
1153 joy 893
1154 joy 1526 <p>The installation process, the `install' rule, starts with line 38.
1155 joy 896 It basically runs the `install' rule from the program's own Makefile,
1156 joy 1526 but installs in the <tt>$(CURDIR)/debian/gentoo</tt> directory - this is
1157     why we specified
1158 joy 893 $(DESTDIR) as the root installation directory in gentoo's Makefile.
1159    
1160 joy 1526 <p>As the comments suggest, the `binary-indep' rule, on the line 48, is
1161     used to build packages independent of architecture. As we don't have any,
1162     nothing will be done there.
1163 joy 893
1164 joy 1618 <p>On to the next rule - `binary-arch', on lines 52 through 79, in which
1165 joy 896 we run several small utilities from the debhelper package that do various
1166     operations on your package files to make the package Policy conforming.
1167 joy 1526
1168     <p>If your package is an `Architecture: all' one, you need to include all
1169     the commands for building the package under the `binary-indep' rule, and
1170     leave the `binary-arch' rule empty instead.
1171 joy 893
1172 joy 1526 <p>The names of debhelper programs start with dh_, and the rest is the
1173     description of what the particular utility does. It is all quite
1174     self-explanatory, but here are some additional explanations:
1175 joy 893
1176     <list>
1177     <item><manref name="dh_testdir" section="1"> checks that you are in the
1178     right directory (i.e. the top-level source directory),
1179     <item><manref name="dh_testroot" section="1"> checks that you have root
1180 joy 1526 permissions which is needed for the targets `binary-arch',
1181     `binary-indep' and `clean',
1182     <item><manref name="dh_installman" section="1"> will copy the manpages
1183     into the right place in the destination directory, you just have to
1184     tell it where they are, relative to the top-level source directory,
1185 joy 893 <item><manref name="dh_strip" section="1"> strips debugging headers from
1186     executable files and libraries, to make them smaller,
1187 joy 1526 <item><manref name="dh_compress" section="1"> compresses man pages and
1188     documentation larger than 4 kB with <manref name="gzip" section="1">,
1189 joy 893 <item><manref name="dh_installdeb" section="1"> copies package related
1190 joy 1526 files (e.g. the maintainer scripts) to the
1191     <file>debian/gentoo/DEBIAN</file> directory,
1192 joy 893 <item><manref name="dh_shlibdeps" section="1"> calculates shared libraries
1193     dependencies of the libraries and executables,
1194 joy 1526 <item><manref name="dh_gencontrol" section="1"> installs a fine-tuned
1195     version of the control file into <file>debian/gentoo/DEBIAN</file>,
1196 joy 893 <item><manref name="dh_md5sums" section="1"> generates MD5 checksums for
1197     all the files in the package.
1198     </list>
1199    
1200     <p>For more complete information on what do all these dh_* scripts do, and
1201 joy 2366 what their other options are, please read their respective manual pages. There
1202     are some other (possibly very useful) dh_* scripts which were not
1203 joy 893 mentioned here. If you need them, read the debhelper documentation.
1204    
1205 joy 896 <p>The binary-arch section is the one where you really should comment
1206 joy 1526 out or remove any lines that call features you don't need. For gentoo,
1207 joy 1527 I'll comment out lines about examples, cron, init, man and info,
1208 joy 1526 simply because gentoo doesn't need them. Also, on the line 68, I'll
1209     replace `ChangeLog' with `FIXES', because that is the real name of the
1210     upstream changelog file.
1211 joy 893
1212     <p>The last two lines (along with any other not explained ones) are just
1213 joy 1198 some more-or-less necessary things, regarding which you can read in the
1214 joy 1526 make manual, and the Policy. For now, they're not important to know about.
1215 joy 893
1216     <chapt id="dother">Other files under debian/
1217    
1218     <p>You will see that there exist several other files in the debian/
1219 joy 2405 subdirectory, most of them with the `ex' suffix or prefix, meaning that
1220     they are examples. Take a look at all of them. If you wish or need to
1221     use any of those features:
1222 joy 1527
1223     <list>
1224     <item>take a look at the related documentation (hint: the Policy Manual),
1225     <item>if necessary modify the files to suit your needs,
1226 joy 1528 <item>rename them to remove the `.ex' suffix if they have one,
1227 joy 2405 <item>rename them to remove the `ex.' prefix if they have one,
1228 joy 1527 <item>modify the `rules' file if necessary.
1229     </list>
1230    
1231 joy 2366 <p>Some of those files, the commonly used ones, are explained in the
1232 joy 893 following sections.
1233    
1234 joy 896 <sect id="readme">README.Debian
1235 joy 893
1236     <p>Any extra details or discrepancies between the original package and
1237 joy 1527 your debianized version should be documented here.
1238 joy 893
1239 joy 1527 <p>dh_make created a default one, this is what it looks like:
1240    
1241     <p><example>
1242 joy 893 gentoo for Debian
1243 joy 1527 -----------------
1244 joy 893
1245     &lt;possible notes regarding this package - if none, delete this file&gt;
1246    
1247 joy 2365 -- Josip Rodin &lt;joy-mg@debian.org&gt;, Wed, 11 Nov 1998 21:02:14 +0100
1248 joy 893 </example>
1249    
1250 joy 1527 <p>Since we don't have anything to put there, we'll delete the file.
1251 joy 893
1252 joy 1527 <sect id="conffiles">conffiles.ex
1253 aph 743
1254     <p>One of the most annoying things about software is when you spend a
1255 joy 1527 great deal of time and effort customizing a program, only to have an
1256 aph 743 upgrade stomp all over your changes. Debian solves this problem by
1257 joy 1527 marking configuration files so that when you upgrade a package, you'll
1258     be prompted whether you want to keep your old configuration or not.
1259 aph 743
1260 joy 1527 <p>The way to do this in a package is to enter the full path to each
1261     configuration file (usually in /etc), one per line, in a file called
1262     <tt/conffiles/. Gentoo has one conffile, /etc/gentoorc, and we'll enter
1263     that in the <tt/conffiles/ file.
1264 joy 838
1265 joy 1527 <p>If your program uses configuration files but also rewrites them on its
1266     own, it's best not to mark them as conffiles because dpkg will then prompt
1267     users to verify the changes all the time.
1268    
1269     <p>If the program you're packaging requires every user to modify the
1270     configuration file in order to work at all, also consider not marking the
1271     file as a conffile.
1272    
1273     <p>You can handle example configuration files from the `maintainer
1274     scripts', for more information see <ref id="maintscripts">.
1275    
1276     <p>If your program has no conffiles, you can safely delete the
1277     <tt/conffiles/ file from the debian/ directory.
1278    
1279     <sect id="crond">cron.d.ex
1280    
1281     <p>If your package requires regularly scheduled tasks to operate properly,
1282     you an use this file to set it up.
1283    
1284     <p>Note that this doesn't include log rotation; for that, see
1285     <manref name="dh_installlogrotate" section="1"> and
1286     <manref name="logrotate" section="8">.
1287    
1288     <p>If not, remove it.
1289    
1290 aph 743 <sect id="dirs">dirs
1291    
1292 joy 1198 <p>This file specifies the directories which we need but the normal
1293 joy 838 installation procedure (make install) somehow doesn't create.
1294 joy 797
1295 joy 1527 <p>By default, it looks like this:
1296    
1297 aph 743 <p><example>
1298 joy 838 usr/bin
1299     usr/sbin
1300 aph 743 </example>
1301    
1302     <p>Note that the preceding slash is not included. We would have normally
1303     changed it to look like this:
1304 joy 1527
1305 aph 743 <p><example>
1306 joy 1527 usr/bin
1307     usr/man/man1
1308 aph 743 </example>
1309    
1310 joy 1527 <p>but those directories are already created in the Makefile, so we won't
1311     need this file, and we will instead delete it.
1312 aph 743
1313 joy 1528 <sect id="docs">docs
1314    
1315     <p>This file specifies the file names of documentation files we can have
1316     dh_installdocs install into the temporary directory for us.
1317    
1318     <p>By default, it will include all existing files in the top-level source
1319     directory that are called "BUGS", "README*", "TODO" etc.
1320    
1321     <p>For gentoo, I also included some other stuff:
1322    
1323     <p><example>
1324     BUGS
1325     CONFIG-CHANGES
1326     CREDITS
1327     ONEWS
1328     README
1329     README.gtkrc
1330     TODO
1331     </example>
1332    
1333     <p>We can also remove this file and instead list these files on the
1334     <tt/dh_installdocs/ command line in the <tt/rules/ file, like this:
1335    
1336     <p><example>
1337     dh_installdocs BUGS CONFIG-CHANGES CREDITS ONEWS README \
1338     README.gtkrc TODO
1339     </example>
1340    
1341     <p>How ever unlikely it may seem, you may not have any such files in your
1342 joy 1552 package's sources. In that case you can safely remove this file. But don't
1343     remove the <tt/dh_installdocs/ invocation from the <tt/rules/ file because
1344     that's used to install the <tt/copyright/ file and other things.
1345 joy 1528
1346 joy 1527 <sect id="emacsen">emacsen-*.ex
1347 aph 743
1348 joy 1527 <p>If your package supplies Emacs files that can be bytecompiled at
1349     package installation time, you can use these files to set it up.
1350 aph 743
1351 joy 1527 <p>They are installed into the temporary directory by
1352     <manref name="dh_installemacsen" section="1">, so don't forget to
1353     uncomment that line in the <tt/rules/ file if you use this.
1354 aph 743
1355 joy 1527 <p>If you don't need these, remove them.
1356    
1357     <sect id="initd">init.d.ex
1358    
1359     <p>If your package is a daemon that needs to be run at system startup,
1360     you've obviously disregarded my initial recommendation, haven't you? :-)
1361    
1362     <p>This is a fairly generic skeleton file for an <file>/etc/init.d/</file>
1363     script, so you'll likely have to edit it, a lot. It gets installed into
1364     the temporary directory by <manref name="dh_installinit" section="1">.
1365    
1366     <p>If you don't need this, remove the file.
1367    
1368     <sect id="manpage">manpage.1.ex, manpage.sgml.ex
1369    
1370     <p>Your program(s) should have a manual page. If they don't, each of these
1371 joy 2366 files is a template that you can fill out.
1372 joy 1527
1373     <p>Manual pages are normally written in <manref name="nroff" section="1">.
1374     The <tt/manpage.1.ex/ example is written in nroff, too.
1375     See the <manref name="man" section="7"> manual page
1376     for a brief description of how to edit such a file.
1377    
1378     <p>If on the other hand you prefer writing SGML instead of nroff, you can
1379     use the <tt/manpage.sgml.ex/ template. If you do this, you have to:
1380     <list>
1381     <item>install the <package/docbook-to-man/ package
1382     <item>add <tt/docbook-to-man/ to the <tt/Build-Depends/ line in the
1383     <tt/control/ file
1384     <item>remove the comment from the docbook-to-man invocation in the
1385     `build' rule of your <tt/rules/ file
1386     </list>
1387    
1388     <p>And remember to rename the file to something like <tt/gentoo.sgml/!
1389    
1390     <p>The final manual page file name should include the name of the program
1391     it is documenting, so we will rename it from "manpage" to "gentoo".
1392     The file name also includes ".1" as the first suffix, which means it's a
1393     manual page for a user command. Be sure to verify that this section is
1394     indeed the correct one. Here's a short list of manual page sections:
1395    
1396 aph 743 <p><example>
1397     Section | Description | Notes
1398     1 User commands Executable commands or scripts.
1399     2 System calls Functions provided by the kernel.
1400     3 Library calls Functions within system libraries.
1401     4 Special files Usually found in /dev
1402     5 File formats E.g. /etc/passwd's format
1403     6 Games Or other frivolous programs
1404     7 Macro packages Such as man macros.
1405     8 System administration Programs typically only run by root.
1406     9 Kernel routines Non-standard calls and internals.
1407     </example>
1408    
1409 joy 1527 <p>So gentoo's man page should be called <tt/gentoo.1/. For X programs you
1410     can tack on another "x" to the section, i.e. <tt/gentoo.1x/.
1411     There was no gentoo.1 man page in the original source so I wrote
1412     it using information from the example and from upstream docs.
1413 aph 743
1414     <sect id="menu">menu.ex
1415    
1416 joy 838 <p>X Window System users usually have a window manager with a menu that
1417     can be customized to launch programs. If they have installed the Debian
1418 joy 1527 <package/menu/ package, a set of menus for every program on the system will be
1419     created for them.
1420    
1421 joy 2366 <p>Here's the default <tt/menu.ex/ file that dh_make created:
1422 aph 743
1423     <p><example>
1424     ?package(gentoo):needs=X11|text|vc|wm section=Apps/see-menu-manual\
1425     title="gentoo" command="/usr/bin/gentoo"
1426     </example>
1427    
1428 joy 1527 <p>The first field after the colon character is "needs", and it specifies
1429     what kind of interface the program needs. Change this to one of the listed
1430     alternatives, e.g. "text" or "X11".
1431    
1432     <p>The next is "section", where the menu and submenu the entry should
1433 joy 838 appear in. The current list of sections is at:
1434 joy 1527 <file>/usr/share/doc/debian-policy/menu-policy.html/ch2.html#s2.1</file>
1435 aph 743
1436 joy 1527 <p>The "title" field is the name of the program. You can start this one
1437     in uppercase if you like. Just keep it short.
1438    
1439     <p>Finally, the "command" field is the command that runs the program.
1440    
1441 aph 743 <p>Now we'll change the menu entry to this:
1442 joy 1527
1443 aph 743 <p><example>
1444 joy 1533 ?package(gentoo): needs=X11 section=Apps/Tools title="Gentoo" command="gentoo"
1445 aph 743 </example>
1446    
1447 joy 1527 <p>You can also add other fields like "longtitle", "icon", "hints" etc.
1448     See <manref name="menufile" section="5">,
1449     <manref name="update-menus" section="1">
1450     and <file>/usr/share/doc/debian-policy/menu-policy.html/</file> for more
1451     information.
1452 joy 838
1453 aph 743 <sect id="watch">watch.ex
1454    
1455 joy 1527 <p>This file is used to configure the <manref name="uscan" section="1">
1456     and <manref name="uupdate" section="1"> programs (in the
1457     <package/devscripts/ package). These are used to watch the site you got
1458     the original source from.
1459 aph 743
1460 joy 1527 <p>Here's what I put in it:
1461    
1462 joy 838 <p><example>
1463     # watch control file for uscan
1464 joy 896 # Site Directory Pattern Version Script
1465     ftp.obsession.se /gentoo gentoo-(.*)\.tar\.gz debian uupdate
1466 joy 838 </example>
1467 aph 743
1468 joy 838 <p>Hint: connect to the Internet, and try running "uscan" in the program
1469 joy 1527 directory once you create the file. And read the manuals! :)
1470 aph 743
1471 joy 1527 <sect id="doc-base">ex.package.doc-base
1472 joy 896
1473 joy 1527 <p>If your package has documentation other than manual pages and info
1474     docs, you should use the `<package/doc-base/' file to register it,
1475     so the user can find it with e.g. <manref name="dhelp" section="1">,
1476     <manref name="dwww" section="1"> or <manref name="doccentral" section="1">.
1477 joy 896
1478 joy 1527 <p>This usually includes HTML, PS and PDF files, shipped in
1479     <file>/usr/share/doc/packagename/</file>.
1480    
1481 joy 2405 <p>This is how gentoo's doc-base file <tt>gentoo.doc-base</tt> looks like:
1482 joy 896
1483     <p><example>
1484     Document: gentoo
1485     Title: Gentoo Manual
1486     Author: Emil Brink
1487     Abstract: This manual describes what Gentoo is, and how it can be used.
1488     Section: Apps/Tools
1489    
1490     Format: HTML
1491     Index: /usr/share/doc/gentoo/html/index.html
1492     Files: /usr/share/doc/gentoo/html/*.html
1493     </example>
1494    
1495 joy 1527 <p>For information on the file format, see
1496     <manref name="install-docs" section="8"> and the <package/doc-base/ manual,
1497     in <file>/usr/share/doc/doc-base/doc-base.html/</file>.
1498 joy 896
1499 joy 838 <sect id="maintscripts">postinst.ex, preinst.ex, postrm.ex, prerm.ex
1500    
1501 joy 1527 <p>These files are called maintainer scripts. They are scripts which are
1502     put in the control area of the package and run by <prgn/dpkg/ when your
1503     package is installed, upgraded or removed.
1504 joy 896
1505     <p>For now, you should try to avoid any manual editing of maintainer
1506     scripts if you possibly can because they tend to get complex. For more
1507 joy 1619 information look in the Policy Manual, chapter 6, and take a look at
1508 joy 838 these example files provided by dh_make.
1509    
1510 joy 1527 <chapt id="build">Building the package
1511    
1512 joy 838 <p>We should now be ready to build the package.
1513    
1514 joy 1530 <sect id="completebuild">Complete rebuild
1515 joy 1529
1516 joy 893 <p>Enter the program's main directory and then issue this command:
1517 joy 838
1518 aph 743 <p><example>
1519 joy 773 dpkg-buildpackage -rfakeroot
1520 aph 743 </example>
1521    
1522 joy 1529 <p>This will do everything for you. It will:
1523     <list>
1524     <item>clean the source tree (debian/rules clean), using <prgn/fakeroot/
1525     <item>build the source package (dpkg-source -b)
1526     <item>build the program (debian/rules build)
1527     <item>build the binary package (debian/rules binary), using <prgn/fakeroot/
1528     <item>sign the source <tt/.dsc/ file, using <prgn/gnupg/
1529     <item>create and sign the upload <tt/.changes/ file, using
1530     <prgn/dpkg-genchanges/ and <prgn/gnupg/
1531     </list>
1532 aph 743
1533 joy 1529 <p>The only input that will be required of you is your GPG key secret pass
1534     phrase, twice.
1535    
1536     <p>After all this is done, you will see the following files in the
1537 osamu 2689 directory above (<file>~/gentoo/</file>):
1538 joy 1529
1539 aph 743 <p><list>
1540     <item><em>gentoo_0.9.12.orig.tar.gz</em>
1541    
1542 joy 1529 <p>This is the original source code tarball, merely renamed to the above
1543 joy 1531 so that it adheres to the Debian standard. Note that this was created
1544     using the `-f' option to <prgn/dh_make/ when we initially ran it.
1545 joy 1529
1546 aph 743 <item><em>gentoo_0.9.12-1.dsc</em>
1547 joy 1529
1548 aph 743 <p>This is a summary of the contents of the source code. The file is
1549 joy 1529 generated from your `control' file, and is used when
1550 joy 770 unpacking the source with <manref name="dpkg-source" section="1">. This
1551 osamu 2676 file is GPG signed, so that people can be sure that it's really yours.
1552 joy 838
1553     <item><em>gentoo_0.9.12-1.diff.gz</em>
1554 joy 1529
1555 joy 838 <p>This compressed file contains each and every addition you made to the
1556 joy 1619 original source code, in the form known as "unified diff". It is made and
1557     used by <manref name="dpkg-source" section="1">. Warning: if you don't name
1558 joy 1531 the original tarball packagename_version.orig.tar.gz, <prgn/dpkg-source/
1559     will fail to generate the .diff.gz file properly!
1560 joy 838
1561 joy 1531 <p>If someone else wants to re-create your package from scratch, they can
1562 joy 1529 easily do so using the above three files. The extraction procedure is
1563     trivial: just copy the three files somewhere else and run
1564     <tt>dpkg-source -x gentoo_0.9.12-1.dsc</tt>.
1565    
1566     <item><em>gentoo_0.9.12-1_i386.deb</em>
1567    
1568     <p>This is your completed binary package. You can use <prgn/dpkg/ to
1569     install and remove this just like any other package.
1570    
1571 joy 838 <item><em>gentoo_0.9.12-1_i386.changes</em>
1572 joy 1529
1573 joy 838 <p>This file describes all the changes made in the current package
1574     revision, and it is used by the Debian FTP archive maintenance programs
1575     to install the binary and source packages in it. It is partly generated
1576 osamu 2676 from the `changelog' file and the .dsc file. This file is GPG signed, so
1577 joy 1529 that people can be sure that it's really yours.
1578 joy 838
1579     <p>As you keep working on the package, behavior will change and new
1580     features will be added. People downloading your package can look at this
1581 joy 1529 file and quickly see what has changed. Debian archive maintenance programs
1582     will also post the contents of this file to the debian-devel-changes
1583     mailing list.
1584 aph 743 </list>
1585    
1586 joy 1529 <p>The long strings of numbers in the .dsc and .changes files are MD5
1587     checksums for the files mentioned.
1588     A person downloading your files can test them with <manref name="md5sum"
1589     section="1"> and if the numbers don't match, they'll know the file is
1590     corrupt or has been tampered with.
1591    
1592     <sect id="quickrebuild">Quick rebuild
1593    
1594 joy 896 <p>With a large package, you may not want to rebuild from scratch every
1595 joy 1529 time while you tune a detail in <file>debian/rules</file>. For testing
1596     purposes, you
1597 joy 896 can make a .deb file without rebuilding the upstream sources like this:
1598 aph 743
1599 joy 896 <p><example>
1600     fakeroot debian/rules binary
1601     </example>
1602    
1603 joy 1529 <p>Once you are finished with your tuning, remember to rebuild following
1604     the above, proper procedure. You may not be able to upload correctly if
1605     you try to upload .deb files built this way.
1606 joy 896
1607 osamu 2680 <sect id="debuild">The <prgn>debuild</prgn> command
1608    
1609     <p>You can automate package build process further with
1610     <prgn>debuild</prgn> command.
1611     See <manref name="debuild" section="1">.
1612    
1613     <p>Customization of the debuild command can be done through
1614     <file>/etc/devscripts.conf</file> or <file>~/.devscripts</file>.
1615     I would suggest at least following items:
1616    
1617     <p><example>
1618     DEBSIGN_KEYID="Your_SSH_keyID"
1619     DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -ICVS -I.svn"
1620     </example>
1621     With these, you can build package always with your GPG key and avoid
1622     including undesired components. (This is good for sponsoring too.)
1623     For example, cleaning source and rebuilding package from a user account
1624     is as simple as:
1625    
1626     <p><example>
1627     debuild clean
1628     debuild
1629     </example>
1630    
1631 osamu 2685 <sect id="dpatch">The <prgn>dpatch</prgn> system
1632 osamu 2679 <p>
1633     The simple use of <prgn>dh_make</prgn> and
1634     <prgn>dpkg-buildpackage</prgn> commands will create a single large
1635     <file>diff.gz</file> file which contains package maintenance files in
1636     <file>debian/</file> and patch files to the source. Such package is a
1637     bit cumbersome to inspect and understand for each source tree
1638     modification later. This is not so nice.
1639     <footnote>
1640     If you are not yet Debian Developer and asking your sponsor to upload
1641     your package after his package review, you should make package as easy
1642     as possible for him to review.
1643     </footnote>
1644     <p>
1645     Several methods for the patch set maintenance have been proposed and in
1646     use with Debian packages. The <prgn>dpatch</prgn> system is one of the
1647     simplest of such patch maintenance system proposed. Other ones are
1648     dbs, cdbs, etc.
1649     <p>
1650     A package which is packaged properly with the <prgn>dpatch</prgn> system
1651     has modifications to the source clearly documented as patch set files in
1652     <file>debian/patches/</file> and the source tree is untouched outside of
1653     <file>debian/</file> directory. If you are asking sponsor to upload
1654     your package, this kind of clear separation and documentation of your
1655     changes are very important to expedite the package review by your
1656     sponsor. The usage method of <prgn>dpatch</prgn> is explained in
1657     <manref section="1" name="dpatch">.
1658     <p>
1659     When someone (including yourself) provides you with a patch to the
1660     source later, then the package modification under dpatch is quite
1661     simple:
1662     <list compact>
1663     <item>Edit patch to make it a -p1 patch to the source tree.
1664     <item>Add header using <prgn>dpatch patch-template</prgn> command.
1665     <item>Drop it into <file>debian/patches</file>
1666     <item>Add this dpatch filenames to <file>debian/patches/00list</file>
1667     </list>
1668     <p>
1669     Also, <prgn>dpatch</prgn> has a capability to make patches architecture
1670     dependent using CPP macro.
1671    
1672     <sect id="option-sa">Including <file>orig.tar.gz</file> for upload
1673     <p>
1674     When you first upload the package to the archive, you need to include
1675     the original <file>orig.tar.gz</file> source. If package version is not
1676 osamu 2798 at <tt>-0</tt> or <tt>-1</tt> Debian revision, you must provide
1677 osamu 2679 <prgn>dpkg-buildpackage</prgn> command with the "<tt>-sa</tt>" option.
1678 osamu 2799 On the other hand, the "<tt>-sd</tt>" option will force to exclude the
1679     original <file>orig.tar.gz</file> source.
1680 osamu 2679
1681 joy 1527 <chapt id="checkit">Checking the package for errors
1682 osamu 2680 <p>
1683    
1684 osamu 2681 <sect id="lintians">The <package>lintian</package> and <package>linda</package> packages
1685 joy 896
1686 osamu 2669 <p>Run <manref name="lintian" section="1"> and
1687     <manref name="linda" section="1"> on your .changes file; these
1688     programs will check for many common packaging errors. The commands are:
1689 aph 743
1690     <p><example>
1691     lintian -i gentoo_0.9.12-1_i386.changes
1692 osamu 2669 linda -i gentoo_0.9.12-1_i386.changes
1693 aph 743 </example>
1694    
1695 joy 1530 <p>Of course, replace the filename with the name of the .changes file
1696 joy 896 generated for your package. If it appears that there are some errors
1697     (lines beginning with E:), read the explanation (the N: lines), correct
1698 joy 1530 mistakes, and rebuild as described in <ref id="completebuild">. If there are
1699     lines that begin with W:, those are warnings, so tune the package or
1700     verify that the warnings are spurious (and make Lintian overrides; see
1701     the documentation for details).
1702 aph 743
1703 osamu 2669 <p>Note that you can build the package with <prgn/dpkg-buildpackage/ , run
1704     <prgn/lintian/ , and <prgn/linda/ all in one command with
1705     <manref name="debuild" section="1">.
1706    
1707 osamu 2770 <sect id="mc">The <prgn>mc</prgn> command
1708 osamu 2682
1709 osamu 2770 <p>You can unpack contents of <file>*.deb</file> package with <manref
1710     name="dpkg-deb" section="1"> command. You can list contents of a
1711     generated Debian package with <manref name="debc" section="1">.
1712     <p>
1713     This can be made into an intuitive process by
1714 osamu 2682 using a file manager like <manref name="mc" section="1"> which will
1715     let you browse not only the contents of <file>*.deb</file> package
1716     files but also <file>*.diff.gz</file> and <file>*.tar.gz</file> files.
1717     <p>
1718 osamu 2770 Be on the lookout for extra unneeded files or zero length files, both
1719     in the binary and source package. Often cruft doesn't get cleaned up
1720     properly; adjust your rules file to compensate for that.
1721     <p>
1722     Tips: `<tt>zgrep ^+++ ../gentoo_0.9.12-1.diff.gz</tt>' will give you a
1723     list of your changes/additions to the source files, and `<tt>dpkg-deb
1724     -c gentoo_0.9.12-1_i386.deb</tt>' or `<tt>debc
1725     gentoo_0.9.12-1_i386.changes</tt>' will list the files in the binary
1726     package.
1727 joy 838
1728 osamu 2770 <sect id="debdiff">The <prgn>debdiff</prgn> command
1729    
1730     <p>You can compare file lists in two binary Debian packages with
1731     <manref name="debdiff" section="1"> command. This is useful for
1732 osamu 2781 verifying that no files have been unintentionally misplaced or removed,
1733 osamu 2770 and no other inadvertent changes were made when updating packages.
1734     You can check group of <file>*.deb</file> files simply by `<tt>debdiff
1735 osamu 2788 old-package.change new-package.change</tt>'.
1736 osamu 2770
1737     <sect id="interdiff">The <prgn>interdiff</prgn> command
1738    
1739     <p>You can compare two <file>diff.gz</file> files with <manref
1740 osamu 2781 name="interdiff" section="1"> command. This is useful for verifying
1741 osamu 2770 that no inadvertent changes were made to the source by the maintainer
1742     when updating packages. Run `<tt>interdiff -z old-package.diff.gz
1743 osamu 2788 new-package.diff.gz</tt>'.
1744 osamu 2770
1745 osamu 2682 <sect id="debi">The <prgn>debi</prgn> command
1746    
1747 joy 896 <p>Install the package to test it yourself, e.g. using the
1748     <manref name="debi" section="1"> command as root. Try to install and run
1749     it on machines other than your own and watch closely for any warnings
1750 joy 1530 or errors both during the installation and while the program is being run.
1751 aph 743
1752 osamu 2676 <sect id="pbuilder">The <package>pbuilder</package> package
1753     <p>
1754 osamu 2669 For clean room (chroot) build environment to verify the build
1755     dependencies, <package>pbuilder</package> package is very useful. This
1756 osamu 2688 ensures clean build from source under the auto-builder for different
1757     architectures and avoid the severity serious FTBFS (Fails To Build From
1758     Source) bug which is always in the RC (release critical) category. See
1759     <url id="&buildd-home;"> for more on the Debian package auto-builder.
1760 osamu 2669 <p>
1761     The most basic use of <package>pbuilder</package> package is the direct
1762     invocation of <prgn>pbuilder</prgn> command from root. For example,
1763     issue following commands in the directory where <file>.orig.tar.gz</file>,
1764     <file>.diff.gz</file>, and <file>.dsc</file> exist
1765     to build a package.
1766     <example>
1767     root # pbuilder create # if second time, pbuilder update
1768     root # pbuilder build foo.dsc
1769     </example>
1770     The newly build packages will be located in
1771     <file>/var/cache/pbuilder/result/</file> with root ownership.
1772     <p>
1773 osamu 2675 The <prgn>pdebuild</prgn> command helps you to use
1774     <package>pbuilder</package> package functions from the normal user
1775     account with <tt><var>numeric_UID</var></tt> and
1776     <tt><var>numeric_GID</var></tt> . I would suggest first customize your
1777     system by setting:
1778 osamu 2669 <example>
1779     BUILDRESULTUID=<var>numeric_UID</var>
1780     BUILDRESULTGID=<var>numeric_GID</var>
1781     AUTO_DEBSIGN=yes
1782     </example>
1783 osamu 2675 in <file>~/.pbuilderrc</file> or <file>/etc/pbuilderrc</file> . You
1784     need to change the ownership of <file>/var/cache/pbuilder/result/</file>
1785     to something like <tt><var>numeric_UID</var>:<var>numeric_GID</var></tt>
1786     with the permission <tt>2775</tt> to enable signing from your user
1787     account with <var>numeric_UID</var> where you keep your secret GPG key
1788     under <file>~/.gnupg/</file>. You also need to set up this user account
1789     with <prgn>sudo</prgn> command.
1790 osamu 2669 <p>
1791     Then, from the root of source tree while having
1792 osamu 2675 <file>orig.tar.gz</file> file in its parent directory, you issue
1793 osamu 2669 following commands:
1794     <example>
1795     $ sudo pbuilder create # if second time, sudo pbuilder update
1796     $ pdebuild
1797     </example>
1798     The newly build packages will be located in
1799     <file>/var/cache/pbuilder/result/</file> with non-root ownership.
1800     <p>
1801 osamu 2675 See <url id="&pbuilder-home;">,
1802 osamu 2669 <manref section="1" name="pdebuild">,
1803     <manref section="5" name="pbuilderrc">, and
1804     <manref section="8" name="pbuilder"> .
1805 joy 770
1806 osamu 2669
1807 osamu 2676 <chapt id="upload">Uploading the package
1808 osamu 2669
1809 joy 1530 <p>Now that you have tested your new package thoroughly, you will be ready
1810     to start the Debian new maintainer application process, as described at
1811     <url id="http://www.debian.org/devel/join/newmaint">
1812 joy 770
1813 osamu 2799 <sect id="upload-debian">Uploading to the Debian archive
1814    
1815 joy 1530 <p>Once you become an official developer, you'll need to upload the
1816     package to the Debian archive. You can do this manually, but it's easier
1817     to use the provided automated tools, like
1818     <manref name="dupload" section="1"> or <manref name="dput" section="1">.
1819     We'll describe how it's done with <prgn/dupload/.
1820 aph 743
1821 joy 1531 <p>First you have to set up dupload's config file. You can either edit the
1822     system-wide <file>/etc/dupload.conf</file> file, or have your own
1823     <file>~/.dupload.conf</file> file override the few things you want to
1824     change. Put something like this in the file:
1825 aph 743
1826 joy 896 <p><example>
1827 joy 838 package config;
1828 joy 1553
1829 osamu 2799 $default_host = "anonymous-ftp-master";
1830 joy 1553
1831 osamu 2799 $cfg{'anonymous-ftp-master'} = {
1832     fqdn => "ftp-master.debian.org",
1833     method => "ftp",
1834     incoming => "/pub/UploadQueue/",
1835     # files pass on to dinstall on ftp-master which sends emails itself
1836     dinstall_runs => 1,
1837     };
1838 joy 1553
1839 joy 838 1;
1840 aph 743 </example>
1841    
1842 joy 838 <p>Of course, change my personal settings to yours, and read the
1843     <manref name="dupload.conf" section="5"> manual page to understand
1844 joy 896 what each of these options means.
1845 joy 773
1846 joy 1530 <p>The $default_host option is the trickiest one -- it determines which of
1847 osamu 2799 the upload queues will be used by default. "anonymous-ftp-master" is the primary
1848 joy 1530 one, but it's possible that you will want to use another, faster one.
1849     For more information about the upload queues, read the Developers'
1850     Reference, section "Uploading a package", at
1851 osamu 2666 <file>&uploading;</file>
1852 joy 1530
1853 joy 893 <p>Then connect to your Internet provider, and issue this command:
1854 aph 743
1855     <p><example>
1856 joy 1530 dupload gentoo_0.9.12-1_i386.changes
1857 aph 743 </example>
1858    
1859 joy 1530 <p><prgn/dupload/ checks that the MD5 checksums of the files match those from the
1860 joy 896 .changes file, so it will warn you to rebuild it as described in
1861 joy 1530 <ref id="completebuild"> so it can properly upload.
1862 joy 896
1863 osamu 2799 <!-- (No more use of ftp-master)
1864 joy 1530 <p>If you upload to "ftp-master", <prgn/dupload/ will ask for your
1865     password on Debian machines, and then upload the packages.
1866 osamu 2799 -->
1867 joy 838
1868 osamu 2799 <p>If you enconter an upload problem at <url id="&ftp-uploadqueue;">,
1869     you can fix this by manually uploading gnupg signed
1870 osamu 2800 <file>*.commands</file> file to <url id="&ftp-uploadqueue;"> with
1871 osamu 2799 <prgn>ftp</prgn>.
1872     <footnote>
1873     See <url id="&ftp-command;">. Alternatively, you may use
1874     <prgn>dcut</prgn> command from the <package>dput</package> package.
1875     </footnote>
1876 osamu 2800 For example, use <file>hello.commands</file>:
1877 osamu 2799 <example>
1878     -----BEGIN PGP SIGNED MESSAGE-----
1879    
1880     Uploader: Roman Hodek &lt;lRoman.Hodek@informatik.uni-erlangen.de&gt;
1881     Commands:
1882     rm hello_1.0-1_i386.deb
1883     mv hello_1.0-1.dsx hello_1.0-1.dsc
1884    
1885     -----BEGIN PGP SIGNATURE-----
1886     Version: 2.6.3ia
1887    
1888     iQCVAwUBNFiQSXVhJ0HiWnvJAQG58AP+IDJVeSWmDvzMUphScg1EK0mvChgnuD7h
1889     BRiVQubXkB2DphLJW5UUSRnjw1iuFcYwH/lFpNpl7XP95LkLX3iFza9qItw4k2/q
1890     tvylZkmIA9jxCyv/YB6zZCbHmbvUnL473eLRoxlnYZd3JFaCZMJ86B0Ph4GFNPAf
1891     Z4jxNrgh7Bc=
1892     =pH94
1893     -----END PGP SIGNATURE-----
1894     </example>
1895    
1896     <sect id="upload-private">Uploading to a private archive
1897    
1898 osamu 2676 <p>If you want to create a personal package archive at
1899 osamu 2684 <tt>URL="http://people.debian.org/~<var>account_name</var>"</tt> as a
1900 osamu 2683 developer with simple invocation of
1901     <tt>dupload -t <var>target_name</var></tt>, you should add following
1902     to <file>/etc/dupload.conf</file> file:
1903 osamu 2676 <example>
1904     # Developer account
1905     $cfg{'<var>target_name</var>'} = {
1906     fqdn =&gt; "people.debian.org",
1907     method =&gt; "scpb",
1908     incoming =&gt; "/home/<var>account_name</var>/public_html/package/",
1909     # I do not need to announce
1910     dinstall_runs =&gt; 1,
1911     };
1912 osamu 2697 $cfg{'<var>target_name</var>'}{preupload}{'changes'} = "
1913     echo 'mkdir -p public_html/package' | ssh people.debian.org 2&gt;/dev/null ;
1914     echo 'Package directory created!'";
1915    
1916 osamu 2676 $cfg{'<var>target_name</var>'}{postupload}{'changes'} = "
1917 osamu 2697 echo 'cd public_html/package ;
1918 osamu 2676 dpkg-scanpackages . /dev/null &gt;Packages || true ;
1919     dpkg-scansources . /dev/null &gt;Sources || true ;
1920 osamu 2697 gzip -c Packages >Packages.gz ;
1921     gzip -c Sources &gt;Sources.gz ' | ssh people.debian.org 2&gt;/dev/null ;
1922     echo 'Package archive created!'";
1923    
1924 osamu 2676 </example>
1925     Here, APT archive is built with a quick and dirty remote shell execution
1926     with SSH. The override files required by <prgn>dpkg-scanpackages</prgn>
1927     and <prgn>dpkg-scansources</prgn> are given as <file>/dev/null</file>.
1928     This technique can be used by non Debian Developer to host his packages
1929 osamu 2775 in his personal web host site. You may alternatively use
1930     <prgn>apt-ftparchive</prgn> or other scripts to create APT archive.
1931 osamu 2676
1932 joy 1524 <chapt id="update">Updating the package
1933 aph 743
1934 joy 1524 <sect id="newrevision">New Debian revision
1935    
1936 joy 896 <p>Let's say that a bug report was filed against your package, #54321,
1937     and it describes a problem that you can solve. To create a new Debian
1938     revision of the package, you need to:
1939    
1940     <list>
1941     <item>Correct the problem in the package source, of course.
1942    
1943 joy 1526 <item>Add a new revision at the top of the Debian changelog file, for
1944 osamu 2770 example with `<tt>dch -i</tt>`, or explicitly with
1945 osamu 2774 `<tt>dch -v &lt;version&gt;-&lt;revision&gt;</tt>'
1946 joy 1526 and then insert the comments using your preferred editor.
1947    
1948     <p>Tip: how to easily get the date in required format?
1949 osamu 2770 Use `<tt>822-date</tt>', or `<tt>date -R</tt>'.
1950 joy 1526
1951     <item>Include a short description of the bug and the solution in the
1952     changelog entry,
1953 joy 896 followed by this: "Closes: #54321". That way, the bug report will be
1954     automagically closed by the archive maintenance software the moment your
1955     package gets accepted in the Debian archive.
1956    
1957 joy 1530 <item>Repeat what you did in <ref id="completebuild">, <ref id="checkit">,
1958 joy 896 and <ref id="upload">. The difference is that this time, original source
1959     archive won't be included, as it hasn't been changed and it already
1960     exists in the Debian archive.
1961     </list>
1962    
1963 osamu 2774 <sect id="newupstream">New upstream release (basic)
1964 joy 1524
1965 joy 896 <p>Now let's consider a different, a wee bit more complicated situation
1966     - a new upstream version was released, and of course you want it packaged.
1967     You need to do the following:
1968    
1969     <list>
1970     <item>Download the new sources and put the tarball (e.g. named
1971 osamu 2770 `<file>gentoo-0.9.13.tar.gz</file>') in the directory above the old source tree
1972 osamu 2689 (e.g. <file>~/gentoo/</file>).
1973 joy 896
1974     <item>Enter the old source directory, and run:
1975    
1976     <example>
1977     uupdate -u gentoo-0.9.13.tar.gz
1978     </example>
1979    
1980 joy 1530 <p>Of course, replace this file name with the name of your program's new source
1981 joy 896 archive. <manref name="uupdate" section="1"> will properly rename that
1982 osamu 2770 tarball, try to apply all the changes from your previous <file>.diff.gz</file> file,
1983     and update the new <file>debian/changelog</file> file.
1984 joy 896
1985 osamu 2770 <item>Change directory to `<file>../gentoo-0.9.13</file>', the new package source tree,
1986 joy 1530 and repeat what you did in <ref id="completebuild">, <ref id="checkit">, and
1987 joy 896 <ref id="upload">.
1988     </list>
1989    
1990 osamu 2770 <p>Note that if you set up `<file>debian/watch</file>' file as described in
1991 joy 896 <ref id="watch">, you can run <manref name="uscan" section="1"> to
1992 joy 1530 automagically look for revised sources, download them, and run
1993     <prgn/uupdate/.
1994 joy 896
1995 osamu 2774 <sect id="newupstream-real">New upstream release (realistic)
1996 osamu 2769
1997     <p>
1998 osamu 2774 When preparing packages for the the Debian archive, you must check
1999     resulting packages in detail. Here is a more realistic example of this
2000     procedure.
2001 osamu 2769
2002     <enumlist compact>
2003    
2004     <item>Verify changes in upstream source
2005    
2006     <list compact>
2007    
2008 osamu 2781 <item>Read the upstream <file>changelog</file>, <file>NEWS</file>, and
2009     whatever other documentation they may have released with the new
2010     version.
2011 osamu 2769
2012 osamu 2770 <item>Do a `<tt>diff -urN</tt>' between the old and new upstream sources
2013     to try to get a feel for the scope of the changes, where work is
2014     actively being done (and thus where new bugs may appear), and also keep
2015     an eye out for anything suspicious.
2016 osamu 2769
2017     </list>
2018    
2019     <item>Port the old Debian packaging to the new version.
2020    
2021     <list compact>
2022    
2023 osamu 2781 <item>Unpack the source tarball and rename the root of the source tree as
2024     <file>&lt;packagename&gt;-&lt;upstream_version&gt;/</file> and
2025     `<tt>cd</tt>' into this directory.
2026 osamu 2769
2027 osamu 2782 <item>Copy the source tarball in the parent directory and rename it as
2028 osamu 2781 <file>&lt;packagename&gt;_&lt;upstream_version&gt;.orig.tar.gz</file> .
2029    
2030     <item>Apply the same kind of modification to the new source tree as the
2031     old source tree. Possible methods are:
2032     <list compact>
2033 osamu 2789 <item>`<tt>zcat <var>/path/to/</var>&lt;packagename&gt;_&lt;old-version&gt;.diff.gz | patch -p1</tt>' command,
2034 osamu 2781 <item>`<prgn>uupdate</prgn>' command,
2035     <item>`<tt>svn merge</tt>' command if you manage the source with
2036     Subversion repository, or
2037     <item>simply copying <file>debian/</file> directory from the old source
2038     tree if it was packaged with <package>dpatch</package>.
2039     </list>
2040    
2041 osamu 2769 <item>Preserve old changelog entries (sounds obvious, but there have
2042     been incidents...)
2043    
2044     <item>The new package version is the upstream release version appended
2045 osamu 2770 with a <tt>-1</tt> Debian revision number, e.g., `<tt>0.9.13-1</tt>'.
2046 osamu 2769
2047     <item>Add changelog record entry with "New upstream release" for this
2048 osamu 2777 new version at the top of <file>debian/changelog</file>. For example
2049     `<tt>dch -v 0.9.13-1</tt>'.
2050 osamu 2769
2051     <item>Describe concisely the changes <em>in</em> the new upstream
2052     release that fix reported bugs and close those bugs in the changelog.
2053    
2054     <item>Describe concisely the changes <em>to</em> the new upstream
2055     release by the maintainer that fix reported bugs and close those bugs in
2056     the changelog.
2057    
2058     <item>If the patch/merge did not apply cleanly, inspect the situation to
2059 osamu 2781 determine what failed (clues are left in <file>.rej</file> files). Most
2060     often the problem is that a patch you applied to the source was
2061     integrated upstream, and thus the patch is no longer relevant.
2062 osamu 2769
2063 osamu 2819 <item>Upgrades to the new version should be silent and nonintrusive
2064     (existing users should not notice the upgrade except by discovering that
2065     old bugs have been fixed and there perhaps are new features).
2066     <footnote>
2067     Please make your package properly updates the config file upon upgrades
2068     using well designed <prgn>postinst</prgn> etc., so that it
2069     <strong>doesn't</strong> do things not wanted by the user! These are
2070     the enhancements that explain <strong>why</strong> people choose Debian.
2071     <p>
2072     When the upgrade is necessarily intrusive (eg., config files scattered
2073     through various home directories with totally different structure), you
2074     may consider to set package to the safe default (e.g., disabled service)
2075     and provide proper documentations required by the policy
2076     (<file>README.Debian</file> and <file>NEWS.Debian</file> ) as the last
2077     resort. But don't bother with the debconf note.
2078     </footnote>
2079 osamu 2769
2080 osamu 2781 <item>If you need to add erased template files for any reason, you
2081     may run <prgn>dh_make</prgn> again in the same, already "debianized",
2082     directory with <tt>-o</tt> option. Then edit it properly.
2083    
2084 osamu 2769 <item>Existing Debian changes need to be reevaluated; throw away stuff that
2085     upstream has incorporated (in one form or another) and remember to
2086     keep stuff that hasn't been incorporated by upstream, unless there is
2087     compelling reason not to.
2088    
2089     <item>If any changes were made to the build system (hopefully you'd know
2090 osamu 2781 from the step 1 and update the <file>debian/rules</file> and
2091     <file>debian/control</file> build dependencies if necessary.
2092 osamu 2769
2093     </list>
2094    
2095 osamu 2781 <item>Build the new package as described in <ref id="debuild"> or
2096     <ref id="pbuilder">. Use of <package>pbuilder</package> is desirable.
2097 osamu 2769
2098     <item>Verify new packages are built correctly.
2099    
2100     <list compact>
2101    
2102 osamu 2770 <item>Perform <ref id="checkit">.
2103 osamu 2769
2104 osamu 2770 <item>Perform <ref id="upgrading">.
2105 osamu 2769
2106 osamu 2770 <item>Check again to see if any bugs have been fixed that are currently
2107 osamu 2781 open in the <url name="Debian Bug Tracking System (BTS)"
2108     id="http://www.debian.org/Bugs/"> .
2109 osamu 2769
2110     <item>Check the contents of the .changes file to make sure you are
2111     uploading to the correct distribution, the proper bugs closures are
2112     listed in the Closes: field, the Maintainer: and Changed-By: fields
2113     match, the file is GPG-signed, etc.
2114    
2115     </list>
2116    
2117     <item>If any changes were made to correct anything in the packaging along
2118 osamu 2770 the way, go back to the step 2 until satisfied.
2119 osamu 2769
2120 osamu 2770 <item>If your upload needs to be sponsored, be sure to note any special
2121     options required when building the package (like '<tt>dpkg-buildpackage
2122     -sa -v ...</tt>') and be sure to inform your sponsor so he or she builds
2123     it correctly.
2124 osamu 2769
2125 osamu 2781 <item>If you are uploading yourself, perform <ref id="upload">.
2126 osamu 2769 </enumlist>
2127    
2128 osamu 2688 <sect id="orig-tar">The <file>orig.tar.gz</file> file
2129     <p>
2130 osamu 2781 If you try to build packages only from the new source tree with
2131     <file>debian/</file> directory without the <file>orig.tar.gz</file> file
2132     in its parent directory, you will end up unintentionally creating a
2133     native source package, which comes without the <file>diff.gz</file>
2134     file. This type of packaging is only appropriate for the
2135     debian-specific packages, which will never be useful in another
2136     distribution.
2137 osamu 2691 <footnote>
2138 osamu 2769 Some people argue that, even for Debian specific packages, it is still
2139 osamu 2699 better practice to package the contents of the <file>debian/</file>
2140 osamu 2769 directory residing in the <file>diff.gz</file> file, rather than in the
2141     <file>orig.tar.gz</file> file.
2142 osamu 2688 </footnote>
2143     <p>
2144 osamu 2781 In order to obtain a non-native source package which consists with both
2145     the <file>orig.tar.gz</file> file and the <file>diff.gz</file> file, you
2146     must manually copy the upstream tarball to the parent directory with its
2147     file name changed into
2148 osamu 2769 <file>&lt;packagename&gt;_&lt;upstream_version&gt;.orig.tar.gz</file> as
2149 osamu 2770 it was done by <prgn>dh_make</prgn> command in <ref id="dh_make">.
2150 osamu 2688
2151 osamu 2676 <sect id="cvs-buildpackage">The <prgn>cvs-buildpackage</prgn> command and similes
2152     <p>
2153 osamu 2696 You should consider to use some source code management system to manage
2154     packaging activity. There are several wrapper scripts which are customized
2155     to be use with the most popular ones.
2156 osamu 2676 <list compact>
2157     <item>CVS
2158     <list compact>
2159     <item><package>cvs-buildpackage</package>
2160     </list>
2161     <item>Subversion
2162     <list compact>
2163     <item><package>svn-buildpackage</package>
2164     </list>
2165     <item>Arch (tla)
2166     <list compact>
2167     <item><package>tla-buildpackage</package>
2168     <item><package>arch-buildpackage</package>
2169     </list>
2170     </list>
2171     <p>
2172     These commands also automate the packaging of new upstream release.
2173    
2174 joy 1530 <sect id="upgrading">Verifying package upgrades
2175    
2176     <p>When you build a new version of the package, you should do the
2177     following to verify that the package can be safely upgraded:
2178    
2179     <list>
2180     <item>upgrade from the previous version
2181     <item>downgrade back again and then remove it,
2182     <item>install the new package
2183     <item>remove it and then reinstall it again,
2184     <item>purge it.
2185     </list>
2186    
2187 osamu 2769 <p>If the package makes use of non-trivial pre/post/inst/rm scipts, be
2188     sure to test the upgrade paths of those.
2189    
2190 joy 1530 <p>Bear in mind that if your package has previously been released in
2191     Debian, people will often be upgrading to your package from the version
2192 joy 1587 that was in the last Debian release. Remember to test upgrades from that
2193 joy 1530 version, too.
2194    
2195 joy 1524 <chapt id="helpme">Where to ask for help
2196 joy 896
2197 joy 838 <p>Before you decide to ask your question in some public place, please
2198 joy 1530 just RTFM. That includes documentation in <file>/usr/share/doc/dpkg</file>,
2199 osamu 2700 <file>/usr/share/doc/debian</file>, <file>&autotools-dev;</file>,
2200     <file>/usr/share/doc/package/*</file>
2201 joy 1530 files and the man/info pages for all the programs mentioned in this document.
2202 osamu 2688 See all the information at <url id="&nm-home;"> and
2203 osamu 2674 <url id="&mentors-faq;">.
2204 joy 1530
2205     <p>If you have questions about packaging that you couldn't find answers to
2206     in the documentation, you can ask them on the Debian Mentors' mailing list
2207     at <email/debian-mentors@lists.debian.org/. The more experienced Debian
2208     developers will gladly help you, but do read at least some of the
2209     documentation before asking a question!
2210    
2211     <p>See <url id="http://lists.debian.org/debian-mentors/"> for more
2212     information about this mailing list.
2213    
2214     <p>When you receive
2215 joy 838 a bug report (yes, actual bug reports!), you will know that it is time
2216     that you dig in the <url name="Debian Bug Tracking System" id="http://www.debian.org/Bugs/">
2217     and read the documentation there, to be able to deal with the reports
2218 joy 1531 efficiently. I highly recommend reading the Developers' Reference,
2219     chapter "Handling Bugs", at
2220 osamu 2666 <file>&bughandling;</file>
2221 aph 743
2222 joy 770 <p>If you still have questions, ask on the Debian Developers' mailing list
2223 joy 1530 at <email/debian-devel@lists.debian.org/. See
2224     <url id="http://lists.debian.org/debian-devel/"> for more information
2225     about this mailing list.
2226 aph 743
2227     <p>Even if it all worked well, it's time to start praying. Why? Because
2228     in just a few hours (or days) users from all around the world will start
2229     to use your package, and if you made some critical error you'll get
2230     mailbombed by numerous angry Debian users... Just kidding. :-)
2231    
2232     <p>Relax and be ready for bug reports, because there is a lot more work
2233 joy 1530 to be done before your package will be fully in line with Debian policies
2234     (once again, read the <em>real documentation</em> for details). Good luck!
2235 aph 743
2236 osamu 2781 <appendix id="pkg-eg">Examples
2237     <p>
2238     Here we package the upstream tarball <var>gentoo-1.0.2</var>.tar.gz and
2239     uploading all the packages to the <tt><var>nm_target</var></tt>.
2240    
2241     <sect id="pkg-simple">Simple packaging example
2242     <p>
2243     <example>
2244     $ mkdir -p <var>/path/to</var> # new empty directory
2245     $ cd <var>/path/to</var>
2246     $ tar -xvzf <var>/path/from/gentoo-1.0.2</var>.tar.gz # get source
2247     $ cd <var>gentoo-1.0.2</var>
2248     $ dh_make -e <var>name@domain.dom</var> -f <var>/path/from/gentoo-1.0.2</var>.tar.gz
2249     ... Answer prompts.
2250 osamu 2802 ... Fix source tree
2251 osamu 2781 ... If it is a script package, set debian/control to "Architecture: all"
2252     ... Do not erase ../<var>gentoo_1.0.2</var>.orig.tar.gz
2253     $ debuild
2254     ... Make sure no warning happens.
2255     $ cd ..
2256 osamu 2802 $ dupload -t <var>nm_target</var> <var>gentoo_1.0.2-1</var>_i386.changes
2257 osamu 2781 </example>
2258    
2259    
2260     <sect id="pkg-dpatch">Packaging example with the <package>dpatch</package> and the <package>pbuilder</package>
2261     <p>
2262     <example>
2263     $ mkdir -p <var>/path/to</var> # new empty directory
2264     $ cd <var>/path/to</var>
2265     $ tar -xvzf <var>/path/from/gentoo-1.0.2</var>.tar.gz
2266     $ cp -a <var>gentoo-1.0.2</var> <var>gentoo-1.0.2-orig</var>
2267     $ cd <var>gentoo-1.0.2</var>
2268     $ dh_make -e <var>name@domain.dom</var> -f /path/from/<var>gentoo-1.0.2</var>.tar.gz
2269     ... Answer prompts.
2270 osamu 2802 ... Fix source tree by editor
2271 osamu 2781 ... Try building packages with "dpkg-buildpackage -rfakeroot -us -uc"
2272     ... Edit source to make source buildable.
2273     ... Do not erase ../<var>gentoo_1.0.2</var>.orig.tar.gz
2274     $ cd ..
2275     $ cp -a <var>gentoo-1.0.2</var> <var>gentoo-1.0.2-keep</var> # safety backup
2276     $ mv <var>gentoo-1.0.2</var>/debian debian
2277     $ diff -Nru <var>gentoo-1.0.2-orig</var> <var>gentoo-1.0.2</var> &gt; <var>patch-file</var>
2278     ... You may overwrite <var>gentoo-1.0.2</var> directory while doing this.
2279     ... Make sure to keep <var>gentoo-1.0.2</var>-keep for your safety
2280     $ mkdir -p debian/patches
2281 osamu 2789 $ dpatch patch-template <var>patch-file</var> \
2282     -p "01_patchname" "patch-file description" \
2283 osamu 2781 &lt; <var>patch-file</var> &gt; debian/patches/01_patchname.dpatch
2284     $ cd debian/patches
2285     $ echo 01_patchname.dpatch >00list
2286     $ cd ../.. # back to <var>/path/to</var>
2287     $ rm -rf <var>gentoo-1.0.2</var>
2288     $ editor debian/rules
2289     </example>
2290 osamu 2790 Here <file>debian/rules</file> originally looks like:
2291 osamu 2781 <example>
2292     config.status: configure
2293     ./configure --prefix=/usr --mandir=/usr/share
2294     build: config.status
2295     ${MAKE}
2296     clean:
2297     $(testdir)
2298     $(testroot)
2299     ${MAKE} distclean
2300     rm -rf debian/imaginary-package debian/files debian/substvars
2301     </example>
2302     You change <file>debian/rules</file> to the following by the editor to
2303     use <package>dpatch</package>:
2304     <example>
2305     config.status: patch configure
2306     ./configure --prefix=/usr --mandir=/usr/share
2307     build: config.status
2308     ${MAKE}
2309     clean: clean-patched unpatch
2310     clean-patched:
2311     $(testdir)
2312     $(testroot)
2313     ${MAKE} distclean
2314     rm -rf debian/imaginary-package debian/files debian/substvars
2315     patch: patch-stamp
2316     patch-stamp:
2317     dpatch apply-all
2318     dpatch call-all -a=pkg-info >patch-stamp
2319    
2320     unpatch:
2321     dpatch deapply-all
2322     rm -rf patch-stamp debian/patched
2323     </example>
2324     <p>
2325     Now you are ready to repackage the source tree with
2326     <package>dpatch</package> system.
2327     <example>
2328     $ tar -xvzf <var>gentoo_1.0.2</var>.orig.tar.gz
2329     $ cp -a debian/ <var>gentoo-1.0.2</var>/debian
2330     $ cd <var>gentoo-1.0.2</var>
2331     $ sudo pbuilder update
2332     $ pdebuild
2333     $ cd /var/cache/pbuilder/result/
2334     $ dupload -t <var>nm_target</var> <var>gentoo_1.0.2-1</var>_i386.changes
2335     </example>
2336    
2337    
2338 aph 743 </book>
2339    
2340     </debiandoc>

  ViewVC Help
Powered by ViewVC 1.1.5