Visualize package dependencies with debtree

The debtree command shows relationships between packages in a visual way. It generates a dependency graph in dot syntax, which you can process with the graphviz command to create a nice visualization. A picture is worth a thousand words, so debtree allows you to see at a glance which other packages a specific package needs.

This is especially interesting in the current migration from the Ubuntu 16.04 to 20.04 base for Ubuntu Touch. You can use debtree to visualize the dependency graph of a package on your 16.04-based Ubuntu Touch phone and do the same on the 20.04-based Ubuntu Touch Platform Development Kit and compare the two to find the differences in dependencies.

Install debtree in the Platform Development Kit

Install the Platform Development Kit as per the instructions in the README on GitHub. Then run the development virtual machine (ubuntu-touch-pdk run) and log in (user phablet, password). Then install debtree:

sudo apt install debtree

This will also install graphviz, because it’s a dependency of the debtree package.

Install debtree in a Libertine container on your phone

The root file system of Ubuntu Touch is read-only. You could remount it as read/write and then install debtree before remounting it as read-only, but this is not recommended for stability. A better alternative is to create a Libertine container and then install debtree in this container.

So open the Terminal app or log in with ssh and then create a new Libertine container:

libertine-container-manager create -i cli

This will take a while: it creates a container (a minimal Ubuntu-based operating system without the kernel) with the identifier cli.

After this, install the debtree package in the container:

libertine-container-manager install-package -i cli -p debtree

And then run a shell session in the container:

libertine-launch -i cli /bin/bash

Now you can run debtree on your Ubuntu Touch phone.

Run debtree

As an example, let’s take a look at the dependencies of the package ubuntu-app-launch in your phone. Run this command in your Libertine container to generate the dependency graph:

debtree –max-depth=2 ubuntu-app-launch | dot -Tpng > Pictures/ubuntu-app-launch.png

The result looks like this:

Odoo • Een foto met een geweldig onderschrift
Dependency graph of the ubuntu-app-launch package in Ubuntu Touch

The –max-depth option limits the number of levels of dependencies that is traversed. If you don’t add this option, the graph becomes unwieldy. You’ll have to experiment with the right value depending on the package and your purpose for visualizing the dependencies.

Each package is shown as a node in the graph, and each dependency as an arrow between nodes. Normal dependencies are shown in blue, recommended dependencies in black, “provides” dependencies in green with an inverted arrow, and conflicts in red. Have a look at debtree’s man page for the full meaning of all colors and node shapes.

Likewise, you can generate the dependency graph for lomiri-app-launch in the PDK as follows:

debtree –max-depth=2 lomiri-app-launch | dot -Tpng > Pictures/lomiri-app-launch.png

This looks like this:

Odoo • Een foto met een geweldig onderschrift
Dependency graph of the lomiri-app-launch package in the Ubuntu Touch Platform Development Kit

All in all, with a bit of experimenting debtree is a useful tool to explore the dependencies between packages in Ubuntu Touch.

Ubuntu Touch Q&A 106
New apps, Porting news, SD card management fixed