This repository was archived by the owner on Feb 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Initial documentation for building packages #85
Merged
rkratky
merged 6 commits into
canonical:2.0-preview
from
tsimonq2:tsimonq2/building-packages
Jun 17, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15d60da
Initial documentation for building packages
tsimonq2 508c474
Fix indentation for bullet-pointed items
tsimonq2 6adbc06
Fix missing _ from links
tsimonq2 eaadfc0
Add a missing newline
tsimonq2 5f62b1e
Add another missed _
tsimonq2 8157485
Update 'Build packages' with lang. and formatting fixes
rkratky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,2 +1,162 @@ | ||||||
| Build packages | ||||||
| ============== | ||||||
|
|
||||||
| In Ubuntu, packages can be built in several ways, depending on the intended | ||||||
| artifacts. We cover the following types of builds: | ||||||
|
|
||||||
| * Source and binary (using ``sbuild`` for a clean environment) | ||||||
| * Binary-only (using ``sbuild`` for a clean environment) | ||||||
| * Source-only (using ``debuild``) | ||||||
| * Binary-only (using ``debuild`` and installed build dependencies) | ||||||
|
|
||||||
| (Many other backends are available, including an ``schroot``-based backend.) | ||||||
|
|
||||||
| Only source uploads are permitted to PPAs or the archive. That | ||||||
| being said, it is best practice to perform a local build and iron out any | ||||||
| potential issues prior to uploading it to any archive. | ||||||
|
|
||||||
|
|
||||||
| Prerequisites | ||||||
| ------------- | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ sudo apt install sbuild debhelper ubuntu-dev-tools piuparts | ||||||
|
|
||||||
| All of the following sections assume you have already fetched the packaging | ||||||
| and are in the same directory as :file:`debian/`. | ||||||
|
|
||||||
| For :manpage:`sbuild(1)`, follow the instructions on the Debian and Ubuntu | ||||||
| sbuild pages as linked in the Resources section. | ||||||
|
|
||||||
|
|
||||||
| ``sbuild``-based builds | ||||||
| ----------------------- | ||||||
|
|
||||||
| This is the standard way of building a package for Ubuntu. All of the Debian | ||||||
| and Ubuntu infrastructure use :manpage:`sbuild(1)`, so it is beneficial to | ||||||
| learn how to use it. For more information on setting up :manpage:`sbuild(1)`, | ||||||
| refer to the links in the Resources section. | ||||||
|
|
||||||
| To do a binary-only build of a package using ``sbuild``, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ sbuild -c <RELEASE>-<ARCH>[-shm] | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| .. note:: | ||||||
|
|
||||||
| It is possible to use ``-d`` instead of ``-c``, but that causes the produced | ||||||
| files to contain the entire chroot name (``<RELEASE>-<ARCH>[-shm]``) instead | ||||||
| of just ``<RELEASE>``. An example chroot name is ``noble-amd64-shm``. | ||||||
|
|
||||||
| To explicitly run Lintian following the build: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ sbuild -c <RELEASE>-<ARCH>[-shm] --run-lintian [--lintian-opts="-EvIiL +pedantic"] | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| To build a package without running :manpage:`dh_clean(1)`, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ sbuild -c <RELEASE>-<ARCH>[-shm] --no-clean-source | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| To build both a binary *and* a source package with one ``sbuild`` run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ sbuild -c <RELEASE>-<ARCH>[-shm] -s | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| .. note:: | ||||||
|
|
||||||
| Launchpad rejects uploads that contains both binaries and sources. | ||||||
| However, this is required for uploads to the Debian NEW queue. That being | ||||||
| said, uploads to Debian with binaries `do not migrate to Testing <https://lists.debian.org/debian-devel-announce/2019/07/msg00002.html>`_. | ||||||
|
|
||||||
| Here is a complete, working example of running the ``autopkgtest`` following the build: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ sbuild -c noble-amd64-shm --run-autopkgtest \ | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| --autopkgtest-virt-server=qemu \ | ||||||
| --autopkgtest-virt-server-opt="/path/to/autopkgtest-noble-amd64.img" \ | ||||||
| --autopkgtest-opt="--apt-pocket=proposed=src:qt6-base" \ | ||||||
| --autopkgtest-opt="-U" --autopkgtest-opt="--ram-size=12000" \ | ||||||
| --autopkgtest-opt="--setup-commands='apt-get -y install aptitude \ | ||||||
| && aptitude -t noble-proposed -y install qt6-base-dev=6.8.1+dfsg-0ubuntu1'" | ||||||
|
|
||||||
|
|
||||||
| Building with ``debuild`` | ||||||
| ------------------------- | ||||||
|
|
||||||
| :manpage:`debuild(1)` (short for :manpage:`dpkg-buildpackage(1)`) is | ||||||
| another tool used to build Debian packages. It is part of the | ||||||
| :manpage:`debhelper(7)` package and written in Perl. | ||||||
|
|
||||||
| Ubuntu maintain its own version the ``debhelper`` package. Therefore, | ||||||
| packages built on Debian may be slightly different than packages built on | ||||||
| Ubuntu. | ||||||
|
|
||||||
|
|
||||||
| Source-only builds | ||||||
| ~~~~~~~~~~~~~~~~~~ | ||||||
|
|
||||||
| To build a source package *without* including the upstream tarball, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ debuild -S -d | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick:
Suggested change
|
||||||
|
|
||||||
| To build a source package *with* the upstream tarball, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ debuild -S -d -sa | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| To build a source package without running Lintian, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ debuild --no-lintian -S -d | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| .. note:: | ||||||
|
|
||||||
| The ``--no-lintian`` flag only works in this case if it is first. | ||||||
|
|
||||||
| To build a source package without running :manpage:`dh_clean(1)`, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ debuild -S -d -nc | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
| .. note:: | ||||||
|
|
||||||
| This tends to fix failures regarding missing build dependencies. | ||||||
|
|
||||||
| To build a source package without a cryptographic signature (not recommended), run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ debuild -S -d -us -uc | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
|
|
||||||
| Local binary-only builds | ||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||
|
|
||||||
| This is really only useful for packages you need to test locally or | ||||||
| packages with minimal build dependencies. Otherwise use :manpage:`sbuild(1)`. | ||||||
|
|
||||||
| To do a binary-only build of a package, run: | ||||||
|
|
||||||
| .. code-block:: text | ||||||
|
|
||||||
| $ debuild -b | ||||||
|
rkratky marked this conversation as resolved.
|
||||||
|
|
||||||
|
|
||||||
| Resources | ||||||
| --------- | ||||||
|
|
||||||
| * `Chapter 6. Building the package (Debian New Maintainers' Guide) <https://www.debian.org/doc/manuals/maint-guide/build.html>`_ | ||||||
| * `SimpleSbuild (Ubuntu Wiki) <https://wiki.ubuntu.com/SimpleSbuild>`_ | ||||||
| * `sbuild (Debian Wiki) <https://wiki.debian.org/sbuild>`_ | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.