/usr/share/doc/maint-guide/html/advanced.en.html is in maint-guide 1.2.40.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Appendix A. Advanced packaging</title>
<link rel="stylesheet" type="text/css" href="debian.css"/>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="home" href="index.en.html" title="Debian New Maintainers' Guide"/>
<link rel="up" href="index.en.html" title="Debian New Maintainers' Guide"/>
<link rel="prev" href="upload.en.html" title="Chapter 9. Uploading the package"/>
</head>
<body>
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Appendix A. Advanced packaging</th>
</tr>
<tr>
<td align="left"><a accesskey="p" href="upload.en.html"><img src="images/prev.png" alt="Prev"/></a> </td>
<th width="60%" align="center"> </th>
<td align="right"> </td>
</tr>
</table>
<hr/>
</div>
<div class="appendix">
<div class="titlepage">
<div>
<div>
<h1 class="title"><a id="advanced"/>Appendix A. Advanced packaging</h1>
</div>
</div>
</div>
<div class="toc">
<p>
<strong>Table of Contents</strong>
</p>
<dl class="toc">
<dt>
<span class="section">
<a href="advanced.en.html#library">A.1. Shared libraries</a>
</span>
</dt>
<dt>
<span class="section">
<a href="advanced.en.html#librarysymbols">A.2. Managing <code class="filename">debian/<em class="replaceable"><code>package</code></em>.symbols</code></a>
</span>
</dt>
<dt>
<span class="section">
<a href="advanced.en.html#multiarch">A.3. Multiarch</a>
</span>
</dt>
<dt>
<span class="section">
<a href="advanced.en.html#librarypackage">A.4. Building a shared library package</a>
</span>
</dt>
<dt>
<span class="section">
<a href="advanced.en.html#native-dh-make">A.5. Native Debian package</a>
</span>
</dt>
</dl>
</div>
<p>
Here are some hints and pointers for advanced packaging topics that you are most likely to deal with.
You are strongly advised to read all the references suggested here.
</p>
<p>
You may need to manually edit the packaging template files generated by the <span class="command"><strong>dh_make</strong></span> command to address topics covered in this chapter. The newer <span class="command"><strong>debmake</strong></span> command should address these topics better.
</p>
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="library"/>A.1. Shared libraries</h2>
</div>
</div>
</div>
<p>
Before packaging shared <a class="ulink" href="http://en.wikipedia.org/wiki/Library_(computing)">libraries</a>, you should read the following primary references in detail:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
<a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html">Debian Policy Manual, 8 "Shared libraries"</a>
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-opersys.html#s-fhs">Debian Policy Manual, 9.1.1 "File System Structure"</a>
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-files.html#s-libraries">Debian Policy Manual, 10.2 "Libraries"</a>
</p>
</li>
</ul>
</div>
<p>
Here are some oversimplified hints for you to get started:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
Shared libraries are <a class="ulink" href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format">ELF</a> object files containing compiled code.
</p>
</li>
<li class="listitem">
<p>
Shared libraries are distributed as <code class="filename">*.so</code> files. (Neither <code class="filename">*.a</code> files nor <code class="filename">*.la</code> files)
</p>
</li>
<li class="listitem">
<p>
Shared libraries are mainly used to share common codes among multiple executables with the <span class="command"><strong>ld</strong></span> mechanism.
</p>
</li>
<li class="listitem">
<p>
Shared libraries are sometimes used to provide multiple plugins to an executable with the <span class="command"><strong>dlopen</strong></span> mechanism.
</p>
</li>
<li class="listitem">
<p>
Shared libraries export <a class="ulink" href="http://en.wikipedia.org/wiki/Symbol_(programming)">symbols</a>, which represent compiled objects such as variables, functions, and classes; and enable access to them from the linked executables.
</p>
</li>
<li class="listitem">
<p>
The <a class="ulink" href="http://en.wikipedia.org/wiki/Soname">SONAME</a> of a shared library <code class="filename">lib<em class="replaceable"><code>foo</code></em>.so</code>.<em class="replaceable"><code>1</code></em>: <code class="literal">objdump -p lib<em class="replaceable"><code>foo</code></em>.so.<em class="replaceable"><code>1</code></em> | grep SONAME</code>
<a href="#ftn.idm3831" class="footnote" id="idm3831"><sup class="footnote">[88]</sup></a>
</p>
</li>
<li class="listitem">
<p>
The SONAME of a shared library usually matches the library file name (but not always).
</p>
</li>
<li class="listitem">
<p>
The SONAME of shared libraries linked to <code class="filename"><em class="replaceable"><code>/usr/bin/foo</code></em></code>: <code class="literal">objdump -p <em class="replaceable"><code>/usr/bin/foo</code></em> | grep NEEDED</code>
<a href="#ftn.idm3844" class="footnote" id="idm3844"><sup class="footnote">[89]</sup></a>
</p>
</li>
<li class="listitem">
<p>
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em><em class="replaceable"><code>1</code></em></code>: the library package for the shared library <code class="filename">lib<em class="replaceable"><code>foo</code></em>.so.<em class="replaceable"><code>1</code></em></code> with the SONAME ABI version <em class="replaceable"><code>1</code></em>.<a href="#ftn.idm3858" class="footnote" id="idm3858"><sup class="footnote">[90]</sup></a>
</p>
</li>
<li class="listitem">
<p>
The package maintainer scripts of the library package must call <span class="command"><strong>ldconfig</strong></span> under the specific circumstances to create the necessary symbolic links for the SONAME.<a href="#ftn.idm3864" class="footnote" id="idm3864"><sup class="footnote">[91]</sup></a>
</p>
</li>
<li class="listitem">
<p>
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em><em class="replaceable"><code>1</code></em>-dbg</code>: the debugging symbols package that contains the debugging symbols for the shared library package <code class="systemitem">lib<em class="replaceable"><code>foo</code></em><em class="replaceable"><code>1</code></em></code>.
</p>
</li>
<li class="listitem">
<p>
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em>-dev</code>: the development package that contains the header files etc. for the shared library <code class="filename">lib<em class="replaceable"><code>foo</code></em>.so.<em class="replaceable"><code>1</code></em></code>.<a href="#ftn.idm3882" class="footnote" id="idm3882"><sup class="footnote">[92]</sup></a>
</p>
</li>
<li class="listitem">
<p>
Debian packages should not contain <code class="filename">*.la</code> Libtool archive files in general.<a href="#ftn.idm3889" class="footnote" id="idm3889"><sup class="footnote">[93]</sup></a>
</p>
</li>
<li class="listitem">
<p>
Debian packages should not use RPATH in general.<a href="#ftn.idm3894" class="footnote" id="idm3894"><sup class="footnote">[94]</sup></a>
</p>
</li>
<li class="listitem">
<p>
Although it is somewhat outdated and is only a secondary reference, <a class="ulink" href="http://www.netfort.gr.jp/~dancer/column/libpkg-guide/libpkg-guide.html">Debian Library Packaging Guide</a> may still be useful.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="librarysymbols"/>A.2. Managing <code class="filename">debian/<em class="replaceable"><code>package</code></em>.symbols</code></h2>
</div>
</div>
</div>
<p>
When you package a shared library, you should create a <code class="filename">debian/<em class="replaceable"><code>package</code></em>.symbols</code> file to manage the minimal version associated with each symbol for backward-compatible ABI changes under the same SONAME of the library for the same shared library package name.<a href="#ftn.idm3907" class="footnote" id="idm3907"><sup class="footnote">[95]</sup></a> You should read the following primary references in detail:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
<a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-symbols">Debian Policy Manual, 8.6.3 "The symbols system"</a><a href="#ftn.idm3913" class="footnote" id="idm3913"><sup class="footnote">[96]</sup></a>
</p>
</li>
<li class="listitem">
<p>
<span class="citerefentry"><span class="refentrytitle">dh_makeshlibs</span>(1)</span>
</p>
</li>
<li class="listitem">
<p>
<span class="citerefentry"><span class="refentrytitle">dpkg-gensymbols</span>(1)</span>
</p>
</li>
<li class="listitem">
<p>
<span class="citerefentry"><span class="refentrytitle">dpkg-shlibdeps</span>(1)</span>
</p>
</li>
<li class="listitem">
<p>
<span class="citerefentry"><span class="refentrytitle">deb-symbols</span>(5)</span>
</p>
</li>
</ul>
</div>
<p>
Here is a rough example of how to create the <code class="systemitem">libfoo1</code> package from the upstream version <code class="literal">1.3</code> with the proper <code class="filename">debian/libfoo1.symbols</code> file:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
Prepare the skeleton debianized source tree using the upstream <code class="filename">libfoo-1.3.tar.gz</code> file.
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
If this is the first packaging of the <code class="systemitem">libfoo1</code> package, create the <code class="filename">debian/libfoo1.symbols</code> file with empty content.
</p>
</li>
<li class="listitem">
<p>
If the previous upstream version <code class="literal">1.2</code> was packaged as the <code class="systemitem">libfoo1</code> package with the proper <code class="filename">debian/libfoo1.symbols</code> in its source package, use it again.
</p>
</li>
<li class="listitem">
<p>
If the previous upstream version <code class="literal">1.2</code> was not packaged with <code class="filename">debian/libfoo1.symbols</code>, create it as the <code class="filename">symbols</code> file from all available binary packages of the same shared library package name containing the same SONAME of the library, for example, versions <code class="literal">1.1-1</code> and <code class="literal">1.2-1</code>.
<a href="#ftn.idm3961" class="footnote" id="idm3961"><sup class="footnote">[97]</sup></a>
</p>
<pre class="screen">
$ dpkg-deb -x libfoo1_1.1-1.deb libfoo1_1.1-1
$ dpkg-deb -x libfoo1_1.2-1.deb libfoo1_1.2-1
$ : > symbols
$ dpkg-gensymbols -v1.1 -plibfoo1 -Plibfoo1_1.1-1 -Osymbols
$ dpkg-gensymbols -v1.2 -plibfoo1 -Plibfoo1_1.2-1 -Osymbols
</pre>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Make trial builds of the source tree with tools such as <span class="command"><strong>debuild</strong></span> and <span class="command"><strong>pdebuild</strong></span>. (If this fails due to missing symbols etc., there were some backward-incompatible ABI changes that require you to bump the shared library package name to something like <code class="systemitem">libfoo1a</code> and you should start over again.)
</p>
<pre class="screen">
$ cd libfoo-1.3
$ debuild
...
dpkg-gensymbols: warning: some new symbols appeared in the symbols file: ...
see diff output below
--- debian/libfoo1.symbols (libfoo1_1.3-1_amd64)
+++ dpkg-gensymbolsFE5gzx 2012-11-11 02:24:53.609667389 +0900
@@ -127,6 +127,7 @@
foo_get_name@Base 1.1
foo_get_longname@Base 1.2
foo_get_type@Base 1.1
+ foo_get_longtype@Base 1.3-1
foo_get_symbol@Base 1.1
foo_get_rank@Base 1.1
foo_new@Base 1.1
...
</pre>
</li>
<li class="listitem">
<p>
If you see the diff printed by the <span class="command"><strong>dpkg-gensymbols</strong></span> as above, extract the proper updated <code class="filename">symbols</code> file from the generated binary package of the shared library.
<a href="#ftn.idm3981" class="footnote" id="idm3981"><sup class="footnote">[98]</sup></a>
</p>
<pre class="screen">
$ cd ..
$ dpkg-deb -R libfoo1_1.3_amd64.deb libfoo1-tmp
$ sed -e 's/1\.3-1/1\.3/' libfoo1-tmp/DEBIAN/symbols \
>libfoo-1.3/debian/libfoo1.symbols
</pre>
</li>
<li class="listitem">
<p>
Build release packages with tools such as <span class="command"><strong>debuild</strong></span> and <span class="command"><strong>pdebuild</strong></span>.
</p>
<pre class="screen">
$ cd libfoo-1.3
$ debuild clean
$ debuild
...
</pre>
</li>
</ul>
</div>
<p>
In addition to the above examples, we need to check the ABI compatibility further and bump versions for some symbols manually as needed.
<a href="#ftn.idm3993" class="footnote" id="idm3993"><sup class="footnote">[99]</sup></a>
</p>
<p>
Although it is only a secondary reference, <a class="ulink" href="http://wiki.debian.org/UsingSymbolsFiles">Debian wiki UsingSymbolsFiles</a> and its linked web pages may be useful.
</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="multiarch"/>A.3. Multiarch</h2>
</div>
</div>
</div>
<p>
The multiarch feature introduced to Debian wheezy integrates support for cross-architecture installation of binary packages (particularly <code class="literal">i386</code><-><code class="literal">amd64</code>, but also other combinations) in <code class="systemitem">dpkg</code> and <code class="systemitem">apt</code>. You should read the following references in detail:</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
<a class="ulink" href="https://wiki.ubuntu.com/MultiarchSpec">Ubuntu wiki MultiarchSpec</a> (upstream)
</p>
</li>
<li class="listitem">
<p>
<a class="ulink" href="http://wiki.debian.org/Multiarch/Implementation">Debian wiki Multiarch/Implementation</a> (Debian situation)
</p>
</li>
</ul>
</div>
<p>
It uses the triplet such as <code class="literal">i386-linux-gnu</code> and <code class="literal">x86_64-linux-gnu</code> for the install path of shared libraries. The actual triplet path is dynamically set into the <code class="literal">$(DEB_HOST_MULTIARCH)</code> variable using the <span class="citerefentry"><span class="refentrytitle">dpkg-architecture</span>(1)</span> command for each binary package build. For example, the path to install multiarch libraries are changed as follows:<a href="#ftn.idm4019" class="footnote" id="idm4019"><sup class="footnote">[100]</sup></a>
</p>
<div class="informaltable">
<a id="tripletpaths"/>
<table class="informaltable" border="1">
<colgroup>
<col style="text-align: left"/>
<col style="text-align: left"/>
<col style="text-align: left"/>
</colgroup>
<thead>
<tr>
<th style="text-align: left">Old path</th>
<th style="text-align: left">i386 multiarch path</th>
<th style="text-align: left">amd64 multiarch path</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<code class="filename">/lib/</code>
</td>
<td style="text-align: left">
<code class="filename">/lib/i386-linux-gnu/</code>
</td>
<td style="text-align: left">
<code class="filename">/lib/x86_64-linux-gnu/</code>
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="filename">/usr/lib/</code>
</td>
<td style="text-align: left">
<code class="filename">/usr/lib/i386-linux-gnu/</code>
</td>
<td style="text-align: left">
<code class="filename">/usr/lib/x86_64-linux-gnu/</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Here are some typical multiarch package split scenario examples for the following:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
a library source <code class="filename">lib<em class="replaceable"><code>foo</code></em>-1.tar.gz</code>
</p>
</li>
<li class="listitem">
<p>
a tool source <code class="filename"><em class="replaceable"><code>bar</code></em>-1.tar.gz</code> written in a compiled language
</p>
</li>
<li class="listitem">
<p>
a tool source <code class="filename"><em class="replaceable"><code>baz</code></em>-1.tar.gz</code> written in an interpreted language
</p>
</li>
</ul>
</div>
<div class="informaltable">
<a id="multiarchtable"/>
<table class="informaltable" border="1">
<colgroup>
<col style="text-align: left"/>
<col style="text-align: left"/>
<col style="text-align: left"/>
<col style="text-align: left"/>
</colgroup>
<thead>
<tr>
<th style="text-align: left">Package</th>
<th style="text-align: left">Architecture:</th>
<th style="text-align: left">Multi-Arch:</th>
<th style="text-align: left">Package content</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em><em class="replaceable"><code>1</code></em></code>
</td>
<td style="text-align: left">any</td>
<td style="text-align: left">same</td>
<td style="text-align: left">
the shared library, co-installable
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em><em class="replaceable"><code>1</code></em>-dbg</code>
</td>
<td style="text-align: left">any</td>
<td style="text-align: left">same</td>
<td style="text-align: left">
the shared library debug symbols, co-installable
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em>-dev</code>
</td>
<td style="text-align: left">any</td>
<td style="text-align: left">same</td>
<td style="text-align: left">
the shared library header files etc., co-installable
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em>-tools</code>
</td>
<td style="text-align: left">any</td>
<td style="text-align: left">foreign</td>
<td style="text-align: left">
the run-time support programs, not co-installable
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem">lib<em class="replaceable"><code>foo</code></em>-doc</code>
</td>
<td style="text-align: left">all</td>
<td style="text-align: left">foreign</td>
<td style="text-align: left">
the shared library documentation files
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem">
<em class="replaceable">
<code>bar</code>
</em>
</code>
</td>
<td style="text-align: left">any</td>
<td style="text-align: left">foreign</td>
<td style="text-align: left">
the compiled program files, not co-installable
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem"><em class="replaceable"><code>bar</code></em>-doc</code>
</td>
<td style="text-align: left">all</td>
<td style="text-align: left">foreign</td>
<td style="text-align: left">
the documentation files for the program
</td>
</tr>
<tr>
<td style="text-align: left">
<code class="systemitem">
<em class="replaceable">
<code>baz</code>
</em>
</code>
</td>
<td style="text-align: left">all</td>
<td style="text-align: left">foreign</td>
<td style="text-align: left">
the interpreted program files
</td>
</tr>
</tbody>
</table>
</div>
<p>
Please note that the development package should contain a symlink for the associated shared library <span class="strong"><strong>without a version number</strong></span>. E.g.: <code class="filename">/usr/lib/x86_64-linux-gnu/libfoo.so</code> -> <code class="filename">libfoo.so.1</code>
</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="librarypackage"/>A.4. Building a shared library package</h2>
</div>
</div>
</div>
<p>
You can build a Debian library package enabling multiarch support using <span class="citerefentry"><span class="refentrytitle">dh</span>(1)</span> as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
Update <code class="filename">debian/control</code>.
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
Add <code class="literal">Build-Depends: debhelper (>=10)</code> for the source package section.
</p>
</li>
<li class="listitem">
<p>
Add <code class="literal">Pre-Depends: ${misc:Pre-Depends}</code> for each shared library binary package.
</p>
</li>
<li class="listitem">
<p>
Add <code class="literal">Multi-Arch:</code> stanza for each binary package section.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Set <code class="filename">debian/compat</code> to "10".
</p>
</li>
<li class="listitem">
<p>
Adjust the path from the normal <code class="literal">/usr/lib/</code> to the multiarch <code class="literal">/usr/lib/$(DEB_HOST_MULTIARCH)/</code> for all packaging scripts.
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
Call <code class="literal">DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)</code> in <code class="filename">debian/rules</code> to set the <code class="literal">DEB_HOST_MULTIARCH</code> variable first.
</p>
</li>
<li class="listitem">
<p>
Replace <code class="literal">/usr/lib/</code> with <code class="literal">/usr/lib/$(DEB_HOST_MULTIARCH)/</code> in <code class="filename">debian/rules</code>.
</p>
</li>
<li class="listitem">
<p>
If <code class="literal">./configure</code> is used in part of the <code class="literal">override_dh_auto_configure</code> target in <code class="filename">debian/rules</code>, make sure to replace it with <code class="literal">dh_auto_configure -- </code>.
<a href="#ftn.idm4181" class="footnote" id="idm4181"><sup class="footnote">[101]</sup></a>
</p>
</li>
<li class="listitem">
<p>
Replace all occurrences of <code class="literal">/usr/lib/</code> with <code class="literal">/usr/lib/*/</code> in <code class="filename">debian/<em class="replaceable"><code>foo</code></em>.install</code> files.
</p>
</li>
<li class="listitem">
<p>
Generate files like <code class="filename">debian/<em class="replaceable"><code>foo</code></em>.links</code> from <code class="filename">debian/<em class="replaceable"><code>foo</code></em>.links.in</code> dynamically by adding a script to the <code class="literal">override_dh_auto_configure</code> target in <code class="filename">debian/rules</code>.
</p>
<pre class="screen">
override_dh_auto_configure:
dh_auto_configure
sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \
debian/<em class="replaceable"><code>foo</code></em>.links.in > debian/<em class="replaceable"><code>foo</code></em>.links
</pre>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
Please make sure to verify that the shared library package contains only the expected files, and that your -dev package still works.
</p>
<p>
All files installed simultaneously as the multiarch package to the same file path should have exactly the same file content. You must be careful of differences generated by the data byte order and by the compression algorithm.
</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a id="native-dh-make"/>A.5. Native Debian package</h2>
</div>
</div>
</div>
<p>
If a package is maintained only for Debian or possibly only for local use, its source may contain all the <code class="filename">debian/*</code> files in it. There are 2 ways to package it.
</p>
<p>
You can make the upstream tarball by excluding the <code class="filename">debian/*</code> files and package it as a non-native Debian package as in <a class="xref" href="first.en.html#workflow" title="2.1. Debian package building workflow">Section 2.1, “Debian package building workflow”</a>. This is the normal way, which some people encourage using.
</p>
<p>
The alternative is the workflow of the native Debian package.
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
Create a native Debian source package in the <code class="literal">3.0 (native)</code>
format using a single compressed tar file in which all files are included.
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal"><em class="replaceable"><code>package</code></em>_<em class="replaceable"><code>version</code></em>.tar.gz</code>
</li>
<li class="listitem">
<code class="literal"><em class="replaceable"><code>package</code></em>_<em class="replaceable"><code>version</code></em>.dsc</code>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Build Debian binary packages from the native Debian source package.
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal"><em class="replaceable"><code>package</code></em>_<em class="replaceable"><code>version</code></em>_<em class="replaceable"><code>arch</code></em>.deb</code>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
For example, if you have source files in <code class="filename">~/mypackage-1.0</code>
without the <code class="filename">debian/*</code> files, you can create a native Debian
package by issuing the <span class="command"><strong>dh_make</strong></span> command as follows:
</p>
<pre class="screen">
$ cd ~/mypackage-1.0
$ dh_make --native
</pre>
<p>
Then the <code class="filename">debian</code> directory and its contents are created
just like in <a class="xref" href="first.en.html#non-native-dh-make" title="2.8. Initial non-native Debian package">Section 2.8, “Initial non-native Debian package”</a>. This does not create a tarball,
since this is a native Debian package. But that is the only difference.
The rest of the packaging activities are practically the same.
</p>
<p>
After execution of the <span class="command"><strong>dpkg-buildpackage</strong></span> command, you will see the following files in the parent directory:
</p>
<div class="itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p>
<code class="filename">mypackage_1.0.tar.gz</code>
</p>
<p>
This is the source code tarball created from the
<code class="filename">mypackage-1.0</code> directory by the
<span class="command"><strong>dpkg-source</strong></span> command. (Its suffix is not <code class="filename">orig.tar.gz</code>.)
</p>
</li>
<li class="listitem">
<p>
<code class="filename">mypackage_1.0.dsc</code>
</p>
<p>
This is a summary of the contents of the source code, as in the non-native
Debian package. (There is no Debian revision.)
</p>
</li>
<li class="listitem">
<p>
<code class="filename">mypackage_1.0_i386.deb</code>
</p>
<p>
This is your completed binary package, as in the non-native Debian package.
(There is no Debian revision.)
</p>
</li>
<li class="listitem">
<p>
<code class="filename">mypackage_1.0_i386.changes</code>
</p>
<p>
This file describes all the changes made in the current package version as in
the non-native Debian package. (There is no Debian revision.)
</p>
</li>
</ul>
</div>
</div>
<div class="footnotes">
<br/>
<hr/>
<div id="ftn.idm3831" class="footnote">
<p><a href="#idm3831" class="para"><sup class="para">[88] </sup></a>
Alternatively: <code class="literal">readelf -d lib<em class="replaceable"><code>foo</code></em>.so.<em class="replaceable"><code>1</code></em> | grep SONAME</code>
</p>
</div>
<div id="ftn.idm3844" class="footnote">
<p><a href="#idm3844" class="para"><sup class="para">[89] </sup></a>
Alternatively: <code class="literal">readelf -d lib<em class="replaceable"><code>foo</code></em>.so.<em class="replaceable"><code>1</code></em> | grep NEEDED</code>
</p>
</div>
<div id="ftn.idm3858" class="footnote">
<p><a href="#idm3858" class="para"><sup class="para">[90] </sup></a>See <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-runtime">Debian Policy Manual, 8.1 "Run-time shared libraries"</a>.</p>
</div>
<div id="ftn.idm3864" class="footnote">
<p><a href="#idm3864" class="para"><sup class="para">[91] </sup></a>See <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-ldconfig">Debian Policy Manual, 8.1.1 "ldconfig"</a>.</p>
</div>
<div id="ftn.idm3882" class="footnote">
<p><a href="#idm3882" class="para"><sup class="para">[92] </sup></a>See <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-static">Debian Policy Manual, 8.3 "Static libraries"</a> and <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-dev">Debian Policy Manual, 8.4 "Development files"</a>.</p>
</div>
<div id="ftn.idm3889" class="footnote">
<p><a href="#idm3889" class="para"><sup class="para">[93] </sup></a>See <a class="ulink" href="http://wiki.debian.org/ReleaseGoals/LAFileRemoval">Debian wiki ReleaseGoals/LAFileRemoval</a>.</p>
</div>
<div id="ftn.idm3894" class="footnote">
<p><a href="#idm3894" class="para"><sup class="para">[94] </sup></a>See <a class="ulink" href="http://wiki.debian.org/RpathIssue">Debian wiki RpathIssue</a>.</p>
</div>
<div id="ftn.idm3907" class="footnote">
<p><a href="#idm3907" class="para"><sup class="para">[95] </sup></a>Backward-incompatible ABI changes normally require you to update the SONAME of the library and the shared library package name to new ones.</p>
</div>
<div id="ftn.idm3913" class="footnote">
<p><a href="#idm3913" class="para"><sup class="para">[96] </sup></a>For C++ libraries and other cases where tracking individual symbols is too difficult, follow <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps">Debian Policy Manual, 8.6.4 "The shlibs system"</a>, instead.</p>
</div>
<div id="ftn.idm3961" class="footnote">
<p><a href="#idm3961" class="para"><sup class="para">[97] </sup></a>
All previous versions of Debian packages are available at <a class="ulink" href="http://snapshot.debian.org/">http://snapshot.debian.org/</a>. The Debian revision is dropped from the version to make it easier to backport the package: <code class="literal">1.1</code> << <code class="literal">1.1-1~bpo70+1</code> << <code class="literal">1.1-1</code> and <code class="literal">1.2</code> << <code class="literal">1.2-1~bpo70+1</code> << <code class="literal">1.2-1</code>
</p>
</div>
<div id="ftn.idm3981" class="footnote">
<p><a href="#idm3981" class="para"><sup class="para">[98] </sup></a>
The Debian revision is dropped from the version to make it easier to backport the package: <code class="literal">1.3</code> << <code class="literal">1.3-1~bpo70+1</code> << <code class="literal">1.3-1</code>
</p>
</div>
<div id="ftn.idm3993" class="footnote">
<p><a href="#idm3993" class="para"><sup class="para">[99] </sup></a>
See <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-updates">Debian Policy Manual, 8.6.2 "Shared library ABI changes"</a>.
</p>
</div>
<div id="ftn.idm4019" class="footnote">
<p><a href="#idm4019" class="para"><sup class="para">[100] </sup></a>Old special purpose library paths such as <code class="filename">/lib32/</code> and <code class="filename">/lib64/</code> are not used anymore.</p>
</div>
<div id="ftn.idm4181" class="footnote">
<p><a href="#idm4181" class="para"><sup class="para">[101] </sup></a>
Alternatively, you can add <code class="literal">--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)</code> and <code class="literal">--libexecdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)</code> arguments to <code class="literal">./configure</code>. Please note that <code class="literal">--libexecdir</code> specifies the default path to install executable programs run by other programs rather than by users. Its Autotools default is <code class="filename">/usr/libexec/</code> but its Debian default is <code class="filename">/usr/lib/</code>.
</p>
</div>
</div>
</div>
<div class="navfooter">
<hr/>
<table width="100%" summary="Navigation footer">
<tr>
<td align="left"><a accesskey="p" href="upload.en.html"><img src="images/prev.png" alt="Prev"/></a> </td>
<td align="center"> </td>
<td align="right"> </td>
</tr>
<tr>
<td align="left" valign="top">Chapter 9. Uploading the package </td>
<td align="center">
<a accesskey="h" href="index.en.html">
<img src="images/home.png" alt="Home"/>
</a>
</td>
<td align="right" valign="top"> </td>
</tr>
</table>
</div>
</body>
</html>
|