When recently setting up a Jetson Xavier NX Developer Kit to boot from a SSD, we needed to figure out what packages to install on top of the default Ubuntu distribution. The answer? Package Lists! Looky here:
You will often hear talk of packages in the Ubuntu world. The Jetson L4T operating system is a version of Ubuntu named L4T. What is the difference between L4T and Ubuntu? Packages.
What are Packages?
Under Ubuntu, packages contain all of the necessary files, meta-data and instructions to install functions or software applications. A package file is a compound file which contains three items. First is a format header, which tells the package manager information about the version of the package format. Second there is a Control tar file (Tape Archive format) which contains information about the actual package itself. Third, there is a Data tar file, which contains the actual data (binaries, sources, libraries and so on) of the package.
There are different types of packages. We mostly think about a package representing libraries and applications. However, there are also packages types which contain source code, ‘meta-packages’, and other types.Meta-packages do not contain much information in and of themselves. However, they do contain a list of dependencies. When the package manager sees the dependencies, it will install them. Thus, Meta-packages tell the system to install a group of packages, a package of packages if you will.
The package manager for Ubuntu is Debian. A package file has the extension .deb. Side note, Debian was named after Debra and Ian Murdock. Ian Murdock was the founder of Debian. The package manager is a lower level part of the operating system which installs, removes and provides information about packages.
dpkg and apt
At the lowest level, dpkg provides the package manager capabilities. For any given package, the Control section provides information to dpkg about how to go about installing (and removing) the package Data on to the operating system. The Control section may contain scripts to help set things up, tear them down, and other system setup tasks. Also, the Control section may contain a list of dependencies, reverse dependencies and other useful hints from which the package manager can take advantage.
While dpkg is capable of managing the system, it wasn’t long before people built tools using dpkg as the base to provide more flexibility. The Advanced Package Tool, or apt, is a higher level tool which provides a friendly interface with dpkg.
One of the features which makes apt a useful user experience is the ability to pull dependencies from remote repositories. dpkg requires all package files to be local, while apt keeps a list of remote repositories where package files can be retrieved if need be. Consequently, apt will grab dependencies from places other than the local machine when needed, and take care of any circular dependencies if encountered.
A Package List is a list of all of the packages installed on a given system. This is valuable for several reasons. Probably the most important is that the package list denotes all of the applications and libraries, along with the Control ‘installation instructions’, for a given system. For example:
$ sudo apt list --installed
Lists the installed packages, along with some other information such as the release number. Dpkg provides the same information in a more concise form:
$ sudo dpkg --get-selections
We can use the ‘>’ redirect command line character to save the result to a file.
$ sudo dpkg --get-selections > package_selections.txt
Once we have the package list, we can use that information to replicate this machines configuration on another. In the video, we compare the configuration of a base Ubuntu distribution with that of a machine which has a JetPack install.
While we could simply do an apt install on all of the packages in the JetPack machines package list on the fresh Ubuntu, in the video we chose a different tact. Instead, we compared the package lists of the default Ubuntu install versus the JetPack install using the diff tool. Diff compares two files and shows the difference. Taking this information, we were able to determine that there is a meta-package with the name nvidia-jetpack which installs the associated Jetson specific libraries such as CUDA, cuDNN, TensorRT, and so forth. To examine the Control information about a package:
$ sudo apt show nvidia-jetpack
This will show the name of the package, the type of package, release number, dependencies, reverse dependencies, conflicts and a wide range of other information.
Other Apt tools
There are a wide variety of tools to support apt. We mentioned earlier that the apt command line tool is a simpler version of other apt related tools. Specifically these are apt-get and apt-cache. There are other apt based tools, one useful one is apt-clone.
You can use apt-clone allows you to generate a package list and other associated data and place it into a file using the clone command. This file can then be brought to another similar machine (same release). Once on the new machine, the apt-clone restore command will configure that machine to be that of the original. You can also use this to reconfigure the original machine to the saved state at the time of the clone.
To be clear, apt-clone does not make a clone of the entire machine; only the installed packages. Typically a developer will keep the code that they are developing in a versioning system or external backup, along with any other data files. You know my saying. “If you cannot generate your system from scratch, you do not have a system”. That’s just a pain train that is coming to get you at the worst possible time.
Some developers use the Aptitude NCurses based interface to apt in the Terminal. This semi-gui provides many of the functions we mention above. A more popular alternative among developers is the GUI called Synaptic. Synaptic provides access to a wide variety of apt tools via the ease of a graphical interface.
This is low level stuff, but it is important to understand if you are a system developer. This article lightly touches on a complex subject area. Like most operating system functions, at the lower levels a package manager is simple. Keep track of configuration and file locations. This is simple in the small, these files go here, a little bit of configuration there and we’re done.
And like most operating system functions, this is complex. This has a lot to do with the sheer number of packages to track, and the dependencies of packages on each other. Circular dependencies and conflicts make things more difficult to wrap ones head around.
However, there are some mature tools to help. Check them out!
thanks for your share
You are welcome and thanks for reading!