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
apt-get source
dget
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
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 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
hello
source package).Copy the download link of the
.dsc
file:Call
dget
with 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).