Adding additional repositories
Software repositories are
essentially URLs in a text file, stored in one of two places.
The main Ubuntu repository list is stored in
/etc/apt/sources.list
. Inside that
file, you'll find a multitude of repositories for Ubuntu's package manager to pull
packages from. In addition, files with an extension of
.list
are read from the
/etc/apt/sources.list.d/
directory and are also used whenever you use
apt
. I'll
demonstrate both methods.
Managing Software Packages
[
92
]
A typical repository line in either of these two files will look similar to the following:
deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
The first section of each line will be either
deb
or
deb-src
, which references whether
the
apt
command will find binary packages (
deb
) or source packages (
deb-src
) there.
Next, we have the actual URL that
apt
will use in order to reach the repository. In
the third section, we have the codename of the release; in this case, it's
focal
(which
refers to the codename for Ubuntu 20.04,
Focal Fossa
).
Continuing, the fourth section of each repository line refers to the
Component
, which
references whether or not the repository contains software that is free and open
source, and is supported officially by Canonical (the company that oversees Ubuntu's
development). The component can be
main
,
restricted
,
universe
, or
multiverse
.
Repositories with a
main
component include officially supported software. This
generally means that the software packages have source code available, so Ubuntu
developers are able to fix bugs. Software marked
restricted
is still supported
but may have a questionable license.
universe
packages are supported by the
community, not Canonical themselves. Finally,
multiverse
packages contain
software that is neither free nor supported, which you would be using at your own
risk.
As you can see from looking at the
/etc/apt/sources.list
file on your server, it's
possible for a repository line to feature software from more than one component.
Each repository URL may include packages from several components, and the way
you differentiate them is to only subscribe to the components you need for that
repository. In our previous example, the repository line included both
main
and
restricted
components. This means that, for that particular example, the
apt
utility
will index both free (
main
) and non-free (
restricted
) packages from that repository.
You can add new
repositories to the
/etc/apt/sources.list
file (and it will function
just fine), but that's not typically the preferred method. Instead, as I mentioned
earlier,
apt
will scan the
/etc/apt/sources.list.d/
directory for text files ending
with the
.list
extension. These text files are formatted the same as the
/etc/apt/
sources.list
file in the sense that you include one additional repository per line, but
this method allows you to add a new repository by simply creating a file for it, and
you can remove the repository by simply deleting that file.
If you weren't already aware, the codename for each Ubuntu
release is based on an animal. The fossa is an animal from
Madagascar that somewhat resembles a cat but with curved ears. If
you didn't already know that, now you do.
Chapter 3
Do'stlaringiz bilan baham: |