/[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 1618 - (hide annotations) (download) (as text)
Sun Apr 28 11:47:11 2002 UTC (11 years, 1 month ago) by joy
File MIME type: text/x-sgml
File size: 76095 byte(s)
another wrong line number, noticed by Taketoshi Sano
1 aph 743 <!doctype debiandoc system>
2    
3     <debiandoc>
4    
5     <book>
6    
7     <titlepag>
8    
9 joy 773 <title>Debian New Maintainers' Guide</title>
10 aph 743
11 joy 838 <author>Josip Rodin <email/jrodin@jagor.srce.hr/
12 aph 743 </author>
13 joy 887 <!--
14     <author>Translated by: [put your name here] <email/[put your e-mail here]/
15     </author>
16     -->
17 aph 743
18 joy 1529 <version>version 1.2, 6 April 2002.</version>
19 aph 743
20     <copyright>
21 joy 1529 <copyrightsummary>Copyright &copy; 1998-2002 Josip Rodin.</copyrightsummary>
22 aph 743
23 joy 1566 <p>This document may be used under the terms the GNU General Public License
24 joy 893 version 2 or higher.
25 aph 743
26 joy 893 <p>This document was made using with these two documents as examples:
27 joy 773
28 joy 797 <p>Making a Debian Package (AKA the Debmake Manual), copyright &copy;
29 joy 1552 1997 Jaldhar Vyas.
30 joy 797
31 aph 743 <p>The New-Maintainer's Debian Packaging Howto, copyright &copy; 1997
32 joy 1552 Will Lowe.
33 aph 743 </copyright>
34    
35     </titlepag>
36    
37     <toc sect>
38    
39 joy 1523 <chapt id="start">Getting started The Right Way
40 aph 743
41 joy 1520 <p>This document tries to describe building of a Debian package to the
42     common Debian user, and wannabe developer. It uses pretty common language,
43     and it's well covered with working examples.
44     There is an old Roman saying, <em>Longum
45 aph 743 iter est per preaecepta, breve et efficax per exempla!</em> (It's a long way
46     by the rules, but short and efficient with examples!).
47    
48     <p>One of the things that makes Debian such a top-notch Linux distribution
49     is its package system. While there is a vast quantity of software already
50     in the Debian format, sometimes you need to install software that isn't.
51     You may be wondering how you can make your own packages and perhaps you
52 joy 896 think it is a very difficult task. Well, if you are a real novice on Linux,
53 joy 770 it is hard, but if you were rookie, you wouldn't be reading this doc now. :-)
54 aph 743 You do need to know a little about Unix programming but you certainly
55     don't need to be a wizard.
56    
57 joy 1520 <p>One thing is certain, though: to properly create and maintain Debian
58     packages you need man hours. Make no mistake, for our system to work the
59     maintainers need to be both technically competent and dilligent.
60    
61 joy 1522 <p>This document will explain every little (at first maybe irrelevant)
62     step, and help you create that first package, and to gain some experience
63     in building next releases of that and maybe other packages later on.
64    
65 joy 896 <p>Newer versions of this document should always be available online at
66 joy 1422 <url name="http://www.debian.org/doc/maint-guide/" id="http://www.debian.org/doc/maint-guide/">
67 joy 1520 and in the `<package/maint-guide/' package.
68     <!-- Translation in <this language> is also available in the
69     `<package/maint-guide-xy/' package. -->
70 joy 896
71 aph 743 <sect id="needprogs">Programs you need for development
72    
73 joy 896 <p>Before you start anything, you should make sure that you have properly
74     installed some additional packages needed for development. Note that the
75     list doesn't contain any packages marked `essential' or `required' - we
76     expect that you have those installed already.
77 joy 770
78 joy 1520 <p>This revision of this document has been updated for the packages in
79     Debian 2.2 (`potato') and 3.0 (`woody').
80 joy 893
81 joy 1520 <p>The following packages come with the standard Debian installation,
82     so you probably have them already (along with any additional packages
83     they depend on).
84 joy 896 Still, you should check with `dpkg -s &lt;package&gt;`.
85 aph 743
86     <list>
87 joy 1521 <item><package/dpkg-dev/ - this package contains the tools needed to unpack,
88 joy 896 build and upload Debian source packages. (see
89     <manref name="dpkg-source" section="1">)
90 aph 743
91 joy 1521 <item><package/file/ - this handy program can determine what type a file is.
92 joy 770 (see <manref name="file" section="1">)
93 aph 743
94 joy 1521 <item><package/gcc/ - the GNU C compiler, necessary if your program like
95 joy 1520 most others is written in the C programming language.
96     (see <manref name="gcc" section="1">)
97     This package will also "pull in" several other packages such as
98 joy 1521 <package/binutils/ which includes programs used to assemble and link
99 joy 1520 object files (see `info binutils` in the <package/binutils-doc/ package)
100 joy 1521 and <package/cpp/, the C preprocessor. (see <manref name="cpp" section="1">)
101 aph 743
102 joy 1521 <item><package/g++/ - the GNU C++ compiler, necessary if your program
103 joy 1520 is written in C++. (see <manref name="g++" section="1">)
104    
105 joy 1521 <item><package/libc6-dev/ - the C libraries and header files gcc needs to
106 joy 1520 link with to create object files. (see `info libc` in the
107     <package/glibc-doc/ package)
108 aph 743
109 joy 1521 <item><package/make/ - usually creation of a program takes several steps,
110 joy 1520 so rather than having to type out the same commands over and over again,
111     you can use this program to automate the process, creating `Makefile's.
112     (see `info make`)
113 aph 743
114 joy 1521 <item><package/patch/ - this very useful utility will take file containing
115 aph 743 a difference listing (produced by the diff program) and apply it to the
116 joy 770 original file, producing a patched version. (see <manref name="patch" section="1">)
117 aph 743
118 joy 1521 <item><package/perl/ - Perl is one of the most used interpreted scripting
119 joy 1520 languages on today's Unix-like systems, often referred to as "Unix's Swiss Army
120 joy 770 Chainsaw". (see <manref name="perl" section="1">)
121 aph 743 </list>
122    
123 joy 1520 <p>You'll probably want to install the following packages, too:
124 aph 743
125     <list>
126 joy 1521 <item><package/autoconf/ and <package/automake/ - many newer programs use
127 joy 1520 configure scripts and Makefiles preprocessed with help of programs like
128     these. (see `info autoconf`, `info automake`)
129    
130 joy 1521 <item><package/dh-make/ and <package/debhelper/ - dh-make is necessary to
131 aph 743 create the skeleton of our example package, and it will use some the
132     debhelper tools for creating packages. They are not essential for creation
133 joy 797 of packages, but it is <strong>highly</strong> recommended for new
134     maintainers. It makes the whole process very much easier to start, and
135     control afterwards. (see <manref name="dh_make" section="1">,
136 joy 838 <manref name="debhelper" section="1">, /usr/share/doc/debhelper/README)
137 aph 743
138 joy 1521 <item><package/devscripts/ - this package contain some nice and useful
139 joy 773 scripts that can be helpful to the maintainers, but they are also not
140 joy 838 necessary for building packages. (see /usr/share/doc/devscripts/README.gz)
141 joy 773
142 joy 1521 <item><package/fakeroot/ - this utility lets you emulate being root which
143 joy 838 is necessary for some parts of the build process. (see
144     <manref name="fakeroot" section="1">)
145    
146 joy 1521 <item><package/gnupg/ - a tool that enables you to digitally <em>sign</em>
147 joy 1520 packages. This is especially important if you want to distribute it to
148     other people, and you will certainly be doing that when your work gets
149     included in the Debian distribution. (see <manref name="gpg" section="1">)
150    
151 joy 1521 <item><package/g77/ - the GNU Fortran 77 compiler, necessary if your
152 joy 1520 program is written in Fortran. (see <manref name="g77" section="1">)
153    
154 joy 1521 <item><package/gpc/ - the GNU Pascal compiler, necessary if your
155     program is written in Pascal. Worthy of note here is <package/fp-compiler/,
156 joy 1520 the Free Pascal Compiler, which is also good at this task.
157     (see <manref name="gpc" section="1">, <manref name="ppc386" section="1">)
158    
159 joy 1521 <item><package/imake/ and <package/xmkmf/ - some programs, usually those
160 joy 1520 made for X11, also use these programs to generate Makefiles from sets of
161     macro functions. (see <manref name="imake" section="1">,
162     <manref name="xmkmf" section="1">)
163    
164 joy 1521 <item><package/lintian/ - this is the Debian package checker that can let
165 joy 893 you know of any common mistakes after you build the package, and explain
166     the errors found. (see <manref name="lintian" section="1">,
167 joy 838 /usr/share/doc/lintian/lintian.html/index.html)
168 aph 743 </list>
169    
170 joy 1520 <p>The following is the <em>very important</em> documentation which you
171     should read along with this document:
172 aph 743
173     <list>
174 joy 1521 <item><package/debian-policy/ - the Policy includes explanations of the
175 joy 1520 structure and contents of the Debian archive, several OS design issues,
176     the Filesystem Hierarchy Standard (which says where each file and
177     directory should be) etc.
178     For you, the most important thing is that it describes requirements that
179 joy 838 each package must satisfy to be included in the distribution.
180     (see /usr/share/doc/debian-policy/policy.html/index.html)
181 aph 743
182 joy 1521 <item><package/developers-reference/ - for all matters not specifically
183 aph 743 about the technical details of packaging, like the structure of the
184     archive, how to rename, orphan, pick up packages, how to do NMUs, how to
185     manage bugs, when and where to upload etc.
186 joy 838 (see /usr/share/doc/developers-reference/developers-reference.html/index.html)
187 aph 743 </list>
188    
189     <p>The short descriptions that are given above only serve to introduce
190     you to what each package does. Before continuing please thoroughly read
191 joy 1520 the documentation of each program, at least the standard usage.
192 joy 770 It may seem like heavy going now, but later on you'll be <em>very</em>
193     glad you read it.
194 aph 743
195 joy 1521 <p>Note: <package/debmake/ is a package that contains some programs that
196 joy 896 function similar to dh-make, but its specific use is <strong>not</strong>
197 joy 1520 covered in this document, because it is <em>deprecated</em>. Please refer
198     to <url name="the Debmake manual" id="http://www.debian.org/~jaldhar/">
199     for more information.
200 joy 838
201 joy 770 <sect id="otherinfo">Other information
202 aph 743
203     <p>There are two types of packages you can make, source and binary.
204     A source package contains code which you can compile into a program.
205     A binary package contains just the finished program. Don't mix terms
206     like source of the program and the source package of the program!
207     Please read the other manuals if you need more details on terminology.
208    
209 joy 896 <p>In Debian, the term `maintainer' is used for the person who makes
210     packages, `upstream author' for the person that made the program, and
211     `upstream maintainer' for the person who currently maintains that program,
212     outside of Debian. Usually author and the upstream maintainer are the
213     same person - and sometimes even the maintainer is the same person.
214     If you made a program, and want it to get in Debian, feel free to submit
215     your application to become a maintainer.
216 aph 743
217     <p>After you build your package (or while doing that), you will have
218     to become an official Debian maintainer if you wish your program to get
219     into the next distribution (if the program is useful, why not?).
220 joy 770 That process is explained in Developer's Reference. Please read it.
221 aph 743
222     <chapt id="first">First steps
223    
224 joy 1522 <sect id="choose">Choose your program
225 aph 743
226 joy 1531 <p>You have probably chosen the package you want to create. The first
227     thing you need to do is check if the package is in the distribution already.
228     If you use the `stable' distribution, maybe it's best that you go to the
229 joy 1523 <url name="package search page" id="http://www.debian.org/distrib/packages">.
230 joy 896 If you use <strong>current</strong> `unstable' distribution, check it out
231 joy 838 with these commands:
232 aph 743 <example>
233     dpkg -s program
234     dpkg -l '*program*'
235     </example>
236    
237 joy 1531 <p>If the package already exists, well, install it! :-) If it happens to
238     be orphaned -- if its maintainer is set to "Debian QA Group", you should
239     be able to pick it up. Consult
240     <url name="the list of orphaned packages" id="http://www.debian.org/devel/wnpp/orphaned">
241     and
242     <url name="the list of packages up for adoption" id="http://www.debian.org/devel/wnpp/rfa_bypackage">
243     to verify that the package is indeed up for grabs.
244    
245     <p>If you are able to adopt the package, get the sources (with something
246     like <tt/apt-get source packagename/) and examine them. This document
247     unfortunately doesn't include comprehensive information about adopting
248     packages. Thankfully you shouldn't have a hard time figuring out how the
249     package works since someone has already done the initial set up for you.
250     Keep reading, though, a lot of the advice below will still be applicable
251     for your case.
252    
253     <p>If the package is new, and you decide you'd like to see it in Debian,
254     proceed as follows:
255    
256     <list>
257     <item>check if no one else is working on the package already at
258     <url name="the list of packages being worked on" id="http://www.de.debian.org/devel/wnpp/being_packaged">.
259     If someone's already on it, contact them if you feel you need to.
260     If not - find another interesting program that nobody maintains.
261 joy 838 </item>
262 aph 743
263 joy 797 <item>program <strong>must</strong> have a license, if possible free as
264 joy 1523 according to the <url name="Debian Free Software Guidelines" id="http://www.debian.org/social_contract#guidelines">.
265     If it doesn't conform to some of these rules but it can be distributed
266     anyway, it could still can be included in the `contrib' or `non-free'
267     sections. If you are unsure about where should it go, post the license
268     text on <email/debian-legal@lists.debian.org/ and ask for advice.
269 aph 743 </item>
270    
271 joy 797 <item>program certainly should <strong>not</strong> run setuid root, or
272     even better - it shouldn't need to be setuid or setgid to anything.</item>
273 aph 743
274 joy 770 <item>program should not be a daemon, or something that goes in */sbin
275 joy 1523 directories, or open a port as root.</item>
276 aph 743
277 joy 1523 <item>program should result in binary executable form, libraries are
278     harder to handle.</item>
279 aph 743
280 joy 1523 <item>it should be well documented, or and the code needs to be
281     understandable (i.e. not obfuscated).</item>
282 aph 743
283 joy 770 <item>you should contact program's author(s) to check if they agree
284     with packaging it. It is important to be able to consult with author(s)
285     about the program in case of any program specific problems, so don't
286     try to package unmaintained pieces of software.</item>
287    
288 aph 743 <item>and last but not the least, you must know that it works, and
289     have it tried for some time.</item>
290     </list>
291    
292     <p>Of course, these things are just safety measures, and intended to save
293 joy 896 you from raging users if you do something wrong in some setuid daemon...
294 aph 743 When you gain some more experience in packaging, you'll be able to do such
295 joy 1523 packages, but even the experienced developers consult the debian-mentors
296 aph 743 mailing list when they are in doubt. And people there will gladly help.
297    
298 joy 770 <p>For more help about these, check in Developer's Reference.
299    
300 joy 1522 <sect id="getit">Get the program, and try it out
301 aph 743
302     <p>So the first thing to do is to find and download the original package.
303     I presume that you already have the source file that you picked up at
304 joy 1523 the author's homepage. Sources for free Unix programs usually come in
305 joy 893 tar/gzip format, with extension .tar.gz, and usually contain the
306     subdirectory called program-version and all the sources in it. If your
307     program's source comes as some other sort of archive (for instance, the
308 joy 896 filename ends in ".Z" or ".zip"), unpack it with appropriate
309 joy 1523 tools, or ask on the debian-mentors mailing list if you're not sure how to unpack it
310 joy 893 correctly (hint: issue `file archive.extension`).
311 aph 743
312 joy 1523 <p>As an example, I'll use program called `gentoo', an X GTK+ file
313 joy 838 manager. Note that the program is already packaged, and has changed
314     substantially from the version while this text was first written.
315 aph 743
316 joy 896 <p>Create a subdirectory under your home directory named 'debian' or 'deb'
317     or anything you find appropriate (e.g. just ~/gentoo/ would do fine in
318     this case). Place the downloaded archive in it, and uncompress it (with
319     `tar xzf gentoo-0.9.12.tar.gz`). Make sure there are no errors, even some
320     "irrelevant" ones, because there will most probably be problems unpacking
321     on other people's systems, whose unpacking tools may or may not ignore
322     those anomalies.
323 aph 743
324 joy 893 <p>Now you have another subdirectory, called 'gentoo-0.9.12'. Change to
325     that directory and <strong>thoroughly</strong> read the provided
326     documentation. Usually there exist files named README*, INSTALL*, *.lsm
327     or *.html. You must find instructions on how to correctly compile and
328     install the program (most probably they'll assume you want to install to
329 joy 896 /usr/local/bin directory; you won't be doing that, but more on that later
330     in <ref id="destdir">).
331 aph 743
332     <p>The process varies from program to program, but a lot of modern
333 joy 770 programs come with a `configure' script that configures the source under
334 aph 743 your system and makes sure that your system is in condition to compile it.
335 joy 1523 After configuring with `./configure`, programs are usually compiled
336 joy 896 with `make`. Some of them support `make check`, to run included
337     self-checks. Installation in destination directories is usually done with
338 joy 770 `make install`.
339 aph 743
340 joy 1198 <p>Now try to compile and run your program, to make sure it works properly
341 aph 743 and doesn't break something else while it's installing or running.
342    
343 joy 1523 <p>Also, you can usually run `make clean` (or better `make distclean`) to
344     clean up the build directory. Sometimes there's even a `make uninstall`
345     which can be used to remove all the installed files.
346 aph 743
347 joy 1523 <sect id="namever">Package name and version
348 aph 743
349 joy 896 <p>You should start packaging with a completely clean (pristine) source
350     directory, or simply with freshly unpacked sources.
351    
352     <p>For the package to be built correctly, you must make the program's
353     original name lowercase (if it isn't already), and you should move the
354     source directory to &lt;packagename&gt;-&lt;version&gt;.
355    
356     <p>If the program name consists of more than one word, contract them to one
357     word, or make an abbreviation. For example, program "John's little editor
358     for X" package would be named johnledx, or jle4x, or whatever you decide,
359     as long as it's under some reasonable limit, e.g. 20 characters.
360    
361 joy 887 <p>Also check for the exact version of the program (to be included in the
362     package version). If that piece of software is not numbered with versions
363     like X.Y.Z, but with some kind of date, feel free to use that date as the
364     version number, prepended with a "0.0." (just in case upstream people one
365     day decide to release a nice version like 1.0). So, if the release or
366     snapshot date was 19th of December, 1998, you can use the version string
367 joy 1523 of 0.0.19981219.
368    
369     <p>Some programs won't be numbered at all, in which case you
370 joy 887 should contact the upstream maintainer to see if they've got some other
371     revision-tracking method.
372 aph 743
373 joy 1523 <sect id="dh_make">Initial "debianization"
374 aph 743
375 joy 770 <p>Make sure you're in the program source directory, and issue this:
376 aph 743
377 joy 770 <p><example>
378 joy 952 dh_make -e your.maintainer@address -f ../gentoo-0.9.12.tar.gz
379 joy 770 </example>
380 joy 838
381     <p>Of course, replace the string "your.maintainer@address" with your
382 joy 893 e-mail address for inclusion in the changelog entry and other files,
383     and the filename with the name of your original source archive. See
384     <manref name="dh_make" section="1"> for details.
385 joy 838
386 joy 770 <p>Some information will come up. It will ask you what sort of package you
387     want to create. Gentoo is a single binary package - it creates only one
388     binary, and thus one .deb file - so we will select the first option, with
389 joy 896 the `s' key, check the information on the screen and confirm with pressing
390 joy 1523 &lt;enter&gt;.
391    
392     <p>Once again, as a new maintainer you are discouraged from creating
393     packages with multiple binary packages, or libraries. It's not too hard,
394     but it does require a bit more knowledge,
395 joy 896 so we won't describe all of it here.
396 joy 770
397 joy 797 <p>Please note that you should run dh_make <strong>only once</strong>,
398     and that it won't behave correctly if you run it again in the same,
399     already "debianized", directory. That also means that you will use a
400     different method to release a new revision or a new version of your
401 joy 896 package in the future. Read more about that later in <ref id="update">
402 joy 797
403 aph 743 <chapt id="modify">Modifying the source
404    
405 joy 893 <p>Normally, programs install themselves in the /usr/local subdirectories.
406 aph 743 But, Debian packages must not use that directory, since it is reserved for
407 joy 893 system administrator's (or user's) private use. This means that you have
408     to take a look at your program's build system, usually starting with the
409     Makefile. This is the script <manref name="make" section="1"> will use to
410     automate building this program. For more details on Makefiles, look in
411     <ref id="rules">.
412 aph 743
413 joy 903 <p>Note that if your program uses GNU <manref name="automake" section="1">
414     and/or <manref name="autoconf" section="1">, meaning the source includes
415     Makefile.am and/or Makefile.in files, respectively, you will need to
416 joy 1198 modify those files. This is because each automake invocation will rewrite
417 joy 903 Makefile.in's with information generated from Makefile.am's, and each
418     ./configure invocation will do the same with Makefile's, with data from
419     Makefile.in's. Editing Makefile.am files requires some knowledge of
420 joy 1198 automake, which you can read about in the automake info entry, whereas editing
421 joy 903 Makefile.in files is pretty much the same as editing Makefile files, just
422     pay attention on the variables, i.e. any strings surrounded with `@'s, for
423     example @CFLAGS@ or @LN_S@, which are replaced with actual stuff on each
424     ./configure invocation.
425 aph 743
426 joy 903 <p>Also note that there isn't space here to go into <em>all</em> the
427 joy 1198 details of fixing upstream sources, but here are a few problems people
428     often run across.
429 joy 903
430 joy 838 <sect id="destdir">Installation in a subdirectory
431 aph 743
432 joy 838 <p>Most of the programs have some way of installing themselves in the
433     existing directory structure of your system, so that their binaries get
434     included in your $PATH, and that you find their documentation and manual
435 joy 1523 pages in common places. However, if you do that, the program will be
436     installed among everything else already on your system. This would make
437     it hard for the packaging tools to figure out which files belong to your
438     package and which don't.
439    
440     <p>Therefore you need to do something else: install the program into a
441     temporary subdirectory from which the maintainer tools will build a working
442 joy 838 .deb package. Everything that is contained in this directory will be
443 joy 1523 installed on user's system when they install your package, the only
444 joy 838 difference is that dpkg will be installing the files in the root
445     directory.
446    
447 joy 1523 <p>This temporary directory is usually created under your debian/
448     directory in the unpacked source tree. It is usually called
449     <file>debian/tmp</file> or <file>debian/packagename</file>.
450    
451     <p>Bear in mind that even though you need to make the program install in
452 joy 1526 debian/packagename, it still needs to behave correctly when placed in the
453     root directory, i.e. when installed from the .deb package. So you mustn't
454 joy 1523 allow the build system to hardcode strings like
455     <tt>/home/me/deb/gentoo-0.9.12/usr/share/gentoo</tt> into the package
456     files.
457    
458     <p>With programs that use GNU autoconf, this will be quite easy. Most such
459     programs have makefiles that are by default set up to allow installation
460     into a random subdirectory while keeping in mind that /usr (for example)
461     is the canonical prefix. When it detects your program uses autoconf,
462     dh_make will set up commands for doing all this
463 joy 838 automatically, so you might as well skip reading this section. But with
464     other programs, you will most probably have to examine and edit the
465     Makefiles.
466    
467     <p>Here's the relevant part of gentoo's Makefile:
468    
469 aph 743 <p><example>
470     # Where to put binary on 'make install'?
471     BIN = /usr/local/bin
472 joy 1523
473     # Where to put icons on 'make install'?
474     ICONS = /usr/local/share/gentoo
475 aph 743 </example>
476    
477 joy 1523 <p>We see that the files are set to install under <file>/usr/local</file>.
478     Change those paths to:
479 aph 743
480     <p><example>
481 joy 1523 # Where to put binary on 'make install'?
482     BIN = $(DESTDIR)/usr/bin
483 aph 743
484 joy 1523 # Where to put icons on 'make install'?
485     ICONS = $(DESTDIR)/usr/share/gentoo
486 aph 743 </example>
487    
488 joy 1523 <p>But why in that directory, and not some other? Because Debian packages
489     never install files beneath <file>/usr/local</file> -- that tree is
490     reserved for the system administrator's use. Such files on Debian
491     systems go under <file>/usr</file> instead.
492 aph 743
493 joy 1523 <p>The more exact locations for binaries, icons, documentation etc are
494     specified in the Filesystem Hierarchy Standard
495     (see /usr/share/doc/debian-policy/fhs/). I recommend you browse it and read
496     the sections that might concern your package.
497 aph 743
498 joy 1523 <p>So, we should install the binary in /usr/bin instead of /usr/local/bin,
499     the manual page in /usr/share/man/man1 instead of /usr/local/man/man1 etc.
500     Notice how there's no manual page mentioned in gentoo's makefile, but
501     since the Debian Policy requires that every program has one, we'll make
502     one later and install it in /usr/share/man/man1.
503    
504     <p>Some programs don't use makefile variables to define paths such as
505     these. This means you might have to edit some real C sources in order to
506     fix them to use the right locations.
507 joy 770 But where and what to search? You can find this out by issuing:
508 joy 1523
509 joy 770 <p><example>
510 joy 1523 grep -rn usr/local/lib *.[ch]
511 joy 770 </example>
512 joy 1523
513     <p>Grep will run recursively through the source tree and tell
514 joy 1199 you the name of the file and the line in it, when it finds an occurrence.
515 aph 743
516 joy 1523 <p>Edit those files and in those lines replace /usr/local/* with usr/*
517     -- and that's about it. Be careful that you don't mess up the rest of
518     the code! :-)
519    
520 joy 896 <p>After that you should find the install target (search for line that
521 joy 1523 starts with `install:', that will usually work) and rename all references
522     to directories other than ones defined at the top of the Makefile.
523     Previously, gentoo's install target said:
524 aph 743
525     <p><example>
526 joy 887 install: gentoo
527 aph 743 install ./gentoo $(BIN)
528 joy 1523 install icons/* $(ICONS)
529 aph 743 install gentoorc-example $(HOME)/.gentoorc
530     </example>
531    
532 joy 770 <p>After our change it says:
533 aph 743 <example>
534     install: gentoo-target
535     install -d $(BIN) $(ICONS) $(DESTDIR)/etc
536     install ./gentoo $(BIN)
537     install -m644 icons/* $(ICONS)
538     install -m644 gentoorc-example $(DESTDIR)/etc/gentoorc
539 joy 1523 </example>
540    
541     <p>You've surely noticed that there's now a <tt>install -d</tt> command
542     before the other commands in the rule. The original makefile didn't have
543     it because usually the /usr/local/bin and other directories already exist
544     on the system where one runs `make install`. However, since we will
545     install into our own empty (or even nonexistent) directory, we will have
546     to create each and every one of those directories.
547    
548     <p>We can also add in other things at the end of the rule, like the
549     installation of additional documentation that the upstream authors
550     sometimes omit:
551    
552     <p><example>
553 joy 838 install -d $(DESTDIR)/usr/share/doc/gentoo/html
554     cp -a docs/* $(DESTDIR)/usr/share/doc/gentoo/html
555 aph 743 </example>
556    
557 joy 896 <p>A careful reader will notice that I changed `gentoo' to `gentoo-target'
558 joy 1523 in the `install:' line. That is called an unrelated bug fix :-)
559 aph 743
560     <p>Whenever you make changes that are not specifically related to Debian
561     package, be sure to send them to the upstream maintainer so they can be
562 joy 1523 included in the next program revision and be useful to everyone else.
563     Also remember to make your fixes not specific to Debian or Linux (or even
564     Unix!) prior to sending them -- make them portable. This will make your
565     fixes much easier to apply.
566 aph 743
567 joy 1523 <p>Note that you don't have to send the debian/* files upstream.
568    
569 joy 896 <sect id="difflibs">Differing libraries
570 aph 743
571     <p>There is one other common problem: libraries are often different from
572 joy 893 platform to platform. For example, Makefile can contain a reference to a
573 joy 1523 library which doesn't exist on Debian systems. In that case, we
574 joy 893 need to change it to a library which does exist in Debian, and serves the
575 joy 1523 same purpose.
576 aph 743
577 joy 903 <p>So, if there is a line in your program's Makefile (or Makefile.in) that
578     says something like this (and your program doesn't compile):
579 aph 743
580     <p><example>
581 joy 770 LIBS = -lcurses -lsomething -lsomethingelse
582 aph 743 </example>
583    
584     <p>Change it to this, and it will most probably work:
585     <p><example>
586 joy 770 LIBS = -lncurses -lsomething -lsomethingelse
587 aph 743 </example>
588    
589 joy 1523 <p>(The author realizes that this is not the best example considering our
590     libncurses package now ships with a libcurses.so symlink, but he couldn't
591     think of a better one. Suggestions very welcome :-)
592    
593 joy 896 <chapt id="dreq">Required stuff under debian/
594 aph 743
595 joy 1525 <p>There is a new subdirectory under the program's source directory,
596     it's called `debian'. There are a number of files in this directory that
597     we should edit in order to customize
598 joy 893 the behavior of the package. The most important of them are `control',
599     `changelog', `copyright' and 'rules', which are required for all packages.
600 aph 743
601 joy 893 <sect id="control">`control' file
602 aph 743
603 joy 1525 <p>This file contains various values which <prgn/dpkg/, <prgn/dselect/ and
604     other package management tools will use to manage the package.
605 aph 743
606 joy 1525 <p>Here is the control file dh_make creates for us:
607    
608 joy 893 <p><example>
609     1 Source: gentoo
610 joy 838 2 Section: unknown
611     3 Priority: optional
612     4 Maintainer: Josip Rodin &lt;jrodin@jagor.srce.hr&gt;
613 joy 1525 5 Build-Depends: debhelper (>> 3.0.0)
614     6 Standards-Version: 3.5.2
615     7
616     8 Package: gentoo
617     9 Architecture: any
618     10 Depends: ${shlibs:Depends}
619     11 Description: &lt;insert up to 60 chars description&gt;
620     12 &lt;insert long description, indented with spaces&gt;
621 aph 743 </example>
622     (I've added the line numbers.)
623    
624 joy 1525 <p>Lines 1-6 are the control information for the source package.
625 aph 743
626 joy 1525 <p>Line 1 is the name of the source package.
627    
628     <p>Line 2 is the section of the distribution the source package goes into.
629    
630     <p>As you may have noticed, Debian is divided in sections: main (the free
631 joy 797 software), non-free (the not really free software) and contrib (free
632     software that depends on non-free software). Under those, there are
633     logical subsections that describe in short what packages are in.
634 joy 896 So we have `admin' for administrator-only programs, `base' for the
635     basic tools, `devel' for programmer tools, `doc' for documentation,
636     `libs' for libraries, `mail' for e-mail readers and daemons, `net' for
637 joy 1525 network apps and daemons, `x11' for X11 programs that don't fit anywhere
638     else, and many more.
639 aph 743
640 joy 1525 <p>Let's change it then to x11. (A "main/" prefix is implied so we can
641     omit it.)
642 joy 797
643 joy 1525 <p>Line 3 describes how important it is that the user installs this package.
644     See the Policy manual for guidance on what to set this field to. The
645     "optional" priority will usually work for new packages.
646    
647     <p>Section and priority are used by frontends like <prgn/dselect/ when
648     they sort packages and select defaults. Once you upload the package to
649     Debian, the value of these two fields can be overridden by the archive
650     maintainers, in which case you will be notified by email.
651 joy 797
652 joy 1525 <p>As this is a normal priority package and doesn't conflict with anything
653     else, we'll leave it as "optional".
654 aph 743
655 joy 1525 <p>Line 4 is the name and email address of the maintainer. Make sure that
656     this field includes a valid "To: " header for an email, because after you
657     upload it, the bug tracking system will use it to deliver bug emails to
658     you. Avoid using commas, ampersands and parenthesis.
659 aph 743
660 joy 1555 <p>The 5th line includes the list of packages required to build your
661 joy 1525 package. Some packages like gcc and make are implied, see the
662     <package/build-essential/ package for details. If some non-standard
663     compiler or other tool is needed to build your package, you should add
664     it to the `Build-Depends' line. Multiple entries are separated with
665     commas; read on for the explanation of binary dependencies to find out
666     more about the syntax of this field.
667 joy 896
668 joy 1525 <p>You can also have Build-Depends-Indep, Build-Conflicts and other fields
669     here. This data will be used by the Debian automatic package building
670     software in order to create binary packages for other computer platforms.
671     See the Policy manual for more information about the build-dependencies
672     and the Developers' Reference for more information about these other
673     platforms (architectures) and how to port software to them.
674 aph 743
675 joy 1525 <p>Here's a hack you can use to find out which packages your package needs
676     to be built:
677     <example>
678     strace -f -o /tmp/log ./configure
679     # or make instead of ./configure, if the package don't use autoconf
680     for x in `dpkg -S $(grep open /tmp/log|perl -pe 's!.* open\(\"([^\"]*).*!$1!' |grep "^/"| sort | uniq| grep -v "^\(/tmp\|/dev\|/proc\)" ) 2>/dev/null|cut -f1 -d":"| sort | uniq`; do echo -n "$x (>=" `dpkg -s $x|grep ^Version|cut -f2 -d":"` "), "; done
681     </example>
682    
683     <p>Gentoo also happens to require <package/xlibs-dev/,
684     <package/libgtk1.2-dev/ and <package/libglib1.2-dev/ to build, so we'll
685     add them here next to <package/debhelper/.
686    
687 joy 1555 <p>Line 6 is the version of the Debian Policy standards this package
688     follows, the versions of the Policy manual you read while making your
689     package.
690    
691     <p>Line 8 is the name of the binary package. This is usually the same as
692 joy 1525 the name of the source package, but it doesn't necessarily have to be that
693     way.
694    
695 joy 1555 <p>Line 9 describes the CPU architecture the binary package can be compiled
696 joy 1525 for. We'll leave this as "any" because <manref name="dpkg-gencontrol"
697 joy 838 section="1"> will fill in the appropriate value for any machine this
698 joy 1525 package gets compiled on.
699    
700     <p>If your package is architecture independent
701 joy 896 (for example, a shell or Perl script, or a document), change this to
702 joy 1525 "all", and read later in <ref id="rules"> about using the `binary-indep'
703 joy 896 rule instead of `binary-arch' for building the package.
704 aph 743
705 joy 1555 <p>Line 10 shows one of the most powerful features of the Debian packaging
706 aph 743 system. Packages can relate to each other in various ways. Apart from
707 joy 838 Depends:, other relationship fields are Recommends:, Suggests:,
708 joy 1525 Pre-Depends:, Conflicts:, Provides:, and Replaces:.
709 aph 743
710 joy 1525 <p>The package management tools usually behave the same way when dealing
711     with these relations; if not, it will be explained.
712 joy 838 (see <manref name="dpkg" section="8">, <manref name="dselect" section="8">,
713 joy 1525 <manref name="apt" section="8">, <manref name="aptitude" section="1"> etc.)
714 joy 838
715 joy 1525 <p>This is what the dependencies mean:
716 joy 838
717 aph 743 <p><list>
718     <item>Depends:
719 joy 838 <p>The package will not be installed unless the packages it depends on
720     are installed. Use this if your program absolutely will not run (or will
721     cause severe breakage) unless a particular package is present.</item>
722 aph 743
723     <item>Recommends:
724 joy 1525 <p>Frontends such as dselect or aptitude will prompt you to install the
725     recommended packages along with your package; dselect will even insist.
726     dpkg and apt-get will ignore this field, though. Use this for packages
727     that are not strictly necessary but are typically used with your
728 joy 838 program.</item>
729 aph 743
730     <item>Suggests:
731 joy 1525 <p>When a user installs your program, all frontends will likely prompt
732     them to install the suggested packages. dpkg and apt-get won't care. Use
733     this for packages which will work nicely with your program but are not at
734     all necessary.</item>
735 aph 743
736 joy 770 <item>Pre-Depends:
737 joy 838 <p>This is stronger than Depends:. The package will not be installed
738     unless the packages it pre-depends on are installed <em>and correctly
739     configured</em>. Use this <strong>very</strong> sparingly and only after
740     discussing it on the debian-devel mailing list. Read: don't use it at
741     all. :-)</item>
742 aph 743
743     <item>Conflicts:
744 joy 838 <p>The package will not be installed until all the packages it conflicts
745 joy 893 with have been removed. Use this if your program absolutely will not run
746 joy 1525 or will cause severe problems if a particular package is present.</item>
747 aph 743
748     <item>Provides:
749 joy 838 <p>For some types of packages where there are multiple alternatives
750 joy 1525 virtual names have been defined. You can get the full list in the
751     /usr/share/doc/debian-policy/virtual-package-names-list.txt.gz file.
752 joy 838 Use this if your program provides a function of an existing virtual
753     package.</item>
754 aph 743
755     <item>Replaces:
756 joy 838 <p>Use this when your program replaces files from another package, or
757 joy 896 completely replaces another package (used in conjunction with Conflicts:).
758 joy 1525 Files from the named packages will be overwritten with the files from your
759     package.
760 joy 838 </item>
761 aph 743 </list>
762    
763     <p>All these fields have uniform syntax. They are a list of package names
764     separated by commas. These package names may also be lists of alternative
765 joy 1525 package names, separated by vertical bar symbols `<tt>|</tt>' (pipe symbols).
766    
767     <p>The fields may restrict their applicability to particular versions of
768     each named package. These versions are listed in parentheses after each
769 joy 838 individual package name, and they should contain a relation from the list
770     below followed by the version number. The relations allowed are:
771     <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>, <tt>=</tt>, <tt>&gt;=</tt> and
772     <tt>&gt;&gt;</tt> for strictly earlier, earlier or equal, exactly equal,
773 joy 1525 later or equal and strictly later, respectively. For example,
774    
775     <p><example>
776     Depends: foo (>= 1.2), libbar1 (= 1.3.4)
777     Conflicts: baz
778     Recommends: libbaz4 (>> 4.0.7)
779     Suggests: quux
780     Replaces: quux (<< 5), quux-foo (<= 7.6)
781     </example>
782 aph 743
783 joy 1525 <p>The last feature you need to know about is ${shlibs:Depends}.
784     After your package has been built and installed into the temporary
785     directory, <manref name="dh_shlibdeps" section="1"> will scan it for
786     binaries and libraries, determine their shared library dependencies and
787     detect which packages they are in, such as libc6 or xlib6g. It'll pass
788     on the list to <manref name="dh_gencontrol" section="1"> which will fill
789     it in the right place, and you won't have to worry about this yourself.
790 aph 743
791 joy 1589 <p>Having said all that, we can leave the Depends: line exactly as it is
792     now, and insert another line after it saying <tt>Suggests: file</tt>,
793 joy 896 because gentoo can use some features provided by that program/package.
794 aph 743
795     <p>Line 11 is the short description. Most people screens are 80 columns
796 joy 838 wide so this shouldn't be longer than about 60 characters. I'll change
797 joy 1525 it to "A fully GUI configurable X file manager using GTK+".
798 aph 743
799     <p>Line 12 is where the long description goes. This should be a paragraph
800 joy 1525 which gives more details about the package. Column 1 of each line should
801     be empty. There must be no blank lines, but you can put a single . (dot)
802     in a column to simulate that. Also, there must be no more that one blank
803     line after the long description.
804 aph 743
805 joy 1525 <p>Finally, here is the updated control file:
806 aph 743
807     <p><example>
808     1 Source: gentoo
809     2 Section: x11
810     3 Priority: optional
811     4 Maintainer: Josip Rodin &lt;jrodin@jagor.srce.hr&gt;
812 joy 1525 5 Build-Depends: debhelper (>> 3.0.0), xlibs-dev, libgtk1.2-dev, libglib1.2-dev
813     6 Standards-Version: 3.5.2
814     7
815     8 Package: gentoo
816     9 Architecture: any
817     10 Depends: ${shlibs:Depends}
818     11 Suggests: file
819 joy 1589 12 Description: A fully GUI configurable X file manager using GTK+
820 joy 1525 13 gentoo is a file manager for Linux written from scratch in pure C. It
821     14 uses the GTK+ toolkit for all of its interface needs. gentoo provides
822     15 100% GUI configurability; no need to edit config files by hand and re-
823     16 start the program. gentoo supports identifying the type of various
824     17 files (using extension, regular expressions, or the 'file' command),
825     18 and can display files of different types with different colors and icons.
826     19 .
827     20 gentoo borrows some of its look and feel from the classic Amiga file
828     21 manager "Directory OPUS" (written by Jonathan Potter).
829 aph 743 </example>
830 joy 838 (I've added the line numbers.)
831 aph 743
832 joy 893 <sect id="copyright">`copyright' file
833 aph 743
834 joy 896 <p>This file contains the information about package upstream resources,
835     copyright and license information. Its format is not dictated by the
836 joy 1526 Policy, but the contents is (section 13.6 "Copyright information").
837 aph 743
838 joy 1526 <p>dh_make created a default one, this is what it looks like:
839    
840 aph 743 <p><example>
841 joy 838 1 This package was debianized by Josip Rodin &lt;jrodin@jagor.srce.hr&gt; on
842 aph 743 2 Wed, 11 Nov 1998 21:02:14 +0100.
843     3
844     4 It was downloaded from &lt;fill in ftp site&gt;
845     5
846     6 Upstream Author(s): &lt;put author(s) name and email here&gt;
847     7
848     8 Copyright:
849     9
850     10 &lt;Must follow here&gt;
851     </example>
852 joy 838 (I've added the line numbers.)
853 aph 743
854     <p>The important things to add to this file are the place you got the
855 joy 896 package from and the actual copyright notice and license. You must
856     include the complete license, unless it's one of the common free software
857     licenses such as GNU GPL or LGPL, BSD or the Artistic license, when you
858     can just refer to the appropriate file in /usr/share/common-licenses/
859 joy 1526 directory that exists on every Debian system.
860 aph 743
861 joy 1526 <p>In short, here's how gentoo's copyright file should look like:
862    
863 aph 743 <p><example>
864 joy 838 1 This package was debianized by Josip Rodin &lt;jrodin@jagor.srce.hr&gt; on
865 aph 743 2 Wed, 11 Nov 1998 21:02:14 +0100.
866     3
867 joy 838 4 It was downloaded from: ftp://ftp.obsession.se/gentoo/
868 aph 743 5
869 joy 838 6 Upstream author: Emil Brink &lt;emil@obsession.se&gt;
870 aph 743 7
871 joy 838 8 This software is copyright (c) 1998-99 by Emil Brink, Obsession
872     9 Development.
873     10
874     11 You are free to distribute this software under the terms of
875     12 the GNU General Public License.
876     13 On Debian systems, the complete text of the GNU General Public
877 joy 1526 14 License can be found in the file `/usr/share/common-licenses/GPL'.
878 aph 743 </example>
879 joy 838 (I've added the line numbers.)
880 aph 743
881 joy 893 <sect id="changelog">`changelog' file
882 aph 743
883 joy 797 <p>This is a required file, which has a special format described in
884 joy 1526 the Policy section 5.3 "debian/changelog". This format is used by dpkg and
885 joy 797 other programs to obtain the version number, revision, distribution and
886     urgency of your package.
887 aph 743
888 joy 797 <p>For you, it is also important, since it is good to have documented
889     all changes you have done. It will help people downloading your package
890 joy 1526 to see whether there are issues with the package that they should know
891     about. It will be saved as
892 joy 896 `/usr/share/doc/gentoo/changelog.Debian.gz' in the binary package.
893 joy 797
894 joy 1526 <p>dh_make creates a default one, and this is how it looks like:
895 joy 797
896 aph 743 <p><example>
897     1 gentoo (0.9.12-1) unstable; urgency=low
898     2
899     3 * Initial Release.
900     4
901 joy 1526 5 -- Josip Rodin &lt;jrodin@jagor.srce.hr&gt; Wed, 11 Nov 1998 21:02:14 +0100
902 aph 743 6
903     </example>
904 joy 838 (I've added the line numbers.)
905 aph 743
906     <p>Line 1 is the package name, version, distribution, and urgency.
907 joy 896 The name must match the source package name, distribution should be
908 joy 1526 either `unstable' (or even `experimental'), and urgency shouldn't
909 joy 896 be changed to anything higher than `low'. :-)
910 aph 743
911     <p>Lines 3-5 are a log entry, where you document changes made in this
912     package revision (not the upstream changes - there is special file for
913 joy 1526 that purpose, created by the upstream authors, which you will later install as
914 joy 838 /usr/share/doc/gentoo/changelog.gz). New lines must be inserted just
915 joy 896 before the uppermost line that begins with asterisk (`*'). You can do
916 joy 1526 it with <manref name="dch" section="1">, or manually with a text editor.
917 aph 743
918 joy 1526 <p>You will end up with something like this:
919    
920 aph 743 <p><example>
921     1 gentoo (0.9.12-1) unstable; urgency=low
922     2
923     3 * Initial Release.
924     4 * This is my first Debian package.
925 joy 838 5 * Adjusted the Makefile to fix $DESTDIR problems.
926     6
927     7 -- Josip Rodin &lt;jrodin@jagor.srce.hr&gt; Wed, 11 Nov 1998 21:02:14 +0100
928     8
929 aph 743 </example>
930 joy 838 (I've added the line numbers.)
931 aph 743
932 joy 1526 <p>You can read more about updating the changelog file later in
933 joy 896 <ref id="update">.
934    
935 joy 893 <sect id="rules">`rules' file
936    
937 joy 896 <p>Now we need to take a look at the exact rules which
938     <manref name="dpkg-buildpackage" section="1"> will use to actually create
939 joy 1526 the package. This file is actually another Makefile, but different than
940     the one(s) in the upstream source. Unlike other files in debian/, this one
941     is marked as executable.
942 joy 893
943 joy 896 <p>Every `rules' file, as any other Makefile, consists of several rules
944     specifying how to handle the source. Each rule consists of targets,
945     filenames or names of actions that should be carried out (e.g. `build:'
946     or `install:'). Rules that you want to execute are invoked as command
947     line arguments (for example, `./debian/rules build` or `make -f rules
948     install`). After the target name, you can name the dependency, program
949     or file that that rule depends on. After that, there can be any number
950 joy 1526 of commands, indented with &lt;tab&gt;. A new rule begins with the target
951     declaration in the first column. Empty lines and lines beginning
952 joy 896 with `#' (hash) are treated as comments and ignored.
953 joy 893
954     <p>You are probably confused now, but it will all be clear upon examination
955 joy 896 of the `rules' file that dh_make gives us as a default. You should also
956     read the `make' entry in info for more information.
957 joy 893
958     <p>The important part to know about the rules file created by dh_make, is
959     that it is just a suggestion. It will work for simple packages but for
960     more complicated ones, don't be afraid to add and subtract from it to fit
961     your needs. Only thing that you must not change are the names of the
962 joy 1526 rules, because all the tools use these names, as mandated by the Policy.
963 joy 893
964 joy 1526 <p>Here's (approximately) how the default debian/rules file that dh_make
965     generated for us looks like:
966    
967 joy 893 <p><example>
968     1 #!/usr/bin/make -f
969 joy 1526 2 # Sample debian/rules that uses debhelper.
970     3 # GNU copyright 1997 to 1999 by Joey Hess.
971     4
972     5 # Uncomment this to turn on verbose mode.
973     6 #export DH_VERBOSE=1
974     7
975     8 # This is the debhelper compatibility version to use.
976     9 export DH_COMPAT=3
977     10
978     11 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
979     12 CFLAGS += -g
980     13 endif
981     14 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
982     15 INSTALL_PROGRAM += -s
983     16 endif
984     17
985     18 build: build-stamp
986     19 build-stamp:
987     20 dh_testdir
988     21
989     22 # Add here commands to compile the package.
990     23 $(MAKE)
991     24 #/usr/bin/docbook-to-man debian/gentoo.sgml > gentoo.1
992 joy 893 25
993 joy 1526 26 touch build-stamp
994     27
995     28 clean:
996     29 dh_testdir
997     30 dh_testroot
998     31 rm -f build-stamp
999     32
1000     33 # Add here commands to clean up after the build process.
1001     34 -$(MAKE) clean
1002     35
1003     36 dh_clean
1004     37
1005     38 install: build
1006     39 dh_testdir
1007     40 dh_testroot
1008     41 dh_clean -k
1009     42 dh_installdirs
1010 joy 893 43
1011 joy 1526 44 # Add here commands to install the package into debian/gentoo.
1012     45 $(MAKE) install DESTDIR=$(CURDIR)/debian/gentoo
1013     46
1014     47 # Build architecture-independent files here.
1015     48 binary-indep: build install
1016     49 # We have nothing to do by default.
1017     50
1018     51 # Build architecture-dependent files here.
1019     52 binary-arch: build install
1020     53 dh_testdir
1021     54 dh_testroot
1022     55 # dh_installdebconf
1023     56 dh_installdocs
1024     57 dh_installexamples
1025     58 dh_installmenu
1026     59 # dh_installlogrotate
1027     60 # dh_installemacsen
1028     61 # dh_installpam
1029     62 # dh_installmime
1030     63 # dh_installinit
1031     64 dh_installcron
1032     65 dh_installman
1033     66 dh_installinfo
1034     67 # dh_undocumented
1035     68 dh_installchangelogs ChangeLog
1036     69 dh_link
1037     70 dh_strip
1038     71 dh_compress
1039     72 dh_fixperms
1040     73 # dh_makeshlibs
1041     74 dh_installdeb
1042     75 # dh_perl
1043     76 dh_shlibdeps
1044     77 dh_gencontrol
1045     78 dh_md5sums
1046     79 dh_builddeb
1047     80
1048     81 binary: binary-indep binary-arch
1049     82 .PHONY: build clean binary-indep binary-arch binary install
1050 joy 893 </example>
1051     (I've added the line numbers.)
1052    
1053 joy 896 <p>You are probably familiar with lines like line 1 from shell and Perl
1054     scripts. It tells the operating system that this file is to be processed
1055     with /usr/bin/make.
1056 joy 893
1057 joy 1526 <p>The meaning of DH_* variables mentioned on lines 6 and 9 should be
1058     evident from the short description. For more information on DH_COMPAT
1059     read the "Debhelper compatibility levels" section of the
1060     <manref name="debhelper" section="1"> manual page.
1061 joy 893
1062 joy 1526 <p>The lines 11 through 16 are a skeleton of support for DEB_BUILD_OPTIONS
1063     parameters, described in the Policy section 11.1 "Binaries". Basically,
1064     these things control if the binaries are to be built with the debugging
1065     symbols, and if they should be stripped upon installation. Again, this is
1066     just a skeleton, a hint that you should do it. You should check into how
1067     the upstream build system handles the inclusion of debugging symbols and
1068     stripping on installation and implement this yourself.
1069    
1070     <p>Usually you can tell gcc to compile with "-g" using the CFLAGS variable
1071     -- if that's the case for your package, propagate the variable by
1072     <em>appending</em> <tt>CFLAGS="$(CFLAGS)"</tt> to the $(MAKE) invocation
1073     in the build rule (see below). Alternatively, if your package uses an
1074     autoconf configure script, you can pass it to configure by
1075     <em>prepending</em> the above string to the ./configure invocation in the
1076     build rule.
1077    
1078     <p>As for the stripping, programs are commonly configured to install
1079     themselves unstripped, and often without an option to change this.
1080     Fortunately, you still have <manref name="dh_strip" section="1"> which
1081     will detect when the DEB_BUILD_OPTIONS=nostrip flag is set and silently
1082     exit.
1083    
1084     <p>Lines 18 through 26 describe the `build' (and its child `build-stamp')
1085     rule, which runs make with the application's own Makefile to compile the
1086     program. We'll talk about the commented out docbook-to-man example later
1087     in <ref id="manpage">.
1088    
1089     <p>The `clean' rule, as specified in lines 28-36, cleans up any unneeded
1090 joy 893 binary or auto-generated stuff, left over from building the package.
1091     This rule must be working at all times (even when the source tree <em/is/
1092     cleaned up!), so please use the forcing options (e.g. for rm, that is
1093 joy 1526 `-f'), or have make ignore return values (failures) using a `-' in front
1094     of the command name.
1095 joy 893
1096 joy 1526 <p>The installation process, the `install' rule, starts with line 38.
1097 joy 896 It basically runs the `install' rule from the program's own Makefile,
1098 joy 1526 but installs in the <tt>$(CURDIR)/debian/gentoo</tt> directory - this is
1099     why we specified
1100 joy 893 $(DESTDIR) as the root installation directory in gentoo's Makefile.
1101    
1102 joy 1526 <p>As the comments suggest, the `binary-indep' rule, on the line 48, is
1103     used to build packages independent of architecture. As we don't have any,
1104     nothing will be done there.
1105 joy 893
1106 joy 1618 <p>On to the next rule - `binary-arch', on lines 52 through 79, in which
1107 joy 896 we run several small utilities from the debhelper package that do various
1108     operations on your package files to make the package Policy conforming.
1109 joy 1526
1110     <p>If your package is an `Architecture: all' one, you need to include all
1111     the commands for building the package under the `binary-indep' rule, and
1112     leave the `binary-arch' rule empty instead.
1113 joy 893
1114 joy 1526 <p>The names of debhelper programs start with dh_, and the rest is the
1115     description of what the particular utility does. It is all quite
1116     self-explanatory, but here are some additional explanations:
1117 joy 893
1118     <list>
1119     <item><manref name="dh_testdir" section="1"> checks that you are in the
1120     right directory (i.e. the top-level source directory),
1121     <item><manref name="dh_testroot" section="1"> checks that you have root
1122 joy 1526 permissions which is needed for the targets `binary-arch',
1123     `binary-indep' and `clean',
1124     <item><manref name="dh_installman" section="1"> will copy the manpages
1125     into the right place in the destination directory, you just have to
1126     tell it where they are, relative to the top-level source directory,
1127 joy 893 <item><manref name="dh_strip" section="1"> strips debugging headers from
1128     executable files and libraries, to make them smaller,
1129 joy 1526 <item><manref name="dh_compress" section="1"> compresses man pages and
1130     documentation larger than 4 kB with <manref name="gzip" section="1">,
1131 joy 893 <item><manref name="dh_installdeb" section="1"> copies package related
1132 joy 1526 files (e.g. the maintainer scripts) to the
1133     <file>debian/gentoo/DEBIAN</file> directory,
1134 joy 893 <item><manref name="dh_shlibdeps" section="1"> calculates shared libraries
1135     dependencies of the libraries and executables,
1136 joy 1526 <item><manref name="dh_gencontrol" section="1"> installs a fine-tuned
1137     version of the control file into <file>debian/gentoo/DEBIAN</file>,
1138 joy 893 <item><manref name="dh_md5sums" section="1"> generates MD5 checksums for
1139     all the files in the package.
1140     </list>
1141    
1142     <p>For more complete information on what do all these dh_* scripts do, and
1143 joy 1526 what are their other options, please read their respective manual pages. There
1144 joy 893 are some other, possibly very useful, dh_* scripts, which were not
1145     mentioned here. If you need them, read the debhelper documentation.
1146    
1147 joy 896 <p>The binary-arch section is the one where you really should comment
1148 joy 1526 out or remove any lines that call features you don't need. For gentoo,
1149 joy 1527 I'll comment out lines about examples, cron, init, man and info,
1150 joy 1526 simply because gentoo doesn't need them. Also, on the line 68, I'll
1151     replace `ChangeLog' with `FIXES', because that is the real name of the
1152     upstream changelog file.
1153 joy 893
1154     <p>The last two lines (along with any other not explained ones) are just
1155 joy 1198 some more-or-less necessary things, regarding which you can read in the
1156 joy 1526 make manual, and the Policy. For now, they're not important to know about.
1157 joy 893
1158     <chapt id="dother">Other files under debian/
1159    
1160     <p>You will see that there exist several other files in the debian/
1161     subdirectory, most of them with the `.ex' suffix, meaning that they are
1162 joy 1527 examples. Take a look at all of them. If you wish or need to use any of
1163     those features:
1164    
1165     <list>
1166     <item>take a look at the related documentation (hint: the Policy Manual),
1167     <item>if necessary modify the files to suit your needs,
1168 joy 1528 <item>rename them to remove the `.ex' suffix if they have one,
1169 joy 1527 <item>modify the `rules' file if necessary.
1170     </list>
1171    
1172     <p>Some of those files, those commonly used ones, are explained in the
1173 joy 893 following sections.
1174    
1175 joy 896 <sect id="readme">README.Debian
1176 joy 893
1177     <p>Any extra details or discrepancies between the original package and
1178 joy 1527 your debianized version should be documented here.
1179 joy 893
1180 joy 1527 <p>dh_make created a default one, this is what it looks like:
1181    
1182     <p><example>
1183 joy 893 gentoo for Debian
1184 joy 1527 -----------------
1185 joy 893
1186     &lt;possible notes regarding this package - if none, delete this file&gt;
1187    
1188 joy 1527 -- Josip Rodin &lt;jrodin@jagor.srce.hr&gt;, Wed, 11 Nov 1998 21:02:14 +0100
1189 joy 893 </example>
1190    
1191 joy 1527 <p>Since we don't have anything to put there, we'll delete the file.
1192 joy 893
1193 joy 1527 <sect id="conffiles">conffiles.ex
1194 aph 743
1195     <p>One of the most annoying things about software is when you spend a
1196 joy 1527 great deal of time and effort customizing a program, only to have an
1197 aph 743 upgrade stomp all over your changes. Debian solves this problem by
1198 joy 1527 marking configuration files so that when you upgrade a package, you'll
1199     be prompted whether you want to keep your old configuration or not.
1200 aph 743
1201 joy 1527 <p>The way to do this in a package is to enter the full path to each
1202     configuration file (usually in /etc), one per line, in a file called
1203     <tt/conffiles/. Gentoo has one conffile, /etc/gentoorc, and we'll enter
1204     that in the <tt/conffiles/ file.
1205 joy 838
1206 joy 1527 <p>If your program uses configuration files but also rewrites them on its
1207     own, it's best not to mark them as conffiles because dpkg will then prompt
1208     users to verify the changes all the time.
1209    
1210     <p>If the program you're packaging requires every user to modify the
1211     configuration file in order to work at all, also consider not marking the
1212     file as a conffile.
1213    
1214     <p>You can handle example configuration files from the `maintainer
1215     scripts', for more information see <ref id="maintscripts">.
1216    
1217     <p>If your program has no conffiles, you can safely delete the
1218     <tt/conffiles/ file from the debian/ directory.
1219    
1220     <sect id="crond">cron.d.ex
1221    
1222     <p>If your package requires regularly scheduled tasks to operate properly,
1223     you an use this file to set it up.
1224    
1225     <p>Note that this doesn't include log rotation; for that, see
1226     <manref name="dh_installlogrotate" section="1"> and
1227     <manref name="logrotate" section="8">.
1228    
1229     <p>If not, remove it.
1230    
1231 aph 743 <sect id="dirs">dirs
1232    
1233 joy 1198 <p>This file specifies the directories which we need but the normal
1234 joy 838 installation procedure (make install) somehow doesn't create.
1235 joy 797
1236 joy 1527 <p>By default, it looks like this:
1237    
1238 aph 743 <p><example>
1239 joy 838 usr/bin
1240     usr/sbin
1241 aph 743 </example>
1242    
1243     <p>Note that the preceding slash is not included. We would have normally
1244     changed it to look like this:
1245 joy 1527
1246 aph 743 <p><example>
1247 joy 1527 usr/bin
1248     usr/man/man1
1249 aph 743 </example>
1250    
1251 joy 1527 <p>but those directories are already created in the Makefile, so we won't
1252     need this file, and we will instead delete it.
1253 aph 743
1254 joy 1528 <sect id="docs">docs
1255    
1256     <p>This file specifies the file names of documentation files we can have
1257     dh_installdocs install into the temporary directory for us.
1258    
1259     <p>By default, it will include all existing files in the top-level source
1260     directory that are called "BUGS", "README*", "TODO" etc.
1261    
1262     <p>For gentoo, I also included some other stuff:
1263    
1264     <p><example>
1265     BUGS
1266     CONFIG-CHANGES
1267     CREDITS
1268     ONEWS
1269     README
1270     README.gtkrc
1271     TODO
1272     </example>
1273    
1274     <p>We can also remove this file and instead list these files on the
1275     <tt/dh_installdocs/ command line in the <tt/rules/ file, like this:
1276    
1277     <p><example>
1278     dh_installdocs BUGS CONFIG-CHANGES CREDITS ONEWS README \
1279     README.gtkrc TODO
1280     </example>
1281    
1282     <p>How ever unlikely it may seem, you may not have any such files in your
1283 joy 1552 package's sources. In that case you can safely remove this file. But don't
1284     remove the <tt/dh_installdocs/ invocation from the <tt/rules/ file because
1285     that's used to install the <tt/copyright/ file and other things.
1286 joy 1528
1287 joy 1527 <sect id="emacsen">emacsen-*.ex
1288 aph 743
1289 joy 1527 <p>If your package supplies Emacs files that can be bytecompiled at
1290     package installation time, you can use these files to set it up.
1291 aph 743
1292 joy 1527 <p>They are installed into the temporary directory by
1293     <manref name="dh_installemacsen" section="1">, so don't forget to
1294     uncomment that line in the <tt/rules/ file if you use this.
1295 aph 743
1296 joy 1527 <p>If you don't need these, remove them.
1297    
1298     <sect id="initd">init.d.ex
1299    
1300     <p>If your package is a daemon that needs to be run at system startup,
1301     you've obviously disregarded my initial recommendation, haven't you? :-)
1302    
1303     <p>This is a fairly generic skeleton file for an <file>/etc/init.d/</file>
1304     script, so you'll likely have to edit it, a lot. It gets installed into
1305     the temporary directory by <manref name="dh_installinit" section="1">.
1306    
1307     <p>If you don't need this, remove the file.
1308    
1309     <sect id="manpage">manpage.1.ex, manpage.sgml.ex
1310    
1311     <p>Your program(s) should have a manual page. If they don't, each of these
1312     files are a template that you can fill out.
1313    
1314     <p>Manual pages are normally written in <manref name="nroff" section="1">.
1315     The <tt/manpage.1.ex/ example is written in nroff, too.
1316     See the <manref name="man" section="7"> manual page
1317     for a brief description of how to edit such a file.
1318    
1319     <p>If on the other hand you prefer writing SGML instead of nroff, you can
1320     use the <tt/manpage.sgml.ex/ template. If you do this, you have to:
1321     <list>
1322     <item>install the <package/docbook-to-man/ package
1323     <item>add <tt/docbook-to-man/ to the <tt/Build-Depends/ line in the
1324     <tt/control/ file
1325     <item>remove the comment from the docbook-to-man invocation in the
1326     `build' rule of your <tt/rules/ file
1327     </list>
1328    
1329     <p>And remember to rename the file to something like <tt/gentoo.sgml/!
1330    
1331     <p>The final manual page file name should include the name of the program
1332     it is documenting, so we will rename it from "manpage" to "gentoo".
1333     The file name also includes ".1" as the first suffix, which means it's a
1334     manual page for a user command. Be sure to verify that this section is
1335     indeed the correct one. Here's a short list of manual page sections:
1336    
1337 aph 743 <p><example>
1338     Section | Description | Notes
1339     1 User commands Executable commands or scripts.
1340     2 System calls Functions provided by the kernel.
1341     3 Library calls Functions within system libraries.
1342     4 Special files Usually found in /dev
1343     5 File formats E.g. /etc/passwd's format
1344     6 Games Or other frivolous programs
1345     7 Macro packages Such as man macros.
1346     8 System administration Programs typically only run by root.
1347     9 Kernel routines Non-standard calls and internals.
1348     </example>
1349    
1350 joy 1527 <p>So gentoo's man page should be called <tt/gentoo.1/. For X programs you
1351     can tack on another "x" to the section, i.e. <tt/gentoo.1x/.
1352     There was no gentoo.1 man page in the original source so I wrote
1353     it using information from the example and from upstream docs.
1354 aph 743
1355     <sect id="menu">menu.ex
1356    
1357 joy 838 <p>X Window System users usually have a window manager with a menu that
1358     can be customized to launch programs. If they have installed the Debian
1359 joy 1527 <package/menu/ package, a set of menus for every program on the system will be
1360     created for them.
1361    
1362     <p>Here's the default <tt/menu.ex/ file that dh_make creates:
1363 aph 743
1364     <p><example>
1365     ?package(gentoo):needs=X11|text|vc|wm section=Apps/see-menu-manual\
1366     title="gentoo" command="/usr/bin/gentoo"
1367     </example>
1368    
1369 joy 1527 <p>The first field after the colon character is "needs", and it specifies
1370     what kind of interface the program needs. Change this to one of the listed
1371     alternatives, e.g. "text" or "X11".
1372    
1373     <p>The next is "section", where the menu and submenu the entry should
1374 joy 838 appear in. The current list of sections is at:
1375 joy 1527 <file>/usr/share/doc/debian-policy/menu-policy.html/ch2.html#s2.1</file>
1376 aph 743
1377 joy 1527 <p>The "title" field is the name of the program. You can start this one
1378     in uppercase if you like. Just keep it short.
1379    
1380     <p>Finally, the "command" field is the command that runs the program.
1381    
1382 aph 743 <p>Now we'll change the menu entry to this:
1383 joy 1527
1384 aph 743 <p><example>
1385 joy 1533 ?package(gentoo): needs=X11 section=Apps/Tools title="Gentoo" command="gentoo"
1386 aph 743 </example>
1387    
1388 joy 1527 <p>You can also add other fields like "longtitle", "icon", "hints" etc.
1389     See <manref name="menufile" section="5">,
1390     <manref name="update-menus" section="1">
1391     and <file>/usr/share/doc/debian-policy/menu-policy.html/</file> for more
1392     information.
1393 joy 838
1394 aph 743 <sect id="watch">watch.ex
1395    
1396 joy 1527 <p>This file is used to configure the <manref name="uscan" section="1">
1397     and <manref name="uupdate" section="1"> programs (in the
1398     <package/devscripts/ package). These are used to watch the site you got
1399     the original source from.
1400 aph 743
1401 joy 1527 <p>Here's what I put in it:
1402    
1403 joy 838 <p><example>
1404     # watch control file for uscan
1405 joy 896 # Site Directory Pattern Version Script
1406     ftp.obsession.se /gentoo gentoo-(.*)\.tar\.gz debian uupdate
1407 joy 838 </example>
1408 aph 743
1409 joy 838 <p>Hint: connect to the Internet, and try running "uscan" in the program
1410 joy 1527 directory once you create the file. And read the manuals! :)
1411 aph 743
1412 joy 1527 <sect id="doc-base">ex.package.doc-base
1413 joy 896
1414 joy 1527 <p>If your package has documentation other than manual pages and info
1415     docs, you should use the `<package/doc-base/' file to register it,
1416     so the user can find it with e.g. <manref name="dhelp" section="1">,
1417     <manref name="dwww" section="1"> or <manref name="doccentral" section="1">.
1418 joy 896
1419 joy 1527 <p>This usually includes HTML, PS and PDF files, shipped in
1420     <file>/usr/share/doc/packagename/</file>.
1421    
1422 joy 896 <p>This is how gentoo's doc-base file looks like:
1423    
1424     <p><example>
1425     Document: gentoo
1426     Title: Gentoo Manual
1427     Author: Emil Brink
1428     Abstract: This manual describes what Gentoo is, and how it can be used.
1429     Section: Apps/Tools
1430    
1431     Format: HTML
1432     Index: /usr/share/doc/gentoo/html/index.html
1433     Files: /usr/share/doc/gentoo/html/*.html
1434     </example>
1435    
1436 joy 1527 <p>For information on the file format, see
1437     <manref name="install-docs" section="8"> and the <package/doc-base/ manual,
1438     in <file>/usr/share/doc/doc-base/doc-base.html/</file>.
1439 joy 896
1440 joy 838 <sect id="maintscripts">postinst.ex, preinst.ex, postrm.ex, prerm.ex
1441    
1442 joy 1527 <p>These files are called maintainer scripts. They are scripts which are
1443     put in the control area of the package and run by <prgn/dpkg/ when your
1444     package is installed, upgraded or removed.
1445 joy 896
1446     <p>For now, you should try to avoid any manual editing of maintainer
1447     scripts if you possibly can because they tend to get complex. For more
1448     information look in the Packaging Manual, section 6, and take a look at
1449 joy 838 these example files provided by dh_make.
1450    
1451 joy 1527 <chapt id="build">Building the package
1452    
1453 joy 838 <p>We should now be ready to build the package.
1454    
1455 joy 1530 <sect id="completebuild">Complete rebuild
1456 joy 1529
1457 joy 893 <p>Enter the program's main directory and then issue this command:
1458 joy 838
1459 aph 743 <p><example>
1460 joy 773 dpkg-buildpackage -rfakeroot
1461 aph 743 </example>
1462    
1463 joy 1529 <p>This will do everything for you. It will:
1464     <list>
1465     <item>clean the source tree (debian/rules clean), using <prgn/fakeroot/
1466     <item>build the source package (dpkg-source -b)
1467     <item>build the program (debian/rules build)
1468     <item>build the binary package (debian/rules binary), using <prgn/fakeroot/
1469     <item>sign the source <tt/.dsc/ file, using <prgn/gnupg/
1470     <item>create and sign the upload <tt/.changes/ file, using
1471     <prgn/dpkg-genchanges/ and <prgn/gnupg/
1472     </list>
1473 aph 743
1474 joy 1529 <p>The only input that will be required of you is your GPG key secret pass
1475     phrase, twice.
1476    
1477     <p>After all this is done, you will see the following files in the
1478     directory above (<tt>~/debian/</tt>):
1479    
1480 aph 743 <p><list>
1481     <item><em>gentoo_0.9.12.orig.tar.gz</em>
1482    
1483 joy 1529 <p>This is the original source code tarball, merely renamed to the above
1484 joy 1531 so that it adheres to the Debian standard. Note that this was created
1485     using the `-f' option to <prgn/dh_make/ when we initially ran it.
1486 joy 1529
1487 aph 743 <item><em>gentoo_0.9.12-1.dsc</em>
1488 joy 1529
1489 aph 743 <p>This is a summary of the contents of the source code. The file is
1490 joy 1529 generated from your `control' file, and is used when
1491 joy 770 unpacking the source with <manref name="dpkg-source" section="1">. This
1492     file is PGP signed, so that people can be sure that it's really yours.
1493 joy 838
1494     <item><em>gentoo_0.9.12-1.diff.gz</em>
1495 joy 1529
1496 joy 838 <p>This compressed file contains each and every addition you made to the
1497     original source code, in the form known as "unified diff". It is made
1498 joy 1531 and by <manref name="dpkg-source" section="1">. Warning: if you don't name
1499     the original tarball packagename_version.orig.tar.gz, <prgn/dpkg-source/
1500     will fail to generate the .diff.gz file properly!
1501 joy 838
1502 joy 1531 <p>If someone else wants to re-create your package from scratch, they can
1503 joy 1529 easily do so using the above three files. The extraction procedure is
1504     trivial: just copy the three files somewhere else and run
1505     <tt>dpkg-source -x gentoo_0.9.12-1.dsc</tt>.
1506    
1507     <item><em>gentoo_0.9.12-1_i386.deb</em>
1508    
1509     <p>This is your completed binary package. You can use <prgn/dpkg/ to
1510     install and remove this just like any other package.
1511    
1512 joy 838 <item><em>gentoo_0.9.12-1_i386.changes</em>
1513 joy 1529
1514 joy 838 <p>This file describes all the changes made in the current package
1515     revision, and it is used by the Debian FTP archive maintenance programs
1516     to install the binary and source packages in it. It is partly generated
1517 joy 1529 from the `changelog' file and the .dsc file. This file is PGP signed, so
1518     that people can be sure that it's really yours.
1519 joy 838
1520     <p>As you keep working on the package, behavior will change and new
1521     features will be added. People downloading your package can look at this
1522 joy 1529 file and quickly see what has changed. Debian archive maintenance programs
1523     will also post the contents of this file to the debian-devel-changes
1524     mailing list.
1525 aph 743 </list>
1526    
1527 joy 1529 <p>The long strings of numbers in the .dsc and .changes files are MD5
1528     checksums for the files mentioned.
1529     A person downloading your files can test them with <manref name="md5sum"
1530     section="1"> and if the numbers don't match, they'll know the file is
1531     corrupt or has been tampered with.
1532    
1533     <sect id="quickrebuild">Quick rebuild
1534    
1535 joy 896 <p>With a large package, you may not want to rebuild from scratch every
1536 joy 1529 time while you tune a detail in <file>debian/rules</file>. For testing
1537     purposes, you
1538 joy 896 can make a .deb file without rebuilding the upstream sources like this:
1539 aph 743
1540 joy 896 <p><example>
1541     fakeroot debian/rules binary
1542     </example>
1543    
1544 joy 1529 <p>Once you are finished with your tuning, remember to rebuild following
1545     the above, proper procedure. You may not be able to upload correctly if
1546     you try to upload .deb files built this way.
1547 joy 896
1548 joy 1527 <chapt id="checkit">Checking the package for errors
1549 joy 896
1550 joy 770 <p>Run <manref name="lintian" section="1"> on your .changes file; this
1551     program will check for many common packaging errors. The command is:
1552 aph 743
1553     <p><example>
1554     lintian -i gentoo_0.9.12-1_i386.changes
1555     </example>
1556    
1557 joy 1530 <p>Of course, replace the filename with the name of the .changes file
1558 joy 896 generated for your package. If it appears that there are some errors
1559     (lines beginning with E:), read the explanation (the N: lines), correct
1560 joy 1530 mistakes, and rebuild as described in <ref id="completebuild">. If there are
1561     lines that begin with W:, those are warnings, so tune the package or
1562     verify that the warnings are spurious (and make Lintian overrides; see
1563     the documentation for details).
1564 aph 743
1565 joy 1530 <p>Note that you can build the package with <prgn/dpkg-buildpackage/ and run
1566     <prgn/lintian/ all in one command with <manref name="debuild" section="1">.
1567 joy 896
1568 joy 838 <p>Look inside the package using a file manager like <manref name="mc" section="1">,
1569     or unpack it in a temporary place using <manref name="dpkg-deb" section="1">.
1570 joy 1530 Be on the lookout for extra unneeded files, both in the binary and source
1571     package. Often cruft doesn't get cleaned up properly; adjust your rules
1572     file to compensate for that. Tips: `zgrep ^+++ ../gentoo_0.9.12-1.diff.gz` will give you a list of
1573 joy 896 your changes/additions to the source files, and `dpkg-deb -c gentoo_0.9.12-1_i386.deb`
1574 joy 1530 will list the files in the binary package.
1575 joy 838
1576 joy 896 <p>Install the package to test it yourself, e.g. using the
1577     <manref name="debi" section="1"> command as root. Try to install and run
1578     it on machines other than your own and watch closely for any warnings
1579 joy 1530 or errors both during the installation and while the program is being run.
1580 aph 743
1581 joy 1530 <chapt id="upload">Uploading the package
1582 joy 770
1583 joy 1530 <p>Now that you have tested your new package thoroughly, you will be ready
1584     to start the Debian new maintainer application process, as described at
1585     <url id="http://www.debian.org/devel/join/newmaint">
1586 joy 770
1587 joy 1530 <p>Once you become an official developer, you'll need to upload the
1588     package to the Debian archive. You can do this manually, but it's easier
1589     to use the provided automated tools, like
1590     <manref name="dupload" section="1"> or <manref name="dput" section="1">.
1591     We'll describe how it's done with <prgn/dupload/.
1592 aph 743
1593 joy 1531 <p>First you have to set up dupload's config file. You can either edit the
1594     system-wide <file>/etc/dupload.conf</file> file, or have your own
1595     <file>~/.dupload.conf</file> file override the few things you want to
1596     change. Put something like this in the file:
1597 aph 743
1598 joy 896 <p><example>
1599 joy 838 package config;
1600 joy 1553
1601 joy 1530 $default_host = "ftp-master";
1602 joy 1553
1603     $cfg{"ftp-master"}{"login"} = "yourdebianusername";
1604    
1605     $cfg{"non-us"}{"login"} = "yourdebianusername";
1606    
1607 joy 838 1;
1608 aph 743 </example>
1609    
1610 joy 838 <p>Of course, change my personal settings to yours, and read the
1611     <manref name="dupload.conf" section="5"> manual page to understand
1612 joy 896 what each of these options means.
1613 joy 773
1614 joy 1530 <p>The $default_host option is the trickiest one -- it determines which of
1615     the upload queues will be used by default. "ftp-master" is the primary
1616     one, but it's possible that you will want to use another, faster one.
1617     For more information about the upload queues, read the Developers'
1618     Reference, section "Uploading a package", at
1619     <file>/usr/share/doc/developers-reference/developers-reference.html/ch-upload.en.html#s-uploading</file>
1620    
1621 joy 893 <p>Then connect to your Internet provider, and issue this command:
1622 aph 743
1623     <p><example>
1624 joy 1530 dupload gentoo_0.9.12-1_i386.changes
1625 aph 743 </example>
1626    
1627 joy 1530 <p><prgn/dupload/ checks that the MD5 checksums of the files match those from the
1628 joy 896 .changes file, so it will warn you to rebuild it as described in
1629 joy 1530 <ref id="completebuild"> so it can properly upload.
1630 joy 896
1631 joy 1530 <p>If you upload to "ftp-master", <prgn/dupload/ will ask for your
1632     password on Debian machines, and then upload the packages.
1633 joy 838
1634 joy 1524 <chapt id="update">Updating the package
1635 aph 743
1636 joy 1524 <sect id="newrevision">New Debian revision
1637    
1638 joy 896 <p>Let's say that a bug report was filed against your package, #54321,
1639     and it describes a problem that you can solve. To create a new Debian
1640     revision of the package, you need to:
1641    
1642     <list>
1643     <item>Correct the problem in the package source, of course.
1644    
1645 joy 1526 <item>Add a new revision at the top of the Debian changelog file, for
1646     example with `dch -i`, or explicitly with
1647     `dch -v &lt;version&gt;-&lt;revision&gt;`
1648     and then insert the comments using your preferred editor.
1649    
1650     <p>Tip: how to easily get the date in required format?
1651     Use `822-date`, or `date -R`.
1652    
1653     <item>Include a short description of the bug and the solution in the
1654     changelog entry,
1655 joy 896 followed by this: "Closes: #54321". That way, the bug report will be
1656     automagically closed by the archive maintenance software the moment your
1657     package gets accepted in the Debian archive.
1658    
1659 joy 1530 <item>Repeat what you did in <ref id="completebuild">, <ref id="checkit">,
1660 joy 896 and <ref id="upload">. The difference is that this time, original source
1661     archive won't be included, as it hasn't been changed and it already
1662     exists in the Debian archive.
1663     </list>
1664    
1665 joy 1524 <sect id="newupstream">New upstream release
1666    
1667 joy 896 <p>Now let's consider a different, a wee bit more complicated situation
1668     - a new upstream version was released, and of course you want it packaged.
1669     You need to do the following:
1670    
1671     <list>
1672     <item>Download the new sources and put the tarball (e.g. named
1673     `gentoo-0.9.13.tar.gz') in the directory above the old source tree
1674     (e.g. ~/debian/).
1675    
1676     <item>Enter the old source directory, and run:
1677    
1678     <example>
1679     uupdate -u gentoo-0.9.13.tar.gz
1680     </example>
1681    
1682 joy 1530 <p>Of course, replace this file name with the name of your program's new source
1683 joy 896 archive. <manref name="uupdate" section="1"> will properly rename that
1684     tarball, try to apply all the changes from your previous .diff.gz file,
1685     and update the new debian/changelog file.
1686    
1687     <item>Change directory to `../gentoo-0.9.13', the new package source tree,
1688 joy 1530 and repeat what you did in <ref id="completebuild">, <ref id="checkit">, and
1689 joy 896 <ref id="upload">.
1690     </list>
1691    
1692     <p>Note that if you set up `debian/watch' file as described in
1693     <ref id="watch">, you can run <manref name="uscan" section="1"> to
1694 joy 1530 automagically look for revised sources, download them, and run
1695     <prgn/uupdate/.
1696 joy 896
1697 joy 1530 <sect id="upgrading">Verifying package upgrades
1698    
1699     <p>When you build a new version of the package, you should do the
1700     following to verify that the package can be safely upgraded:
1701    
1702     <list>
1703     <item>upgrade from the previous version
1704     <item>downgrade back again and then remove it,
1705     <item>install the new package
1706     <item>remove it and then reinstall it again,
1707     <item>purge it.
1708     </list>
1709    
1710     <p>Bear in mind that if your package has previously been released in
1711     Debian, people will often be upgrading to your package from the version
1712 joy 1587 that was in the last Debian release. Remember to test upgrades from that
1713 joy 1530 version, too.
1714    
1715 joy 1524 <chapt id="helpme">Where to ask for help
1716 joy 896
1717 joy 838 <p>Before you decide to ask your question in some public place, please
1718 joy 1530 just RTFM. That includes documentation in <file>/usr/share/doc/dpkg</file>,
1719     <file>/usr/share/doc/debian</file>, <file>/usr/share/doc/package/*</file>
1720     files and the man/info pages for all the programs mentioned in this document.
1721    
1722     <p>If you have questions about packaging that you couldn't find answers to
1723     in the documentation, you can ask them on the Debian Mentors' mailing list
1724     at <email/debian-mentors@lists.debian.org/. The more experienced Debian
1725     developers will gladly help you, but do read at least some of the
1726     documentation before asking a question!
1727    
1728     <p>See <url id="http://lists.debian.org/debian-mentors/"> for more
1729     information about this mailing list.
1730    
1731     <p>When you receive
1732 joy 838 a bug report (yes, actual bug reports!), you will know that it is time
1733     that you dig in the <url name="Debian Bug Tracking System" id="http://www.debian.org/Bugs/">
1734     and read the documentation there, to be able to deal with the reports
1735 joy 1531 efficiently. I highly recommend reading the Developers' Reference,
1736     chapter "Handling Bugs", at
1737     <file>/usr/share/doc/developers-reference/developers-reference.html/ch-bug-handling.en.html</file>
1738 aph 743
1739 joy 770 <p>If you still have questions, ask on the Debian Developers' mailing list
1740 joy 1530 at <email/debian-devel@lists.debian.org/. See
1741     <url id="http://lists.debian.org/debian-devel/"> for more information
1742     about this mailing list.
1743 aph 743
1744     <p>Even if it all worked well, it's time to start praying. Why? Because
1745     in just a few hours (or days) users from all around the world will start
1746     to use your package, and if you made some critical error you'll get
1747     mailbombed by numerous angry Debian users... Just kidding. :-)
1748    
1749     <p>Relax and be ready for bug reports, because there is a lot more work
1750 joy 1530 to be done before your package will be fully in line with Debian policies
1751     (once again, read the <em>real documentation</em> for details). Good luck!
1752 aph 743
1753     </book>
1754    
1755     </debiandoc>

  ViewVC Help
Powered by ViewVC 1.1.5