|
1 | 1 | Build packages |
2 | 2 | ============== |
| 3 | + |
| 4 | +In Ubuntu, packages can be built in several ways, depending on the intended |
| 5 | +artifacts. We cover the following types of builds: |
| 6 | + |
| 7 | +* Source and binary (using ``sbuild`` for a clean environment) |
| 8 | +* Binary-only (using ``sbuild`` for a clean environment) |
| 9 | +* Source-only (using ``debuild``) |
| 10 | +* Binary-only (using ``debuild`` and installed build dependencies) |
| 11 | + |
| 12 | +(Many other backends are available, including an ``schroot``-based backend.) |
| 13 | + |
| 14 | +Only source uploads are permitted to PPAs or the archive. That |
| 15 | +being said, it is best practice to perform a local build and iron out any |
| 16 | +potential issues prior to uploading it to any archive. |
| 17 | + |
| 18 | + |
| 19 | +Prerequisites |
| 20 | +------------- |
| 21 | + |
| 22 | +.. code-block:: text |
| 23 | +
|
| 24 | + $ sudo apt install sbuild debhelper ubuntu-dev-tools piuparts |
| 25 | +
|
| 26 | +All of the following sections assume you have already fetched the packaging |
| 27 | +and are in the same directory as :file:`debian/`. |
| 28 | + |
| 29 | +For :manpage:`sbuild(1)`, follow the instructions on the Debian and Ubuntu |
| 30 | +sbuild pages as linked in the Resources section. |
| 31 | + |
| 32 | + |
| 33 | +``sbuild``-based builds |
| 34 | +----------------------- |
| 35 | + |
| 36 | +This is the standard way of building a package for Ubuntu. All of the Debian |
| 37 | +and Ubuntu infrastructure use :manpage:`sbuild(1)`, so it is beneficial to |
| 38 | +learn how to use it. For more information on setting up :manpage:`sbuild(1)`, |
| 39 | +refer to the links in the Resources section. |
| 40 | + |
| 41 | +To do a binary-only build of a package using ``sbuild``, run: |
| 42 | + |
| 43 | +.. code-block:: text |
| 44 | +
|
| 45 | + $ sbuild -c <RELEASE>-<ARCH>[-shm] |
| 46 | +
|
| 47 | +.. note:: |
| 48 | + |
| 49 | + It is possible to use ``-d`` instead of ``-c``, but that causes the produced |
| 50 | + files to contain the entire chroot name (``<RELEASE>-<ARCH>[-shm]``) instead |
| 51 | + of just ``<RELEASE>``. An example chroot name is ``noble-amd64-shm``. |
| 52 | + |
| 53 | +To explicitly run Lintian following the build: |
| 54 | + |
| 55 | +.. code-block:: text |
| 56 | +
|
| 57 | + $ sbuild -c <RELEASE>-<ARCH>[-shm] --run-lintian [--lintian-opts="-EvIiL +pedantic"] |
| 58 | +
|
| 59 | +To build a package without running :manpage:`dh_clean(1)`, run: |
| 60 | + |
| 61 | +.. code-block:: text |
| 62 | +
|
| 63 | + $ sbuild -c <RELEASE>-<ARCH>[-shm] --no-clean-source |
| 64 | +
|
| 65 | +To build both a binary *and* a source package with one ``sbuild`` run: |
| 66 | + |
| 67 | +.. code-block:: text |
| 68 | +
|
| 69 | + $ sbuild -c <RELEASE>-<ARCH>[-shm] -s |
| 70 | +
|
| 71 | +.. note:: |
| 72 | + |
| 73 | + Launchpad rejects uploads that contains both binaries and sources. |
| 74 | + However, this is required for uploads to the Debian NEW queue. That being |
| 75 | + said, uploads to Debian with binaries `do not migrate to Testing <https://lists.debian.org/debian-devel-announce/2019/07/msg00002.html>`_. |
| 76 | + |
| 77 | +Here is a complete, working example of running the ``autopkgtest`` following the build: |
| 78 | + |
| 79 | +.. code-block:: text |
| 80 | +
|
| 81 | + $ sbuild -c noble-amd64-shm --run-autopkgtest \ |
| 82 | + --autopkgtest-virt-server=qemu \ |
| 83 | + --autopkgtest-virt-server-opt="/path/to/autopkgtest-noble-amd64.img" \ |
| 84 | + --autopkgtest-opt="--apt-pocket=proposed=src:qt6-base" \ |
| 85 | + --autopkgtest-opt="-U" --autopkgtest-opt="--ram-size=12000" \ |
| 86 | + --autopkgtest-opt="--setup-commands='apt-get -y install aptitude \ |
| 87 | + && aptitude -t noble-proposed -y install qt6-base-dev=6.8.1+dfsg-0ubuntu1'" |
| 88 | +
|
| 89 | +
|
| 90 | +Building with ``debuild`` |
| 91 | +------------------------- |
| 92 | + |
| 93 | +:manpage:`debuild(1)` (short for :manpage:`dpkg-buildpackage(1)`) is |
| 94 | +another tool used to build Debian packages. It is part of the |
| 95 | +:manpage:`debhelper(7)` package and written in Perl. |
| 96 | + |
| 97 | +Ubuntu maintain its own version the ``debhelper`` package. Therefore, |
| 98 | +packages built on Debian may be slightly different than packages built on |
| 99 | +Ubuntu. |
| 100 | + |
| 101 | + |
| 102 | +Source-only builds |
| 103 | +~~~~~~~~~~~~~~~~~~ |
| 104 | + |
| 105 | +To build a source package *without* including the upstream tarball, run: |
| 106 | + |
| 107 | +.. code-block:: text |
| 108 | +
|
| 109 | + $ debuild -S -d |
| 110 | +
|
| 111 | +To build a source package *with* the upstream tarball, run: |
| 112 | + |
| 113 | +.. code-block:: text |
| 114 | +
|
| 115 | + $ debuild -S -d -sa |
| 116 | +
|
| 117 | +To build a source package without running Lintian, run: |
| 118 | + |
| 119 | +.. code-block:: text |
| 120 | +
|
| 121 | + $ debuild --no-lintian -S -d |
| 122 | +
|
| 123 | +.. note:: |
| 124 | + |
| 125 | + The ``--no-lintian`` flag only works in this case if it is first. |
| 126 | + |
| 127 | +To build a source package without running :manpage:`dh_clean(1)`, run: |
| 128 | + |
| 129 | +.. code-block:: text |
| 130 | +
|
| 131 | + $ debuild -S -d -nc |
| 132 | +
|
| 133 | +.. note:: |
| 134 | + |
| 135 | + This tends to fix failures regarding missing build dependencies. |
| 136 | + |
| 137 | +To build a source package without a cryptographic signature (not recommended), run: |
| 138 | + |
| 139 | +.. code-block:: text |
| 140 | +
|
| 141 | + $ debuild -S -d -us -uc |
| 142 | +
|
| 143 | +
|
| 144 | +Local binary-only builds |
| 145 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 146 | + |
| 147 | +This is really only useful for packages you need to test locally or |
| 148 | +packages with minimal build dependencies. Otherwise use :manpage:`sbuild(1)`. |
| 149 | + |
| 150 | +To do a binary-only build of a package, run: |
| 151 | + |
| 152 | +.. code-block:: text |
| 153 | +
|
| 154 | + $ debuild -b |
| 155 | +
|
| 156 | +
|
| 157 | +Resources |
| 158 | +--------- |
| 159 | + |
| 160 | +* `Chapter 6. Building the package (Debian New Maintainers' Guide) <https://www.debian.org/doc/manuals/maint-guide/build.html>`_ |
| 161 | +* `SimpleSbuild (Ubuntu Wiki) <https://wiki.ubuntu.com/SimpleSbuild>`_ |
| 162 | +* `sbuild (Debian Wiki) <https://wiki.debian.org/sbuild>`_ |
0 commit comments