Table of Contents
Up to “Chapter 9, 高级打包”, we focused on packaging operations without using Git or any other VCS. These traditional packaging operations were based on the tarball released by the upstream as mentioned in “Section 9.1, “Historical perspective””.
Currently, the git(1) command is the de-facto platform for the VCS tool and is the essential part of both upstream development and Debian packaging activities. (See Debian wiki “Debian git packaging maintainer branch formats and workflows” for existing VCS workflows.)
Note | |
---|---|
Since the non-native Debian source package uses “diff -u” as its backend technology for the maintainer modification, it can’t represent modification involving symlink, file permissions, nor binary data (March 2022 discussion on debian-devel@l.d.o). Please avoid making such maintainer modifications even though these can be recorded in the Git repository. |
Since VCS workflows are complicated topic and there are many practice styles, I only touch on some key points with minimal information, here.
Salsa is the remote Git repository service with associated tools. It offers the collaboration platform for Debian packaging activities using a custom GitLab application instance. See:
There are 2 styles of branch names for the Git repository used for the packaging. See “Section 10.4, “Branch names””.
There are 2 main usage styles for the Git repository for the packaging. See:
There are 2 notable Debian packaging tools for the Git repository for the packaging.
gbp(1) and its subcommands:
dgit(1) and its subcommands:
It is highly desirable to host Debian source code package on Salsa. Over 90% of all Debian source code packages are hosted on Salsa. [20]
The exact VCS repository hosting an existing Debian source code package can
be identified by a metadata field Vcs-*
which can be
viewed with the apt-cache showsrc <package-name>
command.
After signing up for an account on Salsa, make sure that the following pages have the same e-mail address and GPG keys you have configured to be used with Debian, as well as your SSH key:
Salsa runs Salsa CI service as an instance of GitLab CI for “Section 9.4, “持续集成””.
For every “git push” instances, tests which mimic tests run on the official Debian package service can be run by setting Salsa CI configuration file “Section 6.13, “debian/salsa-ci.yml file”” as:
--- include: - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml # Customizations here
The Git repository for the Debian packaging should have at least 2 branches:
In this tutorial, old style branch names are used in examples for simplicity.
Note | |
---|---|
This upstream-branch may need to be created using the tarball released by the upstream independent of the upstream Git repository since it tends to contain automatically generated files. |
The upstream Git repository content can co-exit in the local Git repository used for the Debian packaging by adding its copy. E.g.:
$ git remote add upstream-git <url-upstream-git-repo> $ git fetch upstream-git master:upstream-master
This allows easy cherry-picking from the upstream Git repository for bug fixes.
The patch unapplied Git repository can be summarized as:
The source tree matches extracted contents by “dpkg-source -x --skip-patches” of the Debian source package.
This repository style is useful for all variants of traditional workflows and gdb based workflow:
“Section 5.10, “Patch by “diff -u” approach””
Use helper scripts such as dquilt(1) and gbp-pq(1) to manage data in debian/patches/* files.
Use dput(1) to upload the Debian source package.
Note | |
---|---|
The debian/source/local-options and debian/source/local-patch-header files are meant to be recorded by the git command. These aren’t included in the Debian source package. |
The patch applied Git repository can be summarized as:
The source tree matches extracted contents by “dpkg-source -x” of the Debian source package.
Use one of workflow styles:
dgit-maint-merge(7) workflow.
dgit-maint-debrebase(7) workflow.
The gbp command is provided by the git-buildpackage package.
Use “gbp import-orig” to import the new upstream tar to the git repository.
Use “gbp buildpackage” to build the Debian binary package from the git repository.
Package history management with the git-buildpackage package is becoming the standard practice for many Debian maintainers. See more at:
The dgit command is provided by the dgit package.
This command is designed to manage contents of “Section 10.6, “Patch applied Git repository”” efficiently.
The new dgit package offers commands to automate packaging activities using the git repository as an alternative to still popular gbp-buildpackage. Please read their guide:
The dgit(1) command can push the easy-to-trace change history to the https://browse.dgit.debian.org/ site and can upload Debian package to the Debian repository properly without using dput(1).
The concept around dgit is beyond this tutorial document. Please start reading relevant information:
For “Section 10.5, “Patch unapplied Git repository””, you can generate debian/patches/* files using the gbp-pq(1) command from git commits in the through-away patch-queue branch.
Unlike dquilt which offers similar functionality as seen “Section 5.11, “Patch by dquilt approach”” and “Section 8.5, “Manage patch queue with dquilt””, gbp-pq doesn’t generate .pc/* files.
You can add, drop, and refresh debian/patches/* files with gbp-pq to manage patch queue.
If the package is managed in “Section 10.5, “Patch unapplied Git repository”” using the git-buildpackage package, you can revise the upstream source to fix bug as the maintainer and release a new Debian revision using gbp pq.
Add a new patch recording the upstream source modification on the file buggy_file as:
$ git checkout master $ gbp pq import gbp:info: ... imported on 'patch-queue/master $ vim buggy_file ... $ git add buggy_file $ git commit $ gbp pq export gbp:info: On 'patch-queue/master', switching to 'master' gbp:info: Generating patches from git (master..patch-queue/master) $ git add debian/patches/* $ dch -i $ git commit -a -m "Closes: #<bug_number>" $ git tag debian/<version>-<rev>
Drop (== disable) an existing patch
Refresh debian/patches/* files to make “dpkg-source -b” work as expected after updating a Debian package to the new upstream release.
$ git checkout master $ gbp pq --force import # ensure patch-queue/master branch gbp:info: ... imported on 'patch-queue/master $ git checkout master $ gbp import-orig --pristine-tar --uscan ... gbp:info: Successfully imported version ?.?.? of ../packagename_?.?.?.orig.tar.gz $ gbp pq rebase ... resolve conflicts and commit to patch-queue/master branch $ gbp pq export gbp:info: On 'patch-queue/master', switching to 'master' gbp:info: Generating patches from git (master..patch-queue/master) $ git add debian/patches $ git commit -m "Update patches" $ dch -v <newversion>-1 $ git commit -a -m "release <newversion>-1" $ git tag debian/<newversion>-1
For Debian source packages named “<source-package>” recorded in the snapshot.debian.org archive, an initial git repository managed in “Section 10.5, “Patch unapplied Git repository”” with all of the Debian version history can be generated as follows.
$ gbp import-dscs --debsnap --pristine-tar <source-package>
Here are some hints around dgit-maint-debrebase(7). [21]
See dgit-maint-debrebase(7), dgit(1) and git-debrebase(1) for more.
The quasi-native packaging scheme packages a source without the real upstream tarball using the non-native package format.
Tip | |
---|---|
Some people promote this quasi-native packaging scheme even for programs written only for Debian since it helps to ease communication with the downstream distros such as Ubuntu for bug fixes etc. |
This quasi-native packaging scheme involves 2 preparation steps:
Organize its source tree almost like native Debian package (see “Section 6.4, “原生 Debian 软件包””) with debian/* files with a few exceptions:
Generate missing upstream tarball preferably without debian/* files.
The rest is the same as the non-native packaging workflow as written in “Section 6.1, “打包工作流””.
Although this can be done in many ways (“Section 15.4, “Snapshot upstream tarball (-d, -t)””), you can use the Git repository and “git deborig” as:
$ cd /path/to/<dirname> $ dch -r ... set its <version>-<revision>, e.g., 1.0-1 $ git tag -s debian/1.0-1 $ git rm -rf debian $ git tag -s upstream/1.0 $ git commit -m upstream/1.0 $ git reset --hard HEAD^ $ git deborig $ sbuild