APT-SRC(1p)
π apt-src β manage debian source package trees π
okay bestie, welcome to apt-src, from section 1p of the manual, and yeah it lives in the User Contributed Perl Documentation corner of the world. it's a whole CLI for source packages and honestly? it's giving main character energy. let's go π¦
β¨ SYNOPSIS β¨
apt-src [options] command
apt-src [options] install|remove pkg1 [pkg2 ...]
apt-src location pkg
πΈ DESCRIPTION πΈ
apt-src is a command line interface for downloading, installing, upgrading, and tracking debian source packages. you can run it as a normal user, or as root β no gatekeeping here π
unlike binary packages, source packages do not get installed into some canonical location. instead they're "installed" by unpacking their source tree into a directory, and that directory can be literally anywhere you want it. and get this: a source package can be installed multiple times, in different locations. this program manages source packages installed that way, and also hands you querying facilities so you can figure out where a source package actually lives π
unless you pass the -h or --help option, one of the commands below must be present. no command, no service, periodt.
update π
update the lists of available packages. it's identical to apt-get update, really, and in the default configuration it must be run as root.
install π
install the named source package or packages into the current directory. if a package in the current directory is already installed, it'll attempt to upgrade it instead.
this command will accept the names of binary packages, or source packages. just like with 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. slay, options.
it will make sure that the build-dependencies of the source package are satisfied. no broken builds on my watch β¨
if the --location option is given, the source package gets installed or upgraded into the given location instead of the current directory.
if the --build option is given, each newly installed or upgraded package will be compiled.
upgrade π₯
upgrade all installed source packages β or, if the --location or --here options are used, update only the source packages in the specified directory.
if the --patch option is given (and yeah, that's the default), apt-src will attempt to generate a patch containing any local changes you made to the source package, and will apply that patch to the updated tree. this lets your local changes survive across package upgrades, but it may not always work, and you might sometimes have to merge in your changes by hand π (iykyk)
if the --build option is given, each newly installed or upgraded package will be compiled.
remove π
remove the named source package or packages. the --location and --here options may be used to only remove packages in a particular directory.
build π
build the specified source or sources. if the source isn't installed yet, it will first be installed.
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.
import π
use this option to let apt-src know about an existing, unpacked source tree. besides the name under which it should be imported, you must specify the 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.
list β
with no other parameters, it will list all installed source packages, their status, and the directory they're installed in. if a package's name is given, it'll display only installed instances of that source package. if the --location or --here options are used, they'll limit the list to packages in the specified directory.
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 is the one you want when you need to include files from another source package, or something like that. for example:
-I`apt-src location pkg`
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.
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.
π OPTIONS π
all command line options may be set using the configuration file, and the descriptions below 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. so many variations, so little time π«Ά
-h,--helpβ show a help text.-b,--build,--compileβ build source packages after installing or upgrading them. Configuration Item:APT::Src::Compile.-i,--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.
-p,--patchβ try to patch local changes into the new source tree when upgrading. On by default, use--no-pto disable. Configuration Item:APT::Src::Patch.-l,--locationβ specify a directory; only operate on packages in that directory. Configuration Item:APT::Src::Location.-c,--cwd,--hereβ only operate on packages in the current directory. Configuration Item:APT::Src::Here.--upstream-versionβ only of use with theversioncommand; makes it omit the debian version number from the version of the package output.-k,--keep-builtβ do not delete.debsand other built files after installing them with the--installdebsoption. Configuration Item:APT::Src::KeepBuilt-n,--no-delete-sourceβ do not delete source files when removing source package. Configuration Item:APT::Src:NoDeleteSource--versionβ specify a source tree version. Of use with theimportcommand.-q,--quietβ direct all command output to/dev/nullunless a command fails to run as expected. Configuration item:APT::Src::Quiet-t,--traceβ output each command as it is run. Configuration item:APT::Src::Trace
in addition to the above options, some less-used configuration items may only be specified in the config files, /etc/apt/apt.conf and ~/.apt-src/config. they are:
APT::Src::BuildCommandβ the command to use to build a tree. run in the tree to build, it defaults to"dpkg-buildpackage -b -us -uc", with"-rfakeroot"appended for non-root users.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.sudo(8)is a good choice and the default. if you want to usesu(1), you'll need to set it to"su -c".APT::Src::BuildDepsβ controls whetherapt-srcmakes 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.
π 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. regexps stay winning π
π± ENVIRONMENT π±
this program sets APT_SRC_BUILD when it is building a package.
π EXAMPLES π
to install the source to mutt(1) to /usr/src, build it, and install the resulting debs:
apt-src install --location=/usr/src -i mutt
to track changes to said installed 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 /usr/src/linux, which you unpacked from a www.kernel.org tarball (or from the kernel-source package) into apt-src, so it knows about it:
apt-src import kernel --location=/usr/src/linux --version=2.4.18
in a debian/rules of a kernel module package that needs to figure out if it is being built by apt-src, and if so set the KVERS, KSRC and KDREV variables that 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
π FILES π
/etc/apt/sources.listβ locations to fetch packages from.~/.apt-src/statusβapt-src's status file, lists installed packages./etc/apt/apt.confβ global config file forapt-src(andapt(8)).~/.apt-src/configβ per-user config file forapt-src.
π SEE ALSO π
apt-get(8), sources.list(5), dpkg-source(1)
π 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.
and that's the whole page bestie!! this one was rendered by perl v5.40.1 on 2025-03-29, and it's the APT-SRC(1p) page. go forth and manage those source trees, you absolute icon πβ¨
π¦ where this page comes from
- debian trixie: apt-src 0.25.5
- ubuntu resolute: apt-src 0.25.5
- ubuntu stonking: apt-src 0.25.5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms