= Source Packages = So far we've looked at Debian binary packages (`.deb`). But there are also Debian source packages, which are used to build the binary package. Source packages consist of a `.dsc` file, which in turn references one or more `.tar.gz` files. Source packages are installed with the `dpkg-source` command: {{{ $ dpkg-source -x rpncalc_0.1.dsc dpkg-source: warning: extracting unsigned source package (rpncalc_0.1.dsc) dpkg-source: info: extracting rpncalc in rpncalc-0.1 dpkg-source: info: unpacking rpncalc_0.1.orig.tar.gz dpkg-source: info: unpacking rpncalc_0.1.debian.tar.gz }}} Let's take a look at the actual .dsc file: {{{ $ cat rpncalc_0.1.dsc Format: 3.0 (quilt) Source: rpncalc Binary: rpncalc Architecture: any Version: 0.1 Maintainer: Jonathan Reed Standards-Version: 3.9.3 Build-Depends: debhelper (>= 8.0.0) Package-List: rpncalc deb utils extra Checksums-Sha1: 1a43c631b461e7d942b68cee620a892742a71794 901 rpncalc_0.1.orig.tar.gz b9d7945e5a6e116746fdb4ecf47544c7b8d8fae4 982 rpncalc_0.1.debian.tar.gz Checksums-Sha256: ff72ff17a9ec795ebac7d94818c70d28b3bd88ad0adf623ee479f6ae11841a56 901 rpncalc_0.1.orig.tar.gz d220513f074eafc87cd4f5f2476dbdfe4ede660bf27e793ab1c3409a7245cd25 982 rpncalc_0.1.debian.tar.gz Files: 8114cf4a6a276bf6377df0750ecb68de 901 rpncalc_0.1.orig.tar.gz 2e1c18b8ee84bdd4a24305e547ee8ad7 982 rpncalc_0.1.debian.tar.gz }}} As you can see, it contains metadata about the name of the package, its version, and also contains a list of files -- in this case, rpncalc_0.1.orig.tar.gz and rpncalc_0.1.debian.tar.gz. These are, respectively, the "upstream" or "source" tarball, and the debian changes. Debian goes out of its way to keep its packaging changes separate from the upstream source, so that the same packaging can easily be applied to a newer version of the software in the future. (The files are listed multiple times because their checksums are calculated with multiple digest algorithms (MD5, SHA1, SHA256). Older versions of the dpkg program only understand older algorithms, like MD5.) If you use `tar` to examine the files, you'll see the .debian.tar.gz contains a number of files under the `debian/` subdirectory, and the .orig.tar.gz contains the software itself. N.B. This is version 3.0 of the source format. In older versions, the Debian changes were represented in a .diff.gz which was applied with the `patch` command. Although it was in a different format, the contents were the same. The older 1.0 format is still quite common, as a "lowest common denominator". As with the `dpkg` command, the APT front end is more commonly used. The same repositories which contain binary packages also contain binary source packages. It's possible to get the source package for any binary package with the `apt-get source` command. This command downloads the source package to the current directory and unpacks it for you. Note that a single source package may generate multiple binary packages. For example, if you have the binary package `foo-utils`, which might also come with the package `foo-doc`, the source for both of those would likely be in the `foo` package, so `apt-get source foo-doc` would get you the same source as `apt-get source foo-utils`. However, with APT, you don't have to worry about this -- it will determine what the appropriate source package is, and it will get it for you. === dget === If you just download the `.dsc` file, and try to install it, you'll get an error. For a `.dsc` hosted on the web, you can use the `dget` command, which will fetch the `.dsc` file and then fetch the relevant `.tar.gz` and/or `.diff.gz` files. We now have a source package, which is typically unpacked into a directory with the name of the package and its version (e.g. rpncalc-0.1). If we look in that directory, we'll see the software, as well as a `debian` directory. The `debian` directory contains a number of special files necessary to build the package. Next: [[AnatomyOfAPackage]]