Managing Debian Packages

Management of Debian packages can be performed using graphical applications or command line tools. This document describes how to perform common package management tasks using command line tools.

Note that management of flatpaks is discussed in the Managing Flatpaks section.

Getting Started

Log in to the phone via a serial console or network connection. You should now be able to issue commands at the shell prompt. In this document we prefix each of the commands with the shell prompt to indicate that they are entered at the command line on the phone:

purism@pureos:~$

Next, ensure that the phone has access to the Internet.

Tools

The most useful tool for managing Debian packages is the apt tool. This is used to search for packages in remote repositories, request installation of packages and uninstall them when they are no longer needed.

Another useful tool is dpkg. This is useful for installing individual package files, removing packages, and showing a list of the currently installed packages.

Both of these tools are already installed on the phone.

Listing Packages

To see the list of Debian packages that are installed on your system, enter the following at the command line:

purism@pureos:~$ dpkg -l

This should cause a summary to be shown of the packages that the system knows about, as in the following snippet:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                           Version                                        Architecture Description
+++-==============================================-==============================================-============-=================================================
ii  accountsservice                                0.6.45-2                                       arm64        query and manipulate user account information
ii  acl                                            2.2.53-4                                       arm64        access control list - utilities
ii  adduser                                        3.118                                          all          add and remove users and groups
ii  adwaita-icon-theme                             3.30.1-1                                       all          default icon theme of GNOME

Packages that have been correctly installed are prefixed with ii in the leftmost column.

You may need to press the q key to quit the summary.

Updating the Package Database

The apt tool maintains a database of the Debian packages that are installed on the system. It uses this information to determine whether packages need to be upgraded.

At the command line, enter the following:

purism@pureos:~$ sudo apt update

This should result in a series of communications to remote servers that produce output like the following:

Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://deb.debian.org/debian buster-updates InRelease
Hit:3 http://security.debian.org/debian-security buster/updates InRelease
Hit:4 http://ci.puri.sm scratch InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
18 packages can be upgraded. Run 'apt list --upgradable' to see them.

Note

The exact host names of the servers will change when the system software is finalized.

As suggested by the apt tool, we can run a command to see which packages can be upgraded:

purism@pureos:~$ apt list --upgradable

Note that this command does not require sudo to be used to run it because it only reads information about the packages on the system. It does not need to modify that information.

Upgrading Packages

Packages that are upgradable can be upgraded with this command, again using sudo because permission is needed to modify the database and install files on the system:

purism@pureos:~$ sudo apt upgrade

This should cause a few lines of information about the upgrades to be shown, the amount of data that will be fetched over the network, and the amount of storage required, followed by a question:

Do you want to continue? [Y/n]

Press y to confirm. Otherwise, press n.

Searching for Software

Applications and other components can be obtained from the remote repositories that are known to the system. The apt tool is used to search for items of software by their names. For example, the GNU hello program can be searched for with the following command:

purism@pureos:~$ apt search hello

This will produce a number of suggestions for suitable packages. Amongst these is the relevant package:

hello/stable 2.10-2 arm64
  example package based on GNU hello

The name of the package is on the left of the forward slash.

Installing Packages

To install a package, simply run the apt tool in the following way – in this case to install the GNU hello program:

purism@pureos:~$ sudo apt install hello

If this is successful, the output produced should indicate that the package containing the program was downloaded, unpacked and installed.

Uninstalling Packages

When a piece of software is no longer needed, its package can be uninstalled using the apt tool, as in this example:

purism@pureos:~$ sudo apt remove hello

If the -y option is passed, the package will be removed automatically. Otherwise, you will be asked to confirm that you want to continue with the operation.

Removing Extra Packages

When uninstalling a package, you may be notified about other packages that are installed but not required. Run the apt tool to clean up these extra packages:

purism@pureos:~$ sudo apt autoremove

You will be asked to confirm that you want to remove the extra packages unless you pass the -y option.

Adding and Removing Repositories

By default, you will only be able to install software from the repositories that are provided in the standard configuration for the phone. However, you can change the list of package sources (package repositories) using the apt tool:

purism@pureos:~$ sudo apt edit-sources

This may ask you to choose a text editor before opening the file containing the package sources for you to edit. Refer to the Debian Administrator’s Handbook for guidance on how to customize this file.