File: maint-guide.sgml

package info (click to toggle)
maint-guide 1.2.14
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,256 kB
  • ctags: 27
  • sloc: makefile: 186; sh: 39
file content (2350 lines) | stat: -rw-r--r-- 100,337 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
<!DOCTYPE debiandoc PUBLIC "-//DebianDoc//DTD DebianDoc//EN" [

<!-- textual data entities -->
<!-- first definition wins in SGML -->
<!ENTITY % default  SYSTEM "default.ent">  %default;

]>
<!-- CVS revision of this document "$Revision: 1.116 $"  -->
<!-- CVS revision of original english document "*.**"  -->

<debiandoc>

 <book>

  <titlepag>

   <title>Debian New Maintainers' Guide</title>

   <author>Josip Rodin <email/joy-mg@debian.org/
   </author>
<!--
   <author>Translated by: [put your name here] <email/[put your e-mail here]/
   </author>
  -->

   <version>version 1.2.13, 5 June 2008.</version>

   <copyright>
   <copyrightsummary>Copyright &copy; 1998-2002 Josip Rodin.</copyrightsummary>
   <copyrightsummary>Copyright &copy; 2005-2007 Osamu Aoki.</copyrightsummary>

   <p>This document may be used under the terms the GNU General Public License
   version 2 or higher.

   <p>This document was made using with these two documents as examples:

   <p>Making a Debian Package (AKA the Debmake Manual), copyright &copy;
   1997 Jaldhar Vyas.

   <p>The New-Maintainer's Debian Packaging Howto, copyright &copy; 1997
   Will Lowe.
   </copyright>

  </titlepag>

  <toc sect>

  <chapt id="start">Getting started The Right Way

  <p>This document tries to describe building of a Debian package to the
  common Debian user, and prospectus developer. It uses pretty common language,
  and it's well covered with working examples.
  There is an old Roman saying, <em>Longum
  iter est per preaecepta, breve et efficax per exempla!</em> (It's a long way
  by the rules, but short and efficient with examples!).

  <p>One of the things that makes Debian such a top-notch Linux distribution
  is its package system. While there is a vast quantity of software already
  in the Debian format, sometimes you need to install software that isn't.
  You may be wondering how you can make your own packages and perhaps you
  think it is a very difficult task. Well, if you are a real novice on Linux,
  it is hard, but if you were rookie, you wouldn't be reading this doc now. :-)
  You do need to know a little about Unix programming but you certainly
  don't need to be a wizard.

  <p>One thing is certain, though: to properly create and maintain Debian
  packages you need man hours. Make no mistake, for our system to work the
  maintainers need to be both technically competent and diligent.

  <p>This document will explain every little (at first maybe irrelevant)
  step, and help you create that first package, and to gain some experience
  in building next releases of that and maybe other packages later on.

  <p>Newer versions of this document should always be available online at
  <url name="http://www.debian.org/doc/maint-guide/" id="http://www.debian.org/doc/maint-guide/">
  and in the `<package/maint-guide/' package.
  <!-- Translation in <this language> is also available in the
       `<package/maint-guide-xy/' package. -->

  <sect id="needprogs">Programs you need for development

  <p>Before you start anything, you should make sure that you have properly
  installed some additional packages needed for development. Note that the
  list doesn't contain any packages marked `essential' or `required' - we
  expect that you have those installed already.

  <p>This revision of this document has been updated for the packages in
  Debian 2.2 (`potato') and 3.0 (`woody').

  <p>The following packages come with the standard Debian installation,
  so you probably have them already (along with any additional packages
  they depend on).
  Still, you should check with `dpkg -s &lt;package&gt;`.

  <list>
  <item><package/dpkg-dev/ - this package contains the tools needed to unpack,
  build and upload Debian source packages. (see
  <manref name="dpkg-source" section="1">)

  <item><package/file/ - this handy program can determine what type a file is.
  (see <manref name="file" section="1">)

  <item><package/gcc/ - the GNU C compiler, necessary if your program like
  most others is written in the C programming language.
  (see <manref name="gcc" section="1">)
  This package will also "pull in" several other packages such as
  <package/binutils/ which includes programs used to assemble and link
  object files (see `info binutils` in the <package/binutils-doc/ package)
  and <package/cpp/, the C preprocessor. (see <manref name="cpp" section="1">)

  <item><package/g++/ - the GNU C++ compiler, necessary if your program
  is written in C++. (see <manref name="g++" section="1">)

  <item><package/libc6-dev/ - the C libraries and header files gcc needs to
  link with to create object files. (see `info libc` in the
  <package/glibc-doc/ package)

  <item><package/make/ - usually creation of a program takes several steps,
  so rather than having to type out the same commands over and over again,
  you can use this program to automate the process, creating `Makefile's.
  (see `info make`)

  <item><package/patch/ - this very useful utility will take a file containing
  a difference listing (produced by the diff program) and apply it to the
  original file, producing a patched version. (see <manref name="patch" section="1">)

  <item><package/perl/ - Perl is one of the most used interpreted scripting
  languages on today's Unix-like systems, often referred to as "Unix's Swiss Army
  Chainsaw". (see <manref name="perl" section="1">)
  </list>

  <p>You'll probably want to install the following packages, too:

  <list>
  <item><package/autoconf/ and <package/automake/ - many newer programs use
  configure scripts and Makefiles preprocessed with help of programs like
  these. (see `info autoconf`, `info automake`)

  <item><package/dh-make/ and <package/debhelper/ - dh-make is necessary to
  create the skeleton of our example package, and it will use some of the
  debhelper tools for creating packages. They are not essential for creation
  of packages, but are <strong>highly</strong> recommended for new
  maintainers. It makes the whole process very much easier to start, and
  control afterwards. (see <manref name="dh_make" section="1">,
  <manref name="debhelper" section="1">, /usr/share/doc/debhelper/README)

  <item><package/devscripts/ - this package contains some nice and useful
  scripts that can be helpful to the maintainers, but they are also not
  necessary for building packages. (see /usr/share/doc/devscripts/README.gz)

  <item><package/fakeroot/ - this utility lets you emulate being root which
  is necessary for some parts of the build process. (see
  <manref name="fakeroot" section="1">)

  <item><package/gnupg/ - a tool that enables you to digitally <em>sign</em>
  packages. This is especially important if you want to distribute it to
  other people, and you will certainly be doing that when your work gets
  included in the Debian distribution. (see <manref name="gpg" section="1">)

  <item><package/g77/ - the GNU Fortran 77 compiler, necessary if your
  program is written in Fortran. (see <manref name="g77" section="1">)

  <item><package/gpc/ - the GNU Pascal compiler, necessary if your
  program is written in Pascal. Worthy of note here is <package/fp-compiler/,
  the Free Pascal Compiler, which is also good at this task.
  (see <manref name="gpc" section="1">, <manref name="ppc386" section="1">)

  <item><package/xutils/ - some programs, usually those
  made for X11, also use these programs to generate Makefiles from sets of
  macro functions. (see <manref name="imake" section="1">,
  <manref name="xmkmf" section="1">)

  <item><package/lintian/ - this is the Debian package checker that can let
  you know of any common mistakes after you build the package, and explain
  the errors found. (see <manref name="lintian" section="1">,
  /usr/share/doc/lintian/lintian.html/index.html)

  <item><package/pbuilder/ - this package contains programs which is used 
  for creating and maintaining chroot environment.  Building Debian 
  package in this chroot environment verifies the proper build dependency
  and avoid FTBFS bugs.  (see <manref name="pbuilder" section="8"> and 
  <manref name="pdebuild" section="1">)
  </list>

  <p>The following is the <em>very important</em> documentation which you
  should read along with this document:

  <list>
  <item><package/debian-policy/ - the Policy includes explanations of the
  structure and contents of the Debian archive, several OS design issues,
  the Filesystem Hierarchy Standard (which says where each file and
  directory should be) etc.
  For you, the most important thing is that it describes requirements that
  each package must satisfy to be included in the distribution.
  (see &debian-policy;)

  <item><package/developers-reference/ - for all matters not specifically
  about the technical details of packaging, like the structure of the
  archive, how to rename, orphan, pick up packages, how to do NMUs, how to
  manage bugs, best packaging practices, when and where to upload etc.
  (see &developers-reference;)
  </list>

  <p>The short descriptions that are given above only serve to introduce
  you to what each package does. Before continuing please thoroughly read
  the documentation of each program, at least the standard usage.
  It may seem like heavy going now, but later on you'll be <em>very</em>
  glad you read it.

  <p>Note: <package/debmake/ is a package that contains some programs that
  function similar to dh-make, but its specific use is <strong>not</strong>
  covered in this document, because it is <em>deprecated</em>. 

  <sect id="debiandeveloper">Official Debian Developer

  <p>After you build your package (or while doing that), you may want to 
  become an official Debian Developer to get your new package into the 
  next distribution (if the program is useful, why not?).
  
  <p>You can not become an official Debian Developer over night because
  it takes more than technical skill.  Please do not be discouraged by
  this.  You can still upload your package, if useful to others,  now as
  a maintainer through a sponsor while applying yourself to 
  <url name="the Debian New Maintainer process" id="&nm-home;">.  Here,
  the sponsor is an official Debian Developer who helps maintainer to
  upload packages to the Debian archive.  More details of this procedure
  are explained in the 
  <url id="&mentors-faq;" name="debian-mentors FAQ">.

  <p>Please note that you do not need to create any new package to
  become an official Debian Developer.  Contributing to the existing
  packages can provide a path to become an official Debian Developer
  too.

  <sect id="otherinfo">Other information

  <p>There are two types of packages you can make, source and binary.
  A source package contains code which you can compile into a program.
  A binary package contains just the finished program. Don't mix terms
  like source of the program and the source package of the program!
  Please read the other manuals if you need more details on terminology.

  <p>In Debian, the term `maintainer' is used for the person who makes
  packages, `upstream author' for the person that made the program, and
  `upstream maintainer' for the person who currently maintains that program,
  outside of Debian. Usually author and the upstream maintainer are the
  same person - and sometimes even the maintainer is the same person.
  If you made a program, and want it to get in Debian, feel free to submit
  your application to become a maintainer.

  <chapt id="first">First steps

  <sect id="choose">Choose your program

  <p>You have probably chosen the package you want to create. The first
  thing you need to do is check if the package is in the distribution archive
  already by using <prgn>aptitude</prgn>.
  If you use the `stable' distribution, maybe it's best that you go to the
  <url name="package search page" id="http://www.debian.org/distrib/packages">.

  <p>If the package already exists, well, install it! :-) If it happens to
  be orphaned -- if its maintainer is set to "Debian QA Group", you may
  be able to pick it up. 

<p>Then you should consult the Debian web site at
  <url name="Work-Needing and Prospective Packages" id="http://www.debian.org/devel/wnpp/">
  and its linked pages to check the latest adoption/orphan status of the
  package. 

  <p>If you are able to adopt the package, get the sources (with something
  like <tt/apt-get source packagename/) and examine them. This document
  unfortunately doesn't include comprehensive information about adopting
  packages. Thankfully you shouldn't have a hard time figuring out how the
  package works since someone has already done the initial set up for you.
  Keep reading, though, a lot of the advice below will still be applicable
  for your case.

  <p>If the package is new, and you decide you'd like to see it in Debian,
  proceed as follows:

  <list>
  <item>check if no one else is working on the package already at
  <url name="the list of packages being worked on" id="http://www.de.debian.org/devel/wnpp/being_packaged">.
  If someone's already on it, contact them if you feel you need to.
  If not - find another interesting program that nobody maintains.
  </item>

  <item>program <strong>must</strong> have a license.
  <list>
  <item>For the <tt>main</tt> section, it must be compliant to all the 
  <url name="Debian Free Software Guidelines"
  id="http://www.debian.org/social_contract#guidelines"> (DFSG) and
  <strong>must not</strong> require a package outside of <tt>main</tt> for
  compilation or execution as required by the Debian Policy.  This is desired
  case.</item>
  <item>For the <tt>contrib</tt> section, it <strong>must</strong> be compliant
  to all the DSFG but it may require a package outside of main for compilation
  or execution.</item>
  <item>For the <tt>non-free</tt> section, it <strong>may not</strong> be
  compliant to some of the DSFG but it <strong>must</strong> be
  distributable.</item>
  </list>
  If you are unsure about where it should go, post the license text on
  <email/debian-legal@lists.debian.org/ and ask for advice.
  </item>

  <item>program certainly should <strong>not</strong> run setuid root, or
  even better - it shouldn't need to be setuid or setgid to anything.</item>

  <item>program should not be a daemon, or something that goes in */sbin
  directories, or open a port as root.</item>

  <item>program should result in binary executable form, libraries are
  harder to handle.</item>

  <item>it should be well documented, or and the code needs to be
  understandable (i.e. not obfuscated).</item>

  <item>you should contact program's author(s) to check if they agree
  with packaging it. It is important to be able to consult with author(s)
  about the program in case of any program specific problems, so don't
  try to package unmaintained pieces of software.</item>

  <item>and last but not least, you must know that it works, and
  have tried it for some time.</item>
  </list>

  <p>Of course, these things are just safety measures, and intended to save
  you from raging users if you do something wrong in some setuid daemon...
  When you gain some more experience in packaging, you'll be able to do such
  packages, but even the experienced developers consult the debian-mentors
  mailing list when they are in doubt. And people there will gladly help.

  <p>For more help about these, check in Developer's Reference.

  <sect id="getit">Get the program, and try it out

  <p>So the first thing to do is to find and download the original package.
  I presume that you already have the source file that you picked up at
  the author's homepage. Sources for free Unix programs usually come in
  tar/gzip format, with extension .tar.gz, and usually contain the
  subdirectory called program-version and all the sources in it. If your
  program's source comes as some other sort of archive (for instance, the
  filename ends in ".Z" or ".zip"), unpack it with appropriate
  tools, or ask on the debian-mentors mailing list if you're not sure how to unpack it
  correctly (hint: issue `file archive.extension`).

  <p>As an example, I'll use a program called `gentoo', an X GTK+ file
  manager. Note that the program is already packaged, and has changed
  substantially from the version while this text was first written.

  <p>Create a subdirectory under your home directory named 'debian' or 'deb'
  or anything you find appropriate (e.g. just <file>~/gentoo/</file> would do fine in
  this case). Place the downloaded archive in it, and uncompress it (with
  `tar xzf gentoo-0.9.12.tar.gz`). Make sure there are no errors, even some
  "irrelevant" ones, because there will most probably be problems unpacking
  on other people's systems, whose unpacking tools may or may not ignore
  those anomalies.

  <p>Now you have another subdirectory, called 'gentoo-0.9.12'. Change to
  that directory and <strong>thoroughly</strong> read the provided
  documentation. Usually there are files named README*, INSTALL*, *.lsm
  or *.html. You must find instructions on how to correctly compile and
  install the program (most probably they'll assume you want to install to
  /usr/local/bin directory; you won't be doing that, but more on that later
  in <ref id="destdir">).

  <p>The process varies from program to program, but a lot of modern
  programs come with a `configure' script that configures the source under
  your system and makes sure that your system is in condition to compile it.
  After configuring with `./configure`, programs are usually compiled
  with `make`. Some of them support `make check`, to run included
  self-checks. Installation in destination directories is usually done with
  `make install`.
  
  <p>Now try to compile and run your program, to make sure it works properly
  and doesn't break something else while it's installing or running.

  <p>Also, you can usually run `make clean` (or better `make distclean`) to
  clean up the build directory. Sometimes there's even a `make uninstall`
  which can be used to remove all the installed files.

  <sect id="namever">Package name and version

  <p>You should start packaging with a completely clean (pristine) source
  directory, or simply with freshly unpacked sources.
  
  <p>For the package to be built correctly, you must make the program's
  original name lowercase (if it isn't already), and you should move the
  source directory to &lt;packagename&gt;-&lt;version&gt;.
  
  <p>If the program name consists of more than one word, contract them to one
  word, or make an abbreviation. For example, program "John's little editor
  for X" package would be named johnledx, or jle4x, or whatever you decide,
  as long as it's under some reasonable limit, e.g. 20 characters.

  <p>Also check for the exact version of the program (to be included in the
  package version). If that piece of software is not numbered with versions
  like X.Y.Z, but with some kind of date, feel free to use that date as the
  version number, prepended with a "0.0." (just in case upstream people one
  day decide to release a nice version like 1.0). So, if the release or
  snapshot date was 19th of December, 1998, you can use the version string
  of 0.0.19981219.

  <p>Some programs won't be numbered at all, in which case you
  should contact the upstream maintainer to see if they've got some other
  revision-tracking method.

  <sect id="dh_make">Initial "debianization"

  <p>Make sure you're in the program source directory, and issue this:

  <p><example>
  dh_make -e your.maintainer@address -f ../gentoo-0.9.12.tar.gz
  </example>

  <p>Of course, replace the string "your.maintainer@address" with your
  e-mail address for inclusion in the changelog entry and other files,
  and the filename with the name of your original source archive. See
  <manref name="dh_make" section="1"> for details.
 
  <p>Some information will come up. It will ask you what sort of package you
  want to create. Gentoo is a single binary package - it creates only one
  binary, and thus one .deb file - so we will select the first option, with
  the `s' key, check the information on the screen and confirm by pressing
  &lt;enter&gt;.

  <p>After this execution of <prgn>dh_make</prgn>, a copy of the
  upstream tarball is created as <file>gentoo_0.9.12.orig.tar.gz</file>
  in the parent directory to accommodate the creation of the non-native
  Debian source package with the <file>diff.gz</file>.  
  Please note 2 key features in this file name:
  <list compact>
  <item>Package name and version are separated by the "<tt>_</tt>" .
  <item>There is the "<tt>orig.</tt>" before the "<tt>tar.gz</tt>" .
  </list>

  <p>Once again, as a new maintainer you are discouraged from creating
  complicated packages, e.g.,
  <list compact>
  <item>multiple binary packages,
  <item>library packages,
  <item>the source file format being neither in <tt>tar.gz.</tt> nor
       <tt>tar.bz2</tt>, or
  <item>the source tarball containing undistributable contents.
  </list>
  It's not too hard, but it does require a bit more knowledge, so we
  won't describe all of it here. 

  <p>Please note that you should run <prgn>dh_make</prgn> <strong>only once</strong>,
  and that it won't behave correctly if you run it again in the same,
  already "debianized", directory.  That also means that you will use a
  different method to release a new revision or a new version of your
  package in the future. Read more about that later in <ref id="update">

  <chapt id="modify">Modifying the source

  <p>Normally, programs install themselves in the /usr/local subdirectories. 
  But, Debian packages must not use that directory, since it is reserved for
  system administrator's (or user's) private use. This means that you have
  to take a look at your program's build system, usually starting with the
  Makefile. This is the script <manref name="make" section="1"> will use to
  automate building this program. For more details on Makefiles, look in
  <ref id="rules">.

  <p>Note that if your program uses GNU <manref name="automake" section="1">
  and/or <manref name="autoconf" section="1">, meaning the source includes
  Makefile.am and/or Makefile.in files, respectively, you will need to
  modify those files. This is because each automake invocation will rewrite
  Makefile.in's with information generated from Makefile.am's, and each
  ./configure invocation will do the same with Makefile's, with data from
  Makefile.in's. Editing Makefile.am files requires some knowledge of
  automake, which you can read about in the automake info entry, whereas editing
  Makefile.in files is pretty much the same as editing Makefile files, just
  pay attention to the variables, i.e. any strings surrounded with `@'s, for
  example @CFLAGS@ or @LN_S@, which are replaced with actual stuff on each
  ./configure invocation.  Please make sure to read 
  <file>&autotools-dev;</file> before proceeding.

  <p>Also note that there isn't space here to go into <em>all</em> the
  details of fixing upstream sources, but here are a few problems people
  often run across.

  <sect id="destdir">Installation in a subdirectory

  <p>Most of the programs have some way of installing themselves in the
  existing directory structure of your system, so that their binaries get
  included in your $PATH, and that you find their documentation and manual
  pages in common places. However, if you do that, the program will be
  installed among everything else already on your system. This would make
  it hard for the packaging tools to figure out which files belong to your
  package and which don't.

  <p>Therefore you need to do something else: install the program into a
  temporary subdirectory from which the maintainer tools will build a working
  .deb package. Everything that is contained in this directory will be
  installed on a user's system when they install your package, the only
  difference is that dpkg will be installing the files in the root
  directory.

  <p>This temporary directory is usually created under your debian/
  directory in the unpacked source tree. It is usually called
  <file>debian/packagename</file>.

  <p>Bear in mind that even though you need to make the program install in
  debian/packagename, it still needs to behave correctly when placed in the
  root directory, i.e. when installed from the .deb package. So you mustn't
  allow the build system to hardcode strings like
  <tt>/home/me/deb/gentoo-0.9.12/usr/share/gentoo</tt> into the package
  files.

  <p>With programs that use GNU autoconf, this will be quite easy. Most such
  programs have makefiles that are by default set up to allow installation
  into a random subdirectory while keeping in mind that /usr (for example)
  is the canonical prefix. When it detects your program uses autoconf,
  dh_make will set up commands for doing all this
  automatically, so you might as well skip reading this section. But with
  other programs, you will most probably have to examine and edit the
  Makefiles.

  <p>Here's the relevant part of gentoo's Makefile:

  <p><example>
  # Where to put binary on 'make install'?
  BIN     = /usr/local/bin

  # Where to put icons on 'make install'?
  ICONS   = /usr/local/share/gentoo
  </example>

  <p>We see that the files are set to install under <file>/usr/local</file>.
  Change those paths to:

  <p><example>
  # Where to put binary on 'make install'?
  BIN     = $(DESTDIR)/usr/bin

  # Where to put icons on 'make install'?
  ICONS   = $(DESTDIR)/usr/share/gentoo
  </example>

  <p>But why in that directory, and not some other? Because Debian packages
  never install files beneath <file>/usr/local</file> -- that tree is
  reserved for the system administrator's use. Such files on Debian
  systems go under <file>/usr</file> instead.

  <p>The more exact locations for binaries, icons, documentation etc are
  specified in the Filesystem Hierarchy Standard
  (see /usr/share/doc/debian-policy/fhs/). I recommend you browse it and read
  the sections that might concern your package.

  <p>So, we should install the binary in /usr/bin instead of /usr/local/bin,
  the manual page in /usr/share/man/man1 instead of /usr/local/man/man1 etc.
  Notice how there's no manual page mentioned in gentoo's makefile, but
  since the Debian Policy requires that every program has one, we'll make
  one later and install it in /usr/share/man/man1.

  <p>Some programs don't use makefile variables to define paths such as
  these. This means you might have to edit some real C sources in order to
  fix them to use the right locations.
  But where to search, and exactly what for? You can find this out by issuing:

  <p><example>
  grep -nr -e 'usr/local/lib' --include='*.[c|h]' .
  </example>

  <p>Grep will run recursively through the source tree and tell
  you the name of the file and the line in it, when it finds an occurrence.

  <p>Edit those files and in those lines replace /usr/local/* with usr/*
  -- and that's about it. Be careful that you don't mess up the rest of
  the code! :-)

  <p>After that you should find the install target (search for line that
  starts with `install:', that will usually work) and rename all references
  to directories other than ones defined at the top of the Makefile.
  Previously, gentoo's install target said:

  <p><example>
  install:        gentoo
                  install ./gentoo $(BIN)
                  install icons/* $(ICONS)
                  install gentoorc-example $(HOME)/.gentoorc
  </example>

  <p>After our change it says:
  <example>
  install:        gentoo-target
                  install -d $(BIN) $(ICONS) $(DESTDIR)/etc
                  install ./gentoo $(BIN)
                  install -m644 icons/* $(ICONS)
                  install -m644 gentoorc-example $(DESTDIR)/etc/gentoorc
  </example>

  <p>You've surely noticed that there's now a <tt>install -d</tt> command
  before the other commands in the rule. The original makefile didn't have
  it because usually the /usr/local/bin and other directories already exist
  on the system where one runs `make install`. However, since we will
  install into our own empty (or even nonexistent) directory, we will have
  to create each and every one of those directories.

  <p>We can also add in other things at the end of the rule, like the
  installation of additional documentation that the upstream authors
  sometimes omit:

  <p><example>
                  install -d $(DESTDIR)/usr/share/doc/gentoo/html
                  cp -a docs/* $(DESTDIR)/usr/share/doc/gentoo/html
  </example>

  <p>A careful reader will notice that I changed `gentoo' to `gentoo-target'
  in the `install:' line. That is called an unrelated bug fix :-)

  <p>Whenever you make changes that are not specifically related to Debian
  package, be sure to send them to the upstream maintainer so they can be
  included in the next program revision and be useful to everyone else.
  Also remember to make your fixes not specific to Debian or Linux (or even
  Unix!) prior to sending them -- make them portable. This will make your
  fixes much easier to apply.

  <p>Note that you don't have to send the debian/* files upstream.

  <sect id="difflibs">Differing libraries

  <p>There is one other common problem: libraries are often different from
  platform to platform. For example, a Makefile can contain a reference to a
  library which doesn't exist on Debian systems. In that case, we
  need to change it to a library which does exist in Debian, and serves the
  same purpose.

  <p>So, if there is a line in your program's Makefile (or Makefile.in) that
  says something like this (and your program doesn't compile):

  <p><example>
  LIBS = -lcurses -lsomething -lsomethingelse
  </example>

  <p>Change it to this, and it will most probably work:
  <p><example>
  LIBS = -lncurses -lsomething -lsomethingelse
  </example>

  <p>(The author realizes that this is not the best example considering our
  libncurses package now ships with a libcurses.so symlink, but he couldn't
  think of a better one. Suggestions very welcome :-)

  <chapt id="dreq">Required stuff under debian/

  <p>There is a new subdirectory under the program's source directory,
  it's called `debian'. There are a number of files in this directory that
  we should edit in order to customize
  the behavior of the package. The most important of them are `control',
  `changelog', `copyright' and 'rules', which are required for all packages.

  <sect id="control">`control' file

  <p>This file contains various values which <prgn/dpkg/, <prgn/dselect/ and
  other package management tools will use to manage the package.

  <p>Here is the control file dh_make created for us:

  <p><example>
  1  Source: gentoo
  2  Section: unknown
  3  Priority: optional
  4  Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
  5  Build-Depends: debhelper (>> 3.0.0)
  6  Standards-Version: 3.6.2
  7
  8  Package: gentoo
  9  Architecture: any
  10 Depends: ${shlibs:Depends}
  11 Description: &lt;insert up to 60 chars description&gt;
  12  &lt;insert long description, indented with spaces&gt;
  </example>
  (I've added the line numbers.)

  <p>Lines 1-6 are the control information for the source package.

  <p>Line 1 is the name of the source package.

  <p>Line 2 is the section of the distribution the source package goes into. 

  <p>As you may have noticed, Debian is divided in sections: main (the free
  software), non-free (the not really free software) and contrib (free
  software that depends on non-free software). Under those, there are
  logical subsections that describe in short what packages are in.
  So we have `admin' for administrator-only programs, `base' for the
  basic tools, `devel' for programmer tools, `doc' for documentation,
  `libs' for libraries, `mail' for e-mail readers and daemons, `net' for
  network apps and daemons, `x11' for X11 programs that don't fit anywhere
  else, and many more.

  <p>Let's change it then to x11. (A "main/" prefix is implied so we can
  omit it.)

  <p>Line 3 describes how important it is that the user installs this package.
  See the Policy manual for guidance on what to set this field to. The
  "optional" priority will usually work for new packages.

  <p>Section and priority are used by frontends like <prgn/dselect/ when
  they sort packages and select defaults. Once you upload the package to
  Debian, the value of these two fields can be overridden by the archive
  maintainers, in which case you will be notified by email.
  
  <p>As this is a normal priority package and doesn't conflict with anything
  else, we'll leave it as "optional".

  <p>Line 4 is the name and email address of the maintainer. Make sure that
  this field includes a valid "To: " header for an email, because after you
  upload it, the bug tracking system will use it to deliver bug emails to
  you. Avoid using commas, ampersands and parenthesis.

  <p>The 5th line includes the list of packages required to build your
  package. Some packages like gcc and make are implied, see the
  <package/build-essential/ package for details. If some non-standard
  compiler or other tool is needed to build your package, you should add
  it to the `Build-Depends' line. Multiple entries are separated with
  commas; read on for the explanation of binary dependencies to find out
  more about the syntax of this field.

  <p>You can also have Build-Depends-Indep, Build-Conflicts and other fields
  here. This data will be used by the Debian automatic package building
  software in order to create binary packages for other computer platforms.
  See the Policy manual for more information about the build-dependencies
  and the Developers' Reference for more information about these other
  platforms (architectures) and how to port software to them.

  <p>Here's a hack you can use to find out which packages your package needs
  to be built:
  <example>
  strace -f -o /tmp/log ./configure
  # or make instead of ./configure, if the package doesn't use autoconf
  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
  </example>
  <p>This script returns version numbers for all the "Build-depends". 
  Please note that versioned dependencies which are fulfilable in stable 
  shouldn't be specified as versioned one in the "Build-depends" stanza.

  <p>To manually find exact build dependency for
  <prgn><var>/usr/bin/foo</var></prgn>, you execute
  <example>
  objdump -p <var>/usr/bin/foo</var> | grep NEEDED
  </example>
  and for each library listed, e.g., <prgn>libfoo.so.6</prgn>, execute
  <example>
  dpkg -S libfoo.so.6 
  </example>
  Then you just take -dev version of every package as
  `Build-deps' entry.  If you use <prgn>ldd</prgn> for this
  purpose, it will report indirect lib dependencies as well, resulting
  in the problem of excessive build deps.

  <p>Gentoo also happens to require <package/xlibs-dev/,
  <package/libgtk1.2-dev/ and <package/libglib1.2-dev/ to build, so we'll
  add them here next to <package/debhelper/.

  <p>Line 6 is the version of the Debian Policy standards this package
  follows, the versions of the Policy manual you read while making your
  package.

  <p>Line 8 is the name of the binary package. This is usually the same as
  the name of the source package, but it doesn't necessarily have to be that
  way.

  <p>Line 9 describes the CPU architecture the binary package can be compiled
  for. We'll leave this as "any" because <manref name="dpkg-gencontrol"
  section="1"> will fill in the appropriate value for any machine this
  package gets compiled on.

  <p>If your package is architecture independent
  (for example, a shell or Perl script, or a document), change this to
  "all", and read later in <ref id="rules"> about using the `binary-indep'
  rule instead of `binary-arch' for building the package.

  <p>Line 10 shows one of the most powerful features of the Debian packaging
  system. Packages can relate to each other in various ways. Apart from
  Depends:, other relationship fields are Recommends:, Suggests:,
  Pre-Depends:, Conflicts:, Provides:, and Replaces:.

  <p>The package management tools usually behave the same way when dealing
  with these relations; if not, it will be explained.
  (see <manref name="dpkg" section="8">, <manref name="dselect" section="8">,
  <manref name="apt" section="8">, <manref name="aptitude" section="1"> etc.)

  <p>This is what the dependencies mean:

  <p><list>
  <item>Depends:
  <p>The package will not be installed unless the packages it depends on
  are installed. Use this if your program absolutely will not run (or will
  cause severe breakage) unless a particular package is present.</item>

  <item>Recommends:
  <p>Frontends such as dselect or aptitude will prompt you to install the
  recommended packages along with your package; dselect will even insist. 
  dpkg and apt-get will ignore this field, though. Use this for packages
  that are not strictly necessary but are typically used with your
  program.</item>

  <item>Suggests:
  <p>When a user installs your program, all frontends will likely prompt
  them to install the suggested packages. dpkg and apt-get won't care. Use
  this for packages which will work nicely with your program but are not at
  all necessary.</item>

  <item>Pre-Depends:
  <p>This is stronger than Depends:. The package will not be installed
  unless the packages it pre-depends on are installed <em>and correctly
  configured</em>. Use this <strong>very</strong> sparingly and only after
  discussing it on the debian-devel mailing list. Read: don't use it at
  all. :-)</item>

  <item>Conflicts:
  <p>The package will not be installed until all the packages it conflicts
  with have been removed. Use this if your program absolutely will not run
  or will cause severe problems if a particular package is present.</item>

  <item>Provides:
  <p>For some types of packages where there are multiple alternatives
  virtual names have been defined. You can get the full list in the
  /usr/share/doc/debian-policy/virtual-package-names-list.txt.gz file.
  Use this if your program provides a function of an existing virtual
  package.</item>

  <item>Replaces:
  <p>Use this when your program replaces files from another package, or
  completely replaces another package (used in conjunction with Conflicts:).
  Files from the named packages will be overwritten with the files from your
  package.
  </item>
  </list>

  <p>All these fields have uniform syntax. They are a list of package names
  separated by commas. These package names may also be lists of alternative
  package names, separated by vertical bar symbols `<tt>|</tt>' (pipe symbols).

  <p>The fields may restrict their applicability to particular versions of
  each named package. These versions are listed in parentheses after each
  individual package name, and they should contain a relation from the list
  below followed by the version number. The relations allowed are:
  <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>, <tt>=</tt>, <tt>&gt;=</tt> and
  <tt>&gt;&gt;</tt> for strictly earlier, earlier or equal, exactly equal,
  later or equal and strictly later, respectively. For example,

  <p><example>
  Depends: foo (>= 1.2), libbar1 (= 1.3.4)
  Conflicts: baz
  Recommends: libbaz4 (>> 4.0.7)
  Suggests: quux
  Replaces: quux (<< 5), quux-foo (<= 7.6)
  </example>
  
  <p>The last feature you need to know about is ${shlibs:Depends}.
  After your package has been built and installed into the temporary
  directory, <manref name="dh_shlibdeps" section="1"> will scan it for
  binaries and libraries, determine their shared library dependencies and
  detect which packages they are in, such as libc6 or xlib6g. It'll pass
  on the list to <manref name="dh_gencontrol" section="1"> which will fill
  it in the right place, and you won't have to worry about this yourself.

  <p>Having said all that, we can leave the Depends: line exactly as it is
  now, and insert another line after it saying <tt>Suggests: file</tt>,
  because gentoo can use some features provided by that program/package.

  <p>Line 11 is the short description. Most people screens are 80 columns
  wide so this shouldn't be longer than about 60 characters. I'll change
  it to "fully GUI configurable X file manager using GTK+".

  <p>Line 12 is where the long description goes. This should be a paragraph
  which gives more details about the package. Column 1 of each line should
  be empty. There must be no blank lines, but you can put a single . (dot)
  in a column to simulate that. Also, there must be no more than one blank
  line after the long description.

  <p>Finally, here is the updated control file:

  <p><example>
  1  Source: gentoo
  2  Section: x11
  3  Priority: optional
  4  Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
  5  Build-Depends: debhelper (>> 3.0.0), xlibs-dev, libgtk1.2-dev, libglib1.2-dev
  6  Standards-Version: 3.5.2
  7
  8  Package: gentoo
  9  Architecture: any
  10 Depends: ${shlibs:Depends}
  11 Suggests: file
  12 Description: fully GUI configurable X file manager using GTK+
  13  gentoo is a file manager for Linux written from scratch in pure C. It
  14  uses the GTK+ toolkit for all of its interface needs. gentoo provides
  15  100% GUI configurability; no need to edit config files by hand and re-
  16  start the program. gentoo supports identifying the type of various
  17  files (using extension, regular expressions, or the 'file' command),
  18  and can display files of different types with different colors and icons.
  19  .
  20  gentoo borrows some of its look and feel from the classic Amiga file
  21  manager "Directory OPUS" (written by Jonathan Potter).
  </example>
  (I've added the line numbers.)

  <sect id="copyright">`copyright' file

  <p>This file contains the information about package upstream resources,
  copyright and license information. Its format is not dictated by the
  Policy, but the content is (section 12.6 "Copyright information").

  <p>dh_make created a default one, this is what it looks like:

  <p><example>
  1  This package was debianized by Josip Rodin &lt;joy-mg@debian.org&gt; on
  2  Wed, 11 Nov 1998 21:02:14 +0100.
  3
  4  It was downloaded from &lt;fill in ftp site&gt;
  5
  6  Upstream Author(s): &lt;put author(s) name and email here&gt;
  7
  8  Copyright:
  9
  10 &lt;Must follow here&gt;
  </example>
  (I've added the line numbers.)

  <p>The important things to add to this file are the place you got the
  package from and the actual copyright notice and license. You must
  include the complete license, unless it's one of the common free software
  licenses such as GNU GPL or LGPL, BSD or the Artistic license, when you
  can just refer to the appropriate file in /usr/share/common-licenses/
  directory that exists on every Debian system.

  <p>In short, here's how gentoo's copyright file should look like:

  <p><example>
  1  This package was debianized by Josip Rodin &lt;joy-mg@debian.org&gt; on
  2  Wed, 11 Nov 1998 21:02:14 +0100.
  3
  4  It was downloaded from: ftp://ftp.obsession.se/gentoo/
  5
  6  Upstream author: Emil Brink &lt;emil@obsession.se&gt;
  7
  8  This software is copyright (c) 1998-99 by Emil Brink, Obsession
  9  Development.
  10
  11 You are free to distribute this software under the terms of
  12 the GNU General Public License  either version 2 of the License,
  13 or (at your option) any later version.
  14 On Debian systems, the complete text of the GNU General Public
  15 License can be found in the file `/usr/share/common-licenses/GPL-2'.
  </example>
  (I've added the line numbers.)

  <p>Please follow the HOWTO from the debian-devel-announce: 
  <url id="&copyright-howto;"> .


  <sect id="changelog">`changelog' file

  <p>This is a required file, which has a special format described in
  the Policy section 4.4 "debian/changelog". This format is used by dpkg and
  other programs to obtain the version number, revision, distribution and
  urgency of your package.

  <p>For you, it is also important, since it is good to have documented
  all changes you have done. It will help people downloading your package
  to see whether there are issues with the package that they should know
  about. It will be saved as
  `/usr/share/doc/gentoo/changelog.Debian.gz' in the binary package.

  <p>dh_make created a default one, and this is how it looks like:

  <p><example>
  1  gentoo (0.9.12-1) unstable; urgency=low
  2
  3   * Initial Release.
  4
  5  -- Josip Rodin &lt;joy-mg@debian.org&gt;  Wed, 11 Nov 1998 21:02:14 +0100
  6
  </example>
  (I've added the line numbers.)

  <p>Line 1 is the package name, version, distribution, and urgency.
  The name must match the source package name, distribution should be
  either `unstable' (or even `experimental'), and urgency shouldn't
  be changed to anything higher than `low'. :-)
  
  <p>Lines 3-5 are a log entry, where you document changes made in this
  package revision (not the upstream changes - there is special file for
  that purpose, created by the upstream authors, which you will later install as
  /usr/share/doc/gentoo/changelog.gz). New lines must be inserted just
  before the uppermost line that begins with asterisk (`*'). You can do
  it with <manref name="dch" section="1">, or manually with a text editor.

  <p>You will end up with something like this:

  <p><example>
  1  gentoo (0.9.12-1) unstable; urgency=low
  2
  3   * Initial Release.
  4   * This is my first Debian package.
  5   * Adjusted the Makefile to fix $DESTDIR problems.
  6
  7  -- Josip Rodin &lt;joy-mg@debian.org&gt; Wed, 11 Nov 1998 21:02:14 +0100
  8
  </example>
  (I've added the line numbers.)

  <p>You can read more about updating the changelog file later in
  <ref id="update">.

  <sect id="rules">`rules' file

  <p>Now we need to take a look at the exact rules which
  <manref name="dpkg-buildpackage" section="1"> will use to actually create
  the package. This file is actually another Makefile, but different than
  the one(s) in the upstream source. Unlike other files in debian/, this one
  is marked as executable.

  <p>Every `rules' file, as any other Makefile, consists of several rules
  specifying how to handle the source. Each rule consists of targets,
  filenames or names of actions that should be carried out (e.g. `build:'
  or `install:'). Rules that you want to execute are invoked as command
  line arguments (for example, `./debian/rules build` or `make -f rules
  install`). After the target name, you can name the dependency, program
  or file that the rule depends on. After that, there can be any number
  of commands, indented with &lt;tab&gt;. A new rule begins with the target
  declaration in the first column. Empty lines and lines beginning
  with `#' (hash) are treated as comments and ignored.

  <p>You are probably confused now, but it will all be clear upon examination
  of the `rules' file that dh_make gives us as a default. You should also
  read the `make' entry in info for more information.

  <p>The important part to know about the rules file created by dh_make, is
  that it is just a suggestion. It will work for simple packages but for
  more complicated ones, don't be afraid to add and subtract from it to fit
  your needs. Only thing that you must not change are the names of the
  rules, because all the tools use these names, as mandated by the Policy.

  <p>Here's (approximately) how the default debian/rules file that dh_make
  generated for us looks like:

  <p><example>
&makefile;
  </example>
  (I've added the line numbers.  In the actual <file>debian/rules</file>
  file, the leading white spaces are TAB codes.)

  <p>You are probably familiar with lines like line 1 from shell and Perl
  scripts. It tells the operating system that this file is to be processed
  with /usr/bin/make.

  <p>The meaning of DH_* variables mentioned on lines 8 and 9 should be
  evident from the short description. For information on DH_COMPAT
  read the "Debhelper compatibility levels" section of the
  <manref name="debhelper" section="1"> manual page.

  <p>The lines 11 through 16 are a skeleton of support for DEB_BUILD_OPTIONS
  parameters, described in the Policy section 10.1 "Binaries". Basically,
  these things control if the binaries are to be built with the debugging
  symbols, and if they should be stripped upon installation. Again, this is
  just a skeleton, a hint that you should do it. You should check into how
  the upstream build system handles the inclusion of debugging symbols and
  stripping on installation and implement this yourself.

  <p>Usually you can tell gcc to compile with "-g" using the CFLAGS variable
  -- if that's the case for your package, propagate the variable by
  <em>appending</em> <tt>CFLAGS="$(CFLAGS)"</tt> to the $(MAKE) invocation
  in the build rule (see below). Alternatively, if your package uses an
  autoconf configure script, you can pass it to configure by
  <em>prepending</em> the above string to the ./configure invocation in the
  build rule.

  <p>As for the stripping, programs are commonly configured to install
  themselves unstripped, and often without an option to change this. 
  Fortunately, you still have <manref name="dh_strip" section="1"> which
  will detect when the DEB_BUILD_OPTIONS=nostrip flag is set and silently
  exit.

  <p>Lines 18 through 26 describe the `build' (and its child `build-stamp')
  rule, which runs make with the application's own Makefile to compile the
  program. If your package uses GNU configure utilities to build binaries,
  please make absolutely sure to read <file>&autotools-dev;</file> .
  We'll talk about the commented out docbook-to-man example later
  in <ref id="manpage">.

  <p>The `clean' rule, as specified in lines 28-36, cleans up any unneeded
  binary or auto-generated stuff, left over from building the package.
  This rule must be working at all times (even when the source tree <em/is/
  cleaned up!), so please use the forcing options (e.g. for rm, that is
  `-f'), or have make ignore return values (failures) using a `-' in front
  of the command name.

  <p>The installation process, the `install' rule, starts with line 38.
  It basically runs the `install' rule from the program's own Makefile,
  but installs in the <tt>$(CURDIR)/debian/gentoo</tt> directory - this is
  why we specified
  $(DESTDIR) as the root installation directory in gentoo's Makefile.

  <p>As the comments suggest, the `binary-indep' rule, on the line 48, is
  used to build packages independent of architecture. As we don't have any,
  nothing will be done there.

  <p>On to the next rule - `binary-arch', on lines 52 through 79, in which
  we run several small utilities from the debhelper package that do various
  operations on your package files to make the package Policy conforming.

  <p>If your package is an `Architecture: all' one, you need to include all
  the commands for building the package under the `binary-indep' rule, and
  leave the `binary-arch' rule empty instead.
  
  <p>The names of debhelper programs start with dh_, and the rest is the
  description of what the particular utility does. It is all quite
  self-explanatory, but here are some additional explanations:

  <list>
  <item><manref name="dh_testdir" section="1"> checks that you are in the
        right directory (i.e. the top-level source directory),
  <item><manref name="dh_testroot" section="1"> checks that you have root
        permissions which is needed for the targets `binary-arch',
        `binary-indep' and `clean',
  <item><manref name="dh_installman" section="1"> will copy the manpages
        into the right place in the destination directory, you just have to
        tell it where they are, relative to the top-level source directory,
  <item><manref name="dh_strip" section="1"> strips debugging headers from
        executable files and libraries, to make them smaller,
  <item><manref name="dh_compress" section="1"> compresses man pages and
        documentation larger than 4 kB with <manref name="gzip" section="1">,
  <item><manref name="dh_installdeb" section="1"> copies package related
        files (e.g. the maintainer scripts) to the
        <file>debian/gentoo/DEBIAN</file> directory,
  <item><manref name="dh_shlibdeps" section="1"> calculates shared libraries
        dependencies of the libraries and executables,
  <item><manref name="dh_gencontrol" section="1"> installs a fine-tuned
        version of the control file into <file>debian/gentoo/DEBIAN</file>,
  <item><manref name="dh_md5sums" section="1"> generates MD5 checksums for
        all the files in the package.
  </list>

  <p>For more complete information on what do all these dh_* scripts do, and
  what their other options are, please read their respective manual pages. There
  are some other (possibly very useful) dh_* scripts which were not
  mentioned here. If you need them, read the debhelper documentation.

  <p>The binary-arch section is the one where you really should comment
  out or remove any lines that call features you don't need. For gentoo,
  I'll comment out lines about examples, cron, init, man and info,
  simply because gentoo doesn't need them. Also, on the line 68, I'll
  replace `ChangeLog' with `FIXES', because that is the real name of the
  upstream changelog file.

  <p>The last two lines (along with any other unexplained ones) are just
  some more-or-less necessary things, regarding which you can read in the
  make manual, and the Policy. For now, they're not important to know about.

  <chapt id="dother">Other files under debian/

  <p>You will see that there are several other files in the debian/
  subdirectory, most of them with the `ex' suffix or prefix, meaning that
  they are examples. Take a look at all of them. If you wish or need to
  use any of those features:

  <list>
    <item>take a look at the related documentation (hint: the Policy Manual),
    <item>if necessary modify the files to suit your needs,
    <item>rename them to remove the `.ex' suffix if they have one,
    <item>rename them to remove the `ex.' prefix if they have one,
    <item>modify the `rules' file if necessary.
  </list>

  <p>Some of those files, the commonly used ones, are explained in the
  following sections.

  <sect id="readme">README.Debian

  <p>Any extra details or discrepancies between the original package and
  your debianized version should be documented here.

  <p>dh_make created a default one, this is what it looks like:

  <p><example>
  gentoo for Debian
  -----------------

  &lt;possible notes regarding this package - if none, delete this file&gt;

   -- Josip Rodin &lt;joy-mg@debian.org&gt;, Wed, 11 Nov 1998 21:02:14 +0100
  </example>

  <p>Since we don't have anything to put there, we'll delete the file.

  <sect id="conffiles">conffiles.ex

  <p>One of the most annoying things about software is when you spend a
  great deal of time and effort customizing a program, only to have an
  upgrade stomp all over your changes. Debian solves this problem by
  marking configuration files so that when you upgrade a package, you'll
  be prompted whether you want to keep your old configuration or not.

  <p>The way to do this in a package is to enter the full path to each
  configuration file (usually in /etc), one per line, in a file called
  <tt/conffiles/. Gentoo has one conffile, /etc/gentoorc, and we'll enter
  that in the <tt/conffiles/ file.

  <p>If your program uses configuration files but also rewrites them on its
  own, it's best not to mark them as conffiles because dpkg will then prompt
  users to verify the changes all the time.

  <p>If the program you're packaging requires every user to modify the
  configuration file in order to work at all, also consider not marking the
  file as a conffile.

  <p>You can handle example configuration files from the `maintainer
  scripts', for more information see <ref id="maintscripts">.

  <p>If your program has no conffiles, you can safely delete the
  <tt/conffiles/ file from the debian/ directory.

  <sect id="crond">cron.d.ex

  <p>If your package requires regularly scheduled tasks to operate properly, 
  you can use this file to set it up.

  <p>Note that this doesn't include log rotation; for that, see
  <manref name="dh_installlogrotate" section="1"> and
  <manref name="logrotate" section="8">.

  <p>If not, remove it.

  <sect id="dirs">dirs

  <p>This file specifies the directories which we need but the normal
  installation procedure (make install) somehow doesn't create.

  <p>By default, it looks like this:

  <p><example>
  usr/bin
  usr/sbin
  </example>

  <p>Note that the preceding slash is not included. We would have normally
  changed it to look like this:

  <p><example>
  usr/bin
  usr/man/man1
  </example>
  
  <p>but those directories are already created in the Makefile, so we won't
  need this file, and we will instead delete it.

  <sect id="docs">docs

  <p>This file specifies the file names of documentation files we can have
  dh_installdocs install into the temporary directory for us.

  <p>By default, it will include all existing files in the top-level source
  directory that are called "BUGS", "README*", "TODO" etc.

  <p>For gentoo, I also included some other stuff:

  <p><example>
  BUGS
  CONFIG-CHANGES
  CREDITS
  ONEWS
  README
  README.gtkrc
  TODO
  </example>
  
  <p>We can also remove this file and instead list these files on the
  <tt/dh_installdocs/ command line in the <tt/rules/ file, like this:

  <p><example>
        dh_installdocs BUGS CONFIG-CHANGES CREDITS ONEWS README \
                       README.gtkrc TODO
  </example>

  <p>How ever unlikely it may seem, you may not have any such files in your
  package's sources. In that case you can safely remove this file. But don't
  remove the <tt/dh_installdocs/ invocation from the <tt/rules/ file because
  that's used to install the <tt/copyright/ file and other things.

  <sect id="emacsen">emacsen-*.ex

  <p>If your package supplies Emacs files that can be bytecompiled at
  package installation time, you can use these files to set it up.

  <p>They are installed into the temporary directory by
  <manref name="dh_installemacsen" section="1">, so don't forget to
  uncomment that line in the <tt/rules/ file if you use this.

  <p>If you don't need these, remove them.

  <sect id="initd">init.d.ex

  <p>If your package is a daemon that needs to be run at system startup,
  you've obviously disregarded my initial recommendation, haven't you? :-)

  <p>This is a fairly generic skeleton file for an <file>/etc/init.d/</file>
  script, so you'll likely have to edit it, a lot. It gets installed into
  the temporary directory by <manref name="dh_installinit" section="1">.

  <p>If you don't need this, remove the file.

  <sect id="manpage">manpage.1.ex, manpage.sgml.ex, manpage.xml.ex

  <p>Your program(s) should have a manual page. If they don't, each of these
  files is a template that you can fill out.

  <taglist>

  <tag><file/manpage.1.ex/
  <item><p>Manual pages are normally written in <manref name="nroff" section="1">.
  The <tt/manpage.1.ex/ example is written in nroff, too. 
  See the <manref name="man" section="7"> manual page
  for a brief description of how to edit such a file.

  <p>The final manual page file name should include the name of the program
  it is documenting, so we will rename it from "manpage" to "gentoo". 
  The file name also includes ".1" as the first suffix, which means it's a
  manual page for a user command. Be sure to verify that this section is
  indeed the correct one. Here's a short list of manual page sections:

  <p><example>
  Section |     Description     |     Notes
     1     User commands          Executable commands or scripts.
     2     System calls           Functions provided by the kernel.
     3     Library calls          Functions within system libraries.
     4     Special files          Usually found in /dev
     5     File formats           E.g. /etc/passwd's format
     6     Games                  Or other frivolous programs
     7     Macro packages         Such as man macros.
     8     System administration  Programs typically only run by root.
     9     Kernel routines        Non-standard calls and internals.
  </example>
  
  <p>So gentoo's man page should be called <tt/gentoo.1/. 
  There was no gentoo.1 man page in the original source so I wrote
  it using information from the example and from upstream docs.
  
  <tag><file/manpage.sgml.ex/
  <item><p>If on the other hand you prefer writing SGML instead of nroff, you can
  use the <tt/manpage.sgml.ex/ template. If you do this, you have to:
  
  <list>
    <item>install the <package/docbook-to-man/ package
    <item>add <tt/docbook-to-man/ to the <tt/Build-Depends/ line in the
          <tt/control/ file
    <item>remove the comment from the docbook-to-man invocation in the
          `build' target of your <tt/rules/ file
  </list>

  <p>And remember to rename the file to something like <tt/gentoo.sgml/!

  <tag><file/manpage.xml.ex/
  <item><p>If you prefer XML over SGML, you can use the <tt/manpage.xml.ex/ template.
  If you do this, you have two choices:
  
  <list>
    <item>install the <package/docbook-xsl/ package and an XSLT processor like
          <package/xsltproc/ (recommended)
    <item>add the <tt/docbook-xsl/, <tt/docbook-xml/ and <tt/xsltproc/ packages to the
          <tt/Build-Depends/ line in the <tt/control/ file
    <item>add a rule to the `build' target of your <tt/rules/ file:
      <example>
xsltproc --nonet \
         --param make.year.ranges 1 \
         --param make.single.year.ranges 1 \
         --param man.charmap.use.subset 0 \
         -o debian/ \
         /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl \
         debian/manpage.xml
      </example>
    </item>
  </list>
  
  <p>Alternatively:

  <list>
    <item>install the <package/docbook2x/ package
    <item>add the <tt/docbook2x/ package to the <tt/Build-Depends/ line in the
          <tt/control/ file
    <item>add a rule to the `build' target of your <tt/rules/ file:
      <example>
docbook2man debian/manpage.xml
      </example>
    </item>
  </list>
  
  <p>Rename the source file(s) to something like <tt/gentoo.1.xml/ or so and check
        the package documentations for stylesheet parameters and output options.
  
  </taglist>

  <sect id="menu">menu.ex

  <p>X Window System users usually have a window manager with a menu that
  can be customized to launch programs. If they have installed the Debian
  <package/menu/ package, a set of menus for every program on the system will be
  created for them.

  <p>Here's the default <tt/menu.ex/ file that dh_make created:
  
  <p><example>
  ?package(gentoo):needs="X11|text|vc|wm" section="Apps/see-menu-manual"\
    title="gentoo" command="/usr/bin/gentoo"
  </example>

  <p>The first field after the colon character is "needs", and it specifies
  what kind of interface the program needs. Change this to one of the listed
  alternatives, e.g. "text" or "X11".

  <p>The next is "section", where the menu and submenu the entry should
  appear in. The current list of sections is at:
  <file>/usr/share/doc/debian-policy/menu-policy.html/ch2.html#s2.1</file>

  <p>The "title" field is the name of the program. You can start this one
  in uppercase if you like. Just keep it short.

  <p>Finally, the "command" field is the command that runs the program.

  <p>Now we'll change the menu entry to this:

  <p><example>
  ?package(gentoo): needs="X11" section="Apps/Tools" title="Gentoo" command="gentoo"
  </example>

  <p>You can also add other fields like "longtitle", "icon", "hints" etc.
  See <manref name="menufile" section="5">,
  <manref name="update-menus" section="1">
  and <file>/usr/share/doc/debian-policy/menu-policy.html/</file> for more
  information.

  <sect id="watch">watch.ex

  <p>This file is used to configure the <manref name="uscan" section="1">
  and <manref name="uupdate" section="1"> programs (in the
  <package/devscripts/ package). These are used to watch the site you got
  the original source from.

  <p>Here's what I put in it:

  <p><example>
# watch control file for uscan
# Site            Directory  Pattern               Version  Script
ftp.obsession.se  /gentoo    gentoo-(.*)\.tar\.gz  debian   uupdate
  </example>

  <p>Hint: connect to the Internet, and try running "uscan" in the program
  directory once you create the file. And read the manuals! :)

  <sect id="doc-base">ex.package.doc-base

  <p>If your package has documentation other than manual pages and info
  docs, you should use the `<package/doc-base/' file to register it,
  so the user can find it with e.g. <manref name="dhelp" section="1">,
  <manref name="dwww" section="1"> or <manref name="doccentral" section="1">.

  <p>This usually includes HTML, PS and PDF files, shipped in
  <file>/usr/share/doc/packagename/</file>.

  <p>This is how gentoo's doc-base file <tt>gentoo.doc-base</tt> looks like:

  <p><example>
  Document: gentoo
  Title: Gentoo Manual
  Author: Emil Brink
  Abstract: This manual describes what Gentoo is, and how it can be used.
  Section: Apps/Tools

  Format: HTML
  Index: /usr/share/doc/gentoo/html/index.html
  Files: /usr/share/doc/gentoo/html/*.html
  </example>

  <p>For information on the file format, see
  <manref name="install-docs" section="8"> and the <package/doc-base/ manual,
  in <file>/usr/share/doc/doc-base/doc-base.html/</file>.

  <p>For more details on installing additional documentation, look in <ref id="destdir">.

  <sect id="maintscripts">postinst.ex, preinst.ex, postrm.ex, prerm.ex

  <p>These files are called maintainer scripts. They are scripts which are
  put in the control area of the package and run by <prgn/dpkg/ when your
  package is installed, upgraded or removed.

  <p>For now, you should try to avoid any manual editing of maintainer
  scripts if you possibly can because they tend to get complex. For more
  information look in the Policy Manual, chapter 6, and take a look at
  these example files provided by dh_make.

  <chapt id="build">Building the package

  <p>We should now be ready to build the package.

  <sect id="completebuild">Complete rebuild

  <p>Enter the program's main directory and then issue this command:

  <p><example>
  dpkg-buildpackage -rfakeroot
  </example>

  <p>This will do everything for you. It will:
  <list>
    <item>clean the source tree (debian/rules clean), using <prgn/fakeroot/
    <item>build the source package (dpkg-source -b)
    <item>build the program (debian/rules build)
    <item>build the binary package (debian/rules binary), using <prgn/fakeroot/
    <item>sign the source <tt/.dsc/ file, using <prgn/gnupg/
    <item>create and sign the upload <tt/.changes/ file, using
          <prgn/dpkg-genchanges/ and <prgn/gnupg/
  </list>

  <p>The only input that will be required of you is your GPG key secret pass
  phrase, twice.

  <p>After all this is done, you will see the following files in the
  directory above (<file>~/gentoo/</file>):

  <p><list>
  <item><em>gentoo_0.9.12.orig.tar.gz</em>

  <p>This is the original source code tarball, merely renamed to the above
  so that it adheres to the Debian standard. Note that this was created
  using the `-f' option to <prgn/dh_make/ when we initially ran it.

  <item><em>gentoo_0.9.12-1.dsc</em>

  <p>This is a summary of the contents of the source code. The file is
  generated from your `control' file, and is used when
  unpacking the source with <manref name="dpkg-source" section="1">. This
  file is GPG signed, so that people can be sure that it's really yours.

  <item><em>gentoo_0.9.12-1.diff.gz</em>

  <p>This compressed file contains each and every addition you made to the
  original source code, in the form known as "unified diff". It is made and
  used by <manref name="dpkg-source" section="1">. Warning: if you don't name
  the original tarball packagename_version.orig.tar.gz, <prgn/dpkg-source/
  will fail to generate the .diff.gz file properly!

  <p>If someone else wants to re-create your package from scratch, they can
  easily do so using the above three files. The extraction procedure is
  trivial: just copy the three files somewhere else and run
  <tt>dpkg-source -x gentoo_0.9.12-1.dsc</tt>.

  <item><em>gentoo_0.9.12-1_i386.deb</em>

  <p>This is your completed binary package. You can use <prgn/dpkg/ to
  install and remove this just like any other package.

  <item><em>gentoo_0.9.12-1_i386.changes</em>

  <p>This file describes all the changes made in the current package
  revision, and it is used by the Debian FTP archive maintenance programs
  to install the binary and source packages in it. It is partly generated
  from the `changelog' file and the .dsc file. This file is GPG signed, so
  that people can be sure that it's really yours.

  <p>As you keep working on the package, behavior will change and new
  features will be added. People downloading your package can look at this
  file and quickly see what has changed. Debian archive maintenance programs
  will also post the contents of this file to the debian-devel-changes
  mailing list.
  </list>

  <p>The long strings of numbers in the .dsc and .changes files are MD5
  checksums for the files mentioned.
  A person downloading your files can test them with <manref name="md5sum"
  section="1"> and if the numbers don't match, they'll know the file is
  corrupt or has been tampered with.

  <sect id="quickrebuild">Quick rebuild

  <p>With a large package, you may not want to rebuild from scratch every
  time while you tune a detail in <file>debian/rules</file>. For testing
  purposes, you
  can make a .deb file without rebuilding the upstream sources like this:

  <p><example>
  fakeroot debian/rules binary
  </example>

  <p>Once you are finished with your tuning, remember to rebuild following
  the above, proper procedure. You may not be able to upload correctly if
  you try to upload .deb files built this way.

  <sect id="debuild">The <prgn>debuild</prgn> command

  <p>You can automate package build process further with 
  <prgn>debuild</prgn> command.  
  See <manref name="debuild" section="1">.
  
  <p>Customization of the debuild command can be done through 
  <file>/etc/devscripts.conf</file> or <file>~/.devscripts</file>. 
  I would suggest at least following items:

  <p><example>
  DEBSIGN_KEYID="Your_GPG_keyID"
  DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -ICVS -I.svn"
  </example>
  With these, you can build package always with your GPG key and avoid 
  including undesired components.  (This is good for sponsoring too.)
  For example, cleaning source and rebuilding package from a user account 
  is as simple as:

  <p><example>
  debuild clean
  debuild
  </example>

  <sect id="dpatch">The <prgn>dpatch</prgn> and <prgn>quilt</prgn> systems
<p>
The simple use of <prgn>dh_make</prgn> and
<prgn>dpkg-buildpackage</prgn> commands will create a single large
<file>diff.gz</file> file which contains package maintenance files in
<file>debian/</file> and patch files to the source.  Such a package is a
bit cumbersome to inspect and understand for each source tree
modification later.  This is not so nice.
<footnote>
If you are not yet Debian Developer and asking your sponsor to upload
your package after his package review, you should make package as easy
as possible for him to review.
</footnote>
<p>
Several methods for the patch set maintenance have been proposed and are in
use with Debian packages.  The <prgn>dpatch</prgn> and <prgn>quilt</prgn> systems are two of the
simplest of such patch maintenance systems proposed.  Other ones are
dbs, cdbs, etc.
<p>
A package which is packaged properly with the <prgn>dpatch</prgn> or <prgn>quilt</prgn> systems
has modifications to the source clearly documented as a set of 
-p1 patch files with header in
<file>debian/patches/</file> and the source tree is untouched outside of
<file>debian/</file> directory.  If you are asking a sponsor to upload
your package, this kind of clear separation and documentation of your
changes are very important to expedite the package review by your
sponsor.  The usage method of <prgn>dpatch</prgn> and <prgn>quilt</prgn> is explained in
<manref section="1" name="dpatch">,
<manref section="1" name="dpatch-edit-patch"> and
<manref section="1" name="quilt">.
Both programs provide convenience files to include in <file>debian/rules</file>:
<file>/usr/share/dpatch/dpatch.make</file> and
<file>/usr/share/quilt/quilt.make</file>.

<p>
When someone (including yourself) provides you with a patch to the
source later, then the package modification is quite
simple:
<list compact>
<item>Edit patch to make it a -p1 patch to the source tree.
<item>In the case of <prgn>dpatch</prgn>, add header using `<tt>dpatch patch-template</tt>' command.
<item>Drop it into <file>debian/patches</file>
<item>Add the patch filenames to <file>debian/patches/00list</file> (for <prgn>dpatch</prgn>)
or <file>debian/patches/series</file> (for <prgn>quilt</prgn>).
</list>
<p>
Also, <prgn>dpatch</prgn> has a capability to make patches architecture
dependent using CPP macro.

  <sect id="option-sa">Including <file>orig.tar.gz</file> for upload
  <p>
When you first upload the package to the archive, you need to include
the original <file>orig.tar.gz</file> source.  If package version is not
at <tt>-0</tt> or <tt>-1</tt> Debian revision, you must provide
<prgn>dpkg-buildpackage</prgn> command with the "<tt>-sa</tt>" option.
On the other hand, the "<tt>-sd</tt>" option will force to exclude the
original <file>orig.tar.gz</file> source.

  <chapt id="checkit">Checking the package for errors
  <p>
  
  <sect id="lintians">The <package>lintian</package> package

  <p>Run <manref name="lintian" section="1"> on your .changes file; these
  programs will check for many common packaging errors. The commands are:
  
  <p><example>
  lintian -i gentoo_0.9.12-1_i386.changes
  </example>
  
  <p>Of course, replace the filename with the name of the .changes file
  generated for your package. If it appears that there are some errors
  (lines beginning with E:), read the explanation (the N: lines), correct
  mistakes, and rebuild as described in <ref id="completebuild">. If there are
  lines that begin with W:, those are warnings, so tune the package or
  verify that the warnings are spurious (and make Lintian overrides; see
  the documentation for details).

  <p>Note that you can build the package with <prgn/dpkg-buildpackage/ and run
  <prgn/lintian/ all in one command with 
  <manref name="debuild" section="1">.
  
  <sect id="mc">The <prgn>mc</prgn> command

  <p>You can unpack the contents of <file>*.deb</file> package with <manref
  name="dpkg-deb" section="1"> command.  You can list the contents of a
  generated Debian package with <manref name="debc" section="1">.
  <p>
  This can be made into an intuitive process by
  using a file manager like <manref name="mc" section="1"> which will
  let you browse not only the contents of <file>*.deb</file> package
  files but also <file>*.diff.gz</file> and <file>*.tar.gz</file> files.
  <p> 
  Be on the lookout for extra unneeded files or zero length files, both
  in the binary and source package. Often cruft doesn't get cleaned up
  properly; adjust your rules file to compensate for that. 
  <p>
  Tips: `<tt>zgrep ^+++ ../gentoo_0.9.12-1.diff.gz</tt>' will give you a
  list of your changes/additions to the source files, and `<tt>dpkg-deb
  -c gentoo_0.9.12-1_i386.deb</tt>' or `<tt>debc
  gentoo_0.9.12-1_i386.changes</tt>' will list the files in the binary
  package.  

  <sect id="debdiff">The <prgn>debdiff</prgn> command

  <p>You can compare file lists in two binary Debian packages with
  <manref name="debdiff" section="1"> command.  This is useful for
  verifying that no files have been unintentionally misplaced or removed,
  and no other inadvertent changes were made when updating packages.
  You can check group of <file>*.deb</file> files simply by `<tt>debdiff
  old-package.change new-package.change</tt>'.

  <sect id="interdiff">The <prgn>interdiff</prgn> command

  <p>You can compare two <file>diff.gz</file> files with <manref
  name="interdiff" section="1"> command.  This is useful for verifying
  that no inadvertent changes were made to the source by the maintainer
  when updating packages.  Run `<tt>interdiff -z old-package.diff.gz
  new-package.diff.gz</tt>'.

  <sect id="debi">The <prgn>debi</prgn> command

  <p>Install the package to test it yourself, e.g. using the
  <manref name="debi" section="1"> command as root. Try to install and run
  it on machines other than your own and watch closely for any warnings
  or errors both during the installation and while the program is being run.

  <sect id="pbuilder">The <package>pbuilder</package> package
  <p>
For a clean room (chroot) build environment to verify the build
dependencies, the <package>pbuilder</package> package is very useful.  This
ensures a clean build from source under the auto-builder for different
architectures and avoids the severity serious FTBFS (Fails To Build From
Source) bug which is always in the RC (release critical) category.  See
<url id="&buildd-home;"> for more on the Debian package auto-builder.
<p>
The most basic use of the <package>pbuilder</package> package is the direct
invocation of <prgn>pbuilder</prgn> command from root.  For example,
issue the following commands in the directory where
<file>.orig.tar.gz</file>, <file>.diff.gz</file>, and <file>.dsc</file>
exist to build a package.
<example>
root # pbuilder create # if second time, pbuilder update
root # pbuilder build foo.dsc
</example>
The newly built packages will be located in
<file>/var/cache/pbuilder/result/</file> with root ownership.
<p>
The <prgn>pdebuild</prgn> command helps you to use
<package>pbuilder</package> package functions from the normal user
account.  From the root of the source tree while having
<file>orig.tar.gz</file> file in its parent directory, you issue
the following commands:
<example>
$ sudo pbuilder create # if second time, sudo pbuilder update
$ pdebuild
</example>
The newly built packages will be located in
<file>/var/cache/pbuilder/result/</file> with non-root ownership.
<footnote>
Currently, I would suggest customizing your system by setting
<file>/var/cache/pbuilder/result/</file> directory writable by the user
and setting <file>~/.pbuilderrc</file> or <file>/etc/pbuilderrc</file>
to include
<example>
AUTO_DEBSIGN=yes
</example>
This will allow you to sign generated packages with your secret GPG key
under <file>~/.gnupg/</file>.  Since the <package>pbuilder</package> package
is still evolving, you have to check the actual configuration situation by 
consulting the latest official documentation.
</footnote>
<p>
If you want to add an additional apt source to be used by the
<package>pbuilder</package> package, you set <tt>OTHERMIRROR</tt> in
<file>~/.pbuilderrc</file> or
<file>/etc/pbuilderrc</file> and run (for sarge)
<example>
$ sudo pbuilder update --distribution sarge --override-config
</example>
The use of <tt>--override-config</tt> is needed to update apt source
within chroot environment.
<p>
See <url id="&pbuilder-home;">,
<manref section="1" name="pdebuild">,
<manref section="5" name="pbuilderrc">, and
<manref section="8" name="pbuilder"> .


  <chapt id="upload">Uploading the package

  <p>Now that you have tested your new package thoroughly, you will be ready
  to start the Debian new maintainer application process, as described at
  <url id="http://www.debian.org/devel/join/newmaint">

  <sect id="upload-debian">Uploading to the Debian archive
  
  <p>Once you become an official developer, you'll need to upload the
  package to the Debian archive. You can do this manually, but it's easier
  to use the provided automated tools, like
  <manref name="dupload" section="1"> or <manref name="dput" section="1">.
  We'll describe how it's done with <prgn/dupload/.

  <p>First you have to set up dupload's config file. You can either edit the
  system-wide <file>/etc/dupload.conf</file> file, or have your own
  <file>~/.dupload.conf</file> file override the few things you want to
  change. Put something like this in the file:

  <p><example>
  package config;

  $default_host = "anonymous-ftp-master";

  $cfg{'anonymous-ftp-master'} = {
        fqdn => "ftp-master.debian.org",
        method => "ftp",
        incoming => "/pub/UploadQueue/",
        # files pass on to dinstall on ftp-master which sends emails itself
        dinstall_runs => 1,
  };

  1;
  </example>

  <p>You can read the <manref name="dupload.conf" section="5"> manual
  page to understand what each of these options means.

  <p>The $default_host option is the trickiest one -- it determines which of
  the upload queues will be used by default. "anonymous-ftp-master" is the primary
  one, but it's possible that you will want to use another, faster one.
  For more information about the upload queues, read the Developers'
  Reference, section "Uploading a package", at
  <file>&uploading;</file>

  <p>Then connect to your Internet provider, and issue this command:
  
  <p><example>
  dupload gentoo_0.9.12-1_i386.changes
  </example>

  <p><prgn/dupload/ checks that the MD5 checksums of the files match those from the
  .changes file, so it will warn you to rebuild it as described in
  <ref id="completebuild"> so it can properly upload.

  <!-- (No more use of ftp-master)
  <p>If you upload to "ftp-master", <prgn/dupload/ will ask for your
  password on Debian machines, and then upload the packages.
  -->

  <p>If you encounter an upload problem at <url id="&ftp-uploadqueue;">,
  you can fix this by manually uploading gnupg signed
  <file>*.commands</file> file to <url id="&ftp-uploadqueue;"> with
  <prgn>ftp</prgn>.
  <footnote>
  See <url id="&ftp-command;">.  Alternatively, you may use
  <prgn>dcut</prgn> command from the <package>dput</package> package.
  </footnote>
  For example, use <file>hello.commands</file>:
<example>
-----BEGIN PGP SIGNED MESSAGE-----

Uploader: Roman Hodek &lt;Roman.Hodek@informatik.uni-erlangen.de&gt;
Commands: 
 rm hello_1.0-1_i386.deb
 mv hello_1.0-1.dsx hello_1.0-1.dsc

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia

iQCVAwUBNFiQSXVhJ0HiWnvJAQG58AP+IDJVeSWmDvzMUphScg1EK0mvChgnuD7h
BRiVQubXkB2DphLJW5UUSRnjw1iuFcYwH/lFpNpl7XP95LkLX3iFza9qItw4k2/q
tvylZkmIA9jxCyv/YB6zZCbHmbvUnL473eLRoxlnYZd3JFaCZMJ86B0Ph4GFNPAf
Z4jxNrgh7Bc=
=pH94
-----END PGP SIGNATURE-----
</example>

  <sect id="upload-private">Uploading to a private archive

  <p>If you want to create a personal package archive at
  <tt>URL="http://people.debian.org/~<var>account_name</var>"</tt> as a 
  developer with simple invocation of 
  <tt>dupload -t <var>target_name</var></tt>, you should add the following 
  to <file>/etc/dupload.conf</file> file:
<example>
# Developer account
$cfg{'<var>target_name</var>'} = {
        fqdn =&gt; "people.debian.org",
        method =&gt; "scpb",
        incoming =&gt; "/home/<var>account_name</var>/public_html/package/",
        # I do not need to announce
        dinstall_runs =&gt; 1,
};
$cfg{'<var>target_name</var>'}{preupload}{'changes'} = "
        echo 'mkdir -p public_html/package' | ssh people.debian.org  2&gt;/dev/null ; 
        echo 'Package directory created!'";

$cfg{'<var>target_name</var>'}{postupload}{'changes'} = "
        echo 'cd public_html/package ;
        dpkg-scanpackages . /dev/null &gt;Packages || true ;
        dpkg-scansources . /dev/null &gt;Sources || true ;
        gzip -c Packages >Packages.gz ;
        gzip -c Sources &gt;Sources.gz ' | ssh people.debian.org  2&gt;/dev/null ;
        echo 'Package archive created!'";

</example>
Here, the APT archive is built with a quick and dirty remote shell execution
with SSH.  The override files required by <prgn>dpkg-scanpackages</prgn>
and <prgn>dpkg-scansources</prgn> are given as <file>/dev/null</file>.
This technique can be used by a non Debian Developer to host his packages
on his personal web site.  Alternatively you can use 
<prgn>apt-ftparchive</prgn> or other scripts to create an APT archive.

  <chapt id="update">Updating the package

  <sect id="newrevision">New Debian revision

  <p>Let's say that a bug report was filed against your package, #54321,
  and it describes a problem that you can solve. To create a new Debian
  revision of the package, you need to:

  <list>
  <item>Correct the problem in the package source, of course.

  <item>Add a new revision at the top of the Debian changelog file, for
  example with `<tt>dch -i</tt>`, or explicitly with
  `<tt>dch -v &lt;version&gt;-&lt;revision&gt;</tt>'
  and then insert the comments using your preferred editor.

  <p>Tip: how to easily get the date in required format?
  Use `<tt>822-date</tt>', or `<tt>date -R</tt>'.

  <item>Include a short description of the bug and the solution in the
  changelog entry,
  followed by this: "Closes: #54321". That way, the bug report will be
  automagically closed by the archive maintenance software the moment your
  package gets accepted in the Debian archive.

  <item>Repeat what you did in <ref id="completebuild">, <ref id="checkit">,
  and <ref id="upload">. The difference is that this time, the original source
  archive won't be included, as it hasn't been changed and it already
  exists in the Debian archive.
  </list>

  <sect id="newupstream">New upstream release (basic)

  <p>Now let's consider a different, slightly more complicated situation
  - a new upstream version was released, and of course you want it packaged.
  You need to do the following:

  <list>
  <item>Download the new sources and put the tarball (e.g. named
  `<file>gentoo-0.9.13.tar.gz</file>') in the directory above the old source tree
  (e.g. <file>~/gentoo/</file>).

  <item>Enter the old source directory, and run:

  <example>
  uupdate -u gentoo-0.9.13.tar.gz
  </example>

  <p>Of course, replace this file name with the name of your program's new source
  archive. <manref name="uupdate" section="1"> will properly rename that
  tarball, try to apply all the changes from your previous <file>.diff.gz</file> file,
  and update the new <file>debian/changelog</file> file.

  <item>Change directory to `<file>../gentoo-0.9.13</file>', the new package source tree,
  and repeat what you did in <ref id="completebuild">, <ref id="checkit">, and
  <ref id="upload">.
  </list>

  <p>Note that if you set up a `<file>debian/watch</file>' file as described in
  <ref id="watch">, you can run <manref name="uscan" section="1"> to
  automagically look for revised sources, download them, and run
  <prgn/uupdate/.

  <sect id="newupstream-real">New upstream release (realistic)

<p>
When preparing packages for the the Debian archive, you must check
the resulting packages in detail.  Here is a more realistic example of this
procedure.

<enumlist compact>

<item>Verify changes in upstream source

<list compact>

<item>Read the upstream <file>changelog</file>, <file>NEWS</file>, and
whatever other documentation they may have released with the new
version.

<item>Do a `<tt>diff -urN</tt>' between the old and new upstream sources
to try to get a feel for the scope of the changes, where work is
actively being done (and thus where new bugs may appear), and also keep
an eye out for anything suspicious.

</list>

<item>Port the old Debian packaging to the new version.  

<list compact>

<item>Unpack the source tarball and rename the root of the source tree as
<file>&lt;packagename&gt;-&lt;upstream_version&gt;/</file> and 
`<tt>cd</tt>' into this directory.

<item>Copy the source tarball in the parent directory and rename it as
<file>&lt;packagename&gt;_&lt;upstream_version&gt;.orig.tar.gz</file> .

<item>Apply the same kind of modification to the new source tree as the
old source tree.  Possible methods are:
<list compact>
<item>`<tt>zcat <var>/path/to/</var>&lt;packagename&gt;_&lt;old-version&gt;.diff.gz | patch -p1</tt>' command,
<item>`<prgn>uupdate</prgn>' command,
<item>`<tt>svn merge</tt>' command if you manage the source with
Subversion repository, or
<item>simply copying <file>debian/</file> directory from the old source
tree if it was packaged with <package>dpatch</package> or <package>quilt</package>.
</list>

<item>Preserve old changelog entries (sounds obvious, but there have
been incidents...)

<item>The new package version is the upstream release version appended
with a <tt>-1</tt> Debian revision number, e.g., `<tt>0.9.13-1</tt>'.

<item>Add changelog record entry with "New upstream release" for this
new version at the top of <file>debian/changelog</file>.  For example
`<tt>dch -v 0.9.13-1</tt>'.

<item>Describe concisely the changes <em>in</em> the new upstream
release that fix reported bugs and close those bugs in the changelog.

<item>Describe concisely the changes <em>to</em> the new upstream
release by the maintainer that fix reported bugs and close those bugs in
the changelog.

<item>If the patch/merge did not apply cleanly, inspect the situation to
determine what failed (clues are left in <file>.rej</file> files).  Most
often the problem is that a patch you applied to the source was
integrated upstream, and thus the patch is no longer relevant.

<item>Upgrades to the new version should be silent and nonintrusive
(existing users should not notice the upgrade except by discovering that
old bugs have been fixed and there perhaps are new features).
<footnote>
Please make your package properly updates the config file upon upgrades
using well designed <prgn>postinst</prgn> etc., so that it
<strong>doesn't</strong> do things not wanted by the user!  These are
the enhancements that explain <strong>why</strong> people choose Debian.
<p>
When the upgrade is necessarily intrusive (eg., config files scattered
through various home directories with totally different structure), you
may consider to set package to the safe default (e.g., disabled service)
and provide proper documentations required by the policy
(<file>README.Debian</file> and <file>NEWS.Debian</file> ) as the last
resort. But don't bother with the debconf note.
</footnote>

<item>If you need to add erased template files for any reason, you
may run <prgn>dh_make</prgn> again in the same, already "debianized",
directory with <tt>-o</tt> option.  Then edit it properly.

<item>Existing Debian changes need to be reevaluated; throw away stuff that
upstream has incorporated (in one form or another) and remember to
keep stuff that hasn't been incorporated by upstream, unless there is
a compelling reason not to.

<item>If any changes were made to the build system (hopefully you'd know
from step 1) then update the <file>debian/rules</file> and
<file>debian/control</file> build dependencies if necessary.

</list>

<item>Build the new package as described in <ref id="debuild"> or
<ref id="pbuilder">. Use of <package>pbuilder</package> is desirable.

<item>Verify new packages are built correctly.

<list compact>

<item>Perform <ref id="checkit">.

<item>Perform <ref id="upgrading">.   

<item>Check again to see if any bugs have been fixed that are currently
open in the <url name="Debian Bug Tracking System (BTS)"
id="http://www.debian.org/Bugs/"> .

<item>Check the contents of the .changes file to make sure you are
uploading to the correct distribution, the proper bugs closures are
listed in the Closes: field, the Maintainer: and Changed-By: fields
match, the file is GPG-signed, etc.

</list>

<item>If any changes were made to correct anything in the packaging along
the way, go back to the step 2 until satisfied.  

<item>If your upload needs to be sponsored, be sure to note any special
options required when building the package (like '<tt>dpkg-buildpackage
-sa -v ...</tt>') and be sure to inform your sponsor so he or she builds
it correctly.

<item>If you are uploading yourself, perform <ref id="upload">.
</enumlist>

  <sect id="orig-tar">The <file>orig.tar.gz</file> file
<p>
If you try to build packages only from the new source tree with
<file>debian/</file> directory without the <file>orig.tar.gz</file> file
in its parent directory, you will end up unintentionally creating a
native source package, which comes without the <file>diff.gz</file>
file.  This type of packaging is only appropriate for the
debian-specific packages, which will never be useful in another
distribution.
<footnote>
Some people argue that, even for Debian specific packages, it is still
better practice to package the contents of the <file>debian/</file>
directory residing in the <file>diff.gz</file> file, rather than in the
<file>orig.tar.gz</file> file.
</footnote>
<p>
In order to obtain a non-native source package which consists of both
the <file>orig.tar.gz</file> file and the <file>diff.gz</file> file, you
must manually copy the upstream tarball to the parent directory with its
file name changed into
<file>&lt;packagename&gt;_&lt;upstream_version&gt;.orig.tar.gz</file> as
it was done by <prgn>dh_make</prgn> command in <ref id="dh_make">.

  <sect id="cvs-buildpackage">The <prgn>cvs-buildpackage</prgn> command and similes
<p>
You should consider using a source code management system to manage
packaging activity.  There are several wrapper scripts which are customized 
to be used with the most popular ones.
<list compact>
<item>CVS
<list compact>
<item><package>cvs-buildpackage</package>
</list>
<item>Subversion
<list compact>
<item><package>svn-buildpackage</package>
</list>
<item>Git (git-core)
<list compact>
<item><package>git-buildpackage</package>
</list>
</list>
<p>
These commands also automate the packaging of new upstream releases.

  <sect id="upgrading">Verifying package upgrades

  <p>When you build a new version of the package, you should do the
  following to verify that the package can be safely upgraded:

  <list>
    <item>upgrade from the previous version
    <item>downgrade back again and then remove it,
    <item>install the new package
    <item>remove it and then reinstall it again,
    <item>purge it.
  </list>

  <p>If the package makes use of non-trivial pre/post/inst/rm scripts, be 
  sure to test the upgrade paths of those.

  <p>Bear in mind that if your package has previously been released in
  Debian, people will often be upgrading to your package from the version
  that was in the last Debian release. Remember to test upgrades from that
  version too.

  <chapt id="helpme">Where to ask for help

  <p>Before you decide to ask your question in some public place, please
  just RTFM. That includes documentation in <file>/usr/share/doc/dpkg</file>,
  <file>/usr/share/doc/debian</file>, <file>&autotools-dev;</file>, 
  <file>/usr/share/doc/package/*</file>
  files and the man/info pages for all the programs mentioned in this document.
  See all the information at <url id="&nm-home;"> and
  <url id="&mentors-faq;">.

  <p>If you have questions about packaging that you couldn't find answers to
  in the documentation, you can ask them on the Debian Mentors' mailing list
  at <email/debian-mentors@lists.debian.org/. The more experienced Debian
  developers will gladly help you, but do read at least some of the
  documentation before asking a question!

  <p>See <url id="http://lists.debian.org/debian-mentors/"> for more
  information about this mailing list.

  <p>When you receive
  a bug report (yes, actual bug reports!), you will know that it is time for you
  to dig into the <url name="Debian Bug Tracking System" id="http://www.debian.org/Bugs/">
  and read the documentation there, to be able to deal with the reports
  efficiently. I highly recommend reading the Developers' Reference,
  chapter "Handling Bugs", at
  <file>&bughandling;</file>

  <p>If you still have questions, ask on the Debian Developers' mailing list
  at <email/debian-devel@lists.debian.org/. See
  <url id="http://lists.debian.org/debian-devel/"> for more information
  about this mailing list.

  <p>Even if it all worked well, it's time to start praying. Why? Because
  in just a few hours (or days) users from all around the world will start
  to use your package, and if you made some critical error you'll get
  mailbombed by numerous angry Debian users... Just kidding. :-)

  <p>Relax and be ready for bug reports, because there is a lot more work
  to be done before your package will be fully in line with Debian policies
  (once again, read the <em>real documentation</em> for details). Good luck!

<appendix id="pkg-eg">Examples
<p>
Here we package the upstream tarball <var>gentoo-1.0.2</var>.tar.gz and
uploading all the packages to the <tt><var>nm_target</var></tt>.

<sect id="pkg-simple">Simple packaging example
<p>
<example>
$ mkdir -p <var>/path/to</var> # new empty directory
$ cd <var>/path/to</var>
$ tar -xvzf <var>/path/from/gentoo-1.0.2</var>.tar.gz # get source
$ cd <var>gentoo-1.0.2</var>
$ dh_make -e <var>name@domain.dom</var> -f <var>/path/from/gentoo-1.0.2</var>.tar.gz
... Answer prompts.
... Fix source tree
... If it is a script package, set debian/control to "Architecture: all"
... Do not erase ../<var>gentoo_1.0.2</var>.orig.tar.gz
$ debuild
... Make sure no warning happens.
$ cd ..
$ dupload -t <var>nm_target</var> <var>gentoo_1.0.2-1</var>_i386.changes
</example>


<sect id="pkg-dpatch">Packaging example with the <package>dpatch</package> and the <package>pbuilder</package>
<p>
<example>
$ mkdir -p <var>/path/to</var> # new empty directory
$ cd <var>/path/to</var>
$ tar -xvzf <var>/path/from/gentoo-1.0.2</var>.tar.gz
$ cp -a  <var>gentoo-1.0.2</var> <var>gentoo-1.0.2-orig</var>
$ cd <var>gentoo-1.0.2</var>
$ dh_make -e <var>name@domain.dom</var> -f /path/from/<var>gentoo-1.0.2</var>.tar.gz
... Answer prompts.
</example>
Here part of <file>debian/rules</file> originally looks like:
<example>
configure: configure-stamp
configure-stamp:
        dh_testdir
        # Add here commands to configure the package.
        touch configure-stamp
build: build-stamp
build-stamp: configure-stamp 
        dh_testdir
        # Add here commands to compile the package.
        $(MAKE)
        #docbook-to-man debian/gentoo.sgml > gentoo.1
        touch $@
clean:
        dh_testdir
        dh_testroot
        rm -f build-stamp configure-stamp
        # Add here commands to clean up after the build process.
        -$(MAKE) clean
        dh_clean 
</example>
You change this part of <file>debian/rules</file> to the following 
by the editor to use <package>dpatch</package> and add 
<package>dpatch</package> to the <tt>Build-Depends:</tt> line in the 
<file>debian/control</file> file:
<example>
configure: configure-stamp
configure-stamp: patch
        dh_testdir
        # Add here commands to configure the package.
        touch configure-stamp
build: build-stamp
build-stamp: configure-stamp 
        dh_testdir
        # Add here commands to compile the package.
        $(MAKE)
        #docbook-to-man debian/gentoo.sgml > gentoo.1
        touch $@
clean: clean-patched unpatch
clean-patched:
        dh_testdir
        dh_testroot
        rm -f build-stamp configure-stamp
        # Add here commands to clean up after the build process.
        -$(MAKE) clean
        dh_clean 
patch: patch-stamp
patch-stamp:
     dpatch apply-all
     dpatch call-all -a=pkg-info >patch-stamp
unpatch:
     dpatch deapply-all
     rm -rf patch-stamp debian/patched
</example>
<p>
Now you are ready to repackage the source tree with
<package>dpatch</package> system with the help of 
<prgn>dpatch-edit-patch</prgn>.
<example>
$ dpatch-edit-patch patch 10_firstpatch
... Fix source tree by editor
$ exit 0
... Try building packages with "debuild -us -uc"
... Clean source with "debuild clean"
... Repeat dpatch-edit-patch until making source buildable.
$ sudo pbuilder update
$ pdebuild
$ cd /var/cache/pbuilder/result/
$ dupload -t <var>nm_target</var> <var>gentoo_1.0.2-1</var>_i386.changes
</example>


 </book>

</debiandoc>