- How to Download a source package
- Working with a source package
- See also
The definition of a source package
Source packages provide you with all of the necessary files to compile or otherwise, build the desired piece of software.
It consists, in its simplest form, of three files:
The upstream tarball with .tar.gz ending
A description file with .dsc ending. It contains the name of the package, both, in its filename as well as content (after the Source: keyword).
- A tarball, with any changes made to upstream source, plus all the files created for the Debian package.
This has a .debian.tar.gz (source format : 3.0)
or a .diff.gz ending (source format : 1.0)
Why looking at a source package ?
If you want to know which compile-time options are enabled for a specific package (DebianPackageConfiguration).
Why bother with source package if there is a binary package ?
Some build systems (e.g. cmake) and ad-hoc scripts provide a convenient way to produce Binary packages (i.e. .deb files for Debian, .rpm for ?RedHat, etc) in a uniform fashion. Although such approach sounds appealing at first, it is not only insufficient for upload into Debian proper, where source package is required, but might be inferior, because binary-only distribution
- does not even provide a unified way to obtain the sources of a corresponding software (as it is now with "apt-get source package")
makes it difficult (if not impossible at all) for a user/contributor to rebuild .deb package due to lack of standardization in build procedures and description of build-dependencies. It is often mitigated by upstream authors with detailed descriptions in README, but instructions would vary from package to package, are not guarantee to be complete; thus altogether making rebuilding not straightforward and fragile. So it is of no surprise why Debian policy demands source packages with standardized build procedures -- Debian needs to rebuild architecture-agnostic software for all (>12) supported platforms.
- manually composes "Depends:" for a generated .deb and those quite often would not be correct across Debian suites/releases, thus complicating installation procedures. Quick and dirty solution is often to build statically thus loosing benefits of modularity in Debian, making the software less robust and secure.
How to Download a source package
Sources are normally not installed. You can only install them if you know the package name.
How to find the name of the source package
A source package could generate many .debs. To know the source package name, see the Source: field in the output of
apt-cache show package_name
Sometimes the SOURCE: field is not present, then you can check using:
apt-cache showsrc package_name
With apt-get source
One way to obtain source packages is with
apt-get source <package name>
You need a deb-src entry in your /etc/apt/sources.list file, like :
deb-src http://http.us.debian.org/debian unstable main
A source package is downloaded in the current directory and is not installed (it will not appear in the installed package list), so you need not be root to use apt-get source.
When you are on the page of the package, choose a distribution, and you will have a link to the three files which make the source package.
Working with a source package
How to build the Debian package
apt-get --build source package_name
If you want to make optimized packages from source to your machine in order to possibly get faster operation, install and use apt-build (which in order uses apt-get source -b ...)
How to extract the source files
Assuming the files of the source package are present in the same directory, to unpack a source package, you can typically use :
dpkg-source -x .../path/to/package_name.dsc
All the files will be unpacked into a directory : package-version.