old-www/LDP/www.debian.org/doc/manuals/apt-howto/ch-sourcehandling.en.html

253 lines
9.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>APT HOWTO (Obsolete Documentation) - Working with source packages</title>
<link href="index.en.html" rel="start">
<link href="ch-search.en.html" rel="prev">
<link href="ch-erros.en.html" rel="next">
<link href="index.en.html#contents" rel="contents">
<link href="index.en.html#copyright" rel="copyright">
<link href="ch1.en.html" rel="chapter" title="1 Introduction">
<link href="ch-basico.en.html" rel="chapter" title="2 Basic Configuration">
<link href="ch-apt-get.en.html" rel="chapter" title="3 Managing packages">
<link href="ch-helpers.en.html" rel="chapter" title="4 Very useful helpers">
<link href="ch-search.en.html" rel="chapter" title="5 Getting information about packages.">
<link href="ch-sourcehandling.en.html" rel="chapter" title="6 Working with source packages">
<link href="ch-erros.en.html" rel="chapter" title="7 How to deal with errors">
<link href="ch-distros.en.html" rel="chapter" title="8 What distributions support APT?">
<link href="ch-agradecimentos.en.html" rel="chapter" title="9 Credits">
<link href="ch-novas.en.html" rel="chapter" title="10 New versions of this tutorial">
<link href="ch-basico.en.html#s-sources.list" rel="section" title="2.1 The /etc/apt/sources.list file">
<link href="ch-basico.en.html#s-dpkg-scanpackages" rel="section" title="2.2 How to use APT locally">
<link href="ch-basico.en.html#s-netselect" rel="section" title="2.3 Deciding which mirror is the best to include in the sources.list file: netselect, netselect-apt">
<link href="ch-basico.en.html#s-cdrom" rel="section" title="2.4 Adding a CD-ROM to the sources.list file">
<link href="ch-apt-get.en.html#s-update" rel="section" title="3.1 Updating the list of available packages">
<link href="ch-apt-get.en.html#s-install" rel="section" title="3.2 Installing packages">
<link href="ch-apt-get.en.html#s-remove" rel="section" title="3.3 Removing packages">
<link href="ch-apt-get.en.html#s-upgrade" rel="section" title="3.4 Upgrading packages">
<link href="ch-apt-get.en.html#s-dist-upgrade" rel="section" title="3.5 Upgrading to a new release">
<link href="ch-apt-get.en.html#s-clean" rel="section" title="3.6 Removing unused package files: apt-get clean and autoclean">
<link href="ch-apt-get.en.html#s-dselect-upgrade" rel="section" title="3.7 Using APT with dselect">
<link href="ch-apt-get.en.html#s-default-version" rel="section" title="3.8 How to keep a mixed system">
<link href="ch-apt-get.en.html#s-apt-show-versions" rel="section" title="3.9 How to upgrade packages from specific versions of Debian">
<link href="ch-apt-get.en.html#s-pin" rel="section" title="3.10 How to keep specific versions of packages installed (complex)">
<link href="ch-helpers.en.html#s-equivs" rel="section" title="4.1 How to install locally compiled packages: equivs">
<link href="ch-helpers.en.html#s-localepurge" rel="section" title="4.2 Removing unused locale files: localepurge">
<link href="ch-helpers.en.html#s-helper-show-versions" rel="section" title="4.3 How to know what packages may be upgraded">
<link href="ch-search.en.html#s-cache" rel="section" title="5.1 Discovering package names">
<link href="ch-search.en.html#s-dpkg-search" rel="section" title="5.2 Using dpkg to find package names">
<link href="ch-search.en.html#s-auto-apt" rel="section" title="5.3 How to install packages &quot;on demand&quot;">
<link href="ch-search.en.html#s-apt-file" rel="section" title="5.4 How to discover to which package a file belongs">
<link href="ch-search.en.html#s-apt-listchanges" rel="section" title="5.5 How to keep informed about the changes in the packages.">
<link href="ch-sourcehandling.en.html#s-source" rel="section" title="6.1 Downloading source packages">
<link href="ch-sourcehandling.en.html#s-build-dep" rel="section" title="6.2 Packages needed for compiling a source package">
<link href="ch-erros.en.html#s-erros-comuns" rel="section" title="7.1 Common errors">
<link href="ch-erros.en.html#s-help" rel="section" title="7.2 Where can I find help?">
</head>
<body>
<p><a name="ch-sourcehandling"></a></p>
<hr>
<p>
[ <a href="ch-search.en.html">previous</a> ]
[ <a href="index.en.html#contents">Contents</a> ]
[ <a href="ch1.en.html">1</a> ]
[ <a href="ch-basico.en.html">2</a> ]
[ <a href="ch-apt-get.en.html">3</a> ]
[ <a href="ch-helpers.en.html">4</a> ]
[ <a href="ch-search.en.html">5</a> ]
[ 6 ]
[ <a href="ch-erros.en.html">7</a> ]
[ <a href="ch-distros.en.html">8</a> ]
[ <a href="ch-agradecimentos.en.html">9</a> ]
[ <a href="ch-novas.en.html">10</a> ]
[ <a href="ch-erros.en.html">next</a> ]
</p>
<hr>
<h1>
APT HOWTO (Obsolete Documentation)
<br>Chapter 6 - Working with source packages
</h1>
<hr>
<h2><a name="s-source"></a>6.1 Downloading source packages</h2>
<p>
It's common in the world of free software to study source code or even make
corrections to buggy code. To do this, you would need to download the source
of the program. The APT system provides an easy way to obtain source code to
the many programs contained in the distribution, including all the files needed
to create a .deb for the program.
</p>
<p>
Another common use of Debian sources is to adapt a more recent version of a
program, from the unstable distribution, for example, for use with the stable
distribution. Compiling a package against stable will generate .debs with
dependencies adjusted to match the packages available in this distribution.
</p>
<p>
To accomplish this, the <samp>deb-src</samp> entry in your
<samp>/etc/apt/sources.list</samp> should be pointed at unstable. It should
also be enabled (uncommented). See section <a
href="ch-basico.en.html#s-sources.list">The /etc/apt/sources.list file, Section
2.1</a>.
</p>
<p>
To download a source package, you would use the following command:
</p>
<pre>
$ apt-get source packagename
</pre>
<p>
This will download three files: a <samp>.orig.tar.gz</samp>, a
<samp>.dsc</samp> and a <samp>.diff.gz</samp>. In the case of packages made
specifically for Debian, the last of these is not downloaded and the first
usually won't have <samp>&quot;orig&quot;</samp> in the name.
</p>
<p>
The <samp>.dsc</samp> file is used by dpkg-source for unpacking the source
package into the directory <var>packagename-version</var>. Within each
downloaded source package there is a <samp>debian/</samp> directory that
contains the files needed for creating the .deb package.
</p>
<p>
To auto-build the package when it's been downloaded, just add <samp>-b</samp>
to the command line, like this:
</p>
<pre>
$ apt-get -b source packagename
</pre>
<p>
If you decide not to create the .deb at the time of the download, you can
create it later by running:
</p>
<pre>
$ dpkg-buildpackage -rfakeroot -uc -b
</pre>
<p>
from within the directory that was created for the package after downloading.
To install the package built by the commands above one must use the package
manager directly, like this:
</p>
<pre>
# dpkg -i <var>file.deb</var>
</pre>
<p>
There's a difference between <code>apt-get</code>'s <samp>source</samp> method
and its other methods. The <samp>source</samp> method can be used by normal
users, without needing special root powers. The files are downloaded to the
directory from which the <samp>apt-get source package</samp> command was
called.
</p>
<hr>
<h2><a name="s-build-dep"></a>6.2 Packages needed for compiling a source package</h2>
<p>
Normally, specific headers and shared libraries need to be present in order for
a source package to be compiled. All source packages have a field in their
control files called 'Build-Depends:' that indicates which additional packages
are needed for the package to be built from source.
</p>
<p>
APT has a simple way of downloading these packages. Just run <samp>apt-get
build-dep package</samp>, where `package' is the name of the package you're
going to build. For example:
</p>
<pre>
# apt-get build-dep gmc
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
comerr-dev e2fslibs-dev gdk-imlib-dev imlib-progs libgnome-dev libgnorba-dev
libgpmg1-dev
0 packages upgraded, 7 newly installed, 0 to remove and 1 not upgraded.
Need to get 1069kB of archives. After unpacking 3514kB will be used.
Do you want to continue? [Y/n]
</pre>
<p>
The packages that will be installed are the packages needed in order for
<code>gmc</code> to be built correctly. It's important to note that this
command doesn't look for the source package of the program to be compiled. You
will therefore need to run <samp>apt-get source</samp> separately to get it.
</p>
<p>
If all you want is checking what packages are needed to build a given package,
there's a variant of the <samp>apt-cache show</samp> command (see <a
href="ch-search.en.html">Getting information about packages., Chapter 5</a>,
which will show, among other informations, the <samp>Build-Depends</samp> line
that lists those information, the <samp>Build-Depends</samp> line that lists
those
</p>
<pre>
# apt-cache showsrc <var>package</var>
</pre>
<hr>
<p>
[ <a href="ch-search.en.html">previous</a> ]
[ <a href="index.en.html#contents">Contents</a> ]
[ <a href="ch1.en.html">1</a> ]
[ <a href="ch-basico.en.html">2</a> ]
[ <a href="ch-apt-get.en.html">3</a> ]
[ <a href="ch-helpers.en.html">4</a> ]
[ <a href="ch-search.en.html">5</a> ]
[ 6 ]
[ <a href="ch-erros.en.html">7</a> ]
[ <a href="ch-distros.en.html">8</a> ]
[ <a href="ch-agradecimentos.en.html">9</a> ]
[ <a href="ch-novas.en.html">10</a> ]
[ <a href="ch-erros.en.html">next</a> ]
</p>
<hr>
<p>
APT HOWTO (Obsolete Documentation)
</p>
<address>
1.8.11 - August 2005<br>
<br>
Gustavo Noronha Silva <code><a href="mailto:kov@debian.org">kov@debian.org</a></code><br>
<br>
</address>
<hr>
</body>
</html>