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-ubuntu
, pull-pkg
, and
apt-get source
, and dget
.
git-ubuntu¶
Note
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. You can ask for help in the #ubuntu-devel
channel or open a bug report on Launchpad.
Bug reports are very welcome!
Install¶
The following command will install git-ubuntu
:
sudo snap install --classic --edge git-ubuntu
Basic usage¶
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
You can find further information in these two blog articles (note that they are from 2017):
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¶
The following command will install ubtuntu-dev-tools
, which includes
pull-pkg
:
sudo apt update && sudo apt install ubuntu-dev-tools
Basic usage¶
pull-pkg [OPTIONS] PACKAGE-NAME [SERIES|VERSION]
You can find further information on 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 (although there are others):
pull-lp-source
¶
To download the latest version of the
hello
source package for the Current Release in Development from Launchpad:pull-lp-source hello
To download the latest version of the
hello
source package for the Ubuntumantic
release from Launchpad:pull-lp-source hello mantic
To download version
2.10-3
of thehello
source package from Launchpad:pull-lp-source hello 2.10-3
pull-ppa-source
¶
To download the latest version of the
hello
source 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
hello
source package for themantic
release from the same Launchpad PPA:pull-ppa-source --ppa 'dviererbe/hello' 'hello' 'mantic'
To download version
2.10-3
of thehello
source package for themantic
release 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
hello
source package from Debian:pull-debian-source 'hello'
To download the latest version of the
hello
source package for thesid
release from Debian:pull-debian-source 'hello' 'sid'
To download the version
2.10-3
of thehello
source 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 that you will need to add
such a line for each repository you want to get source
packages from; otherwise you will probably get either the wrong (too old/too new)
source package versions – or none at all.
Basic usage¶
apt source PACKAGE-NAME
You can find further information on the manual page apt(8).
apt-get source PACKAGE-NAME
You can find further information on 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 update && sudo apt install devscripts
Basic usage¶
dget URL
Example¶
Go to Launchpad and select the package you want to download (in this example;
the latest version of the hello
source package):

Next, copy the download link of the .dsc
file:

- Finally, call
dget
with the copied URL: dget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/hello/2.10-3/hello_2.10-3.dsc
Note that this works for links from Debian and Launchpad Personal Package Archives too.
You can find further information on the manual page dget(1).