Maintain Ubuntu Desktop software¶
These are some common, day-to-day operations to build, maintain and package GNOME software for Ubuntu Desktop using the Git Build Package (gbp) workflow.
We use the gnome-control-center repository as an example.
Note
Some applications on Ubuntu Desktop are developed outside of Salsa and GNOME. They have their own, separate workflows, which aren’t described in this guide. The Desktop Team can help you find the right instructions on Matrix: #desktop-dev:ubuntu.com.
Prerequisites¶
Before you start, follow the instructions in Set up Git for Ubuntu Desktop work.
Workflow overview for external contributors¶
If you’re a community contributor and not a member of the Ubuntu Desktop Team, you have to send your contributions through a merge request:
Fork the Git repository on Salsa.
Follow this guide and make the changes in your fork.
Open a Salsa merge request from your fork to the original repository.
In some projects, no Ubuntu branch has been created in a long time. You might have to ask the Desktop Team to create the new branch for you. Contact them on Matrix at #desktop-dev:ubuntu.com.
Local changes¶
With the suggested Git configuration, any non-committed changes (file modifications, additions, or removal) halt the build because they won’t be included. This is a safety reminder.
What you can do when you have such changes:
Ignore them. The resulting package and build won’t include those uncommitted changes. The
../build-area/<your-package>directory will match the last commit.To do this, add the
--git-ignore-newGit option.Force using the current directory with your local modifications instead of the
build-areadirectory, and include any local modifications to the package despite theignore-newoption.For this, add the
--git-ignore-new --git-export=INDEXoptions togbp.
Refresh branches¶
Use the following command to refresh the current ubuntu/<release> branch and the corresponding upstream/<release> branch. This applies only to the branches referenced in the debian/gbp.conf file on your current checkout. Also refresh the pristine-tar branch.
For example, on the
ubuntu/latestbranch:The
pristine-tarbranch has been updated as referenced indebian/gbp.conf.If you have a separate
ubuntu/noblebranch with its ownupstream/46.xbranch:
The gbp pull command, contrary to git pull, is a way to avoid checking out each branch and pulling them one by one.
Push your Git changes to Salsa¶
To contribute changes back to Salsa, push your changes using gbp:
Merge a new upstream version to latest¶
When upstream releases a new version of a given project, you can merge the version on the Debian and Ubuntu latest branches.
This applies when upstream releases the latest version of the latest series: for example when version 50.0 or 50.2 comes out, and version 51 hasn’t been released yet. Always merge new major releases on the latest branch. If you’re merging a new maintenance release of an earlier series, follow Merge a new upstream version to maintenance instead.
Switch to the branch where you want to import the new version, such as
ubuntu/latest:Create a
patch/queue/ubuntu/latestbranch that is useful in case you need to refresh patches later.If you already have the
patch/queuebranch, rebase it:Otherwise, create the
patch/queuebranch:
Check whether this upstream version already exists in Debian:
If Debian already has the upstream version, you don’t have to import the tarball. Merge with the latest upstream code:
The new upstream version is now merged. Push the changes:
Merge a new upstream version to Debian¶
If Debian doesn’t have the new upstream version, add the release to Debian and Ubuntu.
Scan for new releases:
Is
uscanshowing the upstream release that you want to import?If so, you can let
gbpdownload and import the latest release automatically:Otherwise, download the tarball with the new upstream release manually. Then, import the tarball:
Push all related branches:
The
gbptool handles all branches automatically. In the example of this upstream release,gbppushes theubuntu/latest,pristine-tarball+upstream/46.xorupstream/latestbranches.Sync the affected upstream branch to Salsa, or push it to your fork and propose it as a merge request if you aren’t an Ubuntu developer.
Check for dependency changes¶
New upstream releases often change the dependencies of the application. Check for changes.
For example, if the application uses the Meson build system and you’ve updated from version 49.alpha to 49.0:
Reflect the updated package dependencies in the debian/control file. For details, see debian/ directory.
Troubleshooting¶
You might get the following errors when importing the tarball.
Revision not found¶
The reason might be one of the following:
You didn’t get the latest commits and tags in your repository metadata. Fetch them:
Upstream has changed the tagging pattern. Update the
upstream-tagvalue in thedebian/gbp.conffile to match it. For details, see No upstream tarballs in thegbpdocumentation.Upstream is using an inconsistent release pattern. Therefore, the
debian/gbp.conffile can’t use a regular expression for the version.Find the exact tag:
Specify the version manually:
Upstream tag already exists¶
This error means that Debian already has this tarball. Merge from Debian as described in Merge a new upstream version to latest.
Merge a new upstream version to maintenance¶
When upstream releases a new version of a given project, you can merge the version on an Ubuntu maintenance branch. A maintenance branch is a branch for stable releases and backports.
This applies when upstream releases a new version of an earlier series, older than the current major version: for example when version 49.3 comes out, and the latest branch already contains version 50.0. If you’re merging a new release of the latest series, follow Merge a new upstream version to latest instead.
If main has a newer version than the maintenance branch and you are the first one to deal with that case for that maintenance release, additional steps are required.
Check if the
debian/gbp.conffile sets theupstream-branch=upstream/latestoption.Check if the
ubuntu/latestbranch has a newer upstream version than the one that you are importing, which was never imported.For example:
ubuntu/latestis on 46.2.ubuntu/nobleis on 46.1, and we want to update to 46.2.The
pristine-tarlog lists that 46.1 and 46.2 have been imported.Consequently, the
upstream/latestbranch has upstream commits and tags for 46.1, 46.2 and correspondinggbptagsupstream/46.1andupstream/46.2.
If the option is present and
ubuntu/latestis newer, proceed with the next steps.Otherwise, follow these sections:
Switch to the maintenance branch.
Merge a new upstream version, while on the maintenance branch.
Switch to the maintenance branch:
Create a new
upstream/<series>branch:Checkout the latest version of
upstream/latestin your maintenance branch. In this example, it’supstream/46.1:Update the
debian/gbp.conffile to reference the correct upstreamgbpbranch:debian/gbp.conf¶upstream-branch=upstream/46.x
Commit the changes:
Check whether Debian already has the new version in Salsa:
If the version already exists in Debian, use Debian’s upstream branch tags:
Push the
upstreamandpristine-tarbranches to Salsa:
Add the maintenance version in Debian¶
If the version doesn’t exist in Debian yet, add it to Debian and Ubuntu using an upstream tarball.
Fetch from upstream:
Scan for new releases:
Is
uscanshowing the upstream release that you want to import?If so, you can let
gbpdownload and import the latest release automatically:Otherwise, download the tarball with the new upstream release manually. Then, import the tarball:
Push your changes, including the new branch that you want to track:
Push the
upstreamandpristine-tarbranches to Salsa.You can push directly to the GNOME branch if you have the permissions. Otherwise, push to your personal fork and prepare a merge request.
Refresh patches¶
Before merging with an upstream release, refresh the patches.
Rebase the
pqbranch:Use the Git rebase tools to refresh the patches.
Troubleshooting¶
The rebase might not work in certain cases, such as if you’re merging with an upstream/x.z.y tag or if you didn’t create the patch/queue branch first. In those cases, follow these steps:
Switch to the corresponding branch.
If the
patch-queuebranch exists, remove it:Try to find the earliest point where the patches still apply. Increase the value until you find the previous release commit:
Replace
30with a number that determines how far in history you want to look for the patches. The exact number depends on the size of your repository. Larger numbers provide better results, but the search gets increasingly slow, so start small.Re-apply the
debian/patches/seriesfile on top of the new upstream code, stopping for manual action if needed:If a patch doesn’t apply cleanly, fix it:
Resolve the conflict, and record the fix using
git addorgit rm.Proceed with
git rebase --continue.
If the
--time-machinestep orgbp pq rebasefail, import the patches into thepqbranch manually from a file:Regenerate the
debian/patchesdata:Switch back to your
ubuntu/latestorubuntu/<series>branch.Commit the changes.
See also¶
Importing a new upstream version in the gbp documentation.
Add or modify patches¶
You can turn patch files into commits on a branch. This enables you to add new patches or modify existing ones.
Note
We recommend that you manage patches using the gbp tool on Ubuntu Desktop software, as described here. For the legacy patching workflow using the quilt tool, see How to work with Debian patches.
Switch to the correct
ubuntu/branch or your localexperimental-featurebranch. For example:Turn all patches from the
debian/patches/directory into Git commits:This command creates the
patch-queue/ubuntu/latestbranch and switches to it. This branch is based on theubuntu/latestbranch, and all patches referenced in thedebian/patches/seriesfile are applied as separate commits on top of it.Check the commits:
This is similar to using
git logto browse the commits, which also works.Add or modify patches:
Modify the software. Fix a bug or add a new feature. This will be the content of your new patch.
When you commit your changes, every new commit turns into a separate patch applied at the end of the
debian/patches/seriesfile. The commit description is then converted to the patch description.If you want to build a package with the current content without having to switch your branch, use the following command:
Reorder your patches. If you don’t want this patch to be the last one, use an interactive Git rebase:
There, reorder the patches as commits, amend or stash them. Removing a commit also removes the patch from the
debian/patches/seriesfile.Remove or edit patches. Any change to the commits results in the same change to the patch files.
For example, you can use Git commit with the
--amendoption to modify the commit history. For details, see Git Tools - Rewriting History.
Reapply all your changes to the original branch:
Update the changelog. For details, see Update the changelog.
The new patches end up as unstaged changes on your branch. Commit your changes.
Cherry-pick upstream commits¶
You can cherry-pick an upstream commit into a patch file.
Switch to the branch where you want to add the cherry-picked commit. For example, on the
ubuntu/latestbranch:Update the branch:
Turn patches into commits:
Display the upstream Git log in the patch format. Note the hash of the commit that you want to cherry-pick:
Cherry-pick your selected commit using its hash and edit the commit message:
Are there any conflicts?
If there are no conflicts, edit the commit message to comply with DEP 3 - patch file headers. This ends up as the patch header.
If there are conflicts:
Fix them. For example:
Continue with cherry-picking:
Edit the commit message to comply with DEP 3 - patch file headers.
Reapply all your changes to the original branch:
Update the changelog. For details, see Update the changelog.
Commit the changes:
For details about gbp pq, see Add or modify patches.
Update the changelog¶
You can edit the debian/changelog file manually, but it’s recommended to use the following command instead:
By default, this command adds the first line of every commit to the changelog. You can adjust this behavior by including a string at the end of your commit message:
Gbp-Dch: FullAdd this full commit message, not just the first line.
Gbp-Dch: IgnoreSkip this commit in the changelog.
Alternatively, you can include all the commit descriptions:
Then, filter them out by hand at the commit phase.
Import an Ubuntu upload tracked outside of Git¶
You can import a Debian Source Control (DSC) source package as a tarball, even if it doesn’t exist in Git.
Download the source tarball.
You can download the tarball that belongs to an Ubuntu release, like Noble:
Or you can download the tarball based on a package version:
Switch to the branch where you want to place this Ubuntu upload.
Import the tarball:
If there had been changes in your tree, importing the latest tarball reverted all previous changes in Git.
Important
Do not use Git rebase to restore your changes (which would rewrite history) because everyone who pulls from the repository would have conflicts upon refreshing.
Reintroduce your changes by cherry-picking the commits. Because your commits are already in tree but reverted, you must cherry-pick using the following commands:
Push the changes:
This pushes all needed branches, such as
ubuntu/latest, andpristine-tarball+upstream/latestif this upload is a new upstream release.
Create a new maintenance branch¶
Find the latest version in common between the development release and that maintenance branch.
Here, we use the
ubuntu/1%46.1-0ubuntu4version tag as an example.Create a branch from the starting point.
In the
debian/gbp.conffile, changedebian-branchtoubuntu/noble:debian/gbp.conf¶debian-branch = ubuntu/noble
In the
debian/controlfile, changeVcs-Browserto the branch’s page onhttps://salsa.debian.org/<package>/tree/<branch>. For example:debian/control¶Vcs-Browser: https://salsa.debian.org/gnome-team/gnome-control-center/tree/ubuntu/noble
Note
Certain outdated projects might still use the
debian/control.infile. To generatedebian/controlfrom it, use thedh_gnometool during thecleantarget in thedebian/rulesfile.At the end of the
Vcs-Gitvalue, use the-b ubuntu/nobleoption. For example:debian/control¶Vcs-Git: https://salsa.debian.org/gnome-team/gnome-control-center.git -b ubuntu/noble
Make sure that the
XS-Debian-Vcs-GitandXS-Debian-Vcs-Browserfields are set to theVcs-*values but without their Ubuntu versions:XS-Debian-Vcs-Git: https://salsa.debian.org/gnome-team/gnome-control-center.git XS-Debian-Vcs-Browser: https://salsa.debian.org/gnome-team/gnome-control-center
Commit the changes:
Push your changes to Salsa:
Build a package locally¶
To build a local package, we use the sbuild framework and specify the target Ubuntu release. We don’t recommend building the package directly on your system without using sbuild because the test and build phase might be affected by the state of your machine.
Build a binary package for your Ubuntu release and CPU architecture. For example, Ubuntu Noble on the AMD64 architecture:
Build a source package:
With the proposed configuration, the artifacts all end up in the ../build-area directory, including the tarball, which is reconstructed from the pristine-tar + upstream/latest branch. The build directory is then cleaned up.
Useful tips in some potential cases:
Don’t purge the
build-areadirectory after building:Build current branch with local uncommitted modifications:
When merging with Debian, releasing an SRU or uploading a version on top of one that is still in the proposed pocket, include both the Ubuntu and Debian part of the changelog in the
.changesfile, which is generated bydpkg-genchanges. Including all changelog entries ensures that bugs are automatically closed.Add the
-vXoption to include all Debian and Ubuntu versions greater thanX, which is the current version inmain,securityorupdatesrepositories:For example, see the
gnome-control-center_49.0-1ubuntu2_source.changesgenerated file.
Release a new version¶
Note
If this is a sponsored upload, the sponsor performs these steps.
Generate the changelog for native packages. For details, see Update the changelog.
You might need to manually edit the
debian/changelogfile to improve its syntax and clarity.Finalize the changelog and specify the Ubuntu release:
Tag the package:
Build the source package:
If this version hasn’t arrived in the
mainrepository yet, include both the Ubuntu and Debian part of the changelog in the.changesfile, which is generated bydpkg-genchanges. Add the-vXoption to include all Debian and Ubuntu versions greater thanX, whereXis the current version inmain,securityorupdatesrepositories:For example, consider the following scenario:
The
mainpocket contains version3.1.0-1ubuntu1.The
proposedpocket contains3.1.0-1ubuntu2.You’re uploading version
3.1.0-2ubuntu1.
In this case, use the
-v3.1.0-1ubuntu1option so that the changes in3.1.0-1ubuntu2are also listed in the change files.Check the
../build-area/<your-package>.changesfile to make sure that it’s correct. This file instructsdputwhich files to upload and provides a high-level view of the changes, such as the latest changelog entries.For example, changes to the GNU Hello program as packaged for Ubuntu would be described in the
hello_2.10-0ubuntu1.changesfile.Upload the files to the Ubuntu package upload queue:
Push the changes to Salsa:
This pushes all tracked branches to Salsa if you made any changes. The branches include:
ubuntu/latestubuntu/old-seriespristine-tarupstream/lastest