Package Source and - Kali Linux Revealed

Package Source and
Source Package
The word
source
can be ambiguous. A source package—a package containing the
source code of a program—should not be confused with a package source—a repos-
itory (website, FTP server, CD/DVD-ROM, local directory, etc.) that contains pack-
ages.
177
Chapter 8 — Debian Package Management
APT retrieves its packages from a repository, a package storage system or simply, ”package
source”. The
/etc/apt/sources.list
file lists the different repositories (or sources) that pub-
lish Debian packages.
8.1.2. Understanding the
sources.list
File
The
sources.list
file is the key configuration file for defining package sources, and it is impor-
tant to understand how it is laid out and how to configure it since APT will not function without a
properly defined list of package sources. Let’s discuss its syntax, take a look at the various repos-
itories that are used by Kali Linux, and discuss mirrors and mirror redirection, then you will be
ready to put APT to use.
Each active line of the
/etc/apt/sources.list
file (and of the
/etc/apt/sources.list.d/*.
list
files) contains the description of a source, made of three parts separated by spaces. Com-
mented lines begin with a # character:
#deb cdrom:[Debian GNU/Linux 2020.3 _Kali-rolling_ - Official Snapshot amd64 LIVE/
å
INSTALL Binary 20200728-20:25]/ kali-last-snapshot contrib main non-free
deb http://http.kali.org/kali kali-rolling main non-free contrib
Let’s take a look at the syntax of this file. The first field indicates the source type:
• deb for binary packages,
• deb-src for source packages.
The second field gives the base URL of the source: this can consist of a Kali mirror or any other
package archive set up by a third party. The URL can start with file:// to indicate a local source
installed in the system’s file hierarchy, with http:// to indicate a source accessible from a web
server, or with ftp:// for a source available on an FTP server. The URL can also start with cdrom:
for CD/DVD-ROM/Blu-ray disc-based installations, although this is less frequent since network-
based installation methods are more and more common.
The cdrom entries describe the CD/DVD-ROM you have. Contrary to other entries, a CD/DVD-ROM
is not always available, since it has to be inserted into the drive and usually only one disc can be
read at a time. For those reasons, these sources are managed in a slightly different way and need to
be added with the
apt-cdrom
program, usually executed with the add parameter. The latter will
then request the disc to be inserted in the drive and will browse its contents looking for
Packages
files. It will use these files to update its database of available packages (this operation is usually
done by the
apt update
command). After that, APT will request the disc if it needs a package
stored on it.
The syntax of the last field depends on the structure of the repository. In the simplest cases, you
can easily indicate a subdirectory (with a required trailing slash) of the desired source (this is often
a simple “
./
”, which refers to the absence of a subdirectory—the packages are then directly at the
178
Kali Linux Revealed
specified URL). But in the most common case, the repositories will be structured like a Kali mirror,
with multiple distributions each having multiple components. In those cases, name the chosen
distribution, then the components (or sections) to enable. Let’s take a moment to introduce these
sections.
Debian and Kali use three sections to differentiate packages according to the licenses chosen by
the authors of each work. A difference between Debian and Kali is that, Debian only has main
enabled by default, whereas Kali has all three enabled by default.
main contains all packages that fully comply with the
Debian Free Software Guidelines
1
.
The non-free archive is different because it contains software that does not (entirely) conform to
these principles but which can nevertheless be distributed without restrictions.
contrib (contributions) is a set of open source software that cannot function without some non-
free elements. These elements may include software from the non-free section or non-free files
such as game ROMs, BIOS of consoles, etc. contrib also includes free software whose compilation
requires proprietary elements, such as VirtualBox, which requires a non-free compiler to build
some of its files.
Now, let’s take a look at the standard Kali Linux package sources, or repositories.
8.1.3. Kali Repositories
A standard
sources.list
file for a system running Kali Linux refers to one repository (kali-rolling)
and the three previously mentioned components: main, contrib, and non-free:
# Main Kali repository
deb http://http.kali.org/kali kali-rolling main contrib non-free
Let’s take a look at the Kali repositories.
The Kali-Rolling Repository
This is the main repository for end-users. It should always contain installable and recent packages.
It is managed by a tool that merges Debian Testing and the Kali-specific packages in a way that
ensures that each package’s dependencies can be satisfied within kali-rolling. In other words,
barring any bug in maintainer scripts, all packages should be installable.
Since Debian Testing evolves daily, so does Kali Rolling. The Kali-specific packages are also regu-
larly updated as we monitor the upstream releases of the most important packages.
1
https://www.debian.org/social_contract#guidelines
179
Chapter 8 — Debian Package Management
The Kali-Dev Repository
This repository is not for public use. It is a space where Kali developers resolve dependency prob-
lems arising from the merge of the Kali-specific packages into Debian Testing.
It is also the place where updated packages land first, so if you need an update that was released
recently and that has not yet reached kali-rolling, you might be able to grab it from this repository.
This is not recommended for regular users.
The Kali Linux Mirrors
The
sources.list
extracts above refer to http.kali.org: this is a server running
MirrorBrain
2
,
which will redirect your HTTP requests to an official mirror close to you. MirrorBrain monitors
each mirror to ensure that they are working and up-to-date; it will always redirect you to a good
mirror.
|