Dgit brings Git to the Debian archive
Git Happy
Dgit combines the Debian archive with a Git repository, giving package maintainers some totally new options for managing Debian source packages.
Version management systems are a fundamental building block of professional software development. Many projects use Git [1], a version control tool created by Linux founder Linus Torvalds for the Linux kernel developer community. Git offers a distributed development environment with many benefits, such as revision management and flexibility with exchanging code, but it is difficult for a development project with large, legacy archives to interface with the Git environment. A helpful tool known as dgit brings the power of Git to the entire Debian archive. See Table 1.
Table 1
Package Maintenance Workflow with dgit
Command | Comment |
---|---|
dgit clone project |
Retrieve any package from the archive |
cd project/ |
Change to the source directory |
git branch |
Check the current Git branch; result: |
git remote add upstream https://github.com/developer/project |
Set up an upstream repository as an additional remote |
dch -i |
Increment package version in |
Source Package On-Going Development |
|
debcommit -a -e |
Commit with the last Changelog entry as a message |
git status |
Check for overlooked files |
sudo sbuild-createchroot unstable /var/lib/sbuild/unstable-amd64 http://httpredir.debian.org/debian/ |
Set up an Sbuild chroot (architecture also needs to be adapted) |
dgit -wdd --mergechanges:-i sbuild |
Build a new source and binary package with Sbuild |
lintian -iI --color=auto ../projekt_1.0.0-1_amd64.changes |
Check built packages for problems (package: |
sudo dpkg --install ../projekt_1.0.0-1_amd64.deb |
Install binary package |
dgit push |
Upload new package to archive, tag current commit and synchronize with Dgit repository |
Dgit which was created by Ian Jackson, treats the whole Debian archive as a version control system and serves as a "bidirectional gateway between the archive and Git." Dgit [2] lets users load arbitrary source packages from the archive into a local Git repository, then work on them with Git techniques, and finally build the binaries (Figure 1). Package maintainers can use dgit to feed their changes back into the Debian archive.
Clones
Developers install dgit as a CLI tool. The dgit clone <packagename>
command (Figure 2) retrieves any source package from the Debian archive [3]. This step is equivalent to calling apt-get source <packagename>
, although you do not need to state a deb-src
package source in the /etc/apt/sources.list
file. After downloading with dgit, you'll be missing the registry file (.dsc
) and the tarball with the Debian files (.debian.tar.xz
), but there is no need to unpack the source package using dpkg-source -x
.
The source directory is now controlled by Git; you can check this by going to the source directory and by typing git status
. To see whether someone has already managed the package with dgit, you can run the git log
command. If not, you will see a comment telling you that the package was imported from the archive.
If you do not specify a Debian branch (using dgit <packagename> <branch>
), Debian retrieves the source package from the Unstable developer version. You can verify this branch name by reference to the name of the current Git branch by typing git branch
; in the example, the response will be dgit/sid
.
Package Maintenance
Administrators maintain packages by writing patches for changes to the upstream code or modifying the control files in debian/
. Dgit offers you all the Git options for your work on the source directory, thus providing an uncomplicated way of trying things out and reworking changes that you stored, or letting you simply discard the changes. If desired, you can use experimental Git branches for your development.
Debian maintainers can use Debian package maintenance tools in a Git repository (Figure 3). For example, Debcommit (package: devscripts
) automatically generates commit messages from entries in debian/changelog
.
Some developer groups have been maintaining their packages in public Git repositories for a long time. The matching URL is stored in the Vcs-Git
field of the debian/control
file. Dgit automatically sets up the group repository as an additional remote repository after cloning; this leads to a Remote: vcs-git
entry in the .git/config
file.
For a three-way exchange of code, users could include the upstream repository to the Git remotes. It's easy to use this source for cherry-picking from the latest code in a local copy of the upstream repository in Debian patches.
Building
If you want to upload a new package version to the archive or generate binary packages (.deb
), you can build from within the Git directory. Dgit offers wrappers for various build tools, such as the chroot builder Sbuild [4]. If a chroot [5] of Unstable already exists, dgit builds the new source package along with the binary packages with the dgit sbuild
command, optionally in a RAM overly. However, you need to specify the dgit cleaning option, -wdd
, to work around the availability check before changes to the chroot environment.
Another useful default setting in dgit is automatically applying the mergechanges scripts after the build (package: devscripts
). This setting references the _<arch>.changes
file to create another _multi.changes
file that is suitable for source-only uploads. Dgit prefers this approach when uploading; the Build network then rebuilds the binary package for the architecture used locally – which is the generally recommended approach. For this strategy to work properly, you need to specify the --mergechanges:-i
dgit option or configure the tool with this option.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.