How to get the source of a package¶
Before you can work on a source package, you need to get the source code of that package. This article presents four ways to achieve this:
git-ubuntupull-pkgapt-get sourcedget
git-ubuntu¶
git-ubuntu is the modern way of working with Ubuntu source packages.
Warning
git-ubuntu is still in active development and these instructions will likely change over time. While git-ubuntu will become the default packaging method, for now you may encounter rough edges or unsupported edge cases. Ask for help in the #ubuntu-devel channel or open a bug report on Launchpad. Bug reports are very welcome!
Install¶
To install git-ubuntu:
sudo snap install --classic --edge git-ubuntu
Basic use¶
To clone a source package Git repository to a directory:
git-ubuntu clone PACKAGE [DIRECTORY]
To generate the orig tarballs for a given source package:
git-ubuntu export-orig
Example¶
git-ubuntu clone hello
cd hello
git-ubuntu export-orig
pull-pkg¶
The pull-pkg command is part of the ubuntu-dev-tools package and downloads a specific version of a source package, or the latest version from a specified release.
Install¶
To install ubtuntu-dev-tools, which includes pull-pkg:
sudo apt install ubuntu-dev-tools
Basic use¶
pull-pkg [OPTIONS] PACKAGE-NAME [SERIES|VERSION]
Further information in the manual page pull-pkg(1).
Examples¶
There are convenience scripts that follow a similar syntax and set the OPTIONS for pull type and distribution appropriately. Here are three examples:
pull-lp-source¶
To download the latest version of the
hellosource package for the Current Release in Development from Launchpad:pull-lp-source helloTo download the latest version of the
hellosource package for the Ubuntumanticrelease from Launchpad:pull-lp-source hello mantic
To download version
2.10-3of thehellosource package from Launchpad:pull-lp-source hello 2.10-3
pull-ppa-source¶
To download the latest version of the
hellosource package from the Launchpad Personal Package Archive (PPA), also calledhello, of the userdviererbe:pull-ppa-source --ppa 'dviererbe/hello' 'hello'
To download the latest version of the
hellosource package for themanticrelease from the same Launchpad PPA:pull-ppa-source --ppa 'dviererbe/hello' 'hello' 'mantic'
To download version
2.10-3of thehellosource package for themanticrelease from the same Launchpad PPA:pull-ppa-source --ppa 'dviererbe/hello' 'hello' '2.10-3'
pull-debian-source¶
To download the latest version of the
hellosource package from Debian:pull-debian-source 'hello'
To download the latest version of the
hellosource package for thesidrelease from Debian:pull-debian-source 'hello' 'sid'
To download the version
2.10-3of thehellosource package from Debian:pull-debian-source 'hello' '2.10-3'
apt-get source¶
The APT package manager can also fetch source packages.
Important
Source packages are tracked separately from binary packages via deb-src lines in the sources.list(5) files. This means you need to add such a line for each repository you want to get source packages from; otherwise you get either the wrong (too old or too new) source package versions – or none at all.
Basic use¶
apt source PACKAGE-NAME
Further information in the manual page apt(8).
apt-get source PACKAGE-NAME
Further information in the manual page apt-get(8).
Example¶
apt source 'hello'
apt-get source 'hello'
dget¶
The dget command is part of the devscripts package. If you call it with the URL of a .dsc or .changes file it acts as a source package-aware wget(1) and downloads all associated files that are listed in the .dsc or .changes file (Debian tarball, orig tarballs, upstream signatures).
Install¶
sudo apt install devscripts
Basic use¶
dget URL
Example¶
Go to Launchpad and select the package to download (in this example, the latest version of the
hellosource package).Copy the download link of the
.dscfile:Call
dgetwith the copied URL:dget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/hello/2.10-3/hello_2.10-3.dsc
This works for links from Debian and Launchpad PPAs, too.
Further information in the manual page dget(1).