=head1 NAME

apt-src - manage debian source package trees

=head1 SYNOPSIS

B<apt-src> [S<I<options>>] S<I<command>>

B<apt-src> [S<I<options>>] S<B<install|remove>> pkg1 [pkg2 ...]

B<apt-src> S<I<location>> pkg

=head1 DESCRIPTION

B<apt-src> is a command line interface for downloading, installing, upgrading,
and tracking debian source packages. It can be run as a normal user, or as 
root.

Unlike binary packages, source packages are not installed into a canonical
location. Instead, they are "installed" by unpacking their source tree into
a directory, which can be anywhere you wish. A source package can be installed
multiple times, in different locations. This program manages source packages
installed in this way, and provides querying facilities to help find
where a source package is installed.

Unless the -h or --help option is given one of the commands below must be
present.

=over 4

=item update

Update the lists of available packages. Identical to B<apt-get update>, really,
and must be run as root in the default configuration.

=item install

Install the named source package or packages into the current directory.
If a package in the current directory is already installed, it will attempt
to upgrade it. 

This command will accept the names of binary packages, or source packages.
Just like with B<apt-get install>, you can prefix the name with =version or
/release to specify what version to install or what release to take the
source from.

It will make sure that the build-dependencies of the source package are
satisfied.

If the --location option is given, the source package will be installed or
upgraded into the given I<location> instead of the current directory.

If the --build option is given, each newly installed or upgraded package
will be compiled.

=item upgrade

Upgrade all installed source packages, or, if the --location or --here options
are used, update only source packages in the specified directory.

If the --patch option is given (the default), B<apt-src> will attempt to
generate a patch containing any local changes made to the source package,
and will apply this patch to the updated tree. This will allow your local
changes to be preserved across package upgrades, but it may not always work,
and you might sometimes have to merge in your changes by hand.

If the --build option is given, each newly installed or upgraded package
will be compiled.

=item remove

Remove the named source package or packages. The --location and --here options
may be used to only remove packages in a particular directory.

=item build

Build the specified source or sources. If the source is not installed yet,
it will first be installed.

=item clean

Clean the trees of the named source package or packages. The --location and
--here options may be used to only clean packages in a particular directory.

=item import

Use this option to let B<apt-src> know about an existing, unpacked source
tree. Besides the name under which it should be imported, you must specify
the I<location> of the source tree (with --location), and you may need to tell
the version of the source (with --version). Don't expect the build command
to work on this source, unless it has a debian/ directory.

=item list

With no other parameters, it will list all installed source packages; their
status, and the directory they are installed in. If a package's name is given,
it will display only installed instances of that source package. If the 
--location or --here options are used, they will limit the list to packages
in the specified directory.

=item location

Takes a single parameter; the name of a source package. If the package is 
installed, it will return the root of the package's source tree.

This command can be used when you need to include files from another source
package, or something like that. For example:

 -I`apt-src location pkg`

=item version

Takes a single parameter; the name of a source package. If the package is 
installed, it will return the version of the package that is installed.

=item name

Takes a single parameter; the name of a source package (may be specified with
regexps). Returns the name of the source package installed matching that name,
if any.

=back

=head1 OPTIONS

All command line options may be set using the configuration file, the
descriptions indicate the configuration option to set.  For boolean
options you can override the defaults file by using something like
-f-, --no-f, -f=no or several other variations.

=over 4

=item B<-h>, B<--help>

Show a help text.

=item B<-b>, B<--build>, B<--compile>

Build source packages after installing or upgrading them. 
Configuration Item: APT::Src::Compile.

=item B<-i>, B<--installdebs>

Install packages after building sources. Implies --build.
Configuration Item: APT::Src::InstallDebs

Note that if multiple packages are generated from a single source package,
they will all be installed.

=item B<-p>, B<--patch>

Try to patch local changes into new source tree when upgrading. On by default,
use --no-p to disable.
Configuration Item: APT::Src::Patch.

=item B<-l>, B<--location>

Specify a directory; only operate on packages in that directory.
Configuration Item: APT::Src::Location.

=item B<-c>, B<--cwd>, B<--here>

Only operate on packages in the current directory.
Configuration Item: APT::Src::Here.

=item B<--upstream-version>

Only of use with the version command; makes it omit the debian version number
from the version of the package output.

=item B<-k>, B<--keep-built>

Do not delete .debs and other built files after installing them with the
--installdebs option.
Configuration Item: APT::Src::KeepBuilt

=item B<-n>, B<--no-delete-source>

Do not delete source files when removing source package.
Configuration Item: APT::Src:NoDeleteSource

=item B<--version>

Specify a source tree version. Of use with the import command.

=item B<-q>, B<--quiet>

Direct all command output to I</dev/null> unless a command fails to run as
expected. Configuration item: APT::Src::Quiet

=item B<-t>, B<--trace>

Output each command as it is run. Configuration item: APT::Src::Trace

=back

In addition to the above options, some less-used configuration items may only
be specified in the config files, I</etc/apt/apt.conf> and I<~/.apt-src/config>.
They are:

=over 4

=item APT::Src::BuildCommand

The command to use to build a tree. Run in the tree to build, it defaults to
"B<dpkg-buildpackage -b -us -uc>", with "-rfakeroot" appended for non-root users.

=item APT::Src::RootCommand

The command to use if a non-root user needs to become root. This is used for,
example, to satisfy build-deps. L<sudo(8)> is a good choice and the default.
If you want to use L<su(1)>, you'll need to set it to "B<su -c>".

=item APT::Src::BuildDeps

Controls whether B<apt-src> makes sure a source package's build dependencies are
installed when installing or upgrading it. Defaults to true, if you turn
it off, packages may fail to build due to missing build dependencies.

=back


=cut

=head1 NOTE ON NAMES

You can use either binary package names, or source package names when
installing a new source package.

The rest of the time, when dealing with already installed packages, you
currently have to use the source package names (this may later change).
However, you may use regexps as part of the names.

=head1 ENVIRONMENT

This program sets APT_SRC_BUILD when it is building a package.

=head1 EXAMPLES

To install the source to L<mutt(1)> to I</usr/src>, build it, and install
the resulting debs:

  apt-src install --location=/usr/src -i mutt

To track changes to said installed L<mutt(1)> source package, and install debs
whenever a new version comes out:

  apt-src install -i mutt

To install a local copy of package foo, which you are going to
apply a local patch to:

  apt-src install foo
  cd foo-version
  patch <~/my-foo-patch
  apt-src build --installdebs foo
  
To upgrade your local copy of foo, bringing your patch forward, and
building and installing new debs:

  apt-src install -i foo

To import the source tree in I</usr/src/linux>, which you unpacked from
a www.kernel.org tarball (or from the kernel-source package) into 
B<apt-src>, so it knows about it:

  apt-src import kernel --location=/usr/src/linux --version=2.4.18
  
In a I<debian/rules> of a kernel module package that needs to figure out if it is
being built by B<apt-src>, and if so set the KVERS, KSRC and KDREV variables that
L<make-kpkg(1)> used to set:

  ifdef APT_SRC_BUILD
  KDREV=$(shell apt-src version kernel\(-source.\*\)\?)
  KSRC=$(shell apt-src location kernel\(-source.\*\)\?)
  KVERS=$(shell apt-src name kernel\(-source.\*\)\? | sed s/kernel-source-//)
  endif
  
=head1 FILES

=over 4

=item /etc/apt/sources.list

Locations to fetch packages from.

=item ~/.apt-src/status

B<apt-src>'s status file, lists installed packages.

=item /etc/apt/apt.conf

Global config file for B<apt-src> (and L<apt(8)>).

=item ~/.apt-src/config

Per-user config file for B<apt-src>.

=back

=head1 SEE ALSO

L<apt-get(8)>, L<sources.list(5)>, L<dpkg-source(1)>

=head1 AUTHOR

Copyright 2002 Joey Hess <joeyh@debian.org>

This is free software; see the GNU General Public Licence
version 2 or later for copying conditions. There is NO
warranty.


=cut

